/* ===== fonts ===== */
@font-face {
  font-family: "IL Greek"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/ILGreek-Regular.woff2) format("woff2");
  unicode-range: U+0370-03FF, U+1F00-1FFF, U+0300-036F;
}
@font-face {
  font-family: "IL Greek"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(../fonts/ILGreek-Bold.woff2) format("woff2");
  unicode-range: U+0370-03FF, U+1F00-1FFF, U+0300-036F;
}
@font-face {
  font-family: "IL Hebrew"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/ILHebrew-Regular.woff2) format("woff2");
  unicode-range: U+0591-05F4, U+FB1D-FB4F, U+034F, U+200C-200F;
}

/* ===== tokens ===== */
:root {
  --chrome: #2F3343; --chrome-fg: #F7F1E4; --chrome-muted: #C9C2B3; --chrome-accent: #D9A466; --chrome-line: #41465B;
  --fs: 19px;
  --lh: 1.75;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-page: 350ms; --t: 300ms; --t-pop: 200ms;
  --serif-zh: "Noto Serif TC", "Noto Serif CJK TC", "Source Han Serif TC", "Songti TC", "PMingLiU", "MingLiU", "Noto Serif CJK SC", serif;
  --serif: "IL Greek", "Gentium Plus", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif", var(--serif-zh);
  --greek: "IL Greek", "Gentium Plus", "SBL BibLit", "Noto Serif", "Times New Roman", serif;
  --hebrew: "Ezra SIL", "SBL Hebrew", "Noto Serif Hebrew", "Taamey Frank CLM", serif;
  --ui: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --topbar: calc(30px + var(--safe-t));
  --tabbar: calc(54px + var(--safe-b));
}
/* IN CHRIST palette (sampled from the emblem's reel / wallpaper): navy #2F3343 · #363C4F · #41465B,
   gold #C49356 · #D49E61 (dark-gold #8A6431 for text on cream). Contrast: node tools/check-contrast.mjs.
   --line = hairline dividers (decorative); --edge = control borders (≥ 3:1); --logo = emblem / watermark tint. */
:root, [data-theme="warm"] {
  --bg: #FAF6EE; --bg2: #F0E9DB; --card: #FFFDF8; --fg: #2F3343; --fg2: #4A4F63; --muted: #67645F;
  --line: #E4DCCC; --edge: #8E8574; --accent: #8A6431; --accent-soft: rgba(196, 147, 86, .16); --on-accent: #fff;
  --logo: #9C733D; --wm-opacity: .06;
  --hl: #F6E2B6; --sel: rgba(196, 147, 86, .12); --bar: rgba(250, 246, 238, .92); --capsule: #2F3343; --capsule-fg: #F7F1E4;
  --toast-act: #E3B57A; --danger: #B03A2E; --on-danger: #fff;
  --syn-s: #2F64A8; --syn-v: #B03A2E; --syn-o: #2B7A44; --syn-p: #7A4DB0; --syn-a: #8A6431; --syn-fg: #fff;
  --shadow: 0 -6px 28px rgba(47, 51, 67, .16);
  color-scheme: light;
}
[data-theme="light"] {
  --bg: #FFFFFF; --bg2: #F2F3F6; --card: #FFFFFF; --fg: #2F3343; --fg2: #4A4F63; --muted: #63666F;
  --line: #E3E5EA; --edge: #868A96; --accent: #8A6431; --accent-soft: rgba(196, 147, 86, .14); --on-accent: #fff;
  --logo: #9C733D; --wm-opacity: .05;
  --hl: #F6E2B6; --sel: rgba(196, 147, 86, .12); --bar: rgba(255, 255, 255, .92); --capsule: #2F3343; --capsule-fg: #F7F1E4;
  --toast-act: #E3B57A; --danger: #B03A2E; --on-danger: #fff;
  --syn-s: #2F64A8; --syn-v: #B03A2E; --syn-o: #2B7A44; --syn-p: #7A4DB0; --syn-a: #8A6431; --syn-fg: #fff;
  --shadow: 0 -6px 28px rgba(47, 51, 67, .14);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #2F3343; --bg2: #41465B; --card: #363C4F; --fg: #F5EEDF; --fg2: #D9D1C1; --muted: #BDB6A8;
  --line: #474D63; --edge: #868CA0; --accent: #E2AE70; --accent-soft: rgba(212, 158, 97, .10); --on-accent: #23263A;
  --logo: #C49356; --wm-opacity: .05;
  --hl: rgba(212, 158, 97, .30); --sel: rgba(212, 158, 97, .12); --bar: rgba(47, 51, 67, .92); --capsule: #1E2130; --capsule-fg: #F5EEDF;
  --toast-act: #D9A466; --danger: #B03A2E; --on-danger: #fff;
  --syn-s: #8DB8F0; --syn-v: #F0968C; --syn-o: #84CC9A; --syn-p: #C3A5EE; --syn-a: #E2B46E; --syn-fg: #1E2130;
  --shadow: 0 -6px 28px rgba(10, 12, 20, .5);
  color-scheme: dark;
}
[data-theme="oled"] {
  --bg: #000; --bg2: #16171C; --card: #0D0E12; --fg: #EFE8DA; --fg2: #CEC6B7; --muted: #A39D92;
  --line: #24262E; --edge: #6A6D78; --accent: #D49E61; --accent-soft: rgba(212, 158, 97, .16); --on-accent: #000;
  --logo: #C49356; --wm-opacity: .045;
  --hl: rgba(212, 158, 97, .28); --sel: rgba(212, 158, 97, .12); --bar: rgba(0, 0, 0, .94); --capsule: #1C1E26; --capsule-fg: #EFE8DA;
  --toast-act: #D49E61; --danger: #B03A2E; --on-danger: #fff;
  --syn-s: #8DB8F0; --syn-v: #F0968C; --syn-o: #84CC9A; --syn-p: #C3A5EE; --syn-a: #E2B46E; --syn-fg: #000;
  --shadow: 0 -6px 28px rgba(0, 0, 0, .8);
  color-scheme: dark;
}
[data-theme="sepia"] {
  --bg: #F1E6CE; --bg2: #E6D8BA; --card: #F8EFDC; --fg: #2E2A33; --fg2: #4A4038; --muted: #625548;
  --line: #DCCBA8; --edge: #857153; --accent: #7A5628; --accent-soft: rgba(196, 147, 86, .20); --on-accent: #fff;
  --logo: #8F6833; --wm-opacity: .05;
  --hl: #EBCF94; --sel: rgba(160, 112, 52, .13); --bar: rgba(241, 230, 206, .92); --capsule: #2E2A33; --capsule-fg: #F5ECD8;
  --toast-act: #E3B57A; --danger: #A8372C; --on-danger: #fff;
  --syn-s: #2F64A8; --syn-v: #A8372C; --syn-o: #2B7A44; --syn-p: #7A4DB0; --syn-a: #7A5628; --syn-fg: #fff;
  --shadow: 0 -6px 28px rgba(70, 50, 20, .18);
  color-scheme: light;
}

/* ===== base ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body {
  font: var(--fs)/var(--lh) var(--serif); overflow: hidden; overscroll-behavior: none;
  touch-action: manipulation; -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; color: inherit; touch-action: manipulation; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
[lang="grc"], [lang="el"] { font-family: var(--greek); }
[lang="hbo"], [lang="he"] { font-family: var(--hebrew); direction: rtl; }
[lang^="zh"] { font-family: var(--serif-zh); }
[hidden] { display: none !important; }
a { color: var(--accent); }

/* press feedback: instant on, quick fade off */
.press { transition: opacity 120ms var(--ease), transform 120ms var(--ease); }
.press:active, .pressed { opacity: .55; transition-duration: 0s; }

.tag { display: inline-block; font: 600 11px/1.6 var(--ui); color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0 7px; margin-left: 6px; vertical-align: middle; }
.notice { font: 13px/1.6 var(--ui); color: var(--muted); background: var(--bg2); border-radius: 10px; padding: 8px 12px; }
.hint { font: 13px/1.6 var(--ui); color: var(--muted); }
.linkbtn { color: var(--accent); font: 500 15px var(--ui); padding: 6px 4px; }
.linkbtn:has(.ic) { display: inline-flex; align-items: center; }
.linkbtn .ic { width: 20px; height: 20px; margin-left: -4px; }

/* line icons (js/icons.js): 24×24, stroke currentColor 1.75, round; tinted by `color` */
.ic { display: block; flex: none; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ===== IN CHRIST emblem: home logo + watermark (tinted with --logo through a mask) ===== */
.home-logo, .watermark, .picker::before, .subpage::before {
  background: var(--logo);
  -webkit-mask: url(../icons/in-christ.svg) center / contain no-repeat;
  mask: url(../icons/in-christ.svg) center / contain no-repeat;
}
/* One fixed layer between the page background (html/body) and the views, which are transparent.
   Fixed + out of flow: no layout shift, no taps, no effect on the pager's scroll-snap or the sheet. */
.watermark, .picker::before, .subpage::before {
  position: fixed; z-index: 0; left: 50%; top: 50%; width: min(70vw, 360px); aspect-ratio: 1;
  transform: translate(-50%, -50%); opacity: var(--wm-opacity); pointer-events: none; user-select: none;
}
/* opaque overlays (book picker, about page) carry their own copy under their content */
.picker::before, .subpage::before { content: ""; z-index: -1; }
@media print { .watermark, .picker::before, .subpage::before { display: none; } }

/* ===== layout: views ===== */
#app { position: fixed; inset: 0; }
.view { position: absolute; inset: 0; background: transparent; }
/* another tab covers the reader: hide it (keeps its scroll position) so the watermark shows through */
#view-read[inert] { visibility: hidden; }
.view:not([data-view="read"]) {
  z-index: 5; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(var(--safe-t) + 8px) 18px calc(var(--tabbar) + 24px);
}
.fade-in { animation: fade var(--t) var(--ease) both; }
@keyframes fade { from { opacity: 0; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 260ms; animation-timing-function: var(--ease); }
.viewhead { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.viewhead h1 { font: 600 20px var(--ui); margin: 0; }

/* ===== top bar ===== */
.topbar {
  position: absolute; z-index: 3; top: 0; left: 0; right: 0; height: var(--topbar);
  padding-top: var(--safe-t); display: flex; justify-content: center; align-items: center;
  background: var(--bar); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: .5px solid var(--line);
}
.title { color: var(--accent); font: 600 14px/30px var(--serif-zh); letter-spacing: .08em; padding: 0 16px; }

/* ===== pager (3-page virtual, scroll-snap) ===== */
.pager {
  position: absolute; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none;
}
.pager::-webkit-scrollbar { display: none; }
.page {
  flex: 0 0 100%; width: 100%; height: 100%; position: relative;
  scroll-snap-align: start; scroll-snap-stop: always;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain;
  padding: calc(var(--topbar) + 6px) 0 calc(var(--tabbar) + 40px);
  contain: strict;
}
.chapter { max-width: 720px; margin: 0 auto; padding: 0 18px 0 6px; }
.chead { font: 600 13px var(--serif-zh); color: var(--muted); letter-spacing: .1em; text-align: center; margin: 10px 0 14px; }
.boundary, .empty { font: 14px/1.6 var(--ui); color: var(--muted); text-align: center; padding: 30vh 24px 0; }
.skel { height: 3.2em; margin: 14px 0 0 36px; border-radius: 6px; background: var(--bg2); opacity: .7; }
.skel.short { width: 60%; }

.verse {
  display: grid; grid-template-columns: 30px 1fr; column-gap: 4px; position: relative;
  padding: 6px 0 8px; content-visibility: auto; contain-intrinsic-size: auto 9em;
}
.verse::before { /* selection / flash layer: opacity only */
  content: ""; position: absolute; inset: 0 -18px 0 -6px; background: var(--sel); opacity: 0; pointer-events: none;
  transition: opacity var(--t-pop) var(--ease);
}
.verse.sel::before { opacity: 1; }
.verse.flash::before { background: var(--hl); animation: flash 1.6s var(--ease) both; }
@keyframes flash { 0%, 40% { opacity: .9; } 100% { opacity: 0; } }
.vn {
  font: 600 11px/1 var(--ui); color: var(--muted); text-align: right; padding: .62em 4px 8px 0; align-self: start;
  min-height: 32px; font-variant-numeric: tabular-nums;
}
.verse.sel .vn { color: var(--accent); }
.vb { min-width: 0; position: relative; }
.vb p { margin: 0; }
.orig { font-size: 1.06em; line-height: 1.6; padding-bottom: 2px; }
.tr { color: var(--fg); margin-top: .18em !important; }
.tr + .tr { color: var(--fg2); }
.ab { float: right; font: 500 9.5px/2.4 var(--ui); color: var(--muted); margin-left: 8px; letter-spacing: .02em; }
.w, .tk { cursor: pointer; border-radius: 3px; transition: background-color 120ms var(--ease); }
.w.hl, .tk.hl { background: var(--hl); box-shadow: 0 0 0 2px var(--hl); }
.w:focus-visible, .tk:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.w:focus:not(:focus-visible), .tk:focus:not(:focus-visible), .sheet-body:focus { outline: none; }
.w small { display: none; font: 500 9px/1.1 var(--ui); color: var(--muted); letter-spacing: 0; }
.ann-strong .w, .ann-morph .w { display: inline-flex; flex-direction: column; align-items: center; vertical-align: top; line-height: 1.35; margin-bottom: 4px; }
.ann-strong .w .ws { display: block; }
.ann-morph .w .wm { display: block; }
.ann-strong .orig, .ann-morph .orig { line-height: 1.35; }

/* ===== selection capsule ===== */
.selbar {
  position: absolute; z-index: 6; left: 50%; bottom: calc(var(--tabbar) + 12px);
  display: flex; align-items: center; gap: 2px; padding: 4px 6px 4px 14px; border-radius: 99px;
  background: var(--capsule); color: var(--capsule-fg); box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  font: 500 14px var(--ui); white-space: nowrap;
  transform: translate(-50%, 24px) scale(.96); opacity: 0; pointer-events: none;
  transition: transform var(--t-pop) var(--ease), opacity var(--t-pop) var(--ease);
}
.selbar.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.selbar button { padding: 8px 11px; border-radius: 99px; }
.selbar .selcount { opacity: .7; font-size: 12px; margin-right: 4px; }
.selbar .selx { opacity: .8; padding: 7px 9px; }
.selbar .selx .ic { width: 20px; height: 20px; }

/* ===== tab bar ===== */
.tabbar {
  position: fixed; z-index: 7; left: 0; right: 0; bottom: 0; height: var(--tabbar); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bar); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: .5px solid var(--line);
  transition: transform var(--t) var(--ease);
}
.tabbar.hide { transform: translateY(100%); }
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font: 500 10.5px var(--ui); }
.tabbar .ic { width: 23px; height: 23px; }
.tabbar button.active { color: var(--accent); font-weight: 600; }

/* ===== picker ===== */
.picker {
  position: fixed; z-index: 8; inset: 0; background: var(--bg); display: flex; flex-direction: column;
  padding-top: var(--safe-t);
  transform: translateY(100%); opacity: 0; visibility: hidden;
  transition: transform var(--t-page) var(--ease), opacity var(--t-page) var(--ease), visibility 0s var(--t-page);
}
.picker.open { transform: none; opacity: 1; visibility: visible; transition-delay: 0s; }
.picker-head { display: flex; gap: 8px; padding: 10px 14px 4px; align-items: center; }
#jump {
  flex: 1; height: 40px; border-radius: 12px; border: 1px solid var(--edge); background: var(--card);
  padding: 0 14px; font: 16px var(--ui); outline: none;
}
#jump:focus { border-color: var(--accent); }
#jump::-webkit-search-cancel-button { filter: grayscale(1); opacity: .5; }
.jump-hint { min-height: 22px; padding: 2px 20px; font: 600 14px var(--serif-zh); color: var(--accent); }
.jump-hint.bad { color: var(--muted); font-weight: 400; }
.picker-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 14px calc(var(--safe-b) + 24px); }
.bsec h2 { font: 600 13px var(--ui); color: var(--muted); margin: 14px 4px 8px; letter-spacing: .1em; }
.bookgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.book {
  height: 42px; border-radius: 10px; background: var(--card); border: .5px solid var(--line);
  font: 15px var(--serif-zh); color: var(--fg); white-space: nowrap; overflow: hidden;
}
.book.ot { color: var(--muted); opacity: .6; }
.book.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); opacity: 1; }
.chapgrid {
  grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 6px 0 10px;
  animation: pop var(--t) var(--ease) both; transform-origin: top center;
}
.chapgrid .notice { grid-column: 1 / -1; margin: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }
.chap { height: 40px; border-radius: 10px; background: var(--bg2); font: 500 15px var(--ui); font-variant-numeric: tabular-nums; }
.chap.cur { background: var(--accent); color: var(--on-accent); }

/* ===== home (首頁) ===== */
.home { --card-shadow: 0 1px 2px rgba(60, 40, 20, .05), 0 8px 24px rgba(60, 40, 20, .06); }
[data-theme="dark"] .home, [data-theme="oled"] .home { --card-shadow: none; }
.home-head { display: flex; align-items: center; gap: 14px; }
.home-logo { flex: none; width: 76px; height: 76px; }
.home > * { max-width: 640px; margin-left: auto; margin-right: auto; }
.home-head { padding: 22px 4px 18px; }
.home-head h1 { font: 600 26px/1.3 var(--serif-zh); letter-spacing: .06em; margin: 0; color: var(--fg); }
.home-head > div { min-width: 0; }
.home-head p { font: 13px/1.6 var(--ui); color: var(--muted); margin: 4px 0 0; letter-spacing: .04em; }
.hcard {
  display: block; width: 100%; text-align: left; background: var(--card); color: var(--fg);
  border: .5px solid var(--line); border-radius: 18px; box-shadow: var(--card-shadow);
}
.hc-label { display: block; font: 600 12px var(--ui); color: var(--accent); letter-spacing: .14em; }
.hero { position: relative; padding: 18px 48px 18px 20px; }
.hero .hc-ref { display: block; font: 600 24px/1.35 var(--serif-zh); letter-spacing: .04em; margin-top: 6px; overflow-wrap: anywhere; }
.hero .hc-ver { display: block; font: 13px/1.5 var(--ui); color: var(--muted); margin-top: 2px; min-height: 1.5em; }
.hc-go { position: absolute; right: 16px; top: 50%; width: 22px; height: 22px; margin-top: -11px; color: var(--accent); }
.home-search {
  display: flex; align-items: center; gap: 8px; margin-top: 14px; height: 48px; padding: 0 14px;
  background: var(--card); border: 1px solid var(--edge); border-radius: 14px;
}
.home-search:focus-within { border-color: var(--accent); }
.home-search .ic { width: 20px; height: 20px; color: var(--muted); }
.home-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font: 16px var(--ui); }
.home-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.home-quick .hcard { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 14px; font: 500 15px var(--ui); }
.home-quick .ic { width: 22px; height: 22px; color: var(--accent); }
.votd { margin-top: 14px; padding: 16px 20px 14px; animation: fade var(--t) var(--ease) both; }
.votd-text { display: block; font: 17px/1.75 var(--serif-zh); margin-top: 8px; color: var(--fg); }
.votd-ref { display: block; font: 600 13px var(--ui); color: var(--fg2); margin-top: 8px; text-align: right; }
.votd-ref small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.home-books { margin-top: 10px; }
.home-books .bsec h2 { margin: 22px 4px 10px; }
.home-books .book { height: 44px; border-radius: 12px; }
/* 簡稱 tiles: equal squares, ~7 per row on a phone (6 at 320px), more on wider screens */
.bookgrid.short { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.home-books .bookgrid.short .book { height: auto; aspect-ratio: 1; border-radius: 10px; padding: 0; font-size: 16px; letter-spacing: 0; }

/* ===== bottom sheet ===== */
.sheet-backdrop { position: fixed; z-index: 9; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.sheet-backdrop.open { pointer-events: auto; }
.sheet {
  --sheet-top: calc(var(--safe-t) + 10px);
  position: fixed; z-index: 10; left: 0; right: 0; top: 0; height: 100%;
  display: flex; flex-direction: column; background: var(--card); color: var(--fg);
  border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
  touch-action: none; will-change: transform; transform: translate3d(0, 100%, 0);
  max-width: 760px; margin: 0 auto;
}
.sheet-grip { flex: none; height: 26px; display: flex; justify-content: center; align-items: center; cursor: grab; }
.sheet-grip span { width: 38px; height: 4px; border-radius: 4px; background: var(--line); }
.sheet-body { flex: 1; overflow: hidden; padding: 0 20px calc(var(--sheet-top) + var(--safe-b) + 24px); overscroll-behavior: contain; }
.sheet.is-full .sheet-body { overflow-y: auto; }
.wc { font: 16px/1.6 var(--ui); }
.wc-peek { min-height: 0; }
.wc-top { display: flex; align-items: baseline; gap: 12px; }
.wc-word { font-size: 30px; line-height: 1.2; color: var(--fg); }
.wc-strong { font: 600 13px var(--ui); color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 99px; margin-left: auto; }
.wc-sub { margin-top: 2px; display: flex; gap: 10px; align-items: baseline; }
.wc-lemma { font-size: 20px; }
.wc-translit { color: var(--muted); font-style: italic; font-family: var(--serif); }
.wc-parse { margin: 6px 0 0; color: var(--fg2); font-size: 14px; }
.wc-parse code { font: 11px ui-monospace, monospace; color: var(--muted); margin-left: 8px; white-space: nowrap; }
.wc-gloss { margin: 4px 0 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
.wc h3 { font: 600 12px var(--ui); color: var(--muted); letter-spacing: .1em; margin: 18px 0 6px; }
.wc-count { font-weight: 400; margin-left: 6px; }
.wc-def { margin: 0; font-family: var(--serif); }
.wc-refs { margin: 0; padding: 0; list-style: none; }
.wc-refs li a, .reslist li a { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: .5px solid var(--line); text-decoration: none; color: var(--fg); }
.wc-refs b, .reslist b { color: var(--accent); font: 600 13px var(--ui); white-space: nowrap; min-width: 4.6em; }
.wc-refs a.here b { text-decoration: underline; }
.snip { color: var(--fg2); font: 14px/1.5 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.wc-entry { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 14px; }
.wc-entry dt { color: var(--muted); }
.wc-entry dd { margin: 0; }
.wc-more button { margin-top: 8px; }

/* ===== lists / search / notes ===== */
.searchbar input {
  width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--edge); background: var(--card);
  padding: 0 14px; font: 16px var(--ui); outline: none;
}
.searchbar input:focus { border-color: var(--accent); }
.results h3 { font: 600 13px var(--ui); color: var(--muted); margin: 18px 0 4px; }
.results h3 small { font-weight: 400; }
.reslist { list-style: none; margin: 0; padding: 0; }
.reslist li { display: flex; align-items: center; }
.reslist li a { flex: 1; min-width: 0; }
.reslist .ver { font: 10px var(--ui); color: var(--muted); }
.reslist mark { background: var(--hl); color: inherit; border-radius: 2px; }
.reslist .date { font: 11px var(--ui); color: var(--muted); }
.reslist .del { color: var(--muted); padding: 8px 10px; }
.res-head { font: 16px var(--ui); padding: 10px 0; }
.res-head b { color: var(--accent); }

/* ===== settings ===== */
.settings { font: 15px/1.5 var(--ui); }
.settings h2 { font: 600 12px var(--ui); color: var(--muted); letter-spacing: .12em; margin: 22px 2px 8px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg button { border: 1px solid var(--edge); border-radius: 12px; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 14px; background: var(--card); }
.seg button[aria-checked="true"] { border-color: var(--accent); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--edge); display: block; }
.slider { display: grid; grid-template-columns: 3em 1fr 3.6em; align-items: center; gap: 10px; padding: 10px 2px; }
.slider input { accent-color: var(--accent); width: 100%; }
.slider output { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.preview { background: var(--card); border: .5px solid var(--line); border-radius: 12px; padding: 10px 14px; font: var(--fs)/var(--lh) var(--serif); margin: 4px 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; border-bottom: .5px solid var(--line); gap: 12px; }
.toggle small { display: block; color: var(--muted); font-size: 12px; }
.toggle input { width: 44px; height: 26px; accent-color: var(--accent); }
.verlist { list-style: none; margin: 0; padding: 0; }
.verlist li { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px; border-bottom: .5px solid var(--line); }
.check { display: flex; align-items: center; gap: 10px; }
.check small { color: var(--muted); font-size: 12px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.ord button { width: 36px; height: 36px; border-radius: 10px; color: var(--fg2); }
.ord button:disabled { opacity: .25; }
.row { display: flex; width: 100%; justify-content: space-between; padding: 12px 2px; border-bottom: .5px solid var(--line); text-align: left; }
.row { align-items: center; }
.row span { color: var(--muted); }
.row .ic { width: 20px; height: 20px; }
.subpage {
  position: fixed; z-index: 11; inset: 0; background: var(--bg); overflow-y: auto; overscroll-behavior: contain;
  padding: calc(var(--safe-t) + 8px) 18px calc(var(--safe-b) + 30px);
  transform: translateX(100%); transition: transform var(--t-page) var(--ease);
}
.subpage.open { transform: none; }
.lic { list-style: none; padding: 0; margin: 0; }
.lic li, div.lic { padding: 10px 0; border-bottom: .5px solid var(--line); }
.lic small { color: var(--muted); }
.attr { font-size: 13px; color: var(--fg2); }
.small { font-size: 12px; color: var(--muted); word-break: break-all; }

/* ===== dialog / toast ===== */
.note-dialog {
  border: 0; border-radius: 16px; background: var(--card); color: var(--fg); width: min(92vw, 480px); padding: 16px 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); font: 15px var(--ui);
}
.note-dialog[open] { animation: dlg var(--t-pop) var(--ease) both; }
@keyframes dlg { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.note-dialog::backdrop { background: rgba(0, 0, 0, .35); }
.note-dialog h2 { font: 600 16px var(--ui); margin: 0 0 10px; }
.note-dialog textarea { width: 100%; border: 1px solid var(--edge); border-radius: 10px; background: var(--bg); padding: 10px; font: 16px/1.6 var(--serif-zh); resize: vertical; }
.note-dialog menu { display: flex; justify-content: flex-end; gap: 10px; padding: 0; margin: 12px 0 0; }
.note-dialog menu button { padding: 8px 16px; border-radius: 10px; }
.primary { background: var(--accent); color: var(--on-accent); }
.toast {
  position: fixed; z-index: 20; left: 50%; top: calc(var(--topbar) + 10px); max-width: 86vw;
  background: var(--capsule); color: var(--capsule-fg); font: 14px var(--ui); padding: 8px 16px; border-radius: 99px;
  transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  transition: transform var(--t-pop) var(--ease), opacity var(--t-pop) var(--ease);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ===== reduced motion: fades only ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; scroll-behavior: auto !important; }
  .fade-in { animation: fade 160ms linear both !important; }
  .picker { transform: none; }
  .subpage { transform: none; opacity: 0; transition: opacity 160ms linear !important; }
  .subpage.open { opacity: 1; }
  .tabbar.hide { transform: none; opacity: 0; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* lexicon definitions (sanitised HTML) */
.wc-def b { font-weight: 700; }
.wc-def a { color: var(--accent); text-decoration: none; white-space: nowrap; }
.chip { font: 600 12px var(--ui); color: var(--accent); background: var(--accent-soft); border-radius: 99px; padding: 2px 9px; margin: 0 6px 6px 0; }
.wc-def.clamp { max-height: calc(1.6em * 7); overflow: hidden; position: relative; }
.wc-def.clamp.cut::after { content: "…（全文見全屏）"; position: absolute; right: 0; bottom: 0; padding-left: 3em; font: 12px/1.6em var(--ui); color: var(--muted); background: linear-gradient(to right, transparent, var(--card) 2.5em); }
.wc-full .wc-def { margin-bottom: 10px; }
/* at full the 字義 block above shows the whole definition, so drop the clamp and the duplicate */
.sheet.is-full .wc-def.clamp { max-height: none; }
.sheet.is-full .wc-def.clamp.cut::after, .sheet.is-full .wc-full > .wc-def { display: none; }
.cv-measure .verse { content-visibility: visible; }

/* ===== search ===== */
.searchbar { display: flex; gap: 8px; align-items: center; }
.searchbar input { flex: 1; min-width: 0; }
.seg2 { flex: none; display: flex; border: 1px solid var(--edge); border-radius: 12px; overflow: hidden; background: var(--card); height: 44px; }
.seg2 button { padding: 0 12px; font: 500 14px var(--ui); color: var(--muted); }
.seg2 button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); }
.search-progress { display: flex; align-items: center; gap: 10px; font: 12px var(--ui); color: var(--muted); margin: 10px 0 0; }
.sp-bar { flex: 0 0 72px; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.sp-bar i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left center; transition: transform var(--t-pop) var(--ease); }
.search-progress.done .sp-bar { opacity: 0; transition: opacity var(--t) var(--ease); }
.res-group.off h3 { opacity: .55; }
.res-group .g-empty:empty { display: none; }
.res-group .cnt { font-weight: 400; margin-left: 4px; }
.reslist .snip[dir="rtl"] { text-align: right; font-family: var(--hebrew); font-size: 16px; }
.res-zh { font: 14px/1.6 var(--ui); color: var(--fg2); margin: 0 0 6px; }
.res-zh small { color: var(--muted); }

/* ===== Phase 2: chapter heading, Hebrew / RTL ===== */
/* The topbar already shows 「書卷 章」; the in-page heading stays for screen readers only
   (it duplicated the title right under the bar — most visible in the dark themes). */
.chead { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.chapter { position: relative; padding-top: 4px; }
.orig[dir="rtl"] { font-family: var(--hebrew); font-size: 1.22em; line-height: 1.85; text-align: right; }
.orig[dir="rtl"] .w { unicode-bidi: isolate; }
.w small { direction: ltr; unicode-bidi: isolate; }
.ann-strong .orig[dir="rtl"], .ann-morph .orig[dir="rtl"] { line-height: 1.5; }
.ann-strong .orig[dir="rtl"] .wt, .ann-morph .orig[dir="rtl"] .wt { line-height: 1.6; }
:root { --hebrew: "IL Hebrew", "Ezra SIL", "SBL Hebrew", "Noto Serif Hebrew", "Taamey Frank CLM", serif; }

/* bookmark / note markers on the verse number */
.vn { position: relative; }
.verse[data-mark] .vn::after {
  content: ""; position: absolute; right: 4px; top: calc(.62em + 14px); width: 6px; height: 6px; border-radius: 50%;
  background: var(--mk, var(--accent)); opacity: .85;
}
.verse[data-mark~="note"] .vn::after { border-radius: 1.5px; width: 7px; height: 5px; }
.verse[data-mark~="bm"][data-mark~="note"] .vn::after { box-shadow: 0 7px 0 var(--mk, var(--accent)); }
[data-color="red"] { --mk: #d0453a; } [data-color="yellow"] { --mk: #d9a400; } [data-color="green"] { --mk: #3f9a5a; }
[data-color="blue"] { --mk: #3a78c2; } [data-color="purple"] { --mk: #8a5ac2; }

/* toast with action */
.toast.has-act.show { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding-right: 6px; }
.toast-act { color: var(--toast-act); font: 600 14px var(--ui); padding: 4px 10px; border-radius: 99px; }

/* ===== notes list ===== */
.ntools { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.nseg { display: inline-flex; background: var(--bg2); border-radius: 10px; padding: 2px; }
.nseg button { font: 500 13px var(--ui); padding: 6px 10px; border-radius: 8px; color: var(--fg2); }
.nseg button[aria-checked="true"] { background: var(--card); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.nlist { list-style: none; margin: 0; padding: 0; }
.ngroup { font: 600 12px var(--ui); color: var(--muted); letter-spacing: .1em; padding: 14px 2px 4px; }
.nrow { position: relative; overflow: hidden; border-bottom: .5px solid var(--line); }
.nunder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding-right: 22px;
  background: var(--danger); color: var(--on-danger); font: 600 14px var(--ui); opacity: var(--reveal, 0);
  clip-path: inset(0 0 0 calc(100% + var(--dx, 0px))); /* only the strip the row has uncovered */
}
.nfg { position: relative; display: flex; align-items: center; touch-action: pan-y; will-change: transform; }
.nrow.dragging .nfg { cursor: grabbing; }
.nmain { flex: 1; min-width: 0; display: block; padding: 10px 2px; color: var(--fg); text-decoration: none; -webkit-user-drag: none; user-select: none; }
.nhead { display: flex; align-items: center; gap: 8px; }
.nhead b { color: var(--accent); font: 600 14px var(--ui); }
.nhead .date { margin-left: auto; font: 11px var(--ui); color: var(--muted); }
.nkind { width: 12px; height: 14px; flex: none; background: var(--muted); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }
.nkind[data-kind="note"] { clip-path: none; border-radius: 2px; height: 12px; background: none; border: 1.5px solid var(--muted); }
.ndot { width: 9px; height: 9px; border-radius: 50%; background: var(--mk); flex: none; }
.ntext { display: block; margin-top: 2px; font: 14px/1.55 var(--serif-zh); color: var(--fg2); white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.nedit, .ndel { color: var(--muted); padding: 10px 8px; }
.nedit .ic, .ndel .ic { width: 20px; height: 20px; }
.nio { display: flex; gap: 10px; margin-top: 18px; }
.nbtn { flex: 1; text-align: center; border: 1px solid var(--edge); background: var(--card); border-radius: 12px; padding: 10px; font: 500 14px var(--ui); cursor: pointer; }
.nbtn:disabled { opacity: .4; }
.nreport { font: 13px/1.6 var(--ui); background: var(--bg2); border-radius: 10px; padding: 8px 12px; margin: 6px 0; }
.nreport.bad { color: var(--accent); }
.nreport ul { margin: 4px 0 0; padding-left: 18px; }

/* ===== note editor (bottom sheet) ===== */
.ed-backdrop { position: fixed; z-index: 12; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.ed-backdrop.open { pointer-events: auto; }
.ed-sheet {
  position: fixed; z-index: 13; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  background: var(--card); color: var(--fg); border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
  padding: 0 18px calc(var(--safe-b) + 14px); font: 15px var(--ui);
  transform: translate3d(0, 110%, 0); visibility: hidden; will-change: transform; outline: none;
}
.ed-grip { height: 22px; display: flex; justify-content: center; align-items: center; touch-action: none; cursor: grab; }
.ed-grip span { width: 38px; height: 4px; border-radius: 4px; background: var(--line); }
.ed-head { touch-action: none; }
.ed-head h2 { font: 600 16px var(--ui); margin: 0 0 10px; }
.ed-sheet textarea { width: 100%; border: 1px solid var(--edge); border-radius: 10px; background: var(--bg); padding: 10px; font: 16px/1.6 var(--serif-zh); resize: none; max-height: 40vh; }
.ed-sheet textarea:focus { outline: none; border-color: var(--accent); }
.ed-colors { display: flex; gap: 10px; margin: 10px 0 2px; align-items: center; }
.ed-color { width: 30px; height: 30px; border-radius: 50%; background: var(--mk, var(--bg2)); border: 2px solid transparent; font: 11px var(--ui); color: var(--muted); }
.ed-color[aria-checked="true"] { border-color: var(--fg); box-shadow: inset 0 0 0 2px var(--card); }
.ed-err { color: var(--accent); font-size: 13px; min-height: 1.2em; margin: 4px 0 0; }
.ed-actions { display: flex; gap: 8px; padding: 0; margin: 6px 0 0; }
.ed-actions button { padding: 9px 16px; border-radius: 10px; }
.ed-sp { flex: 1; }
.ed-del { color: var(--accent); }

/* ===== settings: versions ===== */
.vname { display: flex; flex-direction: column; line-height: 1.35; }
.vname .copy { font-size: 11px; }

/* ===== word card: zh dictionary, morphemes, tabs ===== */
.wc-zh { color: var(--fg); font-family: var(--serif-zh); }
.wc-zh + .wc-gloss { color: var(--fg2); font-size: 14px; }
.wc-zhdef { white-space: pre-wrap; font: 15px/1.6 var(--serif-zh); margin: 0; }
.wc-zhdef.clamp { max-height: calc(1.6em * 6); overflow: hidden; position: relative; }
.wc-zhdef.clamp.cut::after { content: "…"; position: absolute; right: 0; bottom: 0; padding-left: 2em; background: linear-gradient(to right, transparent, var(--card) 1.5em); }
.sheet.is-full .wc-zhdef.clamp { max-height: none; }
.sheet.is-full .wc-zhdef.clamp.cut::after { display: none; }
.wc-src { font-weight: 400; margin-left: 6px; letter-spacing: 0; }
.wc-morphs { display: flex; flex-wrap: wrap; margin-top: 6px; }
.wc-morphs .chip { font-weight: 500; }
.wc-morphs .chip.on { background: var(--accent); color: var(--on-accent); }
.wc-tabs { display: flex; gap: 4px; margin: 18px 0 4px; border-bottom: .5px solid var(--line); }
.wc-tabs button { font: 600 13px var(--ui); color: var(--muted); padding: 8px 14px; position: relative; }
.wc-tabs button[aria-selected="true"] { color: var(--accent); }
.wc-tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.wc-pane:not([hidden]) { animation: fade var(--t-pop) var(--ease) both; }

/* ===== syntax view ===== */
.synwrap { font: 15px/1.5 var(--ui); }
.syn-title { font: 600 16px var(--ui); margin: 0 0 6px; }
.syn { --syn-x: var(--muted); } /* role colours: theme tokens */
.syn-bar { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.syn-legend { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.syn-legend span { font: 600 11px/1.8 var(--ui); padding: 0 7px; border-radius: 99px; color: var(--syn-fg); background: var(--c); }
[data-rg="s"] { --c: var(--syn-s); } [data-rg="v"] { --c: var(--syn-v); } [data-rg="o"] { --c: var(--syn-o); }
[data-rg="p"] { --c: var(--syn-p); } [data-rg="a"] { --c: var(--syn-a); } [data-rg="x"] { --c: var(--syn-x); }
.syn-tree, .syn-kids { list-style: none; margin: 0; padding: 0; }
.syn-kids { padding-left: 14px; margin-left: 9px; border-left: 1.5px solid var(--line); }
.syn-kids:not([hidden]) { animation: fade var(--t-pop) var(--ease) both; }
.syn-node[data-rg] > .syn-kids { border-left-color: var(--c); }
.syn-row { display: flex; align-items: center; gap: 6px; min-height: 34px; cursor: pointer; }
.syn-tog { width: 22px; height: 28px; flex: none; display: grid; place-items: center; }
.syn-tog .ic { width: 18px; height: 18px; color: var(--muted); transition: transform var(--t-pop) var(--ease); }
.syn-node[aria-expanded="false"] > .syn-row .syn-tog .ic { transform: rotate(-90deg); }
.syn-role { font: 600 11px/1.8 var(--ui); padding: 0 7px; border-radius: 6px; color: var(--syn-fg); background: var(--c, var(--muted)); white-space: nowrap; }
.syn-cat { font: 12px var(--ui); color: var(--muted); white-space: nowrap; }
.syn-prev { flex: 1; min-width: 0; color: var(--fg2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity var(--t-pop) var(--ease); }
.syn-node[aria-expanded="false"] > .syn-row .syn-prev { opacity: 1; }
.syn-leaf { display: flex; align-items: baseline; gap: 6px; min-height: 32px; padding-left: 4px; }
.syn-word { font-size: 18px; padding: 2px 6px; border-radius: 6px; border-bottom: 2px solid var(--c, transparent); }
.syn-word[lang="hbo"] { font-family: var(--hebrew); font-size: 21px; }
.syn-word:disabled { color: var(--muted); cursor: default; }
.syn-leaf.on .syn-word { background: var(--hl); }
.syn-leaf.um .syn-word { font-style: italic; }
.syn-gloss { font: 12px var(--ui); color: var(--muted); }
.syn-attr { font: 11px/1.5 var(--ui); color: var(--muted); margin-top: 14px; }
.tr .sup { color: var(--muted); }

/* ===== navy chrome: home header + tab bar (solid deep-navy blocks, gold/cream text) ===== */
[data-theme="dark"] { --chrome: #1E2130; --chrome-line: #C4935666; }
[data-theme="oled"] { --chrome: #1C1F2C; --chrome-line: #C4935655; }
.tabbar {
  background: var(--chrome); backdrop-filter: none; -webkit-backdrop-filter: none;
  border-top: 1px solid var(--chrome-line);
}
.tabbar button { color: var(--chrome-muted); }
.tabbar button.active { color: var(--chrome-accent); }
.home .home-head {
  max-width: none; margin: calc(-8px - var(--safe-t)) -18px 18px;
  padding: calc(var(--safe-t) + 26px) max(22px, calc((100% - 640px) / 2 + 22px)) 22px;
  background: var(--chrome); border-bottom: 1px solid var(--chrome-line);
}
.home .home-head h1 { color: var(--chrome-fg); }
.home .home-head p { color: var(--chrome-muted); }
.home .home-head .home-logo { --logo: var(--chrome-accent); color: var(--chrome-accent); }
