/* Learn 3D — 設計語言沿用 creativity-3d / me.hellokai07.com（深色星空、Geist + Noto Sans TC） */
:root {
  --bg: #08080a; --ink: #f5f5f6; --text: #c3c3c8; --muted: #8f8f97; --faint: #5f5f68;
  --glass: rgba(255,255,255,.045); --glass-2: rgba(255,255,255,.07);
  --line: rgba(255,255,255,.09); --line-soft: rgba(255,255,255,.05);
  --accent: #f0a46a; --accent-soft: rgba(240,164,106,.14);
  --s-unseen: #7a7a85; --s-weak: #f87171; --s-shaky: #facc15; --s-mastered: #4ade80;
  --ok: #4ade80; --danger: #f87171; --warn: #facc15;
  --sans: "Geist","Noto Sans TC",system-ui,-apple-system,sans-serif;
  --mono: "Geist Mono",ui-monospace,"Cascadia Mono",Consolas,monospace;
  --ease: cubic-bezier(.16,1,.3,1);
  --radius: 20px;
  --side-w: 288px;
  --panel-w: min(460px, 38vw);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); -webkit-font-smoothing: antialiased; line-height: 1.6;
  background-image: radial-gradient(60% 50% at 70% 10%, rgba(240,164,106,.07), transparent 70%);
  overflow: hidden;
  overflow: clip; /* 連程式捲動也擋住，版面固定在視窗內 */
}
html { overflow: clip; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .9em; background: var(--glass-2); padding: 1px 6px; border-radius: 6px; color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- 共用 ---- */
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .18em; color: var(--accent); text-transform: uppercase; }
.label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; color: var(--faint); font-weight: 400; }
.muted { color: var(--muted); font-size: 14px; }
.pad { padding: 12px 14px; }
.fineprint { font-size: 12px; color: var(--faint); margin: 8px 0 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.plain { padding-left: 1.2em; margin: 0 0 8px; font-size: 14px; }
.plain li { margin: 4px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: transform .3s var(--ease), opacity .3s var(--ease), background .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease);
}
.btn-primary { background: var(--ink); color: #0b0b0d; border-color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: #fff; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-ghost { background: var(--glass); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: rgba(255,255,255,.25); color: var(--ink); }
.btn-danger { background: rgba(248,113,113,.14); color: var(--danger); border-color: rgba(248,113,113,.4); }
.btn-danger:hover:not(:disabled) { background: rgba(248,113,113,.24); }
.danger-text { color: var(--danger); }
.btn.wide { width: 100%; }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.text-btn { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.text-btn:hover { color: var(--ink); background: var(--glass-2); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 999px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; color: var(--text);
  transition: background .2s var(--ease), color .2s var(--ease);
}
.icon-btn:hover { background: var(--glass-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-btn svg circle { fill: currentColor; stroke: none; }

.spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--faint); border-top-color: var(--accent); vertical-align: -2px; }
@media (prefers-reduced-motion: no-preference) { .spinner { animation: spin .8s linear infinite; } }
@keyframes spin { to { transform: rotate(360deg); } }

.form-msg { min-height: 20px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.form-msg.err { color: var(--danger); }
.field { display: block; margin: 14px 0 0; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type="text"], textarea, select {
  width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.03); color: var(--ink); outline: none; font-size: 15px;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}
input[type="text"]:focus, textarea:focus, select:focus { border-color: rgba(255,255,255,.32); background: rgba(255,255,255,.06); }
textarea { resize: vertical; line-height: 1.6; }
select { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
select option { background: #141418; }
::placeholder { color: var(--faint); }

/* ---- 版面 ---- */
.app {
  height: 100dvh; display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) 0;
  transition: grid-template-columns .45s var(--ease);
}
.app.panel-open { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--panel-w); }
.mobilebar { display: none; }

/* ---- 左欄 ---- */
.sidebar {
  display: flex; flex-direction: column; min-height: 0; padding: 18px 14px 12px;
  border-right: 1px solid var(--line-soft); background: rgba(10,10,13,.75);
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 2px 6px 14px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none;
  font-family: var(--mono); font-size: 12px; letter-spacing: .18em; text-transform: uppercase;
}
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.mock-badge {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--accent);
  padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(240,164,106,.35); background: var(--accent-soft);
}
.drawer-close { display: none; margin-left: auto; }
.new-topic { margin-bottom: 12px; }
.rooms { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; }
.room-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.room {
  width: 100%; display: grid; grid-template-columns: 40px minmax(0,1fr) auto; gap: 10px; align-items: center;
  text-align: left; padding: 10px; border-radius: 14px; border: 1px solid transparent; background: transparent; cursor: pointer;
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
.room:hover { background: var(--glass); }
.room[aria-current="true"] { background: var(--glass-2); border-color: var(--line); }
.room-avatar {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 700; color: var(--ink); font-size: 15px;
  background: conic-gradient(var(--s-mastered) calc(var(--p, 0) * 1%), rgba(255,255,255,.08) 0);
  position: relative;
}
.room-avatar::after { content: attr(data-initial); position: absolute; inset: 3px; border-radius: 9px; background: #121216; display: grid; place-items: center; }
.room-main { min-width: 0; }
.room-title, .room-sub { display: block; }
.room-title { color: var(--ink); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-sub { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--danger); color: #1a0606; font-size: 12px; font-weight: 700; font-family: var(--mono);
}
.sidebar-foot { border-top: 1px solid var(--line-soft); padding-top: 10px; margin-top: 8px; }
.bridge-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 4px 6px; }
.bridge-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.bridge-status[data-state="ok"] .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.bridge-status[data-state="off"] .dot { background: var(--danger); }
.bridge-status[data-state="mock"] .dot { background: var(--accent); }
.ai-settings { margin-top: 4px; font-size: 13px; }
.ai-settings summary { cursor: pointer; padding: 6px; border-radius: 8px; color: var(--text); list-style-position: inside; }
.ai-settings summary:hover { background: var(--glass); }
.ai-settings[open] { max-height: 46dvh; overflow-y: auto; }
.ai-group { padding: 8px 6px 4px; display: grid; gap: 6px; }
.ai-group-title { color: var(--ink); font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.mini-field { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }

/* ---- 中間 ---- */
.stage { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.topic { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.topic-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 22px 28px 8px; flex-wrap: wrap; position: relative; z-index: 4; }
.topic-title-wrap { min-width: 0; flex: 1 1 280px; }
.topic-title { color: var(--ink); font-size: clamp(20px, 2.4vw, 28px); font-weight: 800; letter-spacing: -.01em; margin: 4px 0 2px; line-height: 1.25; text-wrap: balance; }
.topic-meta { font-size: 13px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.topic-meta b { color: var(--ink); font-family: var(--mono); font-weight: 500; }
.topic-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); }
.seg-btn { border: 0; background: transparent; color: var(--muted); padding: 6px 14px; min-height: 32px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--glass-2); color: var(--ink); }
.menu {
  margin: 0; inset: auto; padding: 6px; min-width: 160px; border-radius: 14px; border: 1px solid var(--line);
  background: #131317; color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--glass-2); color: var(--ink); }
.menu-item.danger { color: var(--danger); }

.legend {
  list-style: none; margin: 0 28px; padding: 0; display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); position: relative; z-index: 4;
}
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--c); box-shadow: 0 0 8px var(--c); }
.lg[data-s="unseen"] { --c: var(--s-unseen); }
.lg[data-s="weak"] { --c: var(--s-weak); }
.lg[data-s="shaky"] { --c: var(--s-shaky); }
.lg[data-s="mastered"] { --c: var(--s-mastered); }
.lg-current { background: transparent; border: 2px solid var(--accent); box-shadow: 0 0 10px var(--accent); }
.lg-locked { background: #3a3a42; box-shadow: none; }

.viz { position: relative; flex: 1; min-height: 0; }
.map { position: absolute; inset: 0; overflow: hidden; }
.map canvas { display: block; }
.map-hint { position: absolute; right: 20px; bottom: 16px; z-index: 3; font-size: 12px; color: var(--faint); pointer-events: none; }

/* 3D 標籤 */
.node-label {
  font-size: 10.5px; color: var(--ink); white-space: nowrap; transform: translateY(-13px);
  text-shadow: 0 0 6px rgba(0,0,0,.95), 0 0 2px #000; pointer-events: none; opacity: 0;
  transition: opacity .3s var(--ease); letter-spacing: .01em;
}
.node-label.show { opacity: .72; }
.node-label.hot { opacity: 1; color: #fff; }
.node-label.root { font-size: 12px; font-weight: 700; transform: translateY(-18px); }
.node-label.locked { color: var(--muted); }
.node-label.current { color: var(--accent); }
.node-label.on { opacity: 1; font-weight: 700; color: #fff; }
.ring-label { font-family: var(--mono); font-size: 10px; color: var(--faint); pointer-events: none; opacity: .7; }

/* 節點卡 */
.node-card {
  position: absolute; z-index: 6; right: 20px; top: 12px; width: min(340px, calc(100% - 32px));
  max-height: calc(100% - 24px); overflow-y: auto; padding: 18px 18px 16px; border-radius: 18px;
  background: rgba(14,14,18,.88); border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0,0,0,.55);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 13px;
}
@media (prefers-reduced-motion: no-preference) { .node-card:not([hidden]) { animation: cardIn .4s var(--ease); } }
@keyframes cardIn { from { opacity: 0; translate: 0 8px; } }
.node-card .nc-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; }
.nc-name { color: var(--ink); font-size: 18px; font-weight: 700; margin: 4px 36px 6px 0; line-height: 1.35; }
.nc-summary { margin: 0 0 10px; color: var(--text); line-height: 1.6; }
.nc-sec { margin-top: 12px; }
.nc-sec h3 { margin: 0 0 6px; font-size: 11px; font-family: var(--mono); letter-spacing: .1em; color: var(--faint); font-weight: 500; }
.nc-sec ul { margin: 0; padding-left: 1.1em; }
.nc-sec li { margin: 3px 0; }
.nc-hist { list-style: none; padding: 0 !important; display: grid; gap: 4px; }
.nc-hist li { display: flex; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.nc-lock { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(250,204,21,.08); color: var(--warn); font-size: 12px; }
.nc-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: var(--glass-2); }
.status-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.status-chip[data-s="unseen"] { --c: var(--s-unseen); }
.status-chip[data-s="weak"] { --c: var(--s-weak); }
.status-chip[data-s="shaky"] { --c: var(--s-shaky); }
.status-chip[data-s="mastered"] { --c: var(--s-mastered); }
.mis-item { padding: 8px 10px; border-radius: 10px; background: rgba(248,113,113,.07); margin: 6px 0; list-style: none; }
.mis-item b { color: var(--ink); font-weight: 600; display: block; }
.mis-item small { color: var(--muted); }

/* 2D 清單 */
.list-view { position: absolute; inset: 0; overflow-y: auto; padding: 8px 28px 32px; }
.layer { margin-top: 16px; }
.layer h2 { margin: 0 0 8px; font-size: 12px; font-family: var(--mono); letter-spacing: .12em; color: var(--faint); font-weight: 500; }
.layer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.lnode {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; min-height: 44px;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); cursor: pointer;
}
.lnode:hover { border-color: rgba(255,255,255,.22); }
.lnode[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lnode .lg { flex: none; }
.lnode .ln-name { flex: 1; min-width: 0; color: var(--ink); font-size: 14px; }
.lnode .ln-tag { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.lnode.locked { opacity: .5; }
.lnode.current .ln-name::after { content: " · 目前"; color: var(--accent); font-size: 12px; }

/* 空狀態與橋接卡 */
.empty { margin: auto; padding: 40px 24px; max-width: 560px; text-align: center; }
.empty h1 { color: var(--ink); font-size: clamp(30px, 5vw, 44px); margin: 10px 0; }
.lead { font-size: 16px; line-height: 1.75; margin: 0 0 20px; }
.bridge-card {
  position: absolute; z-index: 8; left: 50%; top: 50%; translate: -50% -50%; width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 32px); overflow-y: auto;
  padding: 24px 26px; border-radius: var(--radius); background: rgba(16,16,20,.94); border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.bridge-card h2 { color: var(--ink); margin: 8px 0 10px; font-size: 20px; }
.bridge-card p, .bridge-card li { font-size: 14px; }
.bridge-card ol { padding-left: 1.3em; }

/* ---- 右側問答面板 ---- */
.panel {
  min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  border-left: 1px solid var(--line-soft); background: rgba(11,11,14,.92);
}
.app:not(.panel-open) .panel { visibility: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 18px 20px 10px; border-bottom: 1px solid var(--line-soft); min-width: var(--panel-w); }
.panel-title { color: var(--ink); font-size: 17px; margin: 2px 0 0; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 40px; min-width: var(--panel-w); scrollbar-width: thin; }
.panel-tab {
  position: fixed; right: 0; top: 50%; translate: 0 -50%; z-index: 9; writing-mode: vertical-rl;
  padding: 16px 8px; border-radius: 12px 0 0 12px; border: 1px solid var(--line); border-right: 0;
  background: rgba(20,20,24,.9); color: var(--ink); cursor: pointer; font-size: 13px; letter-spacing: .2em;
}
.panel-tab:hover { background: #1c1c22; }
.app.panel-open .panel-tab { display: none; }
.qa-empty { color: var(--muted); font-size: 14px; padding: 24px 4px; }

.qa-sec { margin: 0 0 18px; }
.qa-sec > h3 { margin: 0 0 8px; font-size: 11px; font-family: var(--mono); letter-spacing: .14em; color: var(--accent); font-weight: 500; text-transform: uppercase; }
.qa-lecture { font-size: 15px; line-height: 1.85; color: var(--text); white-space: pre-line; }
.qa-node { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.qa-kind { padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.code {
  margin: 0; padding: 12px 14px; border-radius: 12px; background: #0e0e12; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 13px; line-height: 1.6; color: #e8e8ec; overflow-x: auto; white-space: pre; tab-size: 2;
}
.code code { background: none; padding: 0; border-radius: 0; font-size: inherit; color: inherit; }
.out-label { font-size: 11px; color: var(--faint); font-family: var(--mono); margin: 8px 0 4px; letter-spacing: .08em; }
.out { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(74,222,128,.05); border: 1px solid rgba(74,222,128,.15); font-family: var(--mono); font-size: 12.5px; white-space: pre; overflow-x: auto; color: #d9f5e3; }
.explain { margin: 0; padding: 0; list-style: none; counter-reset: ex; display: grid; gap: 8px; }
.explain li { counter-increment: ex; display: grid; grid-template-columns: 24px 1fr; gap: 8px; font-size: 14px; line-height: 1.7; }
.explain li::before { content: counter(ex); width: 22px; height: 22px; border-radius: 50%; background: var(--glass-2); color: var(--ink); font-size: 12px; display: grid; place-items: center; font-family: var(--mono); margin-top: 2px; }

.tbl-wrap { overflow: auto; max-inline-size: 100%; max-block-size: min(420px, 60vh); border-radius: 12px; border: 1px solid var(--line); margin-bottom: 12px; container-type: inline-size; }
.tbl { border-collapse: separate; border-spacing: 0; font-size: 12.5px; min-width: 100%; }
.tbl caption { caption-side: top; text-align: left; padding: 8px 12px; color: var(--ink); font-weight: 600; font-size: 13px; background: rgba(255,255,255,.03); position: sticky; left: 0; }
.tbl caption small { color: var(--faint); font-weight: 400; font-family: var(--mono); margin-left: 6px; }
.tbl thead th { position: sticky; top: 0; z-index: 1; background: #17171c; color: var(--ink); font-weight: 600; font-family: var(--mono); text-align: left; }
.tbl th, .tbl td { padding: 6px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.tbl td { color: var(--text); }
.tbl td.num { text-align: right; font-family: var(--mono); }
.tbl td.null { color: var(--faint); font-style: italic; }
.tbl tbody tr:hover td { background: rgba(255,255,255,.025); }

.visual { margin-bottom: 14px; }
.visual-title { font-size: 13px; color: var(--ink); font-weight: 600; margin: 0 0 6px; }
.mermaid-box { padding: 12px; border-radius: 12px; background: #0e0e12; border: 1px solid var(--line); overflow-x: auto; }
.mermaid-box svg { display: block; margin: 0 auto; height: auto; }
.chart-svg { width: 100%; height: auto; display: block; background: #0e0e12; border: 1px solid var(--line); border-radius: 12px; }
.chart-svg text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart-svg .val { fill: var(--ink); }
.chart-svg .bar { fill: var(--accent); opacity: .85; }
.chart-svg .axis { stroke: var(--line); }
.chart-svg .lineplot { stroke: var(--accent); fill: none; stroke-width: 2; }
.chart-svg .pt { fill: var(--accent); }

.question { font-size: 16px; line-height: 1.8; color: var(--ink); white-space: pre-line; padding: 14px 16px; border-radius: 14px; background: var(--glass-2); border: 1px solid var(--line); }
.hint { margin-top: 10px; font-size: 14px; }
.hint summary { cursor: pointer; color: var(--accent); width: fit-content; }
.hint p { margin: 6px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); }

.conf { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
.conf legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 8px; }
.conf legend b { color: var(--danger); font-weight: 500; }
.conf-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.conf-opt input { position: absolute; opacity: 0; pointer-events: none; }
.conf-opt span {
  display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; padding: 6px 4px; text-align: center;
  border-radius: 12px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; font-size: 13px;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.conf-opt span:hover { border-color: rgba(255,255,255,.25); }
.conf-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.conf-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.answer-box { margin-top: 14px; }
.answer-box textarea { min-height: 120px; }
.answer-box textarea.mono { font-family: var(--mono); font-size: 13.5px; tab-size: 2; white-space: pre; overflow-x: auto; }
.answer-tip { font-size: 12px; color: var(--faint); margin-top: 4px; }
.qa-submit { margin-top: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.verdict { margin-top: 20px; padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--glass); }
@media (prefers-reduced-motion: no-preference) { .verdict { animation: cardIn .45s var(--ease); } }
.verdict[data-r="ok"] { border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.06); }
.verdict[data-r="partial"] { border-color: rgba(250,204,21,.4); background: rgba(250,204,21,.05); }
.verdict[data-r="wrong"] { border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.06); }
.v-result { font-size: 18px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.v-delta { font-family: var(--mono); font-size: 13px; color: var(--muted); font-weight: 400; }
.v-danger { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(248,113,113,.14); border: 1px solid rgba(248,113,113,.45); color: #ffd4d4; font-size: 14px; }
.v-feedback { margin: 10px 0 0; font-size: 15px; line-height: 1.8; white-space: pre-line; }
.v-compare { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; margin-top: 12px; }
.v-compare > div { min-width: 0; }
.v-compare .out { font-size: 11.5px; }
.v-compare .out.bad { background: rgba(248,113,113,.05); border-color: rgba(248,113,113,.2); color: #ffd9d9; }
.v-ref { margin-top: 12px; font-size: 14px; }
.v-ref summary { cursor: pointer; color: var(--accent); width: fit-content; }
.v-ref .code { margin-top: 6px; white-space: pre-wrap; }
.mis-tag { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 4px 12px; border-radius: 999px; background: rgba(248,113,113,.12); color: #ffc9c9; font-size: 13px; }
.v-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.notice { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font-size: 14px; }
.notice.err { background: rgba(248,113,113,.12); color: #ffd4d4; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px 4px; font-size: 14px; }

/* ---- 對話框 ---- */
.dlg {
  width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 26px; border-radius: var(--radius);
  background: #111114; color: var(--text); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.dlg-wide { width: min(620px, calc(100% - 32px)); }
.dlg:modal { overscroll-behavior: contain; }
.dlg::backdrop { background: rgba(4,4,6,.72); backdrop-filter: blur(6px); overflow: hidden; overscroll-behavior: contain; }
.dlg h1 { color: var(--ink); font-size: 20px; margin: 8px 0 12px; line-height: 1.4; }
.dlg p { font-size: 14px; line-height: 1.7; margin: 0 0 12px; }
.dlg .row { margin-top: 16px; }
.dlg-x { position: absolute; top: 12px; right: 12px; margin: 0; }
.dlg-x .icon-btn { width: 34px; height: 34px; }
@media (prefers-reduced-motion: no-preference) {
  .dlg[open] { animation: dlgIn .35s var(--ease); }
}
@keyframes dlgIn { from { opacity: 0; translate: 0 10px; } }
.nt-q { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.nt-q legend { color: var(--ink); font-weight: 600; font-size: 15px; margin-bottom: 8px; padding: 0; }
.nt-opts { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); }
.nt-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; }
.nt-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.nt-opt input { margin-top: 4px; accent-color: var(--accent); }
.nt-opt b { display: block; color: var(--ink); font-weight: 600; font-size: 14px; }
.nt-opt small { color: var(--muted); font-size: 12px; }
.nt-other { margin-top: 6px; }
.planning { text-align: center; padding: 20px 0 8px; }
.planning-title { color: var(--ink); font-size: 16px; font-weight: 600; margin: 16px 0 4px !important; }
.orbit { position: relative; width: 96px; height: 96px; margin: 0 auto; }
.orbit-core { position: absolute; inset: 40px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 24px var(--accent); }
.orbit-ring { position: absolute; border-radius: 50%; border: 1px solid var(--line); }
.orbit-ring.r1 { inset: 20px; } .orbit-ring.r2 { inset: 0; }
.orbit-ring i { position: absolute; top: -3px; left: 50%; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .orbit-ring.r1 { animation: spin 3s linear infinite; }
  .orbit-ring.r2 { animation: spin 5s linear infinite reverse; }
}

.toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 60; max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 999px; background: rgba(20,20,24,.95); border: 1px solid var(--line); color: var(--ink); font-size: 13px; }
.toast.err { border-color: rgba(248,113,113,.5); }

/* ---- 手機：左右變抽屜 ---- */
@media (max-width: 767px) {
  body { overflow: hidden; }
  .app, .app.panel-open { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .mobilebar {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft);
    background: rgba(8,8,10,.92);
  }
  .mobilebar-title { flex: 1; min-width: 0; color: var(--ink); font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
  .stage { grid-row: 2; }
  .sidebar, .panel {
    position: fixed; top: 0; bottom: 0; z-index: 40; visibility: hidden;
    box-shadow: 0 0 60px rgba(0,0,0,.7); transition: translate .35s var(--ease), visibility 0s linear .35s;
  }
  .sidebar { left: 0; width: min(320px, 86vw); translate: -100% 0; background: #0c0c0f; }
  .panel { right: 0; width: 100%; translate: 100% 0; background: #0c0c0f; border-left: 0; }
  .app:not(.panel-open) .panel { visibility: hidden; }
  .app[data-drawer="left"] .sidebar, .app[data-drawer="right"] .panel { translate: 0 0; visibility: visible; transition: translate .35s var(--ease), visibility 0s; }
  @media (prefers-reduced-motion: reduce) { .sidebar, .panel { transition: none; } }
  .panel-head, .panel-body { min-width: 0; padding-left: 16px; padding-right: 16px; }
  .drawer-close { display: inline-grid; }
  .panel-tab { display: none; }
  .scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.55); }
  .topic-head { padding: 14px 16px 6px; gap: 10px; }
  .topic-title { font-size: 19px; }
  .topic-actions { width: 100%; }
  .topic-actions { flex-wrap: nowrap; gap: 6px; }
  .topic-actions .btn { flex: 1 1 0; min-width: 0; padding: 8px 10px; }
  .seg-btn { padding: 6px 10px; }
  .legend { margin: 0 16px; gap: 10px; font-size: 11px; }
  .legend .lg-extra { display: none; }
  .list-view { padding: 4px 16px 24px; }
  .map-hint { display: none; }
  .node-card { left: 16px; right: 16px; width: auto; top: auto; bottom: 12px; max-height: 60%; }
  .v-compare { grid-template-columns: 1fr; }
  .bridge-card { padding: 20px; }
}

/* 語音輸入 */
.mic-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 8px; }
.mic-btn { min-height: 36px; padding: 6px 14px; font-size: 13px; }
.mic-btn.on { color: #fff; border-color: #ef4444; background: rgba(239,68,68,.18); }
@media (prefers-reduced-motion: no-preference) {
  .mic-btn.on { animation: micPulse 1.4s ease-in-out infinite; }
}
@keyframes micPulse { 50% { box-shadow: 0 0 0 6px rgba(239,68,68,.12); } }
.mic-lang { min-height: 36px; border-radius: 10px; background: transparent; color: var(--text); border: 1px solid var(--line); padding: 0 8px; font: inherit; font-size: 13px; }
.mic-status { font-size: 12px; color: var(--accent); }
.mic-note { flex-basis: 100%; font-size: 11.5px; color: var(--faint); }
