/* ───────── Scriptorium ───────── */
:root {
  --ui: 'Inter', system-ui, -apple-system, sans-serif;
  --serif: 'EB Garamond', 'Iowan Old Style', Georgia, serif;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;

  --bg: #241811;            /* desk */
  --bg-2: #2e2018;
  --chrome: #1b120d;        /* top bar / sidebar */
  --chrome-2: #2a1c14;
  --chrome-line: #3d2b20;
  --chrome-ink: #eadfcb;
  --chrome-dim: #a8957c;
  --gold: #d8b46a;
  --gold-dim: #9c7d45;

  --paper: #f7f0e0;
  --paper-2: #efe4cc;
  --paper-edge: #e2d4b5;
  --ink: #2a2118;
  --ink-soft: #5d4f3f;
  --ink-faint: #8c7b66;
  --rule: rgba(80, 55, 30, .25);
  --red: #a8201a;
  --accent: #7a1f1f;

  --panel: #fbf7ee;
  --panel-ink: #2a2118;
  --panel-line: #e4d9c3;
  --panel-soft: #f2ead9;

  --hl-yellow: rgba(255, 214, 64, .48);
  --hl-green: rgba(120, 200, 110, .40);
  --hl-blue: rgba(110, 170, 240, .38);
  --hl-pink: rgba(245, 120, 160, .36);
  --hl-purple: rgba(170, 120, 230, .36);
  --sel: rgba(122, 31, 31, .10);

  --fs: 17px;
  --pw: 420px;  --ph: 600px;
  --top: 56px;
}
body.night {
  --paper: #1f1b16; --paper-2: #1a1713; --paper-edge: #2b251e;
  --ink: #e0d6c2; --ink-soft: #b5a88f; --ink-faint: #8a7d67; --rule: rgba(220, 200, 160, .18);
  --red: #ff8a78; --accent: #e0a070;
  --panel: #211c17; --panel-ink: #e6dcc8; --panel-line: #3a3027; --panel-soft: #2a241d;
  --hl-yellow: rgba(230, 190, 40, .30); --hl-green: rgba(100, 190, 90, .28); --hl-blue: rgba(90, 150, 230, .30);
  --hl-pink: rgba(240, 100, 150, .28); --hl-purple: rgba(160, 110, 230, .30); --sel: rgba(255, 200, 150, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--ui); color: var(--chrome-ink); overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #3a281c 0%, var(--bg) 55%, #160e09 100%);
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* ── top bar ── */
.topbar {
  height: var(--top); display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: linear-gradient(#22170f, var(--chrome)); border-bottom: 1px solid var(--chrome-line);
  position: relative; z-index: 30;
}
.brand { font-family: var(--display); font-weight: 700; letter-spacing: .08em; font-size: 19px; color: var(--gold); white-space: nowrap; }
.brand-mark { color: #c9542e; margin-right: 2px; }
.quick { flex: 1; max-width: 560px; }
.quick input, #translation, .side-filter input {
  width: 100%; background: var(--chrome-2); border: 1px solid var(--chrome-line); color: var(--chrome-ink);
  border-radius: 8px; padding: 8px 12px; outline: none;
}
.quick input:focus, .side-filter input:focus { border-color: var(--gold-dim); }
#translation { width: auto; max-width: 190px; }
.tb-btns { display: flex; gap: 4px; margin-left: auto; }
.tb-btns button {
  background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; display: flex; align-items: center; gap: 6px;
  color: var(--chrome-dim); position: relative;
}
.tb-btns button span { font-size: 15px; color: var(--gold); }
.tb-btns button em { font-style: normal; font-size: 13px; }
.tb-btns button:hover, .tb-btns button.on { color: var(--chrome-ink); background: var(--chrome-2); border-color: var(--chrome-line); }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: #777; position: absolute; top: 5px; right: 5px; }
.ai-dot.ok { background: #5fbf6a; box-shadow: 0 0 6px #5fbf6a; }
.ai-dot.bad { background: #e0574a; }
.ai-dot.busy { background: var(--gold); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.icon-btn { background: none; border: 0; font-size: 18px; padding: 4px 8px; color: inherit; }
.only-narrow { display: none; }

/* ── layout ── */
.layout { display: flex; height: calc(100% - var(--top)); }
.sidebar {
  width: 236px; flex: none; background: linear-gradient(90deg, var(--chrome), #20160f); border-right: 1px solid var(--chrome-line);
  display: flex; flex-direction: column; z-index: 20;
}
.side-filter { padding: 10px; border-bottom: 1px solid var(--chrome-line); }
.side-scroll { overflow-y: auto; flex: 1; padding: 6px 0 30px; scrollbar-width: thin; scrollbar-color: #4a372a transparent; }
.side-sec { font-family: var(--display); font-size: 11px; letter-spacing: .18em; color: var(--gold-dim); padding: 14px 16px 6px; text-transform: uppercase; }
.bk { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 16px; color: var(--chrome-ink); font-family: var(--serif); font-size: 16px; }
.bk:hover { background: rgba(255, 255, 255, .04); }
.bk.cur { color: var(--gold); }
.bk small { float: right; color: var(--chrome-dim); font-family: var(--ui); font-size: 11px; margin-top: 4px; }
.chgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; padding: 4px 12px 10px 16px; }
.chgrid button { background: var(--chrome-2); border: 1px solid var(--chrome-line); border-radius: 4px; padding: 4px 0; font-size: 12px; color: var(--chrome-dim); }
.chgrid button:hover { color: var(--chrome-ink); border-color: var(--gold-dim); }
.chgrid button.cur { background: var(--gold); color: #2a1a0e; border-color: var(--gold); font-weight: 600; }
.bk.back-matter { font-family: var(--ui); font-size: 13.5px; color: var(--chrome-dim); }
.bk.back-matter:hover, .bk.back-matter.cur { color: var(--gold); }

.desk { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; padding: 28px 18px 10px; }

/* ── the book ── */
.book { position: relative; }
.cover {
  padding: 10px 12px; border-radius: 10px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.06), transparent 40%),
    repeating-linear-gradient(45deg, rgba(0,0,0,.05) 0 2px, transparent 2px 4px),
    linear-gradient(135deg, #5b2f1d, #3b1c10 60%, #2c140b);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.8), 0 10px 20px rgba(0,0,0,.45), inset 0 0 0 1px rgba(216,180,106,.25), inset 0 0 0 5px rgba(0,0,0,.25);
}
.spread {
  position: relative; display: flex; width: calc(var(--pw) * 2); height: var(--ph);
  perspective: 2600px;
}
.book.single .spread { width: var(--pw); }
.book.single .page.left, .book.single .gutter { display: none; }
.page { position: relative; width: var(--pw); height: var(--ph); background: var(--paper); overflow: hidden; }
.page.left {
  border-radius: 3px 0 0 3px;
  background: linear-gradient(to left, rgba(60,35,15,.22), rgba(60,35,15,.06) 5%, transparent 12%), linear-gradient(var(--paper), var(--paper-2));
  box-shadow: -1px 0 0 var(--paper-edge), -2px 1px 0 #d8c8a6, -3px 2px 0 var(--paper-edge), -4px 3px 0 #cdbb95;
}
.page.right {
  border-radius: 0 3px 3px 0;
  background: linear-gradient(to right, rgba(60,35,15,.22), rgba(60,35,15,.06) 5%, transparent 12%), linear-gradient(var(--paper), var(--paper-2));
  box-shadow: 1px 0 0 var(--paper-edge), 2px 1px 0 #d8c8a6, 3px 2px 0 var(--paper-edge), 4px 3px 0 #cdbb95;
}
.book.single .page.right { border-radius: 3px; background: linear-gradient(to right, rgba(60,35,15,.16), transparent 6%), linear-gradient(var(--paper), var(--paper-2)); }
body.night .page.left, body.night .page.right { box-shadow: none; }
.gutter { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(60,35,15,.25); pointer-events: none; z-index: 2; }
.holder { position: absolute; inset: 0; }

/* page content */
.pg { position: absolute; inset: 0; padding: 26px 34px 16px; display: flex; flex-direction: column; overflow: hidden; color: var(--ink); font-family: var(--serif); }
.page.left .pg { padding-right: 38px; }
.page.right .pg { padding-left: 38px; }
.pg-head { flex: none; display: flex; justify-content: space-between; font-family: var(--display); font-size: 10.5px; letter-spacing: .16em; color: var(--ink-faint); border-bottom: 1px solid var(--rule); padding-bottom: 5px; margin-bottom: 12px; text-transform: uppercase; min-height: 19px; }
.pg-body { flex: none; font-size: var(--fs); line-height: 1.52; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.pg-notes { flex: none; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--rule); font-size: calc(var(--fs) * .66); line-height: 1.35; color: var(--ink-soft); }
.pg-notes ol { list-style: none; margin: 0; padding: 0; }
.pg-notes li { margin: 0 0 3px; text-align: left; cursor: pointer; }
.pg-notes li:hover { color: var(--ink); }
.pg-notes .fn-l { color: var(--accent); font-style: italic; font-weight: 600; }
.pg-notes .fn-ref { font-family: var(--ui); font-size: .85em; font-weight: 600; color: var(--ink-faint); margin-right: 2px; }
.pg-notes li.note-kjv { font-style: italic; }
.pg-notes li.note-ai .ai-mark { color: var(--accent); }
.pg-notes li.note-user .ai-mark { color: #3b6ea8; }
.pg-foot { flex: none; text-align: center; font-family: var(--display); font-size: 11px; color: var(--ink-faint); padding-top: 8px; letter-spacing: .1em; }
.pg.blank { display: flex; align-items: center; justify-content: center; }
.ornament { font-size: 42px; color: var(--paper-edge); font-family: var(--serif); }
body.night .ornament { color: #3a3128; }

.para { margin: 0; text-indent: 1.3em; }
.para.cont, .para.first { text-indent: 0; }
.para.poetry { text-indent: -1.2em; padding-left: 1.6em; text-align: left; hyphens: manual; }
.vn { font-family: var(--ui); font-size: .55em; font-weight: 600; color: var(--gold-dim); vertical-align: .55em; margin-right: .2em; line-height: 0; text-indent: 0; user-select: none; }
body.night .vn { color: #b8955a; }
.chapnum.d2 { font-size: 3em; } .chapnum.d3 { font-size: 2.5em; }
.chapnum { float: left; font-family: var(--display); font-weight: 700; font-size: 3.5em; line-height: .82; color: var(--accent); margin: .06em .14em -.05em 0; }
.verse { border-radius: 2px; cursor: pointer; transition: background .2s; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.verse:hover { background: rgba(122, 31, 31, .045); }
.verse.sel { background: var(--sel); box-shadow: 0 1.5px 0 var(--accent); }
.verse.flash { animation: flash 1.8s ease-out; }
@keyframes flash { 0%, 30% { background: rgba(216, 180, 106, .6); } 100% { background: transparent; } }
.verse.hl-yellow { background: var(--hl-yellow); } .verse.hl-green { background: var(--hl-green); }
.verse.hl-blue { background: var(--hl-blue); } .verse.hl-pink { background: var(--hl-pink); } .verse.hl-purple { background: var(--hl-purple); }
.verse.sel.hl-yellow, .verse.sel.hl-green, .verse.sel.hl-blue, .verse.sel.hl-pink, .verse.sel.hl-purple { box-shadow: 0 1.5px 0 var(--accent); }
.j { color: var(--red); }
body.no-red .j { color: inherit; }
.lord .sc { font-size: .76em; letter-spacing: .05em; }
i.add { font-style: italic; color: var(--ink-soft); }
.verse.sel .w[data-s] { border-bottom: 1px dotted var(--accent); cursor: help; }
.verse.sel .w[data-s]:hover { background: rgba(216, 180, 106, .35); }
sup.fn { font-family: var(--serif); font-style: italic; font-size: .62em; color: var(--accent); vertical-align: .6em; line-height: 0; margin-left: 1px; font-weight: 600; }
.note-ic { font-size: .7em; color: #3b6ea8; vertical-align: .35em; margin-left: 2px; cursor: pointer; }

.book-title { text-align: center; margin: 8px 0 14px; }
.book-title .bt-small { font-family: var(--display); font-size: 11px; letter-spacing: .3em; color: var(--ink-faint); }
.book-title .bt-name { font-family: var(--display); font-weight: 700; font-size: calc(var(--fs) * 1.75); letter-spacing: .06em; color: var(--accent); line-height: 1.15; margin: 4px 0; }
.book-title .bt-rule { color: var(--gold-dim); font-size: 13px; letter-spacing: .5em; }
.chap-title { text-align: center; font-family: var(--display); font-size: 12px; letter-spacing: .3em; color: var(--ink-faint); margin: 6px 0 10px; }
.chap-title.not-first { margin-top: 0; }
.ps-title, .sec-head { text-align: center; font-style: italic; color: var(--ink-soft); font-size: .92em; margin: 2px 0 8px; text-indent: 0; }
.sec-head { font-style: normal; font-variant: small-caps; letter-spacing: .04em; margin-top: 10px; }
.chapter-end { text-align: center; color: var(--gold-dim); margin: 12px 0 4px; letter-spacing: .6em; }
.tr-copy { font-family: var(--ui); font-size: 9.5px; line-height: 1.35; color: var(--ink-faint); text-align: left; margin-top: 10px; }

/* appendix pages */
.ap-title { text-align: center; font-family: var(--display); font-weight: 700; color: var(--accent); font-size: calc(var(--fs) * 1.3); letter-spacing: .05em; margin: 6px 0 12px; line-height: 1.2; }
.ap-h { font-family: var(--display); font-size: 12.5px; letter-spacing: .14em; color: var(--accent); margin: 12px 0 4px; text-transform: uppercase; }
.ap-p { margin: 0 0 8px; font-size: .95em; text-align: left; }
.ap-row { display: grid; gap: 8px; font-size: .8em; line-height: 1.3; padding: 3px 0; border-bottom: 1px solid var(--rule); text-align: left; }
.ap-row.c2 { grid-template-columns: 1.1fr 1.6fr; } .ap-row.c3 { grid-template-columns: 1fr 1.4fr 1fr; } .ap-row.c4 { grid-template-columns: 1.05fr 1fr .9fr 1.6fr; }
.ap-row.th { font-family: var(--ui); font-weight: 600; font-size: .66em; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); border-bottom: 1px solid var(--ink-faint); }
.ap-row > :first-child { font-weight: 600; }
.ap-row.th > :first-child { font-weight: 600; }
.pg a.ref, .panel a.ref, .popover a.ref { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(122,31,31,.3); cursor: pointer; }
.pg a.ref:hover, .panel a.ref:hover, .popover a.ref:hover { border-bottom-color: var(--accent); }

/* ── page-turn leaf ── */
.leaf { position: absolute; top: 0; width: 50%; height: 100%; transform-style: preserve-3d; z-index: 10; pointer-events: none; }
.leaf.from-right { left: 50%; transform-origin: left center; }
.leaf.from-left { left: 0; transform-origin: right center; }
.book.single .leaf { width: 100%; left: 0; }
.leaf .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; background: linear-gradient(var(--paper), var(--paper-2)); }
.leaf .back { transform: rotateY(180deg); }
.leaf .shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.leaf.from-right .front .shade { background: linear-gradient(to left, rgba(0,0,0,.35), rgba(0,0,0,.05) 60%, transparent); }
.leaf.from-right .back .shade { background: linear-gradient(to left, rgba(0,0,0,.25), transparent 50%); }
.leaf.from-left .front .shade { background: linear-gradient(to right, rgba(0,0,0,.35), rgba(0,0,0,.05) 60%, transparent); }
.leaf.from-left .back .shade { background: linear-gradient(to right, rgba(0,0,0,.25), transparent 50%); }
.leaf.turning .shade { animation: shade .8s ease-in-out forwards; }
.leaf.from-right.turning { animation: flipNext .8s cubic-bezier(.42,.08,.3,1) forwards; }
.leaf.from-left.turning { animation: flipPrev .8s cubic-bezier(.42,.08,.3,1) forwards; }
.leaf.back-in.turning { animation: flipBackIn .8s cubic-bezier(.42,.08,.3,1) forwards; }
@keyframes flipNext { 0% { transform: rotateY(0); } 100% { transform: rotateY(-180deg); } }
@keyframes flipPrev { 0% { transform: rotateY(0); } 100% { transform: rotateY(180deg); } }
@keyframes flipBackIn { 0% { transform: rotateY(-180deg); } 100% { transform: rotateY(0); } }
@keyframes shade { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }
.leaf.turning .face { box-shadow: 0 0 18px rgba(0,0,0,.22); }

/* ── bookmark tabs ── */
.bm-tabs { position: absolute; left: 30px; right: 30px; top: -20px; height: 24px; display: flex; gap: 6px; justify-content: flex-end; z-index: 1; pointer-events: none; }
.bm-tab {
  pointer-events: auto; position: relative; height: 30px; min-width: 34px; max-width: 120px; padding: 4px 10px 0; border: 0;
  border-radius: 6px 6px 0 0; font-size: 11px; font-weight: 600; color: rgba(255,255,255,.95); text-shadow: 0 1px 1px rgba(0,0,0,.3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: inset 0 -6px 8px -6px rgba(0,0,0,.35), 0 -1px 3px rgba(0,0,0,.25);
  transform: translateY(0); transition: transform .15s;
}
.bm-tab:hover { transform: translateY(-4px); }
.bm-tab.here { transform: translateY(-6px); }
.bm-ribbon { position: absolute; top: -4px; width: 16px; height: 44px; z-index: 6; pointer-events: none; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 85%, 0 100%); box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.c-red { background: #b8342b; } .c-orange { background: #d4762a; } .c-gold { background: #c49a2c; } .c-green { background: #4b8a4b; }
.c-teal { background: #2f8a86; } .c-blue { background: #3b6ea8; } .c-purple { background: #7651a8; } .c-pink { background: #c4517f; }

/* ── bottom bar ── */
.bookbar { display: flex; align-items: center; gap: 14px; margin-top: 16px; width: min(100%, calc(var(--pw) * 2 + 24px)); }
.book.single + .bookbar { width: min(100%, calc(var(--pw) + 24px)); }
.nav-btn {
  background: linear-gradient(#3b291d, #2a1c13); border: 1px solid #4d3626; color: var(--chrome-ink); border-radius: 22px; padding: 8px 18px;
  font-family: var(--display); font-size: 13px; letter-spacing: .06em; white-space: nowrap;
}
.nav-btn:hover { border-color: var(--gold-dim); color: var(--gold); }
.nav-btn:disabled { opacity: .35; cursor: default; }
.where { flex: 1; text-align: center; min-width: 0; }
.where-label { font-family: var(--display); color: var(--gold); font-size: 15px; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.where-pages { font-size: 11.5px; color: var(--chrome-dim); }
.bar-tools { display: flex; gap: 6px; }
.pill { background: rgba(255,255,255,.04); border: 1px solid var(--chrome-line); color: var(--chrome-dim); border-radius: 16px; padding: 5px 11px; font-size: 12px; white-space: nowrap; }
.pill:hover { color: var(--chrome-ink); border-color: var(--gold-dim); }
.pill.busy { color: var(--gold); animation: pulse 1.2s infinite; }
.pill.done { color: var(--gold); }

/* ── selection toolbar ── */
.selbar {
  position: absolute; bottom: 72px; left: 50%; transform: translateX(-50%); z-index: 25; display: flex; align-items: center; flex-wrap: wrap; justify-content: center;
  gap: 4px; padding: 6px 8px; background: rgba(27, 18, 13, .96); border: 1px solid #4d3626; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  width: max-content; max-width: calc(100% - 24px); animation: rise .18s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
.selbar > button { background: none; border: 0; color: var(--chrome-ink); padding: 6px 9px; border-radius: 7px; font-size: 13px; white-space: nowrap; }
.selbar > button:hover { background: var(--chrome-2); color: var(--gold); }
.sel-label { font-family: var(--display); color: var(--gold); font-size: 13px; padding: 0 8px; white-space: nowrap; }
.sel-colors { display: flex; gap: 4px; padding: 0 6px; border-left: 1px solid var(--chrome-line); border-right: 1px solid var(--chrome-line); }
.sel-colors button { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); padding: 0; }
.sel-colors button:hover { border-color: #fff; }
.sel-colors [data-hl=yellow] { background: #f3cc3f; } .sel-colors [data-hl=green] { background: #7cc36f; } .sel-colors [data-hl=blue] { background: #6fa6ec; }
.sel-colors [data-hl=pink] { background: #ef7ea6; } .sel-colors [data-hl=purple] { background: #a985e4; }
.sel-colors .hl-clear { background: none; color: var(--chrome-dim); font-size: 13px; line-height: 14px; }
.sel-hint { width: 100%; text-align: center; font-size: 11px; color: var(--chrome-dim); padding-top: 2px; }

/* ── side panel ── */
.panel {
  width: 0; flex: none; overflow: hidden; background: var(--panel); color: var(--panel-ink); border-left: 1px solid var(--chrome-line);
  display: flex; flex-direction: column; transition: width .25s ease; z-index: 22;
}
.panel.open { width: 420px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 10px 18px; border-bottom: 1px solid var(--panel-line); min-width: 420px; }
.panel-head h2 { margin: 0; font-family: var(--display); font-size: 16px; letter-spacing: .06em; color: var(--accent); }
.panel-view { display: none; flex: 1; min-height: 0; flex-direction: column; min-width: 420px; }
.panel-view.on { display: flex; }
.pv-scroll { flex: 1; overflow-y: auto; padding: 14px 18px; min-height: 0; }
.pv-top { padding: 12px 18px; border-bottom: 1px solid var(--panel-line); display: flex; flex-direction: column; gap: 8px; }
.field { width: 100%; border: 1px solid var(--panel-line); background: #fff; color: var(--panel-ink); border-radius: 8px; padding: 8px 10px; outline: none; }
body.night .field { background: #17130f; }
.field:focus { border-color: var(--accent); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 500; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: none; color: var(--accent); border: 1px solid var(--panel-line); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.chip { font-size: 12px; border: 1px solid var(--panel-line); background: var(--panel-soft); color: var(--panel-ink); border-radius: 14px; padding: 4px 10px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.muted { color: #8c7b66; font-size: 12.5px; }
.seg { display: inline-flex; border: 1px solid var(--panel-line); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 5px 10px; font-size: 12px; color: var(--panel-ink); }
.seg button.on { background: var(--accent); color: #fff; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }

/* chat */
.ctx-chip { display: flex; align-items: center; gap: 8px; font-size: 12.5px; background: var(--panel-soft); border: 1px solid var(--panel-line); border-radius: 8px; padding: 6px 10px; }
.ctx-chip b { font-family: var(--display); color: var(--accent); font-weight: 600; }
.ctx-chip .x { margin-left: auto; background: none; border: 0; color: #8c7b66; }
.msgs { display: flex; flex-direction: column; gap: 14px; }
.msg { font-size: 14.5px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 14px 14px 4px 14px; max-width: 88%; white-space: pre-wrap; }
.msg.ai { font-family: var(--serif); font-size: 16.5px; }
.msg.ai p { margin: 0 0 .6em; } .msg.ai ul, .msg.ai ol { margin: 0 0 .6em; padding-left: 1.3em; }
.msg.ai h3, .msg.ai h4, .msg.ai h5 { font-family: var(--display); font-size: 13px; letter-spacing: .08em; color: var(--accent); margin: .8em 0 .3em; }
.msg.ai blockquote { margin: 0 0 .6em; padding-left: 10px; border-left: 3px solid var(--panel-line); color: #6b5b48; }
.msg.ai code { font-size: .85em; background: var(--panel-soft); padding: 1px 4px; border-radius: 4px; }
.msg-tools { display: flex; gap: 6px; margin-top: 4px; font-family: var(--ui); }
.thinking { font-family: var(--ui); font-size: 12px; color: #8c7b66; border-left: 2px solid var(--panel-line); padding-left: 8px; margin-bottom: 8px; white-space: pre-wrap; max-height: 140px; overflow: auto; }
.thinking summary { cursor: pointer; }
.typing::after { content: '▍'; animation: pulse 1s infinite; color: var(--accent); }
.err { color: #b3261e; font-family: var(--ui); font-size: 13px; }
.composer { border-top: 1px solid var(--panel-line); padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.composer textarea { resize: none; min-height: 44px; max-height: 160px; }
.quick-asks { display: flex; gap: 5px; flex-wrap: wrap; }
.empty-state { text-align: center; color: #8c7b66; padding: 30px 10px; font-size: 13.5px; line-height: 1.6; }
.empty-state .big { font-family: var(--display); color: var(--accent); font-size: 18px; margin-bottom: 6px; }

/* results / lists */
.res { padding: 9px 0; border-bottom: 1px solid var(--panel-line); cursor: pointer; }
.res:hover .res-ref { color: var(--accent); text-decoration: underline; }
.res-ref { font-family: var(--display); font-size: 12px; letter-spacing: .05em; font-weight: 600; color: var(--panel-ink); }
.res-text { font-family: var(--serif); font-size: 15.5px; line-height: 1.45; margin-top: 2px; }
.res-text mark { background: var(--hl-yellow); color: inherit; border-radius: 2px; padding: 0 1px; }
.res-why { font-size: 12px; color: #8c7b66; font-style: italic; }
.per-book { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.per-book .chip { font-size: 11px; padding: 2px 8px; }
.summary-box { font-family: var(--serif); font-size: 15.5px; background: var(--panel-soft); border-left: 3px solid var(--accent); padding: 10px 12px; margin-bottom: 10px; border-radius: 0 8px 8px 0; }
.note-card { border: 1px solid var(--panel-line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
body.night .note-card { background: #17130f; }
.note-card .nc-refs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.note-card .nc-body { font-family: var(--serif); font-size: 15px; line-height: 1.5; }
.note-card .nc-body p { margin: 0 0 .5em; }
.note-card .nc-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: #8c7b66; margin-top: 6px; }
.tag-ai { font-size: 10px; background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 8px; margin-left: 6px; }
.hl-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.tabs2 { display: flex; gap: 0; border-bottom: 1px solid var(--panel-line); padding: 0 18px; }
.tabs2 button { background: none; border: 0; padding: 10px 12px; font-size: 13px; color: #8c7b66; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs2 button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.letters { display: flex; flex-wrap: wrap; gap: 2px; }
.letters button { background: none; border: 1px solid transparent; border-radius: 4px; width: 22px; font-size: 12px; padding: 2px 0; color: var(--panel-ink); }
.letters button:hover, .letters button.on { border-color: var(--accent); color: var(--accent); }
.dict-terms { columns: 2; column-gap: 14px; }
.dict-terms button { display: block; background: none; border: 0; padding: 2px 0; font-family: var(--serif); font-size: 15px; color: var(--panel-ink); text-align: left; width: 100%; }
.dict-terms button:hover { color: var(--accent); }
.dict-entry h3 { font-family: var(--display); color: var(--accent); margin: 0 0 8px; font-size: 18px; }
.dict-entry { font-family: var(--serif); font-size: 15.5px; line-height: 1.55; }
.dict-entry p { margin: 0 0 .7em; }
.lex-card { border-bottom: 1px solid var(--panel-line); padding: 10px 0; }
.lemma { font-size: 22px; font-family: var(--serif); }
.lex-id { font-family: var(--ui); font-size: 11px; background: var(--panel-soft); border: 1px solid var(--panel-line); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.translit { font-style: italic; color: #6b5b48; }
.lex-def { font-family: var(--serif); font-size: 15px; margin: 4px 0; }
.lex-kjv { font-size: 12.5px; color: #6b5b48; }
.settings-grid { display: flex; flex-direction: column; gap: 14px; }
.settings-grid h4 { margin: 8px 0 0; font-family: var(--display); font-size: 12px; letter-spacing: .1em; color: var(--accent); }
.status-box { font-size: 13px; padding: 10px 12px; border-radius: 8px; background: var(--panel-soft); border: 1px solid var(--panel-line); line-height: 1.5; }
.tr-list { display: flex; flex-direction: column; gap: 6px; }
.tr-item { font-size: 12.5px; padding: 8px 10px; border: 1px solid var(--panel-line); border-radius: 8px; }
.tr-item b { font-size: 13.5px; }
.tr-item.off { opacity: .6; }

/* popover (word study, notes) */
.popover {
  position: fixed; z-index: 50; width: 360px; max-width: calc(100vw - 20px); max-height: min(70vh, 520px); overflow: auto; background: var(--panel); color: var(--panel-ink);
  border: 1px solid var(--panel-line); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.45); padding: 14px 16px; font-size: 14px;
}
.popover h4 { margin: 0 0 2px; font-family: var(--display); color: var(--accent); font-size: 14px; }
.popover .pop-x { position: absolute; top: 6px; right: 8px; background: none; border: 0; font-size: 16px; color: #8c7b66; }
.popover .row { margin-top: 10px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(10, 6, 4, .55); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); color: var(--panel-ink); border-radius: 14px; width: 560px; max-width: 100%; max-height: 86vh; overflow: auto; padding: 18px 20px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal h3 { margin: 0 0 10px; font-family: var(--display); color: var(--accent); font-size: 17px; }
.modal textarea.field { min-height: 160px; resize: vertical; font-family: var(--serif); font-size: 16px; line-height: 1.5; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.cmp-row { padding: 10px 0; border-bottom: 1px solid var(--panel-line); }
.cmp-row .tr-name { font-family: var(--ui); font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--accent); text-transform: uppercase; }
.cmp-row .cmp-text { font-family: var(--serif); font-size: 16.5px; line-height: 1.5; }
.colors { display: flex; gap: 8px; margin: 8px 0; }
.colors button { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; }
.colors button.on { border-color: var(--panel-ink); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: #1b120d; color: var(--chrome-ink); border: 1px solid #4d3626; padding: 9px 16px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 70; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.measure { position: fixed; left: -10000px; top: 0; visibility: hidden; pointer-events: none; }

/* ── responsive ── */
@media (max-width: 1100px) {
  .tb-btns button em { display: none; }
  .brand { font-size: 16px; }
}
@media (max-width: 860px) {
  .only-narrow { display: block; }
  .sidebar { position: fixed; top: var(--top); bottom: 0; left: 0; transform: translateX(-100%); transition: transform .25s; box-shadow: 10px 0 30px rgba(0,0,0,.5); }
  .sidebar.open { transform: none; }
  .panel.open { position: fixed; top: var(--top); right: 0; bottom: 0; width: min(420px, 100vw); }
  .panel-head, .panel-view { min-width: 0; width: min(420px, 100vw); }
  .brand { display: none; }
  #translation { max-width: 110px; }
  .bar-tools .pill { padding: 5px 8px; }
  .nav-btn span { display: none; }
  .desk { padding: 26px 10px 8px; }
}
@media (max-width: 560px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .tb-btns button { padding: 6px 7px; }
  .bookbar { gap: 6px; }
  .bar-tools { flex-direction: column; }
  .pg { padding: 20px 22px 12px !important; }
}

/* ── sign in ── */
.auth { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 30%, #3a281c 0%, var(--bg) 60%, #120b07 100%); }
.auth-box { width: 400px; max-width: 100%; }
.auth-brand { font-family: var(--display); font-weight: 700; letter-spacing: .1em; font-size: 30px; color: var(--gold); text-align: center; }
.auth-sub { text-align: center; color: var(--chrome-dim); font-family: var(--serif); font-style: italic; font-size: 17px; margin: 2px 0 20px; }
.auth-card { background: var(--panel); color: var(--panel-ink); border-radius: 14px; padding: 22px 24px; box-shadow: 0 30px 70px rgba(0,0,0,.55), inset 0 0 0 1px rgba(216,180,106,.25); }
.auth-card h3 { margin: 0 0 14px; font-family: var(--display); color: var(--accent); font-size: 17px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; }
.auth-card label small { font-weight: 400; color: #8c7b66; }
.auth-card .field { font-size: 15px; padding: 10px 12px; }
.btn.wide { width: 100%; padding: 11px; font-size: 15px; }
.auth-tabs { display: flex; margin: -6px -6px 16px; border-bottom: 1px solid var(--panel-line); }
.auth-tabs button { flex: 1; background: none; border: 0; padding: 10px; font-size: 14px; color: #8c7b66; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.auth-tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.auth-msg { font-size: 13px; min-height: 0; }
.auth-msg:empty { display: none; }
.auth-msg.err, .auth-fine.err { color: #b3261e; }
.auth-msg.info, .auth-fine.info { color: #3a7a44; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.auth-fine { font-size: 12.5px; color: #8c7b66; margin: 0; text-align: center; }
.auth-sent { text-align: center; }
.auth-sent p { font-family: var(--serif); font-size: 16px; line-height: 1.5; }
.auth-icon { font-size: 40px; color: var(--accent); }
.account-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
