﻿:root {
  --bg: #1e2127; --panel: #262a31; --panel2: #2f343c; --line: #3a404a;
  --text: #e8eaed; --muted: #9aa3ad; --accent: #5aa9ff; --go: #3fb950; --warn: #ff6b6b;
  --sel: #ffd84d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px "Microsoft JhengHei UI", "Microsoft JhengHei", system-ui, sans-serif; overflow: hidden; }
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: #5b6573; background: #363c45; }
button.primary { background: #2f6fd6; border-color: #2f6fd6; }
button.primary:hover { background: #3b7ce6; }
button.go { background: #2a8a3e; border-color: #2a8a3e; font-weight: bold; }
button.go:hover { background: #33a14a; }
button:disabled { opacity: .45; cursor: default; }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; width: 100%; }
input[type=range] { padding: 0; accent-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }

#top { height: 52px; display: flex; align-items: center; gap: 6px; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.logo { font-weight: bold; font-size: 16px; margin-right: 10px; white-space: nowrap; }
#main { position: absolute; top: 52px; bottom: 30px; left: 0; right: 0; display: flex; }
#tools { width: 74px; background: var(--panel); border-right: 1px solid var(--line); padding: 8px 6px;
  display: flex; flex-direction: column; gap: 14px; }
#tools .group { display: flex; flex-direction: column; gap: 6px; }
#tools button { display: flex; flex-direction: column; align-items: center; padding: 6px 0; font-size: 12px; }
#tools button b { font-size: 20px; font-weight: normal; }
#tools button.on { background: #24496f; border-color: var(--accent); }
#stage { flex: 1; position: relative; min-width: 0; }
#stage canvas { display: block; }
#tip { position: absolute; pointer-events: none; background: rgba(0,0,0,.78); color: #fff; padding: 4px 9px;
  border-radius: 6px; font-weight: bold; font-size: 15px; display: none; white-space: nowrap; z-index: 5; }
#empty { position: absolute; top: 38%; left: 0; right: 0; text-align: center; pointer-events: none; color: var(--muted); }
#empty .big { font-size: 26px; color: var(--text); margin-bottom: 8px; }
#stage.dragover::after { content: "放開就變成方塊"; position: absolute; inset: 12px; border: 3px dashed var(--accent);
  border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 28px;
  background: rgba(30,60,100,.35); pointer-events: none; }
#busy { position: absolute; inset: 0; background: rgba(20,22,26,.72); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; font-size: 17px; z-index: 6; }
.spin { width: 46px; height: 46px; border: 5px solid #444; border-top-color: var(--accent); border-radius: 50%;
  animation: sp 0.9s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

#matBox { background: var(--panel2); border-radius: 10px; padding: 6px 8px; max-height: 36%; display: flex; flex-direction: column; }
#matBox summary { cursor: pointer; font-weight: bold; padding: 2px 0; }
#mats { overflow-y: auto; margin-top: 6px; }
.mat { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.mat:hover { background: #3a414b; }
.mat img { width: 22px; height: 22px; image-rendering: pixelated; }
.mat .n { margin-left: auto; text-align: right; color: var(--muted); font-size: 12px; white-space: nowrap; }
.mat .rep { display: none; padding: 1px 6px; font-size: 11px; }
.mat:hover .rep { display: inline-block; }

#status { position: absolute; bottom: 0; left: 0; right: 0; height: 30px; display: flex; align-items: center;
  gap: 16px; padding: 0 12px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; }

.dlg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center;
  justify-content: center; z-index: 20; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px;
  width: 440px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); overflow: auto; }
.card.wide { width: 860px; }
.card h2 { margin: 0 0 12px; font-size: 19px; }
.cols { display: flex; gap: 18px; }
.drop { flex: 1; min-height: 340px; border: 2px dashed var(--line); border-radius: 12px; display: flex;
  align-items: center; justify-content: center; text-align: center; line-height: 2; background: var(--bg);
  overflow: hidden; position: relative; }
.drop.over { border-color: var(--accent); }
.drop img { max-width: 100%; max-height: 380px; object-fit: contain; }
.opts { width: 380px; display: flex; flex-direction: column; gap: 4px; }
.lbl { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); }
.lbl b { color: var(--text); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button { padding: 7px 6px; text-align: center; }
.seg button small { display: block; color: var(--muted); font-size: 11px; }
.seg button.on { background: #24496f; border-color: var(--accent); }
.chk { margin-top: 10px; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
#expResult { margin-top: 10px; font-size: 13px; line-height: 1.6; word-break: break-all; }
#toast { position: fixed; bottom: 46px; left: 50%; transform: translateX(-50%); background: #111; color: #fff;
  padding: 9px 16px; border-radius: 10px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 30; }
#toast.show { opacity: .95; }
@media (max-width: 900px) {
  .cols { flex-direction: column; } .opts { width: auto; } #side { width: 230px; }
  #top .view, .logo { display: none; }
}

/* ---------- 創造模式 ---------- */
#crosshair { display: none; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; pointer-events: none; z-index: 5; mix-blend-mode: difference; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: #fff; }
#crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
#crosshair::after { left: 0; top: 10px; width: 22px; height: 2px; }
body.creative #crosshair { display: block; }
body.creative #tools { display: none; }
body.creative #side { display: none; }
body.creative.inv #side { display: flex; position: fixed; right: 50%; transform: translateX(50%); top: 70px; bottom: 110px; width: min(720px, 94vw); z-index: 30; box-shadow: 0 10px 40px #000a; border: 2px solid var(--line); border-radius: 10px; }
body.creative.inv #palette { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
#lockHint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: #0008; color: #fff; z-index: 6; text-align: center; cursor: pointer; }
#lockHint .big { font-size: 28px; font-weight: 700; }
#lockHint .muted { color: #cfd6de; line-height: 1.8; margin-top: 6px; }
#btnMode.on { background: var(--accent); }

#toast { bottom: 96px; }


/* ---------- 建築工具參數列 ---------- */
#shapeBar { position: absolute; left: 10px; top: 10px; z-index: 4; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: #1e2127e6; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--text); font-size: 13px; max-width: calc(100% - 20px); }
#shapeBar.hidden { display: none; }
#shapeBar label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#shapeBar label.off { display: none; }
#shapeBar input[type=number] { width: 52px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; }
#tools { overflow-y: auto; }

/* ---------- 建築範本 ---------- */
.pf-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; min-height: 280px; }
#pfList { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; align-content: start; max-height: 56vh; overflow-y: auto; }
.pf-card { border: 2px solid var(--line); border-radius: 8px; padding: 8px; cursor: pointer; background: var(--panel2); }
.pf-card:hover { border-color: var(--accent); }
.pf-card.on { border-color: var(--sel); }
.pf-card .ic { font-size: 26px; }
.pf-card .nm { font-weight: 700; margin: 2px 0; }
.pf-card .ds { color: var(--muted); font-size: 12px; line-height: 1.35; }
#pfOpts label { display: block; margin: 8px 0 3px; color: var(--muted); }
#pfOpts input, #pfOpts select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; }
#placeHint { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 5; background: #2b6cb0ee; color: #fff; padding: 6px 14px; border-radius: 8px; font-size: 14px; }
@media (max-width: 760px) { .pf-cols { grid-template-columns: 1fr; } }

/* ---------- AI 搜尋建模 ---------- */
#aiBuild { display: flex; gap: 4px; align-items: center; flex: 1 1 360px; max-width: 520px; }
#aiBuild input { flex: 1; min-width: 120px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
#aiBuild select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px; }
#aiPanel { position: absolute; right: 10px; top: 10px; width: 300px; z-index: 6; background: #1e2127f2; border: 1px solid var(--line); border-radius: 10px; padding: 10px; box-shadow: 0 8px 24px #0008; }
#aiPanel.hidden { display: none; }
#aiPanel .ap-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
#aiPanel .ap-head button { padding: 0 6px; }
#aiPanel .ap-bar { height: 4px; background: var(--line); border-radius: 2px; margin: 6px 0; overflow: hidden; }
#aiPanel .ap-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
#apChosen img { width: 100%; max-height: 160px; object-fit: contain; background: #0003; border-radius: 6px; }
#apChosen .why { font-size: 12px; color: var(--muted); margin-top: 2px; }
#apCands { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 6px; }
#apCands img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; }
#apCands img:hover { border-color: var(--accent); }
#apCands .lbl { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* 取消按鈕 */
#drop { position: relative; }
#btnClearImg { position: absolute; top: 6px; right: 6px; z-index: 2; background: #000a; color: #fff; border: 1px solid #fff6; border-radius: 6px; padding: 3px 8px; }
#btnClearImg.hidden { display: none; }
#apCancel.hidden { display: none; }
#placeHint button { margin-left: 8px; background: #fff2; color: #fff; border: 1px solid #fff8; border-radius: 6px; padding: 1px 8px; }
/* 上方列不要擠成兩行 */
#top { flex-wrap: nowrap; overflow-x: auto; }
#top button { white-space: nowrap; flex-shrink: 0; }
#aiBuild { flex: 1 1 260px; min-width: 220px; }

/* ---------- Minecraft 創造模式物品欄風格 ---------- */
#side { width: 376px; background: #c6c6c6; color: #404040; display: flex; flex-direction: column; padding: 8px; gap: 6px; min-height: 0;
  border: 0; box-shadow: inset 3px 3px 0 #fff, inset -3px -3px 0 #555; border-left: 2px solid #000; }
#side .muted { color: #595959; }
.ico { image-rendering: auto; display: block; pointer-events: none; }
#cats { order: 0; display: flex; flex-wrap: wrap; gap: 2px; margin: 0 0 2px; padding-bottom: 4px; border-bottom: 2px solid #fff; }
#cats button { width: 36px; height: 32px; padding: 0; border-radius: 0; font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center;
  background: #a0a0a0; color: #222; border: 2px solid; border-color: #fff #555 #555 #fff; }
#cats button img { width: 26px; height: 26px; }
#cats button:hover { background: #b8b8b8; }
#cats button.on { background: #c6c6c6; border-color: #fff #555 #c6c6c6 #fff; height: 36px; margin-bottom: -6px; position: relative; z-index: 1; box-shadow: 0 0 0 1px #000; }
#current { order: 1; display: flex; align-items: center; gap: 10px; padding: 4px; background: transparent; border-radius: 0; margin-top: 6px; }
#curImg { width: 46px; height: 46px; padding: 3px; background: #8b8b8b; border: 2px solid; border-color: #373737 #fff #fff #373737; }
#curName { font-weight: bold; font-size: 15px; color: #404040; }
#search { order: 2; background: #000; color: #fff; border: 2px solid; border-color: #a0a0a0 #fff #fff #a0a0a0; border-radius: 0; padding: 4px 8px; }
#search::placeholder { color: #777; }
#palette { order: 3; flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(9, 36px); justify-content: center; gap: 0;
  align-content: start; min-height: 120px; padding: 2px; background: #c6c6c6; scrollbar-color: #8b8b8b #c6c6c6; }
.slot { width: 36px; height: 36px; padding: 2px; background: #8b8b8b; border: 2px solid; border-color: #373737 #fff #fff #373737; position: relative; cursor: pointer; box-sizing: border-box; }
.slot img { width: 28px; height: 28px; }
#palette .slot:hover::after, #hotbar .slot:hover::after { content: ""; position: absolute; inset: -2px; background: rgba(255,255,255,.5); pointer-events: none; }
#palette .slot.on { outline: 2px solid #fff; box-shadow: 0 0 0 4px #000, 0 0 8px 4px #fff8; z-index: 1; }
#matBox { order: 4; background: #8b8b8b; border: 2px solid; border-color: #373737 #fff #fff #373737; border-radius: 0; padding: 4px 6px; max-height: 34%; display: flex; flex-direction: column; color: #fff; }
#matBox summary { cursor: pointer; font-weight: bold; padding: 2px 0; text-shadow: 1px 1px 0 #3f3f3f; }
#matBox .muted { color: #ddd; }
#mats { overflow-y: auto; margin-top: 4px; }
.mat { display: flex; align-items: center; gap: 8px; padding: 2px 4px; border-radius: 0; cursor: pointer; font-size: 13px; }
.mat:hover { background: rgba(255,255,255,.35); }
.mat img { width: 26px; height: 26px; }
.mat .n { margin-left: auto; text-align: right; color: #eee; font-size: 12px; white-space: nowrap; }
.mat .rep { display: none; padding: 1px 6px; font-size: 11px; border-radius: 0; background: #c6c6c6; color: #222; border: 2px solid; border-color: #fff #555 #555 #fff; }
.mat:hover .rep { display: inline-block; }
@media (max-width: 900px) { #side { width: 376px; } }

#mctip { position: fixed; display: none; z-index: 100; pointer-events: none; background: rgba(16,0,16,.94); color: #fff; padding: 3px 7px 4px;
  border: 2px solid; border-color: #5000ff #28007f #28007f #5000ff; box-shadow: 0 0 0 2px rgba(16,0,16,.94); font-size: 15px; line-height: 1.4; white-space: nowrap; }
#mctip .t2 { color: #a8a8a8; font-size: 13px; }

#hotbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 0; padding: 3px; background: rgba(0,0,0,.5); border: 2px solid #1a1a1a; z-index: 5; }
#hotbar .slot { width: 50px; height: 50px; padding: 4px; background: rgba(139,139,139,.55); border: 2px solid; border-color: rgba(55,55,55,.9) rgba(255,255,255,.55) rgba(255,255,255,.55) rgba(55,55,55,.9); }
#hotbar .slot img { width: 38px; height: 38px; }
#hotbar .slot.on { border: 3px solid #fff; outline: 2px solid #000; outline-offset: 0; z-index: 1; padding: 3px; }
#hotbar .slot .num { position: absolute; left: 2px; top: 0; font-size: 10px; color: #fff; text-shadow: 1px 1px 0 #000; }
#hotName { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); color: #fff; text-shadow: 1px 1px 0 #000; font-size: 15px; pointer-events: none; z-index: 5; opacity: 0; transition: opacity .4s; }
#hotName.show { opacity: 1; }

