/* ESU 單字卡：暖紙色，英文用襯線體（書頁感），中文與介面用系統無襯線。全部顏色走 CSS 變數。 */
:root {
  --bg: #f6f1e7; --surface: #fffdf8; --surface2: #efe8d8; --ink: #2a2620; --ink2: #4f4739; --muted: #6b6253;
  --line: #e1d8c5; --line2: #cfc3aa; --accent: #a8402a; --accent-ink: #ffffff; --accent-soft: #f6dfd6; --accent-soft-ink: #8a2f1b;
  --hl: #ffe08a; --good: #2b7449; --bad: #b3261e; --bad-soft: #f9e0dd; --warn-soft: #fbefd0; --star: #c58a00;
  --skel1: #eae2d0; --skel2: #f5efe2; --shadow: 0 1px 2px rgba(60, 40, 10, .08), 0 6px 20px rgba(60, 40, 10, .08);
  --serif: ui-serif, "New York", Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --r: 16px; --tab-h: 58px; --kb: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #17150f; --surface: #221f18; --surface2: #2d2a21; --ink: #ede6d6; --ink2: #cfc6b2; --muted: #a79d88; --line: #3a3529; --line2: #4d4636; --accent: #ec8a68; --accent-ink: #1d1209; --accent-soft: #3d2b22; --accent-soft-ink: #f4b99f; --hl: #6a5516; --good: #6cc48d; --bad: #f19a92; --bad-soft: #442522; --warn-soft: #3d3418; --star: #e6b73a; --skel1: #2d2a21; --skel2: #3a3629; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35); color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #17150f; --surface: #221f18; --surface2: #2d2a21; --ink: #ede6d6; --ink2: #cfc6b2; --muted: #a79d88; --line: #3a3529; --line2: #4d4636; --accent: #ec8a68; --accent-ink: #1d1209; --accent-soft: #3d2b22; --accent-soft-ink: #f4b99f; --hl: #6a5516; --good: #6cc48d; --bad: #f19a92; --bad-soft: #442522; --warn-soft: #3d3418; --star: #e6b73a; --skel1: #2d2a21; --skel2: #3a3629; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35); color-scheme: dark; }
:root[data-fs="lg"] { font-size: 112.5%; }
:root[data-fs="xl"] { font-size: 125%; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body { color: var(--ink); font: 1rem/1.6 var(--sans); overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
[hidden] { display: none !important; }
[lang="en"] { font-family: var(--serif); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pad { padding: .5rem 0; }
.noscript { padding: 2rem; }

/* ───────── 外殼：窄螢幕＝一次一個畫面＋底部分頁列；≥900px＝左右兩欄 ───────── */
.app { position: fixed; inset: 0; height: 100vh; height: 100dvh; display: grid; grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
.col { position: relative; grid-row: 1; grid-column: 1; min-width: 0; min-height: 0; }
.tabbar { grid-row: 2; grid-column: 1; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tab { flex: 1; min-height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .8125rem; font-weight: 600; color: var(--muted); text-decoration: none; transition: color .15s, transform .12s; }
.tab:active { transform: scale(.94); }
.tab.on { color: var(--accent); }
.kb-open .tabbar { display: none; }
.netbar { position: fixed; top: 0; left: 0; right: 0; z-index: 40; display: flex; gap: 8px; align-items: center; justify-content: center; padding: calc(4px + env(safe-area-inset-top)) 12px 4px; background: var(--warn-soft); color: var(--ink); font-size: .8125rem; text-align: center; border-bottom: 1px solid var(--line2); }
.is-offline .view-in { padding-top: calc(36px + env(safe-area-inset-top)); }

.view { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; outline: none; display: flex; flex-direction: column; }
.view-in { width: 100%; max-width: 720px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) 16px 28px; flex: 1 0 auto; }
.view-head { display: flex; align-items: baseline; gap: 12px; padding: 10px 0 12px; }
.view-head h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 800; letter-spacing: .01em; }
.view-sub { color: var(--muted); font-size: .9375rem; }
.view-head.with-back { padding: 0 0 6px; margin-left: -8px; }
.back-btn { display: inline-flex; align-items: center; gap: 2px; min-height: 48px; padding: 0 12px 0 4px; border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 1.0625rem; border-radius: 12px; }
.back-btn:active { background: var(--accent-soft); }

@media (min-width: 900px) {
  .app { grid-template-columns: 420px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .tabbar { grid-row: 1; grid-column: 1; border-top: 0; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding-bottom: 0; }
  .tab { flex-direction: row; gap: 8px; min-height: 52px; }
  .col-side { grid-row: 2; grid-column: 1; border-right: 1px solid var(--line); }
  .col-main { grid-row: 1 / 3; grid-column: 2; background: var(--bg); }
  .col-main .view-in { padding-top: 22px; max-width: 760px; }
  .toasts { bottom: 24px !important; }
  .back-btn { display: none; }
  .view-head.with-back { display: none; }
  .view-in { padding-left: 20px; padding-right: 20px; }
  .netbar { left: 420px; }
}

.ph-main { height: 100%; min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; color: var(--muted); padding: 24px; }
.ph-main h2 { color: var(--ink2); font-size: 1.375rem; }
.ph-main p { max-width: 22rem; }
.ph-art { width: 108px; height: 108px; border-radius: 50%; display: grid; place-items: center; background: var(--surface2); color: var(--muted); }

/* grid 的欄寬預設是 min-content，長字串會把版面撐寬；一律限制成 1fr */
.recent-list, .rows, .pend-list, .usages, .timeline, .cands, .confirm-btns, .book-list, .set-card, .cand-skel, .result-actions, .set-block, .steps { grid-template-columns: minmax(0, 1fr); }

/* ───────── 按鈕與表單 ───────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border: 1.5px solid transparent; border-radius: 14px; background: var(--surface2); color: var(--ink); font-weight: 650; font-size: 1rem; text-decoration: none; text-align: center; transition: transform .12s, background .15s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px rgba(168, 64, 42, .25); }
.btn.soft { background: var(--accent-soft); color: var(--accent-soft-ink); }
.btn.ghost { background: transparent; border-color: var(--line2); color: var(--ink2); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { min-height: 44px; padding: 0 16px; font-size: .9375rem; }
.btn.big { width: 100%; min-height: 58px; font-size: 1.125rem; border-radius: 16px; }
.btn-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-target { font-style: italic; margin: 0 .1em; }
.icon-btn { display: inline-grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--surface2); color: var(--ink2); transition: transform .12s, background .15s; flex: none; }
.icon-btn.small { width: 44px; height: 44px; background: none; }
.icon-btn:active { transform: scale(.92); }
.text-input { width: 100%; min-height: 52px; padding: 0 16px; border: 1.5px solid var(--line2); border-radius: 14px; background: var(--surface); font-size: max(1rem, 16px); }
.text-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line2); background: var(--surface); color: var(--ink2); font-size: .9375rem; font-weight: 600; max-width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.toggle.on { background: var(--accent-soft); color: var(--accent-soft-ink); border-color: var(--accent); }
.chip-chev { opacity: .6; flex: none; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; flex: none; }
.spinner.on-accent { border-color: rgba(255, 255, 255, .4); border-top-color: var(--accent-ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--surface2); margin: 12px 0; font-size: .9375rem; }
.notice p { flex: 1; }
.notice.warn { background: var(--warn-soft); flex-wrap: wrap; }
.notice.offline { background: var(--warn-soft); }
.notice.small { font-size: .875rem; }

/* ───────── 查字 ───────── */
.q-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 20px; padding: 12px; box-shadow: var(--shadow); }
.q-card:focus-within { border-color: var(--accent); }
.q-input { display: block; width: 100%; min-height: 96px; border: 0; background: none; resize: none; padding: 6px 6px 4px; font-family: var(--serif); font-size: max(1.1875rem, 16px); line-height: 1.5; outline: none; }
.q-input::placeholder { color: var(--muted); font-family: var(--sans); }
.q-tools { display: flex; gap: 8px; padding-top: 6px; justify-content: flex-end; }
.q-tools .btn { min-height: 44px; padding: 0 14px; font-size: .9375rem; }
.tokens { margin: 14px -2px 2px; line-height: 1; }
.tok { display: inline-flex; align-items: center; min-height: 44px; margin: 3px 2px; padding: 0 11px; border: 1.5px solid var(--line2); border-radius: 12px; background: var(--surface); font-family: var(--serif); font-size: 1.1875rem; transition: transform .1s, background .15s, color .15s; }
.tok:active { transform: scale(.95); }
.tok.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.gap { font-family: var(--serif); font-size: 1.1875rem; color: var(--muted); margin: 0 1px 0 -1px; }
.tok-hint { margin-top: 6px; color: var(--muted); font-size: .875rem; }
.hint { color: var(--muted); font-size: .875rem; line-height: 1.5; }
.q-meta { margin: 14px 0 6px; display: flex; }
.bar-spacer { height: 8px; }
.actionbar { position: sticky; bottom: 0; z-index: 4; flex: none; padding: 20px 16px calc(12px + 0px); background: linear-gradient(to top, var(--bg) 62%, transparent); pointer-events: none; }
.actionbar-in { max-width: 720px; margin: 0 auto; pointer-events: auto; }
.kb-open .actionbar { position: fixed; left: 0; right: 0; bottom: var(--kb); background: var(--bg); padding: 10px 16px; border-top: 1px solid var(--line); }
.pending, .recent { margin-top: 22px; }
.sec-t { font-size: 1.125rem; font-weight: 750; margin: 0 0 8px; display: flex; align-items: center; gap: 4px; }
.sec-t.small { font-size: .9375rem; color: var(--ink2); }
.pend-list { margin-top: 8px; display: grid; gap: 8px; }
.pend { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; background: var(--surface); border: 1.5px dashed var(--line2); border-radius: 14px; }
.pend-t { min-width: 0; display: flex; flex-direction: column; }
.pend-t strong { font-size: 1.0625rem; overflow-wrap: anywhere; }
.pend-s { color: var(--muted); font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pend-b { display: flex; gap: 4px; align-items: center; flex: none; }
.recent-list { display: grid; gap: 8px; }
.mini { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; min-height: 64px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; text-decoration: none; transition: transform .12s, background .15s; }
.mini:active { transform: scale(.985); background: var(--surface2); }
.mini-img { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: none; background: var(--surface2); }
.mini-img.ph, .row-img.ph, .tile-img.ph { display: grid; place-items: center; font-family: var(--serif); font-weight: 700; color: var(--muted); background: var(--surface2); }
.mini-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mini-t strong { font-size: 1.0625rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-m { color: var(--muted); font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-chev, .row-chev { color: var(--muted); flex: none; }
.book-pick .muted { margin-bottom: 12px; }
.book-list { display: grid; gap: 6px; margin: 14px 0; }
.list-btn { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px; border: 0; border-radius: 12px; background: var(--surface2); text-align: left; }
.list-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.confirm-btns { display: grid; gap: 10px; margin-top: 18px; }
.confirm-msg { color: var(--ink2); }

/* ───────── 卡片 ───────── */
.card { padding-bottom: 8px; }
.status-slot { position: sticky; bottom: 10px; z-index: 4; margin-top: 12px; }
.status { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-soft-ink); box-shadow: 0 4px 18px rgba(60, 40, 10, .22); border: 1px solid var(--accent); }
.status.solo { box-shadow: none; }
.status.solo { margin: 14px 0; }
.status-txt { display: flex; flex-direction: column; font-size: .9375rem; line-height: 1.45; }
.status-txt strong { font-size: 1rem; }
.card-head { padding: 4px 0 6px; }
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.chunk { font-family: var(--serif); font-size: 2.125rem; line-height: 1.15; font-weight: 700; overflow-wrap: anywhere; hyphens: auto; letter-spacing: .005em; }
.chunk.long { font-size: 1.5rem; line-height: 1.25; }
.speak { background: var(--accent-soft); color: var(--accent-soft-ink); margin-top: -2px; }
.speak.playing { background: var(--accent); color: var(--accent-ink); }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 8px; color: var(--ink2); }
.ipa { font-size: 1.0625rem; color: var(--muted); }
.pos { font-size: .9375rem; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--surface2); font-size: .8125rem; font-weight: 700; color: var(--ink2); }
.prev { margin-top: 8px; font-size: .9375rem; color: var(--muted); }
.prev-l { font-weight: 600; }
.prev-s { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .9375rem; margin-top: 2px; overflow-wrap: anywhere; }
.card-answer { margin: 14px 0 6px; }
.sentence, .md-quote { margin: 0 0 8px; padding: 12px 14px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 14px 14px 0; font-family: var(--serif); font-size: 1.1875rem; line-height: 1.6; overflow-wrap: anywhere; }
.hl { background: var(--hl); color: inherit; border-radius: 5px; padding: 0 .12em; font-weight: 650; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.sentence strong, .md-quote strong { background: var(--hl); border-radius: 5px; padding: 0 .12em; }
.src { font-size: .875rem; color: var(--muted); margin: -2px 0 8px 4px; }
.meaning { margin: 10px 0 4px; padding: 14px 16px; border-radius: 18px; background: var(--accent-soft); color: var(--accent-soft-ink); }
.meaning.general { background: var(--surface2); color: var(--ink); }
.meaning-l { font-size: .8125rem; font-weight: 750; letter-spacing: .08em; opacity: .85; }
.meaning-t { margin-top: 2px; font-size: 1.6875rem; line-height: 1.35; font-weight: 800; overflow-wrap: anywhere; }
.meaning-t.flow { font-size: 1.1875rem; font-weight: 650; line-height: 1.55; }
.meaning-skel { margin-top: 8px; }
.meaning-skel .skel { display: block; margin: 8px 0; }
.card-sec { margin-top: 24px; }
.row-l { font-size: .8125rem; font-weight: 750; letter-spacing: .08em; color: var(--muted); margin-bottom: 2px; }
.core { font-size: 1.125rem; line-height: 1.6; }
.why-core, .why-etym { margin-top: 10px; }
.why-image { margin: 14px 0 6px; }
.why-fold { margin-top: 10px; }
.etym { color: var(--ink2); line-height: 1.6; overflow-wrap: anywhere; }
.story { line-height: 1.75; }
.sources { margin-top: 8px; font-size: .875rem; color: var(--muted); }
.md-link { color: var(--accent); text-underline-offset: 3px; }
.fig { margin: 0; width: 100%; max-width: 420px; }
.fig-btn { display: block; width: 100%; aspect-ratio: 1 / 1; padding: 0; border: 0; border-radius: 20px; overflow: hidden; background: var(--surface2); box-shadow: var(--shadow); }
.fig-btn:active { transform: scale(.985); }
.fig-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.fig-ph { aspect-ratio: 1 / 1; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; text-align: center; color: var(--ink2); background: linear-gradient(110deg, var(--skel1) 30%, var(--skel2) 45%, var(--skel1) 60%); background-size: 300% 100%; animation: shimmer 2s ease-in-out infinite; }
.fig-note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: 14px; background: var(--surface2); color: var(--ink2); font-size: .9375rem; }
.fold { border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.fold summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 14px; cursor: pointer; font-weight: 650; list-style: none; border-radius: 14px; }
.fold summary::-webkit-details-marker { display: none; }
.fold-chev { transition: transform .2s; color: var(--muted); }
.fold[open] .fold-chev { transform: rotate(90deg); }
.fold-body { padding: 2px 14px 14px; }
.fold-body .md-list { padding-left: 0; }
.fold-skel { min-height: 48px; display: flex; align-items: center; padding: 0 14px; }
.info-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; margin: -8px 0; border: 0; background: none; color: var(--muted); border-radius: 50%; }
.usages { display: grid; gap: 10px; }
.usage { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.usage.star-row { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-ink); }
.usage.star-row .u-zh, .usage.star-row .freq { color: var(--accent-soft-ink); }
.u-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.freq { font-size: .875rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink2); flex: none; min-width: 7.2rem; }
.freq.none { font-weight: 500; color: var(--muted); }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.star-row .bar { background: rgba(255, 255, 255, .55); }
.bar i { display: block; height: 100%; width: var(--w, 0%); border-radius: 99px; background: var(--accent); }
.u-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.u-text { font-size: 1.1875rem; font-weight: 500; overflow-wrap: anywhere; }
.u-text strong { font-weight: 800; }
.u-zh { color: var(--ink2); font-size: 1rem; }
.star { color: var(--star); font-size: 1.0625rem; }
.u-ex { margin-top: 6px; padding-left: 12px; border-left: 3px solid var(--line2); font-size: .9375rem; color: var(--ink2); line-height: 1.55; overflow-wrap: anywhere; }
.u-ex.see { color: var(--muted); }
.u-ex strong { font-weight: 800; }
.u-src { color: var(--muted); font-family: var(--sans); }
.card-foot { margin-top: 28px; }
.timeline { display: grid; gap: 10px; }
.tl { padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.tl-h { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .875rem; font-weight: 650; }
.tl-b { color: var(--muted); font-weight: 500; }
.tl-s { margin-top: 4px; font-size: 1.0625rem; overflow-wrap: anywhere; }
.tl-m { margin-top: 2px; font-size: .9375rem; color: var(--ink2); }
.danger-zone { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.danger-t { color: var(--bad); border-color: var(--bad); }
.warn-i { font-size: 1.25rem; }

/* 骨架（微光） */
.skel { display: inline-block; height: 1em; border-radius: 8px; vertical-align: middle; background: linear-gradient(90deg, var(--skel1) 25%, var(--skel2) 37%, var(--skel1) 63%); background-size: 400% 100%; animation: shimmer 1.5s ease infinite; }
.skel.tall { height: 1.7rem; }
.w30 { width: 30%; } .w40 { width: 40%; } .w50 { width: 50%; } .w60 { width: 60%; } .w80 { width: 80%; } .w90 { width: 90%; }
.lines .skel, .usages.skeleton .skel { display: block; margin: 6px 0; }
.usages.skeleton .u-top .skel { display: inline-block; margin: 0; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* markdown（舊卡與小段說明） */
.md { line-height: 1.7; }
.md-p { margin: .35rem 0; overflow-wrap: anywhere; }
.md-list { padding-left: 1.2rem; margin: .35rem 0; list-style: disc; display: grid; gap: .45rem; }
ol.md-list { list-style: decimal; }
.md-hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.md-code { font-family: var(--sans); font-size: .875em; font-variant-numeric: tabular-nums; padding: 1px 8px; border-radius: 8px; background: var(--surface2); white-space: nowrap; }
.li-cont { margin-top: 3px; padding-left: 10px; border-left: 3px solid var(--line2); color: var(--ink2); font-size: .9375rem; }
.legacy-use .md-list { list-style: none; padding-left: 0; gap: 10px; }
.legacy-use .md-list > li { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.legacy-why .md-list { gap: .6rem; }
.legacy-why .md-list > li { list-style: none; margin-left: -1.2rem; }
.legacy-why .md-p { margin: .35rem 0; }

/* 整句模式 */
.result-actions { display: grid; gap: 10px; margin-top: 24px; }
.cands { display: grid; gap: 10px; margin-top: 12px; }
.cand { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 72px; padding: 12px 14px; text-align: left; background: var(--surface); border: 1.5px solid var(--line2); border-radius: 18px; transition: transform .12s, border-color .15s; }
.cand:active { transform: scale(.98); border-color: var(--accent); }
.cand-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cand-chunk { font-size: 1.375rem; font-weight: 700; overflow-wrap: anywhere; }
.cand-zh { color: var(--ink2); }
.cand-r { font-size: .8125rem; font-weight: 700; color: var(--accent-soft-ink); background: var(--accent-soft); padding: 3px 10px; border-radius: 99px; text-align: center; max-width: 7.5rem; }
.cand-r.none { color: var(--muted); background: var(--surface2); }
.cand-chev { color: var(--muted); flex: none; }
.cand-skel { display: grid; gap: 10px; margin-top: 12px; }
.skel-box { height: 72px; background: linear-gradient(90deg, var(--skel1) 25%, var(--skel2) 37%, var(--skel1) 63%); background-size: 400% 100%; animation: shimmer 1.5s ease infinite; border: 0; }
.errpanel { margin: 24px 0; padding: 28px 20px; text-align: center; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.errpanel.soft { background: var(--surface2); }
.errpanel h2 { font-size: 1.375rem; }
.errpanel p { color: var(--ink2); max-width: 26rem; }
.errpanel-i { color: var(--bad); }
.errpanel .confirm-btns { width: 100%; max-width: 22rem; }
.stub-h { font-size: 2rem; }

/* ───────── 紀錄 ───────── */
.lib-bar { position: sticky; top: calc(-10px - env(safe-area-inset-top)); z-index: 3; margin: 0 -16px; padding: calc(8px + env(safe-area-inset-top) * 0) 16px 10px; background: var(--bg); }
.search-wrap { position: relative; }
.search { width: 100%; min-height: 50px; padding: 0 44px; border: 1.5px solid var(--line2); border-radius: 14px; background: var(--surface); font-size: max(1rem, 16px); -webkit-appearance: none; appearance: none; }
.search::-webkit-search-cancel-button { display: none; }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-i { position: absolute; left: 14px; top: 15px; color: var(--muted); }
.search-x { position: absolute; right: 2px; top: 3px; width: 44px; height: 44px; }
.lib-ctl { display: flex; gap: 10px; margin-top: 10px; align-items: center; justify-content: space-between; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface2); gap: 2px; }
.seg.wide { display: flex; }
.seg.wide .seg-b { flex: 1; }
.seg-b { min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: none; color: var(--ink2); font-weight: 650; font-size: .9375rem; display: inline-flex; align-items: center; justify-content: center; }
.seg-b.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.seg.icons .seg-b { padding: 0 12px; }
.lib-chips { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.lib-chips:empty { display: none; }
.wall { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
@media (min-width: 600px) { .wall { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { position: relative; display: flex; flex-direction: column; min-width: 0; text-decoration: none; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: transform .12s; text-align: left; padding: 0; }
a.tile:active { transform: scale(.97); }
.tile.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.tile-media { position: relative; display: block; aspect-ratio: 1 / 1; background: var(--surface2); }
.tile-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-img.ph { font-size: 2.5rem; }
.tile-count { position: absolute; right: 8px; top: 8px; padding: 2px 9px; border-radius: 99px; background: rgba(30, 24, 14, .72); color: #fff; font-size: .75rem; font-weight: 700; }
.tile-cap { display: flex; flex-direction: column; gap: 1px; padding: 8px 12px 12px; min-height: 66px; }
.tile-chunk { font-family: var(--serif); font-weight: 700; font-size: 1.0625rem; line-height: 1.25; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-chunk.big { font-size: 1.375rem; }
.tile-mean { color: var(--ink2); font-size: .875rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-sub { color: var(--muted); font-size: .8125rem; }
.tile.think { aspect-ratio: 1 / 1; }
.tile-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; text-align: center; border: 0; background: var(--surface); }
.tile-face.front:active { background: var(--surface2); }
.tile-face.back { background: var(--accent-soft); color: var(--accent-soft-ink); opacity: 0; pointer-events: none; transition: opacity .2s; }
.tile-face.back .tile-mean { color: inherit; font-weight: 700; font-size: 1rem; -webkit-line-clamp: 3; }
.tile-face.front { transition: opacity .2s; }
.tile.flipped .tile-face.back { opacity: 1; pointer-events: auto; }
.tile.flipped .tile-face.front { opacity: 0; pointer-events: none; }
.tile-back-b { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tile.stub { min-height: 120px; border-style: dashed; background: transparent; justify-content: center; align-items: center; padding: 12px; }
.tile.stub .tile-front { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; opacity: .85; }
.skel-tile { padding: 0 0 12px; gap: 8px; }
.skel-tile .tile-media { display: block; border-radius: 0; }
.skel-tile .skel:last-child { margin: 0 12px; }
.rows { display: grid; gap: 8px; margin-top: 8px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 8px 12px 8px 8px; width: 100%; text-align: left; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; transition: transform .12s, background .15s; }
.row:active { transform: scale(.985); background: var(--surface2); }
.row.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.row.stub { border-style: dashed; background: transparent; }
.row-img { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex: none; background: var(--surface2); display: grid; place-items: center; }
.row-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-t strong { font-family: var(--serif); font-size: 1.125rem; line-height: 1.3; overflow-wrap: anywhere; }
.row-m { color: var(--ink2); font-size: .9375rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-m.hidden-ans { color: var(--muted); font-style: italic; }
.row-d { color: var(--muted); font-size: .8125rem; }
.group { margin-top: 18px; }
.group-h { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 0 4px; border: 0; background: none; text-align: left; font-weight: 700; }
.group-h.static { cursor: default; }
.group-chev { transition: transform .2s; color: var(--muted); }
.group-chev.open { transform: rotate(90deg); }
.group-n { font-family: var(--serif); font-size: 1.1875rem; }
.group-c { color: var(--muted); font-size: .875rem; font-weight: 500; }
.empty { text-align: center; padding: 48px 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty h2 { font-size: 1.375rem; }
.empty p { color: var(--ink2); max-width: 24rem; }
.empty-art { width: 96px; height: 96px; display: grid; place-items: center; border-radius: 50%; background: var(--surface2); color: var(--muted); }

/* ───────── 設定 ───────── */
.set-sec { margin-top: 20px; }
.set-card { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; display: grid; gap: 14px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.set-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-block { display: grid; gap: 10px; }
.switch { position: relative; flex: none; width: 56px; height: 34px; border: 0; border-radius: 99px; background: var(--line2); transition: background .2s; }
.switch .knob { position: absolute; left: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] .knob { transform: translateX(22px); }
.font-sample { padding: 10px 12px; border-radius: 12px; background: var(--bg); font-size: 1.1875rem; line-height: 1.5; }
.mac-row { display: flex; gap: 12px; align-items: flex-start; }
.dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--muted); }
.dot.ok { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 25%, transparent); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 22%, transparent); }
.mac { display: grid; gap: 10px; justify-items: start; }
.steps { padding-left: 1.3rem; list-style: decimal; display: grid; gap: .5rem; margin: 6px 0 12px; padding-right: 8px; }
.fold .steps { margin: 4px 14px 14px; }
.set-upd { margin-top: 18px; }
.ver { text-align: center; margin: 24px 0 8px; }

/* ───────── 登入 ───────── */
.login { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); overflow: auto; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: center; }
.login-logo { border-radius: 18px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 1.75rem; }
.login-form { width: 100%; display: grid; gap: 12px; margin-top: 8px; }
.login-msg { min-height: 1.4em; font-size: .9375rem; color: var(--ink2); text-align: left; }
.login-msg.bad { color: var(--bad); font-weight: 600; }
.login-setup { width: 100%; text-align: left; }
.login-setup h2 { font-size: 1.25rem; margin-bottom: 6px; }
.cmd { display: block; padding: 12px; border-radius: 12px; background: var(--surface2); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .8125rem; overflow-wrap: anywhere; user-select: all; }

/* ───────── 底部面板、提示條、看大圖 ───────── */
.overlays { position: relative; z-index: 50; }
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.backdrop { position: absolute; inset: 0; background: rgba(20, 14, 6, .5); opacity: 0; transition: opacity .2s; }
.sheet { position: relative; width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; overflow: auto; background: var(--surface); border-radius: 24px 24px 0 0; padding: 8px 20px calc(22px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .22s ease; outline: none; box-shadow: 0 -8px 40px rgba(0, 0, 0, .25); }
.sheet-wrap.open .backdrop { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.closing .backdrop { opacity: 0; }
.sheet-wrap.closing .sheet { transform: translateY(100%); }
.sheet-grab { width: 44px; height: 5px; border-radius: 99px; background: var(--line2); margin: 4px auto 12px; }
.sheet-title { font-size: 1.25rem; font-weight: 800; margin-bottom: 8px; }
.sheet-body > * + * { margin-top: 12px; }
.legend p { line-height: 1.65; }
@media (min-width: 900px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 24px; transform: translateY(16px); opacity: 0; } .sheet-wrap.open .sheet { opacity: 1; } .sheet-grab { display: none; } .sheet-wrap.closing .sheet { transform: translateY(16px); opacity: 0; } }
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 12px; pointer-events: none; }
.kb-open .toasts { bottom: calc(var(--kb) + 80px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 4px; max-width: 520px; width: 100%; padding: 4px 4px 4px 16px; border-radius: 16px; background: #2b2619; color: #fdf8ea; box-shadow: 0 8px 28px rgba(0, 0, 0, .3); animation: pop .2s ease; }
:root[data-theme="dark"] .toast { background: #f1e9d6; color: #231e14; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #f1e9d6; color: #231e14; } }
.toast.warn { background: #7d1d16; color: #fff; }
.toast-msg { flex: 1; padding: 10px 0; font-size: .9375rem; line-height: 1.45; }
.toast-act { min-height: 44px; padding: 0 14px; border: 0; background: none; color: #ffb59c; font-weight: 800; font-size: .9375rem; border-radius: 12px; }
:root[data-theme="dark"] .toast-act { color: #a8402a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast-act { color: #a8402a; } }
.toast-x { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: inherit; opacity: .7; border-radius: 12px; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.lightbox { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); background: rgba(10, 8, 4, .94); }
.lightbox-img { max-width: 100%; max-height: 82vh; max-height: 82dvh; border-radius: 12px; object-fit: contain; }
.lightbox-cap { color: #e8e0cc; }
.lightbox-x { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .skel, .fig-ph, .skel-box { animation: none; }
}

.resume { display: flex; align-items: center; gap: 4px; margin: 0 0 14px; padding: 2px 2px 2px 0; border-radius: 16px; background: var(--accent-soft); color: var(--accent-soft-ink); }
.resume-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 8px 0 14px; text-decoration: none; font-weight: 650; }
.resume-t { flex: 1; min-width: 0; line-height: 1.4; padding: 6px 0; }
