/* 室內 3D 空間模擬 / UI 樣式 */

:root {
  --bg: #12151a;
  --panel: #1a1e26;
  --panel-2: #222835;
  --line: #2e3646;
  --ink: #e6eaf2;
  --ink-dim: #9aa5b8;
  --accent: #4da3ff;
  --accent-ink: #06121f;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --radius: 8px;
  --side-w: 328px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; }

/* ── 視埠 ──────────────────────────────────────────────── */
#viewport { position: relative; flex: 1; min-width: 0; }
#canvas { display: block; width: 100%; height: 100%; }
/* 俯視與立體：左鍵是「抓住畫布拖動」，游標要先講出來 */
#viewport.grab #canvas { cursor: grab; }
#viewport.grab.grabbing #canvas { cursor: grabbing; }

#labels {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.room-label {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9), 0 0 14px rgba(0, 0, 0, .7);
  white-space: nowrap;
  pointer-events: none;
}
.dim-label {
  color: #ffd479;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .95);
  white-space: nowrap;
  pointer-events: none;
}

/* 頂列：左邊標題、右邊工具列，放在同一個 flex 列裡就永遠不會互相蓋到。
   標題可以被壓縮（省略號），工具列的字絕對不能斷行 —— 「上帝視角」斷成兩行是不能接受的。 */
#viewport { container-type: inline-size; }
#topbar {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; align-items: center; gap: 12px;
  pointer-events: none;
}
#hud {
  flex: 1; min-width: 0;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
}
#hud-title {
  font-size: 16px; font-weight: 700; letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#hud-sub { font-size: 12px; color: var(--ink-dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#viewbar {
  flex: none;
  display: flex; align-items: center; gap: 4px;
  background: rgba(20, 24, 32, .82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  pointer-events: auto;
}
#viewbar button { white-space: nowrap; }
#viewbar .vb-chk {
  display: flex; align-items: center; gap: 5px;
  padding: 0 6px; font-size: 12px; white-space: nowrap; cursor: pointer;
  color: var(--ink-dim);
}
#viewbar .vb-chk:has(:checked) { color: var(--accent); font-weight: 600; }
#viewbar .vb-chk input { accent-color: var(--accent); margin: 0; }
#viewbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }

/* 視埠變窄：工具列先縮字距與內距，再把副標拿掉，最後才犧牲標題 */
@container (max-width: 820px) {
  #viewbar button { padding: 5px 8px; font-size: 12px; }
  #viewbar { gap: 2px; }
  #hud-sub { display: none; }
}
@container (max-width: 700px) {
  #hud { display: none; }
  #viewbar button { padding: 5px 7px; }
}
/* 手機寬度：工具列放不下時可以左右捲，右邊的測距、娃娃屋、歸位、截圖才按得到 */
@container (max-width: 640px) {
  #viewbar { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  #viewbar::-webkit-scrollbar { display: none; }
}

/* 漫遊提示靠左、留出右下角給漫遊選項面板（190px），兩個才不會疊在一起 */
#walkhint {
  position: absolute; left: 12px; right: 226px; bottom: 44px;
  background: rgba(20, 24, 32, .9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--ink-dim);
  max-width: 560px;
}
#walkhint b { color: var(--ink); }

/* ── 選取物件快捷列 ────────────────────────────────────── */
#objbar {
  position: absolute; left: 50%; bottom: 52px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 5px;
  background: rgba(20, 24, 32, .9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 6px 5px 12px;
  white-space: nowrap;
  z-index: 5;
}
#objbar[hidden] { display: none; }
#shellbar {
  position: absolute; left: 50%; bottom: 52px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(20, 24, 32, .9);
  backdrop-filter: blur(8px);
  border: 1px solid #ffb020;
  border-radius: var(--radius);
  padding: 5px 6px 5px 12px;
  white-space: nowrap;
  z-index: 5;
  font-size: 12px;
}
#shellbar[hidden] { display: none; }
#shellbar-name { font-weight: 600; }
#removed-list { list-style: none; margin: 0; padding: 0; }
#removed-list li { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; font-size: 12px; border-bottom: 1px solid var(--line); }
#removed-list .rm { background: none; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-dim); cursor: pointer; padding: 1px 8px; font-size: 11px; }
#removed-list .rm:hover { border-color: var(--accent); color: var(--ink); }
#objbar-name {
  font-size: 12px; font-weight: 600;
  margin-right: 4px;
  max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}

/* ── 材質分頁 ──────────────────────────────────────────── */
#rooms { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.room-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  cursor: pointer;
  font: inherit; font-size: 12px;
  color: var(--ink);
  text-align: left;
}
.room-btn.on { border-color: var(--accent); background: #26344a; }
.room-btn .chips { display: flex; gap: 3px; flex: none; }
.room-btn .chip { width: 13px; height: 13px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .35); }
.room-btn .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lib { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.lib.sw { grid-template-columns: repeat(5, 1fr); }
.lib button {
  padding: 0; overflow: hidden;
  border-radius: 6px;
  border: 2px solid transparent;
  background: var(--panel-2);
  cursor: pointer;
}
.lib button.on { border-color: var(--accent); }
.lib button .sw-box { display: block; height: 30px; }
.lib.sw button .sw-box { height: 26px; }
.lib button .sw-nm {
  display: block; font-size: 9px; line-height: 1.3;
  color: var(--ink-dim); padding: 3px 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── 記錄分頁 ──────────────────────────────────────────── */
#plans, #history { list-style: none; margin: 8px 0 0; padding: 0; }
#plans li, #history li {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 12px;
}
#plans li:hover, #history li:hover { border-color: var(--accent); }
#history li.now { border-color: var(--accent); background: #26344a; }
#history li.future { opacity: .45; }
#plans li .nm, #history li .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#plans li .tm, #history li .tm { font-size: 10px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
#plans li .rm { background: none; border: 0; color: var(--ink-dim); cursor: pointer; padding: 0 2px; }
#plans li .rm:hover { color: var(--danger); }

#plan-name {
  flex: 1; min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 6px 9px;
  font: inherit; font-size: 12px;
}
#plan-name:focus { outline: 0; border-color: var(--accent); }
.row #btn-save-plan { flex: 0 0 auto; }

button[disabled] { opacity: .35; cursor: default; }
button[disabled]:hover { border-color: var(--line); }

/* 底列：左邊狀態列、右邊操作提示，各占一半，視埠再窄也不會疊在一起 */
#modehint {
  position: absolute; right: 12px; bottom: 12px;
  max-width: 58%;
  background: rgba(20, 24, 32, .86);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 12px;
  color: var(--ink-dim);
  white-space: nowrap;
  pointer-events: none;
  overflow: hidden; text-overflow: ellipsis;
}
#modehint b { color: var(--ink); font-weight: 600; }
#modehint[hidden] { display: none; }

#crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  pointer-events: none;
}
#crosshair::before, #crosshair::after {
  content: ''; position: absolute;
  background: rgba(255, 255, 255, .75);
  box-shadow: 0 0 3px rgba(0, 0, 0, .8);
}
#crosshair::before { left: 7px; top: 0; width: 2px; height: 16px; }
#crosshair::after { top: 7px; left: 0; height: 2px; width: 16px; }

#walk-opts {
  position: absolute; right: 12px; bottom: 12px;
  background: rgba(20, 24, 32, .85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 11px;
  color: var(--ink-dim);
  width: 190px;
}
#walk-opts output { color: var(--accent); font-variant-numeric: tabular-nums; }
#walk-opts input[type=range] { margin-top: 4px; }

#statusbar {
  position: absolute; left: 12px; bottom: 12px;
  font-size: 12px;
  color: var(--ink-dim);
  background: rgba(20, 24, 32, .75);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  pointer-events: none;
  max-width: 40%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── 側欄 ──────────────────────────────────────────────── */
#side {
  width: var(--side-w);
  flex: none;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
}

#tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
#tabs button {
  flex: 1;
  background: none; border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-dim);
  padding: 11px 4px;
  font: inherit; font-size: 13px;
  cursor: pointer;
}
#tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
#tabs button:hover { color: var(--ink); }

.tab { display: none; flex: 1; overflow-y: auto; padding: 12px; min-height: 0; }
.tab.on { display: block; }

.searchrow { margin-bottom: 10px; }
#search {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
}
#search:focus { outline: 0; border-color: var(--accent); }

/* 目錄 */
.cat-group { margin-bottom: 16px; }
.cat-group > h4 {
  margin: 0 0 8px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .14em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.cat-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cat-item {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 4px 6px;
  cursor: pointer;
  text-align: center;
  color: var(--ink);
  font: inherit;
  transition: border-color .12s, background .12s, transform .08s;
}
.cat-item:hover { border-color: var(--accent); background: #262d3c; }
.cat-item:active { transform: scale(.96); }
.cat-item .ic { font-size: 20px; line-height: 1.2; display: block; }
.cat-item .nm { font-size: 11px; display: block; margin-top: 3px; }
.cat-item .sz { font-size: 9px; color: var(--ink-dim); display: block; font-variant-numeric: tabular-nums; }

/* 清單 */
#placed { list-style: none; margin: 0 0 12px; padding: 0; }
#placed li {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 5px;
  cursor: pointer;
  font-size: 13px;
}
#placed li:hover { border-color: var(--accent); }
#placed li.sel { border-color: var(--accent); background: #26344a; }
#placed li .ic { font-size: 15px; }
#placed li .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#placed li .sz { font-size: 10px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
#placed li .rm { background: none; border: 0; color: var(--ink-dim); cursor: pointer; font-size: 14px; padding: 0 2px; }
#placed li .rm:hover { color: var(--danger); }

.empty { color: var(--ink-dim); font-size: 13px; text-align: center; padding: 28px 8px; line-height: 1.8; }

/* 場景設定 */
.tab h3 {
  margin: 18px 0 8px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .14em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.tab h3:first-child { margin-top: 0; }
.tab h3 output { color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: 0; }

.chk { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; font-size: 13px; }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; }

input[type=range] { width: 100%; accent-color: var(--accent); }

.hint { font-size: 11px; color: var(--ink-dim); line-height: 1.7; margin: 8px 0 0; }
.hint b { color: var(--ink); }

/* 右鍵選單 */
#ctxmenu {
  position: fixed; z-index: 40;
  min-width: 150px;
  background: rgba(24, 28, 36, .97);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
#ctxmenu[hidden] { display: none; }
#ctxmenu .hd {
  font-size: 11px; color: var(--ink-dim);
  padding: 4px 9px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}
#ctxmenu button {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: none; border: 0; border-radius: 5px;
  color: var(--ink); font: inherit; font-size: 12px;
  padding: 6px 9px; cursor: pointer; text-align: left;
}
#ctxmenu button:hover { background: var(--panel-2); }
#ctxmenu button.danger:hover { background: #46242a; color: #ffb4b4; }
#ctxmenu button .k { margin-left: auto; font-size: 10px; color: var(--ink-dim); }
#ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* 快捷鍵速查 */
#helpsheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 10, 14, .62);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
#helpsheet[hidden] { display: none; }
#helpsheet .sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 22px 22px;
  max-width: 660px; width: 100%;
  max-height: 100%; overflow: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
#helpsheet h2 {
  display: flex; align-items: center;
  font-size: 15px; margin: 0 0 14px;
}
#helpsheet h2 button {
  margin-left: auto; background: none; border: 0;
  color: var(--ink-dim); font-size: 15px; cursor: pointer; padding: 0 4px;
}
#helpsheet h2 button:hover { color: var(--ink); }
#helpsheet .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
#helpsheet h3 { font-size: 12px; color: var(--accent); margin: 0 0 6px; letter-spacing: .04em; }
#helpsheet section > h3:not(:first-child) { margin-top: 16px; }
#helpsheet dl { margin: 0; font-size: 12px; }
#helpsheet dt { color: var(--ink-dim); float: left; clear: left; width: 110px; margin-bottom: 5px; }
#helpsheet dd { margin: 0 0 5px 118px; }
#helpsheet kbd {
  background: var(--panel-2); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 4px;
  padding: 0 4px; font-size: 10px; font-family: ui-monospace, monospace;
}
@media (max-width: 620px) { #helpsheet .cols { grid-template-columns: 1fr; } }

/* 清單依空間分組 */
#placed .grp {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 11px; color: var(--ink-dim);
  padding: 9px 2px 4px;
  border: 0; background: none; cursor: default;
  letter-spacing: .06em;
}
#placed .grp::before { content: ''; flex: none; width: 3px; height: 11px; border-radius: 2px; background: var(--accent); }
#placed .grp .n { margin-left: auto; font-variant-numeric: tabular-nums; }

/* 抓著家具時，物件上方的尺寸（寬 × 深 × 高） */
.drag-size {
  background: rgba(20, 24, 32, .92);
  border: 1px solid rgba(143, 208, 255, .7);
  border-radius: 4px;
  padding: 1px 6px;
  color: #cfe9ff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.drag-size b { color: #fff; font-weight: 600; }
/* 拖曳時的即時距離標註 */
.drag-dim {
  background: rgba(20, 24, 32, .9);
  border: 1px solid rgba(255, 212, 121, .5);
  border-radius: 4px;
  padding: 1px 5px;
  color: #ffd479;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: none;
}

/* 走到門前的提示 */
#doorhint {
  position: absolute; left: 50%; top: 58%;
  transform: translateX(-50%);
  background: rgba(20, 24, 32, .88);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--ink);
  pointer-events: none;
  z-index: 6;
}
#doorhint[hidden] { display: none; }
/* 對著鏡子時的計算說明（漫遊） */
#mirrorhint {
  position: absolute; left: 50%; top: 12%;
  transform: translateX(-50%);
  max-width: min(92vw, 720px);
  background: rgba(20, 24, 32, .82);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px; line-height: 1.5;
  color: var(--ink);
  pointer-events: none;
  z-index: 6;
  text-align: center;
}
#mirrorhint[hidden] { display: none; }

/* 測距 */
#btn-measure.on, #btn-level.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.measure-label.lv-x { color: #ff8a7a; border-color: #ff8a7a; }
.measure-label.lv-y { color: #7fd98f; border-color: #7fd98f; }
.measure-label.lv-z { color: #7ab8ff; border-color: #7ab8ff; }
.measure-anchor { pointer-events: none; }
.measure-snap-hint {
  background: rgba(255, 95, 210, .92); color: #fff; border-radius: 4px; padding: 1px 6px;
  font-size: 11px; white-space: nowrap; pointer-events: none;
}
.measure-label {
  background: rgba(20, 24, 32, .92);
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 2px 7px;
  color: #ffd479;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: none;
}

/* 動線檢查 */
#access { list-style: none; margin: 8px 0 0; padding: 0; }
#access li {
  display: flex; align-items: baseline; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: 6px;
  padding: 6px 9px; margin-bottom: 4px;
  font-size: 12px; cursor: pointer;
}
#access li.warn { border-left-color: #e2c66b; }
#access li.bad  { border-left-color: var(--danger); }
#access li:hover { border-color: var(--accent); }
#access li .nm { flex: 1; min-width: 0; }
#access li .w  { font-variant-numeric: tabular-nums; font-weight: 600; }
#access li .g  { font-size: 10px; color: var(--ink-dim); }

/* 機電遮擋檢查 */
#mep-conflict { list-style: none; margin: 8px 0 0; padding: 0; }
#mep-conflict li {
  display: flex; align-items: baseline; gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid #e2c66b;
  border-radius: 6px;
  padding: 6px 9px; margin-bottom: 4px;
  cursor: pointer; font-size: 12px;
}
#mep-conflict li.bad { border-left-color: var(--danger); }
#mep-conflict li:hover { border-color: var(--accent); }
#mep-conflict li .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mep-conflict li .by { font-size: 10px; color: var(--ink-dim); }

/* 存檔狀態列 */
#store-state::before { content: '●'; margin-right: 6px; color: var(--ink-dim); }
#store-state[data-state="file"]::before { color: #6fcf7f; }
#store-state[data-state="local"]::before { color: #e2c66b; }
#store-state[data-state="error"] { color: #ff8f8f; }
#store-state[data-state="error"]::before { color: #ff8f8f; }
#store-dir { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; word-break: break-all; opacity: .65; margin-top: 2px; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 11px; }

#meta { margin: 0; font-size: 12px; }
#meta dt { color: var(--ink-dim); float: left; clear: left; width: 92px; }
#meta dd { margin: 0 0 4px 96px; font-variant-numeric: tabular-nums; }

/* ── 檢視器（選取物件） ────────────────────────────────── */
#inspector {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  padding: 10px 12px 12px;
  max-height: 58%;
  overflow-y: auto;
}
#inspector header { display: flex; align-items: center; margin-bottom: 9px; }
#insp-name { flex: 1; font-weight: 700; font-size: 13px; }
#insp-close { background: none; border: 0; color: var(--ink-dim); cursor: pointer; font-size: 15px; padding: 0 2px; }
#insp-close:hover { color: var(--ink); }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 7px; }
#inspector label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 10px; color: var(--ink-dim);
}
#inspector label.full { margin-bottom: 8px; }
#inspector input[type=number] {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  padding: 5px 6px;
  font: inherit; font-size: 12px;
  font-variant-numeric: tabular-nums;
  width: 100%;
}
#inspector input[type=number]:focus { outline: 0; border-color: var(--accent); }
#out-rot { color: var(--accent); font-variant-numeric: tabular-nums; }

#swatches { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
#swatches .sw-title { flex-basis: 100%; font-size: 11px; color: var(--muted, #9aa3ad); }
#swatches button {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer; padding: 0;
}
#swatches button.on { border-color: #fff; }

/* ── 按鈕 ──────────────────────────────────────────────── */
button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 6px 11px;
  font: inherit; font-size: 12px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
button:hover { border-color: var(--accent); }
button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }

.row { display: flex; gap: 6px; flex-wrap: wrap; }
.row.gap { margin-top: 10px; }
.row button { flex: 1; }

/* ── 載入中 ────────────────────────────────────────────── */
#loading {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  color: var(--ink-dim);
  transition: opacity .35s;
}
#loading.gone { opacity: 0; pointer-events: none; }
.spin {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sp .8s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ── 窄螢幕 ────────────────────────────────────────────── */
@media (max-width: 860px) {
  body { flex-direction: column; }
  #side { width: 100%; height: 46%; border-left: 0; border-top: 1px solid var(--line); }
  #viewport { height: 54%; flex: none; }
  .cat-items { grid-template-columns: repeat(4, 1fr); }
}

/* ── 應用程式內確認框 ─────────────────────────────────── */
#confirm {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .45);
}
#confirm[hidden] { display: none; }
#confirm .box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 14px; min-width: 280px; max-width: 420px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
#confirm p { margin: 0 0 14px; font-size: 14px; }
#confirm .row { justify-content: flex-end; }
#plans li.cur { border-color: var(--accent); }
#plans li.cur .nm i { font-style: normal; color: var(--accent); font-size: 11px; }
#plans li input.ren { flex: 1; min-width: 0; font: inherit; padding: 1px 4px; }

/* 手機寬度：狀態列與操作提示同在底部一列會疊在一起，提示改放到狀態列上面一層
   （放在檔案最後：同樣的選擇器，後面的才蓋得過上面 #modehint 的 right/bottom） */
@container (max-width: 560px) {
  #modehint { left: 12px; right: 12px; bottom: 44px; max-width: none; }
}

/* 沒勾「編輯家具」：檢視器唯讀（欄位、按鈕變淡、不能按），只留關閉 */
#inspector.readonly input, #inspector.readonly button:not(#insp-close), #inspector.readonly #swatches button {
  opacity: .45; pointer-events: none;
}

/* 手機寬度：操作提示移到 44px 之後，選取物件的快捷列再往上一層，不要蓋住提示 */
@container (max-width: 560px) {
  #objbar, #shellbar { bottom: 84px; }
}

/* 全螢幕漫遊：畫面占滿整個螢幕，只留準星與右下角的漫遊面板（面板變淡，滑過去才清楚） */
#viewport:fullscreen { width: 100vw; height: 100vh; background: #000; }
#viewport.immersive #topbar, #viewport.immersive #walkhint, #viewport.immersive #modehint,
#viewport.immersive #statusbar { display: none !important; }
#viewport.immersive #walk-opts { opacity: .35; transition: opacity .2s; }
#viewport.immersive #walk-opts:hover { opacity: 1; }
#walk-opts .wide { width: 100%; margin-bottom: 6px; }

/* 漫遊面板：可以收合，收起來只剩一條小標題（不擋畫面） */
#walk-opts .head {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  color: var(--ink); font-size: 12px; font-weight: 600; padding: 2px 0; cursor: pointer;
}
#walk-opts .head:hover { color: var(--accent); }
#walk-opts .body { margin-top: 6px; }
#walk-opts.collapsed { width: auto; padding: 5px 10px; }
#walk-opts.collapsed .body { display: none; }
