:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --side: #eeece6;
  --ink: #24211d;
  --muted: #7a746c;
  --line: #e2ded5;
  --accent: #2e6b62;
  --accent-weak: #e2eeeb;
  --warn: #a8691b;
  --warn-weak: #fbf1e1;
  --err: #b23b3b;
  --err-weak: #fbe9e9;
  --radius: 8px;
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
}

* { box-sizing: border-box; }
body { margin: 0; }
.booting { padding: 2rem; color: var(--muted); }

/* ---------------------------------------------------------------- 版面 */
.shell { height: 100vh; display: flex; flex-direction: column; }
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr) 300px; flex: 1; min-height: 0; }
.side { background: var(--side); border-right: 1px solid var(--line); padding: 1.2rem 0.8rem; overflow-y: auto; display: flex; flex-direction: column; }
.main { overflow-y: auto; padding: 1.4rem 2rem 4rem; }
.checks { border-left: 1px solid var(--line); background: var(--panel); padding: 1.2rem 1rem; overflow-y: auto; }

.book-title { font-size: 1.15rem; font-weight: 700; margin: 0 0.4rem 0.2rem; }
.book-meta { color: var(--muted); font-size: 0.8rem; margin: 0 0.4rem 1.2rem; }
.nav-group { margin-bottom: 1.2rem; }
.nav-group h3 { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.08em; margin: 0 0.4rem 0.3rem; font-weight: 600; }
.nav-item { display: flex; justify-content: space-between; align-items: center; padding: 0.38rem 0.6rem;
  border-radius: 6px; color: var(--ink); text-decoration: none; cursor: pointer; }
.nav-item:hover { background: rgba(0, 0, 0, 0.04); }
.nav-item.active { background: var(--panel); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); font-weight: 600; }
.nav-item.disabled { color: var(--muted); cursor: default; }
.nav-item .count { color: var(--muted); font-size: 0.8rem; font-weight: 400; }

/* ---------------------------------------------------------------- 頁首 */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  position: sticky; top: -1.4rem; background: var(--bg); padding: 1.4rem 0 0.8rem; margin-top: -1.4rem; z-index: 5; }
.page-head h1 { font-size: 1.4rem; margin: 0; display: flex; align-items: center; gap: 0.6rem; }
.page-head .hint { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.88rem; max-width: 46rem; }
.actions { display: flex; gap: 0.5rem; align-items: center; flex-shrink: 0; }

.badge { white-space: nowrap; font-size: 0.72rem; font-weight: 600; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--accent-weak); color: var(--accent); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.muted { background: var(--side); color: var(--muted); }

/* ---------------------------------------------------------------- 按鈕與輸入 */
button { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 0.35rem 0.85rem; border-radius: 6px; cursor: pointer; }
button:hover:not(:disabled) { border-color: #c9c3b8; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; border-style: dashed; color: var(--muted); }
button.small { font-size: 0.85rem; padding: 0.2rem 0.7rem; }
button.icon { padding: 0.15rem 0.45rem; font-size: 0.85rem; color: var(--muted); }
button.danger, button.icon.danger:hover { color: var(--err); }
kbd { font-size: 0.7rem; opacity: 0.75; margin-left: 0.3rem; font-family: inherit; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 0.3rem 0.8rem; }
.seg button.on { background: var(--accent-weak); color: var(--accent); font-weight: 600; }

input, textarea, select { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 6px;
  padding: 0.4rem 0.6rem; background: #fff; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
textarea { resize: vertical; field-sizing: content; min-height: 4.2rem; }
textarea.big { min-height: 60vh; line-height: 1.8; }
textarea.code, .code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.85rem; }
input[readonly] { background: var(--bg); color: var(--muted); }

.field { margin-bottom: 0.9rem; }
.field > label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; }
.field .help { font-size: 0.78rem; color: var(--muted); font-weight: 400; margin-left: 0.4rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.9rem; }

.error { background: var(--err-weak); color: var(--err); border-radius: var(--radius); padding: 0.6rem 0.9rem;
  white-space: pre-wrap; margin-bottom: 1rem; font-size: 0.9rem; }
.note { color: var(--muted); font-size: 0.85rem; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

/* ---------------------------------------------------------------- 卡片 */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 0.9rem; }
.card-head { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 0.6rem; }
.card-head input.title { font-weight: 600; font-size: 1.02rem; }
.card-head .tools { display: flex; gap: 0.2rem; flex-shrink: 0; }
.check { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; font-size: 0.88rem; cursor: pointer; }
.check input { width: auto; }

details.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 0.8rem; }
details.section > summary { padding: 0.7rem 1.1rem; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.section > summary::after { content: "▸"; color: var(--muted); }
details.section[open] > summary::after { content: "▾"; }
details.section > .body { padding: 0 1.1rem 0.4rem; }

/* ---------------------------------------------------------------- 清單 + 編輯器 */
.split { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.picker { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.4rem; position: sticky; top: 4.5rem; }
.pick { display: block; padding: 0.5rem 0.6rem; border-radius: 6px; cursor: pointer; }
.pick:hover { background: var(--bg); }
.pick.on { background: var(--accent-weak); }
.pick .name { font-weight: 600; display: flex; justify-content: space-between; gap: 0.4rem; align-items: center; }
.pick .sub { font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .add { width: 100%; margin-top: 0.3rem; }

.list-editor { display: flex; flex-direction: column; gap: 0.35rem; }
.list-row { display: flex; gap: 0.35rem; align-items: flex-start; }
.list-row .num { color: var(--muted); font-size: 0.85rem; width: 1.4rem; text-align: right; padding-top: 0.45rem; flex-shrink: 0; }
.list-row select { width: 11rem; flex-shrink: 0; }
.list-row textarea { min-height: 2.4rem; }
.list-editor > button { align-self: flex-start; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem 0.75rem; cursor: pointer; font-size: 0.88rem; background: #fff; user-select: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------------------------------------------------------------- 專案總覽 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.8rem; margin: 1rem 0 1.4rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; cursor: pointer; }
.stat .num { font-size: 1.5rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 0.82rem; }
code.cmd { background: var(--side); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.85rem; }

/* ---------------------------------------------------------------- 故事線分布 */
table.grid { border-collapse: collapse; font-size: 0.85rem; background: var(--panel); }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 0.3rem 0.55rem; text-align: center; }
table.grid th:first-child, table.grid td:first-child { text-align: left; white-space: nowrap; }
table.grid td.on { background: var(--accent-weak); color: var(--accent); font-weight: 700; }
.scroll-x { overflow-x: auto; }

/* ---------------------------------------------------------------- 檢查面板 */
.checks h2 { font-size: 1rem; margin: 0 0 0.8rem; display: flex; justify-content: space-between; align-items: center; }
.issue { padding: 0.5rem 0.6rem; border-radius: 6px; margin-bottom: 0.4rem; font-size: 0.86rem; cursor: pointer; display: flex; gap: 0.45rem; }
.issue:hover { filter: brightness(0.97); }
.issue.error { background: var(--err-weak); color: var(--err); }
.issue.warning { background: var(--warn-weak); color: var(--warn); }
.issue.info { background: var(--bg); color: var(--muted); }
.issue .where { font-size: 0.72rem; opacity: 0.8; }
.ok-msg { color: var(--accent); font-size: 0.9rem; }

/* ---------------------------------------------------------------- 提示 */
.toast { position: fixed; bottom: 3.2rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 0.55rem 1.1rem; border-radius: 999px; font-size: 0.9rem; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18); z-index: 20; }
.toast.warn { background: var(--warn); }
.toast.error { background: var(--err); }

/* ---------------------------------------------------------------- 專案 */
.book-switch { display: block; border-radius: 8px; padding: 0.3rem 0; margin-bottom: 0.6rem; cursor: pointer; }
.book-switch:hover, .book-switch.active { background: rgba(0, 0, 0, 0.04); }
.book-switch .book-meta { margin-bottom: 0.2rem; }
.switch-icon { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 0.9rem; margin-bottom: 1rem; }
.project-grid .card { margin-bottom: 0; display: flex; flex-direction: column; }
.project-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.project-card .project-title { font-size: 1.05rem; flex: 1; }
.project-card p.note { margin: 0.15rem 0; }
.project-card .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; }
.project-card .toolbar { margin-top: auto; padding-top: 0.6rem; }
.project-card.new { border-style: dashed; }
button.danger-bg { background: var(--err); border-color: var(--err); color: #fff; }

/* ---------------------------------------------------------------- 模型選單 */
.model-picker { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.model-picker select { width: auto; max-width: 15rem; padding: 0.22rem 0.4rem; font-size: 0.84rem; }
.model-picker select.chosen { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------------- 寫作畫面 */
.warn-text { color: var(--warn); }
.err-text { color: var(--err); }
.section-title { font-size: 1.05rem; margin: 2rem 0 0.6rem; }
.side-note { margin: 0.2rem 0.6rem; font-size: 0.8rem; }
.chapter-item { font-size: 0.9rem; }
.chapter-item > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-status { display: inline-block; width: 1.2rem; color: var(--accent); }

.banner { border-radius: var(--radius); padding: 0.6rem 0.9rem; margin-bottom: 1rem; font-size: 0.9rem; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-weak); color: var(--warn); }
.cta { text-align: center; padding: 2rem; }
.cta h2 { margin-top: 0; }

.tabs { display: flex; gap: 0.2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: 0.45rem 1rem; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs a.on { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }

.toolbar { display: flex; gap: 0.5rem; align-items: center; margin: 0.6rem 0; }
.toolbar button { white-space: nowrap; flex-shrink: 0; }
.toolbar .spacer, .spacer { flex: 1; }
.footer-actions { display: flex; gap: 0.6rem; align-items: center; margin: 1.2rem 0 2rem; }

table.plan-table { border-collapse: collapse; width: 100%; background: var(--panel); font-size: 0.9rem; }
table.plan-table th { text-align: left; font-size: 0.78rem; color: var(--muted); font-weight: 600; padding: 0.4rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.plan-table td { padding: 0.35rem 0.3rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plan-table td.no { text-align: center; padding-top: 0.6rem; font-weight: 600; }
table.plan-table input, table.plan-table select, table.plan-table textarea { padding: 0.3rem 0.45rem; font-size: 0.9rem; }
table.plan-table textarea { min-height: 2.2rem; }
table.plan-table tr.detail td { background: var(--bg); padding: 0.8rem; }
table.plan-table .chips .chip { font-size: 0.8rem; padding: 0.05rem 0.55rem; }
.status-dot { cursor: pointer; display: inline-block; padding-top: 0.4rem; color: var(--accent); }
.tension input { width: 4rem; }
.tbar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 4px; width: 4rem; }
.tbar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
input.w6 { width: 6rem; }
table.plan-table input.w-title { min-width: 8.5rem; }
table.plan-table select.w-pov { min-width: 6.5rem; }
table.grid.left th, table.grid.left td { text-align: left; }
.fs-table { width: 100%; }
.fs-table input, .fs-table select { padding: 0.25rem 0.4rem; font-size: 0.88rem; }

.scene-card .card-head input.title { font-weight: 400; }
.scene-text .card-head { align-items: baseline; }
.scene-status { color: var(--accent); width: 1rem; }
.scene-summary { flex: 1; color: var(--muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prose { font-size: 1.02rem; line-height: 1.95; max-width: 46em; }
.prose p { margin: 0 0 0.9em; text-indent: 2em; }
.prose.live { white-space: pre-wrap; }
.prose.partial { opacity: 0.7; }
.prose.partial p.note { text-indent: 0; }
.cursor { animation: blink 1s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
textarea.prose-edit { line-height: 1.9; font-size: 1rem; }
ul.warnings { list-style: none; padding: 0; margin: 0.4rem 0; font-size: 0.84rem; color: var(--warn); }
.state-view p { margin: 0.4rem 0; }
.state-view table { margin: 0.5rem 0; width: 100%; }

.chapter-info h2 { font-size: 1rem; margin: 0 0 0.6rem; }
.chapter-info h3 { font-size: 0.85rem; margin: 1rem 0 0.4rem; color: var(--muted); }
.chapter-info dl { display: grid; grid-template-columns: 4.2rem 1fr; gap: 0.3rem 0.5rem; font-size: 0.88rem; margin: 0; }
.chapter-info dt { color: var(--muted); }
.chapter-info dd { margin: 0; }
.chapter-info ol { padding-left: 1.2rem; font-size: 0.86rem; margin: 0; }

.statusbar { height: 36px; flex-shrink: 0; border-top: 1px solid var(--line); background: var(--panel); display: flex; align-items: center;
  justify-content: space-between; padding: 0 1rem; font-size: 0.84rem; gap: 1rem; }
.statusbar .job { display: flex; align-items: center; gap: 0.5rem; min-width: 0; overflow: hidden; white-space: nowrap; }
.statusbar .meta { display: flex; gap: 1rem; color: var(--muted); white-space: nowrap; }
.statusbar button.small { padding: 0.05rem 0.6rem; }
.spin { display: inline-block; animation: spin 1.2s linear infinite; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-bg { position: fixed; inset: 0; background: rgba(30, 28, 24, 0.35); display: flex; align-items: center; justify-content: center; z-index: 30; }
.modal { background: var(--panel); border-radius: 10px; padding: 1.2rem 1.4rem; width: min(560px, 92vw); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2); }
.modal.wide { width: min(1100px, 94vw); }
.modal h2 { margin: 0 0 0.6rem; font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.history { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; max-height: 65vh; }
.history .versions { overflow-y: auto; border-right: 1px solid var(--line); padding-right: 0.5rem; }
.history .compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; min-height: 0; }
.history .compare h3 { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.3rem; }
pre.prose-box { white-space: pre-wrap; font-family: inherit; background: var(--bg); border-radius: 6px; padding: 0.7rem; margin: 0;
  max-height: 58vh; overflow-y: auto; font-size: 0.88rem; line-height: 1.7; }

@media (max-width: 1180px) {
  .app { grid-template-columns: 200px minmax(0, 1fr); }
  .checks { display: none; }
}

/* 正文標示（decisions D65）：底色標出高頻詞、與前文重複、段首重複、審稿問題，滑過顯示原因 */
mark.mk { color: inherit; padding: 0 1px; border-radius: 2px; background: none; }
.mk-overused { background: #fbeec4; }
.mk-repeat { background: #f7d9d4; }
.mk-same_start { box-shadow: inset 0 -2px 0 #d29a3a; }
.mk-review { background: #dfe9f7; box-shadow: inset 0 -2px 0 #4f7cc0; cursor: help; }
mark.flash { animation: flash 0.6s ease-in-out 4; }
@keyframes flash { 50% { background: #9fc0ef; } }
.text-tools { font-size: 0.84rem; margin-bottom: 0.4rem; }
.text-tools label.check { display: inline-flex; gap: 0.3rem; align-items: center; cursor: pointer; }
.text-tools label.check input { width: auto; }
.legend { display: inline-flex; gap: 0.6rem; color: var(--muted); }
.legend .mk { padding: 0 0.3rem; color: var(--ink); }
.sel-toolbar { position: fixed; transform: translate(-50%, calc(-100% - 6px)); z-index: 25; }
.sel-toolbar button { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }

/* 選段改寫 */
.rewrite-dialog .compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 0.6rem; }
.rewrite-dialog .compare h3 { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.3rem; }
.rewrite-dialog pre.prose-box { max-height: 40vh; min-height: 6rem; }

/* 審稿 */
.tabs .count { display: inline-block; margin-left: 0.3rem; font-size: 0.7rem; font-weight: 700; background: var(--err); color: #fff;
  border-radius: 999px; padding: 0 0.4rem; line-height: 1.3rem; vertical-align: 1px; }
.badge.danger { background: var(--err-weak); color: var(--err); }
.issue-card.sev-major { border-left: 3px solid var(--err); }
.issue-card.st-fixed, .issue-card.st-ignored { opacity: 0.6; }
.issue-card p.detail { margin: 0.4rem 0; }
blockquote.quote { margin: 0.4rem 0; padding: 0.35rem 0.7rem; border-left: 3px solid #4f7cc0; background: #f1f5fb; font-size: 0.92rem; }
blockquote.quote.link { cursor: pointer; }
blockquote.quote.link:hover { background: #e3ecf8; }
blockquote.quote.missing { border-left-color: var(--line); background: var(--bg); color: var(--muted); }
.card.upstream ul, .stale-banner ul.changes { margin: 0.3rem 0 0; padding-left: 1.2rem; font-size: 0.86rem; }

/* stale 橫幅 */
.stale-banner { flex-direction: column; align-items: stretch; }
.stale-banner .stale-actions { display: flex; gap: 0.5rem; }
.stale-banner ul.changes { color: var(--ink); max-height: 14rem; overflow-y: auto; }
a.link { color: var(--accent); cursor: pointer; text-decoration: underline; margin-left: 0.4rem; }

/* 全書檢視（decisions D68）：資料顏色用 dataviz 參考色盤（已驗證 CVD 與對比），文字一律用文字色 */
.viz-root { --series-1: #2a78d6; --series-2: #eb6834; --grid: #e1e0d9; --axis: #c3c2b7; --muted-ink: #898781; --surface: #ffffff; position: relative; }
.viz-head { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.4rem; }
.legend-key { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.line-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: middle; }
.line-key.s1 { background: #2a78d6; } .line-key.s2 { background: #eb6834; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(11, 11, 11, 0.1); }
.planned-key { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.viz-plot { position: relative; }
.viz-plot svg { width: 100%; height: auto; display: block; touch-action: none; }
.viz-plot .grid { stroke: var(--grid); stroke-width: 1; }
.viz-plot .grid.base { stroke: var(--axis); }
.viz-plot .tick { fill: var(--muted-ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-plot .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-plot .series.s1 { stroke: var(--series-1); } .viz-plot .series.s2 { stroke: var(--series-2); }
.viz-plot .dot { stroke: var(--surface); stroke-width: 2; }
.viz-plot .dot.s1 { fill: var(--series-1); } .viz-plot .dot.s2 { fill: var(--series-2); }
.viz-plot .crosshair { stroke: var(--axis); stroke-width: 1; }
.viz-plot .end-label { fill: var(--muted); font-size: 12px; }
.viz-tip { position: absolute; top: 4px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 0.35rem 0.6rem; font-size: 0.8rem; pointer-events: none; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1); white-space: nowrap; }
.viz-tip .tip-title { color: var(--muted); margin-bottom: 0.15rem; }
.viz-tip strong { display: inline-block; min-width: 1.4rem; font-variant-numeric: tabular-nums; }
.viz-table { margin-top: 0.4rem; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.9rem; }
.stat-label { font-size: 0.8rem; color: var(--muted); }
.stat-value { font-size: 1.35rem; font-weight: 600; margin-top: 0.1rem; }
.stat-sub { font-size: 0.75rem; color: var(--muted); }
table.heat { border-collapse: separate; border-spacing: 2px; font-size: 0.78rem; }
table.heat th { font-weight: 500; color: var(--muted); }
table.heat th.colno { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; }
table.heat th.colno a { cursor: pointer; }
table.heat th.rowname { text-align: right; padding-right: 0.5rem; white-space: nowrap; color: var(--ink); max-width: 14rem; }
table.heat th.rowname .desc { font-size: 0.7rem; color: var(--muted); white-space: normal; font-weight: 400; }
table.heat td { width: 26px; height: 26px; border-radius: 4px; text-align: center; position: relative; background: var(--bg);
  box-shadow: inset 0 0 0 1px rgba(11, 11, 11, 0.06); font-variant-numeric: tabular-nums; cursor: default; color: var(--ink); }
table.heat td:hover, table.heat td:focus { outline: 2px solid var(--ink); outline-offset: 0; }
table.heat td.planned::after { content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: 0.85; }
table.heat td .miss { color: var(--warn); font-size: 0.8rem; }
table.heat.fs td.fs-pending { box-shadow: inset 0 0 0 1px var(--axis, #c3c2b7); background: transparent; }
table.heat.fs td.fs-dropped { background: repeating-linear-gradient(135deg, transparent 0 4px, #c3c2b7 4px 5px); }
table.heat.fs td.fs-none { background: transparent; box-shadow: none; }
table.heat.fs .fs-mark { font-size: 0.72rem; font-weight: 700; }
.swatch.fs-pending { box-shadow: inset 0 0 0 1px #c3c2b7; }
.swatch.fs-dropped { background: repeating-linear-gradient(135deg, transparent 0 3px, #c3c2b7 3px 4px) !important; }
ul.fs-warnings { list-style: none; padding: 0; margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--warn); }
.export-card .toolbar { margin-top: 0.4rem; }

/* ---------------------------------------------------------------- 登入與帳號（BookWriter） */
a.button, label.button { display: inline-block; cursor: pointer; font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 0.35rem 0.85rem; border-radius: 6px; cursor: pointer; text-decoration: none; text-align: center; }
a.button:hover, label.button:hover { border-color: #c9c3b8; }
label.button.disabled { opacity: .5; pointer-events: none; }
a.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
a.button.small, label.button.small { font-size: 0.85rem; padding: 0.05rem 0.6rem; }
.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.signin-card { width: min(420px, 100%); padding: 1.6rem 1.8rem; }
.signin-card h1 { margin: 0 0 0.4rem; font-size: 1.5rem; }
.signin-card > button.primary { width: 100%; margin: 0.2rem 0 0.6rem; }
.signin-tabs { margin: 0.6rem 0 1rem; }
.signin-buttons { display: flex; flex-direction: column; gap: 0.6rem; margin: 1rem 0; }
.user-box { margin-top: auto; padding: 0.8rem 0.4rem 0; border-top: 1px solid var(--line); font-size: 0.85rem; }
.user-box .user-name { font-weight: 600; display: flex; align-items: center; gap: 0.4rem; }
.user-box .user-points { display: flex; flex-wrap: wrap; gap: 0 0.2rem; align-items: baseline; color: var(--ink); }
.user-box .user-points a.link { margin-left: 0; }
.user-box .signout { margin-left: 0; color: var(--muted); font-size: 0.8rem; }
