/* ===== 主題色（三組底色） ===== */
:root, [data-theme="warm"] {
  --bg: #F7F3EA; --surface: #FFFDF8; --surface-2: #F1EBDD; --ink: #1F2A24; --muted: #535E58;
  --line: #E0D7C6; --primary: #2F6B4F; --primary-ink: #FFFFFF; --primary-soft: #E3EFE7;
  --accent: #B8892B; --accent-ink: #6A4C10; --accent-soft: #F6EBD3; --sea: #2B6A8F;
  --danger: #A63D2F; --warn: #9A6A00; --ok: #2F6B4F; --shadow: 0 10px 30px rgba(40,35,20,.14);
  color-scheme: light;
}
[data-theme="ocean"] {
  --bg: #13243A; --surface: #1A304C; --surface-2: #223B5B; --ink: #EEF3F8; --muted: #B9C6D5;
  --line: #2F4A6C; --primary: #7CCBA2; --primary-ink: #0F2233; --primary-soft: #21445A;
  --accent: #E2BC66; --accent-ink: #F2D79A; --accent-soft: #3A3A33; --sea: #5FA3CC;
  --danger: #FF9A8A; --warn: #F2C35B; --ok: #7CCBA2; --shadow: 0 10px 30px rgba(0,0,0,.4);
  color-scheme: dark;
}
[data-theme="forest"] {
  --bg: #EDF4EE; --surface: #FAFDFB; --surface-2: #E0ECE3; --ink: #1B2A21; --muted: #4B5E53;
  --line: #CADDCF; --primary: #2F6B4F; --primary-ink: #FFFFFF; --primary-soft: #D9EBDF;
  --accent: #B8892B; --accent-ink: #6A4C10; --accent-soft: #F3EAD4; --sea: #2B6A8F;
  --danger: #A63D2F; --warn: #8A5F00; --ok: #2F6B4F; --shadow: 0 10px 30px rgba(20,50,30,.14);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-size: 16px; line-height: 1.65; overflow: hidden; -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
a { color: var(--primary); text-underline-offset: 3px; }
[data-theme="ocean"] a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--primary); color: var(--primary-ink); padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 8px; }
[hidden] { display: none !important; }

/* ===== 上方工具列 ===== */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); min-height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; line-height: 1.3; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar { display: flex; gap: 4px; flex: none; }
.tool {
  min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; position: relative;
}
.tool:hover { background: var(--surface-2); border-color: var(--line); }
.tool[aria-expanded="true"] { background: var(--primary-soft); border-color: var(--primary); }
.tool .count { position: absolute; top: 3px; right: 3px; min-width: 18px; height: 18px; border-radius: 9px; font-size: 11px; line-height: 18px; background: var(--accent); color: #fff; padding: 0 4px; }
[data-theme="ocean"] .tool .count { color: #13243A; }
.tool-text { font-size: 14px; }

/* ===== 按鈕 ===== */
.btn {
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 18px; }
.linklike { background: none; border: none; color: inherit; text-decoration: underline; cursor: pointer; padding: 6px 4px; min-height: 32px; }

/* ===== 設定彈出框 ===== */
.popover {
  position: fixed; z-index: 40; top: 66px; right: 12px; width: min(380px, calc(100vw - 24px));
  max-height: calc(100vh - 80px); overflow: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); padding: 14px;
}
.popover fieldset { border: none; margin: 0 0 12px; padding: 0; }
.popover legend { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.swatches, .seg { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch, .seg button {
  min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-size: 14px;
}
.swatch[aria-pressed="true"], .seg button[aria-pressed="true"] { border: 2px solid var(--primary); background: var(--primary-soft); font-weight: 700; }
.chip { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); display: inline-block; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--primary); }
.popover .btn { margin: 0 6px 6px 0; }

/* ===== 3D 舞台 ===== */
#stage { position: fixed; inset: 0; }
#canvasWrap { position: absolute; inset: 0; }
#canvasWrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#labels.faded .label { opacity: .12; pointer-events: none; }
.label {
  position: absolute; left: 0; top: 0; pointer-events: auto; transform-origin: 50% 100%;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
  background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; padding: 5px 10px 6px; box-shadow: 0 4px 14px rgba(0,0,0,.15);
  font-size: 13.5px; line-height: 1.3; white-space: nowrap; transition: opacity .25s;
  min-height: 36px; justify-content: center; will-change: transform;
}
.label .lname { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.label .num { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 11px; background: var(--primary); color: var(--primary-ink); font-size: 12px; padding: 0 5px; }
.label .lsub { font-size: 12px; color: var(--muted); }
.label.visited .num { background: var(--accent); color: #fff; }
[data-theme="ocean"] .label.visited .num { color: #13243A; }
.label.center { border: 2px solid var(--primary); font-size: 14.5px; }
.label.compact .lsub { display: none; }
.label.dim { opacity: .18; }
.label:hover, .label:focus-visible { opacity: 1 !important; z-index: 5; border-color: var(--primary); }
.label.hidden { display: none; }

.hud { position: absolute; z-index: 10; display: flex; gap: 8px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-left { left: 12px; top: 72px; flex-direction: column; align-items: flex-start; }
.hud-right { right: 12px; bottom: 44px; }
.hud-bottom { left: 0; right: 0; bottom: 0; justify-content: center; align-items: center; gap: 10px; font-size: 12.5px; padding: 4px 12px calc(4px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--muted); flex-wrap: wrap; }
.chip-hud { background: color-mix(in srgb, var(--surface) 90%, transparent); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: 18px; color: var(--muted); background: var(--bg); z-index: 20; }

/* ===== 觀測員對話泡泡 ===== */
.bubble {
  position: absolute; left: 0; top: 0; z-index: 15; width: min(300px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); border: 2px solid var(--primary); border-radius: 16px;
  padding: 12px 14px; box-shadow: var(--shadow); transform: translate(-50%, calc(-100% - 18px));
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -11px; width: 18px; height: 18px; background: var(--surface); border-right: 2px solid var(--primary); border-bottom: 2px solid var(--primary); transform: translateX(-50%) rotate(45deg); }
.bubble .who { font-weight: 700; }
.bubble .where { font-size: 12.5px; color: var(--muted); }
.bubble .say { margin: 6px 0 10px; }
.bubble .row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== 內容面板（桌機側邊、手機底部抽屜） ===== */
.panel {
  position: fixed; z-index: 25; top: 60px; right: 0; bottom: 0; width: min(460px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; animation: slideIn .28s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-handle { display: none; }
.panel-head { position: absolute; top: 8px; right: 10px; z-index: 2; }
.panel-body { overflow-y: auto; padding: 18px 20px 40px; flex: 1; outline: none; overscroll-behavior: contain; }
#panelTitle:focus, .sheet-head h2:focus { outline: none; }
.panel-body h2 { margin: 0 52px 4px 0; font-size: 22px; line-height: 1.35; }
.eyebrow { font-size: 13px; color: var(--muted); margin: 0 0 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--ink); border: 1px solid var(--line); }
.tag.demo { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.tag.verified { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.tag.pending { background: transparent; color: var(--warn); border-color: var(--warn); }
.section { margin-top: 18px; }
.section > h3 { font-size: 16px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.section > h3::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }
.lead { font-size: 15.5px; }
.panel ul, .prose ul { padding-left: 1.2em; margin: 6px 0; }
.panel li { margin: 4px 0; }
.observer-box { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; border: 1px dashed var(--line); }
.observer-box p { margin: 4px 0; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* 資訊卡 */
.card {
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 12px 14px; margin: 8px 0;
}
.card-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.card h4 { margin: 6px 0 4px; font-size: 15.5px; line-height: 1.45; }
.card .meta { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.card .meta dt { display: inline; font-weight: 700; }
.card .meta dd { display: inline; margin: 0 10px 0 2px; }
.card details summary { cursor: pointer; color: var(--primary); font-size: 14px; min-height: 32px; display: flex; align-items: center; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.fav-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.card-grid { display: grid; gap: 8px; }
.notice { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--ink); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 10px 0; }

/* 中央儀表板 */
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.kpi { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); }
.kpi .k-name { font-size: 13px; color: var(--muted); }
.kpi .k-val { font-size: 24px; font-weight: 700; line-height: 1.2; }
.kpi .k-target { font-size: 12.5px; color: var(--muted); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bar.warn > span { background: var(--accent); }
.bar.late > span { background: var(--danger); }
.proj { margin: 8px 0; }
.proj-row { display: flex; justify-content: space-between; gap: 8px; font-size: 14.5px; }
.status { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.status.ok { color: var(--ok); } .status.warn { color: var(--warn); } .status.late { color: var(--danger); }
.risk-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.risk-table th, .risk-table td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lv { font-weight: 700; } .lv-高 { color: var(--danger); } .lv-中 { color: var(--warn); } .lv-低 { color: var(--ok); }
.brief-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.brief-item { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.brief-item b { display: block; }
.brief-item .src { font-size: 12.5px; color: var(--muted); }

/* ===== 全版面清單 sheet ===== */
.sheet {
  position: fixed; z-index: 35; top: 60px; left: 0; right: 0; bottom: 0; background: var(--bg);
  display: flex; flex-direction: column; animation: fadeUp .25s ease;
}
@keyframes fadeUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.sheet-head h2 { margin: 0; font-size: 19px; }
.sheet-body { overflow-y: auto; padding: 14px 16px 60px; width: 100%; max-width: 980px; margin: 0 auto; flex: 1; overscroll-behavior: contain; }
.note { color: var(--muted); font-size: 14px; margin: 4px 0 10px; }
.search-box input, .guide-form input {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chips button { min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; }
.chips button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.island-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.island-item { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.island-item h3 { margin: 0; font-size: 16.5px; display: flex; gap: 8px; align-items: center; }
.island-item .num { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 13px; background: var(--primary); color: var(--primary-ink); font-size: 13px; }
.island-item.visited .num { background: var(--accent); color: #fff; }
.island-item p { margin: 0; font-size: 14.5px; color: var(--muted); }
.island-item .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.search-results:empty { display: none; }
.search-results { margin: 10px 0 14px; }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 6px 0; }
.result mark { background: var(--accent-soft); color: inherit; padding: 0 2px; border-radius: 3px; }
.result .where { font-size: 12.5px; color: var(--muted); }
.sources-block { margin-top: 28px; padding-top: 12px; border-top: 2px solid var(--line); }
.source-list { padding-left: 1.4em; font-size: 14px; }
.source-list li { margin: 6px 0; }
.site-foot { margin-top: 20px; font-size: 13.5px; color: var(--muted); }

/* 小嚮導 */
.guide-log { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.msg { max-width: 92%; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.msg.me { align-self: flex-end; background: var(--primary-soft); }
.msg .hit { margin: 6px 0; padding-top: 6px; border-top: 1px dashed var(--line); }
.guide-form { display: flex; gap: 8px; position: sticky; bottom: 0; background: var(--bg); padding: 8px 0; }

/* 歡迎與分享 */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(10,20,15,.45); padding: 16px; }
.modal-card { background: var(--surface); border-radius: 18px; padding: 22px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow); text-align: center; }
.modal-card h2 { margin: 6px 0; }
.modal-card .tips { text-align: left; font-size: 14.5px; color: var(--muted); }
.mascot { width: 110px; height: 110px; }
.modal-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
#shareCanvas { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 60px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); font-size: 14.5px; }
.noscript { padding: 80px 20px; text-align: center; }
.prose h3 { margin: 16px 0 6px; }
.error-box { max-width: 520px; margin: 120px auto; text-align: center; padding: 20px; }

/* ===== 沒有 WebGL：清單版變成主畫面 ===== */
body.no-webgl { overflow: auto; }
body.no-webgl #stage { display: none; }
body.no-webgl #listView { position: static; min-height: 100vh; padding-top: 60px; animation: none; }
body.no-webgl #listView [data-close] { display: none; }
body.no-webgl .panel { top: 60px; }

/* ===== 標案雷達 ===== */
.tender-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.tender-tabs [aria-selected="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.tender-kw { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.kw-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--primary-soft); border: 1px solid var(--primary); font-size: 14px; }
.kw-chip button { border: 0; background: transparent; color: inherit; font-size: 16px; min-width: 32px; min-height: 32px; cursor: pointer; border-radius: 50%; }
.kw-chip button:hover { background: var(--surface-2); }
.tender-add { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.tender-add input { flex: 1 1 160px; min-width: 0; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
.tender-filters { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 8px; font-size: 14px; }
.tender-filters select, .tender-filters input[type="search"] { min-height: 38px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; max-width: 100%; }
.tender-filters label { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tender-status { margin: 4px 0 8px; }
.error-box.small { margin: 8px 0; max-width: none; text-align: left; padding: 10px 12px; font-size: 14px; border: 1px solid var(--accent); border-radius: 10px; background: var(--surface); }
.tender-card h4 { margin: 6px 0 4px; }
.tender-card p { margin: 2px 0; }
.tender-links { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14.5px; }
.tender-links ul { padding-left: 1.2em; }
.tender-links li { margin: 6px 0; }
.btn[disabled] { opacity: .55; cursor: progress; }

/* ===== 統計儀表 ===== */
.stats-bar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 10px 0; }
.stats-bar select { min-height: 40px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
.stats-h { margin: 16px 0 8px; font-size: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.stat-card { min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stat-label { font-size: 14px; color: var(--ink-2, var(--ink)); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--primary); margin: 4px 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-value.small { font-size: 18px; }
.stat-sub { font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.stats-table { margin-top: 12px; }
.stats-table summary, .stats-diag summary { cursor: pointer; font-weight: 700; min-height: 40px; display: flex; align-items: center; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.table-wrap th, .table-wrap td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.table-wrap th:first-child, .table-wrap td:first-child { text-align: left; }
.link-btn { border: 0; background: none; color: var(--primary); font: inherit; text-decoration: underline; cursor: pointer; padding: 4px 0; min-height: 32px; }
.stats-diag { margin-top: 16px; font-size: 13px; }
.stats-diag pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; background: var(--bg); padding: 8px; border-radius: 8px; border: 1px solid var(--line); }

/* ===== 減少動態 ===== */
body.reduced *, body.reduced *::before, body.reduced *::after { animation: none !important; transition: none !important; }

/* ===== 平板 ===== */
@media (max-width: 1024px) {
  .tool-text { display: none; }
}
/* ===== 手機 ===== */
@media (max-width: 768px) {
  .topbar { padding: 6px 8px; gap: 6px; min-height: 56px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand h1 { font-size: 15px; }
  .brand-sub { display: none; }
  .toolbar { gap: 0; }
  .tool { min-width: 40px; padding: 0 6px; }
  .tool[data-open="help"], .tool[data-open="intel"], .tool[data-open="guide"], .tool[data-open="fav"] { display: none; }
  .hud-left { top: 64px; left: 8px; }
  body.panel-open .hud-left, body.panel-open .hud-right { display: none; }
  .chip-hud { font-size: 12.5px; padding: 5px 10px; }
  .hud-right { right: 8px; bottom: 54px; }
  .hud-bottom { font-size: 11.5px; }
  .label { font-size: 12.5px; padding: 4px 8px; }
  .label .lsub { display: none; }
  .label.compact:not(.center) .ltext { display: none; }
  .label.compact:not(.center) { padding: 4px; min-height: 30px; border-radius: 15px; }
  .panel { top: auto; left: 0; right: 0; width: 100%; height: 72vh; border-left: none; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; animation: drawerUp .28s ease; }
  @keyframes drawerUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .panel-handle { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
  .panel-body { padding: 10px 16px 40px; }
  .panel-body h2 { font-size: 19px; }
  .sheet, .popover { top: 56px; }
  .island-list { grid-template-columns: 1fr; }
  .kpi .k-val { font-size: 20px; }
}
@media (max-width: 380px) {
  .brand h1 { max-width: 34vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  body { overflow: visible; }
  .topbar, #stage, .panel, .modal, .popover, .toast { display: none !important; }
  .sheet { position: static; }
}

.mobile-only { display: none; }
@media (max-width: 768px) { .mobile-only { display: block; } }
