/* Yuet Notes —— 殼：token、側欄、頁、block、database。地圖喺 maps.css。 */

:root {
  --font: -apple-system, BlinkMacSystemFont, "PingFang HK", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #fbfaf8;
  --surface: #ffffff;
  --side: #f4f2ee;
  --ink: #1f1d1a;
  --ink-2: #5d5850;
  --ink-3: #98928a;
  --line: #e7e3dc;
  --line-2: #d9d4cb;
  --hover: rgba(60, 48, 30, .055);
  --press: rgba(60, 48, 30, .1);
  --focus: #2f6bdc;
  --shadow-1: 0 1px 2px rgba(40, 30, 15, .06), 0 2px 8px rgba(40, 30, 15, .05);
  --shadow-2: 0 10px 30px rgba(40, 30, 15, .14), 0 2px 6px rgba(40, 30, 15, .08);

  --accent: #2f6bdc;  --accent-soft: #e9f0fd;  --accent-ink: #1d4fb0;
  --amber: #b97a12;   --amber-soft: #fbf1dc;
  --green: #2c8f55;   --green-soft: #e3f3e9;
  --red: #c8433a;     --red-soft: #fbe9e7;
  --purple: #7a5bc9;  --purple-soft: #efeafb;

  /* select／tag 顏色 */
  --c-gray: #ecebe8;   --t-gray: #57534c;
  --c-brown: #f1e6dc;  --t-brown: #7a4e2c;
  --c-orange: #fbe7d6; --t-orange: #a0501a;
  --c-yellow: #faf0cf; --t-yellow: #8a6a0c;
  --c-green: #def2e5;  --t-green: #23704a;
  --c-blue: #dfeafb;   --t-blue: #2457b3;
  --c-purple: #ece5fa; --t-purple: #6343ad;
  --c-pink: #f9e1ec;   --t-pink: #a3376b;
  --c-red: #fbe1de;    --t-red: #ae3329;

  --side-w: 264px;
  --page-w: 720px;
  --wide-w: 1000px;
  --r-s: 6px; --r-m: 10px; --r-l: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191817; --surface: #211f1d; --side: #1f1d1b;
    --ink: #ecebe7; --ink-2: #b3ada4; --ink-3: #7d776f;
    --line: #2f2c29; --line-2: #3b3834;
    --hover: rgba(255, 250, 240, .06); --press: rgba(255, 250, 240, .1);
    --focus: #7aa5ff;
    --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 12px 34px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.3);
    --accent: #7aa5ff; --accent-soft: rgba(122,165,255,.14); --accent-ink: #a9c4ff;
    --amber: #e7b04e; --amber-soft: rgba(231,176,78,.14);
    --green: #5fca8a; --green-soft: rgba(95,202,138,.14);
    --red: #ff7a6e; --red-soft: rgba(255,122,110,.14);
    --purple: #b39dff; --purple-soft: rgba(179,157,255,.14);
    --c-gray: #34312e; --t-gray: #cfcac2; --c-brown: #3d3027; --t-brown: #e0bb9c; --c-orange: #432f20; --t-orange: #f2b07f;
    --c-yellow: #3f3720; --t-yellow: #ecd17e; --c-green: #203a2b; --t-green: #8bdcaa; --c-blue: #1f2f4a; --t-blue: #9dbefa;
    --c-purple: #2f2747; --t-purple: #c6b4ff; --c-pink: #42263a; --t-pink: #f3a6c9; --c-red: #46241f; --t-red: #ffa69b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #191817; --surface: #211f1d; --side: #1f1d1b;
  --ink: #ecebe7; --ink-2: #b3ada4; --ink-3: #7d776f;
  --line: #2f2c29; --line-2: #3b3834;
  --hover: rgba(255, 250, 240, .06); --press: rgba(255, 250, 240, .1);
  --focus: #7aa5ff;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 12px 34px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.3);
  --accent: #7aa5ff; --accent-soft: rgba(122,165,255,.14); --accent-ink: #a9c4ff;
  --amber: #e7b04e; --amber-soft: rgba(231,176,78,.14);
  --green: #5fca8a; --green-soft: rgba(95,202,138,.14);
  --red: #ff7a6e; --red-soft: rgba(255,122,110,.14);
  --purple: #b39dff; --purple-soft: rgba(179,157,255,.14);
  --c-gray: #34312e; --t-gray: #cfcac2; --c-brown: #3d3027; --t-brown: #e0bb9c; --c-orange: #432f20; --t-orange: #f2b07f;
  --c-yellow: #3f3720; --t-yellow: #ecd17e; --c-green: #203a2b; --t-green: #8bdcaa; --c-blue: #1f2f4a; --t-blue: #9dbefa;
  --c-purple: #2f2747; --t-purple: #c6b4ff; --c-pink: #42263a; --t-pink: #f3a6c9; --c-red: #46241f; --t-red: #ffa69b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.7; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 殼 ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-padding-top: 24px; }
.boot { padding: 120px 24px; text-align: center; color: var(--ink-3); }

/* 側欄 */
.side {
  width: var(--side-w); flex: none; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden; font-size: 14.5px; line-height: 1.4;
}
.side-top { padding: 14px 10px 6px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.brand-name { font-weight: 650; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--ink-3); }
.side-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: var(--r-s); color: var(--ink-2); text-align: left; min-height: 32px; }
.side-btn:hover { background: var(--hover); }
.side-btn .ico { width: 20px; text-align: center; flex: none; opacity: .8; }
.side-btn kbd { margin-left: auto; font: 11px var(--mono); color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.side-label { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 14px 8px 4px; display: flex; align-items: center; justify-content: space-between; }
.side-label button { width: 22px; height: 22px; border-radius: 5px; color: var(--ink-3); display: grid; place-items: center; }
.side-label button:hover { background: var(--hover); color: var(--ink); }
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: 14px; }
.trow { position: relative; display: flex; align-items: center; gap: 2px; border-radius: var(--r-s); min-height: 32px; padding-right: 4px; }
.trow:hover { background: var(--hover); }
.trow.on { background: var(--press); }
.trow.on .tlink { color: var(--ink); font-weight: 560; }
.ttog { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 5px; color: var(--ink-3); }
.ttog:hover { background: var(--press); }
.ttog svg { transition: transform .16s var(--ease); }
.ttog[aria-expanded="true"] svg { transform: rotate(90deg); }
.ttog.empty { visibility: hidden; }
.tlink { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 5px 2px; text-decoration: none; color: var(--ink-2); }
.tlink .ticon { width: 20px; text-align: center; flex: none; }
.tlink .tname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tact { display: none; gap: 2px; }
.trow:hover .tact, .trow:focus-within .tact { display: flex; }
.tact button { width: 24px; height: 24px; border-radius: 5px; color: var(--ink-3); display: grid; place-items: center; font-size: 15px; }
.tact button:hover { background: var(--press); color: var(--ink); }
.side-foot { padding: 10px 14px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.ok { background: var(--green); }
.dot.warn { background: var(--amber); }
.dot.err { background: var(--red); }

/* 頂欄 */
.topbar { height: 48px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 12px 0 16px; border-bottom: 1px solid transparent; transition: border-color .2s; }
.topbar.scrolled { border-bottom-color: var(--line); }
.icon-btn { width: 32px; height: 32px; border-radius: var(--r-s); display: grid; place-items: center; color: var(--ink-2); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; font-size: 14px; color: var(--ink-2); }
.crumbs a { text-decoration: none; padding: 3px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.crumbs a:hover { background: var(--hover); }
.crumbs .sep { color: var(--ink-3); }
.topbar .grow { flex: 1; }
.sync { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-3); padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
button.sync:hover { background: var(--hover); color: var(--ink-2); }

/* ---------- 頁 ---------- */
.page { width: 100%; max-width: calc(var(--page-w) + 96px); margin: 0 auto; padding: 56px 48px 40vh; }
.page-icon { font-size: 56px; line-height: 1; width: 72px; height: 72px; display: grid; place-items: center; border-radius: var(--r-m); margin: 0 0 12px -8px; }
.page-icon:hover { background: var(--hover); }
.page-title {
  font-size: 40px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; margin: 0 0 6px; outline: none;
  word-break: break-word;
}
.page-title:empty::before { content: "未命名"; color: var(--ink-3); }
.page-meta { font-size: 13px; color: var(--ink-3); margin-bottom: 28px; display: flex; gap: 14px; flex-wrap: wrap; }
.page-tail { min-height: 120px; cursor: text; }

/* block 行 */
.blocks { position: relative; }
.blk { position: relative; margin: 1px 0; padding-left: calc(var(--indent, 0) * 26px); border-radius: 4px; }
.blk.gap-top { margin-top: 1.1em; }
.gutter {
  position: absolute; top: 0; left: calc(var(--indent, 0) * 26px - 52px); height: 30px;
  display: flex; align-items: center; gap: 1px; opacity: 0; transition: opacity .12s;
}
.blk:hover > .gutter, .blk.menu-open > .gutter { opacity: 1; }
.gutter button { width: 24px; height: 24px; border-radius: 5px; display: grid; place-items: center; color: var(--ink-3); }
.gutter button:hover { background: var(--hover); color: var(--ink-2); }
.g-drag { cursor: grab; }
.blk.dragging { opacity: .35; }
.drop-line { position: absolute; left: 0; right: 0; height: 3px; border-radius: 2px; background: var(--focus); opacity: .7; pointer-events: none; z-index: 5; }
.blk.selected::after { content: ""; position: absolute; inset: -2px -6px; border-radius: 6px; background: var(--accent-soft); z-index: -1; }

.txt { outline: none; white-space: pre-wrap; word-break: break-word; min-height: 1.7em; padding: 3px 2px; }
.txt:empty::before { content: attr(data-ph); color: var(--ink-3); pointer-events: none; }
.txt:not(:focus):empty::before { content: ""; }
.blk:only-child .txt:empty::before, .txt.ph-always:empty::before { content: attr(data-ph); }
.txt b, .txt strong { font-weight: 650; }
.txt code { font: .88em var(--mono); background: var(--hover); color: var(--red); padding: .1em .35em; border-radius: 4px; }
.txt a { color: var(--accent-ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.mention { display: inline-flex; align-items: baseline; gap: 3px; text-decoration: none !important; color: var(--ink) !important; border-bottom: 1px solid var(--line-2); font-weight: 520; }
.mention:hover { background: var(--hover); }

.t-heading1 .txt { font-size: 30px; line-height: 1.3; font-weight: 700; padding-top: 10px; letter-spacing: -.005em; }
.t-heading2 .txt { font-size: 23px; line-height: 1.35; font-weight: 680; padding-top: 6px; }
.t-heading3 .txt { font-size: 18.5px; line-height: 1.4; font-weight: 650; }
.blk.t-heading1 { margin-top: 1.6em; } .blk.t-heading2 { margin-top: 1.4em; } .blk.t-heading3 { margin-top: 1em; }
.blk:first-child { margin-top: 0; }
.gutter { }
.t-heading1 > .gutter { top: 14px; } .t-heading2 > .gutter { top: 9px; } .t-heading3 > .gutter { top: 2px; }

.li { display: flex; align-items: flex-start; }
.li .mk { flex: none; width: 26px; min-height: 1.7em; padding-top: 3px; display: flex; justify-content: center; color: var(--ink-2); user-select: none; }
.li .mk.bullet::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-top: .72em; }
.li .mk.bullet.l1::before { background: none; border: 1.5px solid currentColor; }
.li .mk.bullet.l2::before { border-radius: 1px; }
.li .mk.num { font-variant-numeric: tabular-nums; justify-content: flex-end; padding-right: 7px; }
.li .txt { flex: 1; min-width: 0; }
.li .check { width: 18px; height: 18px; margin: 6px 4px 0 2px; border-radius: 4px; border: 1.5px solid var(--ink-3); display: grid; place-items: center; flex: none; transition: background .15s, border-color .15s; }
.li .check svg { opacity: 0; transform: scale(.6); transition: opacity .15s, transform .2s var(--ease); }
.t-todo.done .check { background: var(--accent); border-color: var(--accent); }
.t-todo.done .check svg { opacity: 1; transform: none; }
.t-todo.done .txt { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-3); }

.t-quote .txt { border-left: 3px solid var(--ink); padding: 2px 0 2px 16px; margin: 4px 0; font-size: 17px; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-m); background: var(--hover); margin: 6px 0; }
.callout.tone-info { background: var(--accent-soft); }
.callout.tone-good { background: var(--green-soft); }
.callout.tone-warn { background: var(--amber-soft); }
.callout .c-ico { font-size: 19px; line-height: 1.6; flex: none; border-radius: 6px; width: 26px; text-align: center; }
.callout .c-ico:hover { background: var(--press); }
.callout .txt { flex: 1; min-width: 0; padding: 0; }
.t-divider .hr { padding: 12px 0; cursor: default; }
.t-divider .hr::before { content: ""; display: block; height: 1px; background: var(--line-2); }
.codebox { position: relative; background: var(--hover); border-radius: var(--r-m); margin: 6px 0; }
.codebox .txt { font: 14px/1.6 var(--mono); padding: 16px 18px; overflow-x: auto; white-space: pre; tab-size: 2; }
.codebox .lang { position: absolute; top: 6px; right: 10px; font-size: 11.5px; color: var(--ink-3); }

.imgbox { margin: 8px 0; }
.imgbox img { display: block; max-width: 100%; border-radius: var(--r-m); }
.imgbox figcaption { font-size: 13.5px; color: var(--ink-3); padding-top: 6px; }
.img-empty { display: flex; gap: 8px; align-items: center; padding: 14px; border-radius: var(--r-m); background: var(--hover); color: var(--ink-3); }
.img-empty input { flex: 1; min-width: 0; border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r-s); padding: 6px 10px; }

.pagelink { display: flex; align-items: center; gap: 10px; padding: 5px 6px; margin: 0 -6px; border-radius: var(--r-s); text-decoration: none; }
.pagelink:hover { background: var(--hover); }
.pagelink .pl-ico { width: 24px; text-align: center; font-size: 18px; }
.pagelink .pl-name { font-weight: 560; border-bottom: 1px solid var(--line-2); }
.pagelink .pl-sub { color: var(--ink-3); font-size: 13px; margin-left: auto; }
.missing { padding: 12px 14px; border-radius: var(--r-m); border: 1px dashed var(--line-2); color: var(--ink-3); font-size: 14px; }

/* 寬 block（地圖、database）衝出閱讀欄 */
.blk.wide { margin: 14px 0 18px; }
.blk.wide > .blk-body { width: min(var(--wide-w), calc(100vw - var(--side-w) - 64px)); margin-left: 50%; transform: translateX(-50%); }
.blk.wide > .gutter { left: calc(50% - min(var(--wide-w), calc(100vw - var(--side-w) - 64px)) / 2 - 52px); }

/* ---------- 浮層：選單／popover ---------- */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
#layer > * { pointer-events: auto; }
.pop {
  position: fixed; min-width: 220px; max-width: min(340px, calc(100vw - 24px)); max-height: min(420px, 70vh); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow-2);
  padding: 6px; font-size: 14px; line-height: 1.35;
  animation: pop-in .14s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.pop-h { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 8px 10px 4px; display: flex; align-items: center; gap: 6px; }
.pop-h button { color: var(--ink-3); border-radius: 4px; padding: 0 4px; }
.pop-h button:hover { background: var(--hover); }
.pop-i { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 6px 8px; border-radius: var(--r-s); min-height: 36px; }
.pop-i.on, .pop-i:hover { background: var(--hover); }
.pop-i .pi-ico { width: 34px; height: 34px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; flex: none; font-size: 15px; color: var(--ink-2); }
.pop-i.small .pi-ico { width: 22px; height: 22px; border: 0; background: none; }
.pop-i .pi-t { font-weight: 520; }
.pop-i .pi-d { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.pop-i.danger { color: var(--red); }
.pop-empty { padding: 10px; color: var(--ink-3); }
.pop-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.pop input.pop-search { width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-s); padding: 6px 9px; background: var(--bg); margin-bottom: 4px; outline: none; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; padding: 4px; }
.emoji-grid button { height: 34px; border-radius: 6px; font-size: 20px; }
.emoji-grid button:hover { background: var(--hover); }

/* 快搵 */
.modal-scrim { position: fixed; inset: 0; background: rgba(20, 15, 10, .32); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.finder { position: fixed; top: 12vh; left: 50%; transform: translateX(-50%); width: min(620px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-2); overflow: hidden; border: 1px solid var(--line); animation: pop-in .16s var(--ease); }
.finder input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 16px 18px; font-size: 17px; background: transparent; outline: none; }
.finder .f-list { max-height: 56vh; overflow-y: auto; padding: 6px; }
.finder .pop-i .pi-d { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finder mark { background: var(--amber-soft); color: inherit; border-radius: 3px; }

/* toast */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(560px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); border-radius: var(--r-m); padding: 10px 14px; font-size: 14px; box-shadow: var(--shadow-2); animation: pop-in .18s var(--ease); pointer-events: auto; white-space: pre-wrap; }
.toast.err { background: var(--red); color: #fff; }

/* 錯誤橫額（內容驗證唔過） */
.banner { margin: 0 0 24px; padding: 12px 16px; border-radius: var(--r-m); background: var(--red-soft); color: var(--red); font-size: 13.5px; line-height: 1.55; }
.banner b { display: block; margin-bottom: 4px; }
.banner code { font: 12.5px var(--mono); white-space: pre-wrap; display: block; color: var(--ink-2); }

/* ---------- Database ---------- */
.db { --cell-h: 36px; }
.db-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 2px 8px; }
.db-title { font-size: 18px; font-weight: 680; display: flex; align-items: center; gap: 8px; margin-right: 6px; }
.db-tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.db-tab { padding: 4px 10px; border-radius: var(--r-s); font-size: 14px; color: var(--ink-3); display: inline-flex; gap: 6px; align-items: center; }
.db-tab:hover { background: var(--hover); color: var(--ink-2); }
.db-tab.on { color: var(--ink); font-weight: 560; box-shadow: inset 0 -2px 0 var(--ink); border-radius: 0; }
.db-head .grow { flex: 1; }
.db-chip { font-size: 12.5px; color: var(--ink-3); padding: 3px 8px; border-radius: 999px; background: var(--hover); display: inline-flex; gap: 6px; align-items: center; }
.db-chip button { color: inherit; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r-s); font-size: 14px; font-weight: 560; }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { opacity: .88; }
.btn.ghost { color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); }

.db-scroll { overflow-x: auto; border-top: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.db-table { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 14px; line-height: 1.4; }
.db-table th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 13px; height: 34px; padding: 0 10px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
.db-table th button { display: inline-flex; align-items: center; gap: 6px; color: inherit; padding: 4px 6px; margin: 0 -6px; border-radius: 5px; }
.db-table th button:hover { background: var(--hover); color: var(--ink-2); }
.db-table th .sort { color: var(--accent); }
.db-table td { height: var(--cell-h); padding: 0 10px; border-bottom: 1px solid var(--line); vertical-align: middle; position: relative; }
.db-table td + td, .db-table th + th { border-left: 1px solid var(--line); }
.db-table tr:hover td { background: color-mix(in srgb, var(--hover) 60%, transparent); }
.cell { min-height: var(--cell-h); display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; cursor: pointer; padding: 5px 0; }
.cell.empty::after { content: "—"; color: var(--line-2); }
.cell-title { display: flex; align-items: center; gap: 8px; min-height: var(--cell-h); }
.cell-title .ct-name { font-weight: 560; cursor: text; flex: 1; min-width: 0; padding: 5px 0; }
.cell-title .ct-name:empty::before { content: "未命名"; color: var(--ink-3); font-weight: 400; }
.cell-title .open { opacity: 0; font-size: 12px; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--ink-2); background: var(--surface); white-space: nowrap; transition: opacity .12s; }
tr:hover .cell-title .open, .cell-title .open:focus-visible { opacity: 1; }
.cell-title .ct-ico { width: 18px; text-align: center; }
.cell-in { width: 100%; border: 0; outline: 2px solid var(--focus); border-radius: 4px; padding: 5px 6px; margin: 0 -6px; background: var(--surface); }
.row-act { position: absolute; left: -30px; top: 50%; transform: translateY(-50%); opacity: 0; width: 24px; height: 24px; border-radius: 5px; color: var(--ink-3); display: grid; place-items: center; }
tr:hover .row-act { opacity: 1; }
.row-act:hover { background: var(--hover); }
.db-add { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; color: var(--ink-3); font-size: 14px; border-bottom: 1px solid var(--line); text-align: left; }
.db-add:hover { background: var(--hover); color: var(--ink-2); }
.db-empty { padding: 18px 10px; color: var(--ink-3); font-size: 14px; border-bottom: 1px solid var(--line); }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 5px; font-size: 13px; font-weight: 500; white-space: nowrap; background: var(--c-gray); color: var(--t-gray); }
.tag.lg { height: 24px; font-size: 13.5px; }
.tag[data-c="brown"] { background: var(--c-brown); color: var(--t-brown); }
.tag[data-c="orange"] { background: var(--c-orange); color: var(--t-orange); }
.tag[data-c="yellow"] { background: var(--c-yellow); color: var(--t-yellow); }
.tag[data-c="green"] { background: var(--c-green); color: var(--t-green); }
.tag[data-c="blue"] { background: var(--c-blue); color: var(--t-blue); }
.tag[data-c="purple"] { background: var(--c-purple); color: var(--t-purple); }
.tag[data-c="pink"] { background: var(--c-pink); color: var(--t-pink); }
.tag[data-c="red"] { background: var(--c-red); color: var(--t-red); }
.tag .dotc { width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; opacity: .75; }
.prog { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 90px; }
.prog .bar { flex: 1; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.prog .bar i { display: block; height: 100%; border-radius: inherit; background: var(--ink-2); transition: width .3s var(--ease); }
.prog.full .bar i { background: var(--green); }
.prog .pct { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; width: 34px; text-align: right; }
.cbx { width: 18px; height: 18px; border-radius: 4px; border: 1.5px solid var(--ink-3); display: grid; place-items: center; }
.cbx.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.muted { color: var(--ink-3); }

/* 看板 */
.board { display: flex; gap: 14px; overflow-x: auto; padding: 10px 2px 12px; border-top: 1px solid var(--line); align-items: flex-start; -webkit-overflow-scrolling: touch; }
.col { flex: 0 0 264px; display: flex; flex-direction: column; gap: 8px; border-radius: var(--r-m); padding: 6px; transition: background .15s; min-height: 80px; }
.col.over { background: var(--hover); }
.col-h { display: flex; align-items: center; gap: 8px; padding: 2px 4px 4px; }
.col-h .n { font-size: 13px; color: var(--ink-3); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 11px 12px; box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 8px; cursor: pointer; text-align: left; width: 100%; font-size: 14px; line-height: 1.45;
  transition: transform .15s var(--ease), box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-2); }
.card.dragging { opacity: .4; }
.card .cd-t { font-weight: 600; font-size: 14.5px; display: flex; gap: 6px; }
.card .cd-row { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; color: var(--ink-2); }
.card .cd-next { color: var(--ink-2); font-size: 13px; }
.card .cd-next::before { content: "→ "; color: var(--ink-3); }
.col .db-add { border: 0; border-radius: var(--r-s); }
.card input { border: 0; outline: none; background: transparent; font-weight: 600; width: 100%; }

/* ---------- 地圖全頁 ---------- */
.mappage { max-width: calc(var(--wide-w) + 96px); margin: 0 auto; padding: 40px 48px 120px; }
.mappage-head { margin-bottom: 18px; }
.mappage-head .kind { font-size: 13px; color: var(--ink-3); }
.mappage-head h1 { font-size: 32px; line-height: 1.25; margin: 4px 0 6px; }
.used-in { font-size: 13.5px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.used-in a { color: var(--ink-2); text-decoration: none; padding: 2px 8px; border-radius: 999px; background: var(--hover); }

/* ---------- 手機 ---------- */
@media (max-width: 860px) {
  .side { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .24s var(--ease); box-shadow: var(--shadow-2); }
  .app.side-open .side { transform: none; }
  .side-scrim { position: fixed; inset: 0; z-index: 39; background: rgba(20, 15, 10, .3); }
  .menu-btn { display: grid; }
  .page { padding: 28px 16px 40vh; }
  .page-title { font-size: 32px; }
  .page-icon { font-size: 44px; width: 56px; height: 56px; margin-left: -4px; }
  .blk.wide > .blk-body { width: calc(100vw - 32px); }
  .blk.wide > .gutter { display: none; }
  .gutter { display: none; }
  .mappage { padding: 24px 16px 80px; }
  .db-table { min-width: 560px; }
  .row-act { display: none; }
  .crumbs a { max-width: 140px; }
}
@media (min-width: 861px) and (max-width: 1180px) {
  .blk.wide > .blk-body { width: calc(100vw - var(--side-w) - 64px); }
}
@media (hover: none) {
  .gutter { display: none; }
  .tact { display: flex; }
  .cell-title .open { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
