:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #0f172a;
  --soft: #5b6676;
  --faint: #94a0b1;
  --rule: #e4e7ec;
  --accent: #4338ca;
  --accent-soft: #eef0ff;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --diff: #b45309;
  --diff-soft: #fdf1dc;
  --hit: #fff1b8;
  --shadow: 0 1px 2px rgb(15 23 42 / .05), 0 4px 16px rgb(15 23 42 / .04);
  --radius: 16px;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --greek: 'Noto Serif', 'Gentium Plus', 'Times New Roman', serif;
  --hebrew: 'Noto Serif Hebrew', 'SBL Hebrew', 'Ezra SIL', 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0f14;
    --card: #151a22;
    --ink: #eef1f6;
    --soft: #a3adbd;
    --faint: #6d7889;
    --rule: #262d39;
    --accent: #a5b0ff;
    --accent-soft: #1e2244;
    --ok: #6fd08c;
    --ok-soft: #14301f;
    --diff: #f2b765;
    --diff-soft: #3a2a10;
    --hit: #5b4a10;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--ui); font-weight: 700; line-height: 1.15; letter-spacing: -.02em; margin: 0; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- frame ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem 1.5rem; flex-wrap: wrap;
  padding: .7rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.brand small { display: block; font-weight: 400; font-size: .76rem; color: var(--soft); letter-spacing: 0; }
.seal { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 10px; background: var(--accent); color: var(--card); font-weight: 700; }
.top nav { display: flex; gap: .15rem; margin-left: auto; background: var(--bg); border-radius: 999px; padding: .2rem; }
.top nav a { padding: .4rem .95rem; border-radius: 999px; color: var(--soft); text-decoration: none; font-size: .9rem; font-weight: 500; }
.top nav a.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* a switch: a checkbox drawn as a sliding toggle */
.switch { display: inline-flex; align-items: center; gap: .6rem; font-size: .9rem; font-weight: 500; color: var(--soft); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; flex: none; width: 2.6rem; height: 1.5rem; border-radius: 999px; background: var(--faint); transition: background .18s; }
.switch .track::after { content: ''; position: absolute; top: .16rem; left: .16rem; width: 1.18rem; height: 1.18rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .18s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(1.1rem); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch:has(input:checked) { color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .switch .track, .switch .track::after { transition: none; } }

main { max-width: 1160px; margin: 0 auto; padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1rem, 4vw, 2.5rem) 5rem; }
.foot { border-top: 1px solid var(--rule); padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 3rem; color: var(--soft); font-size: .85rem; }
.foot p { max-width: 1160px; margin: 0 auto; }
.loading, .error { color: var(--soft); padding: 4rem 0; text-align: center; }
.error { color: var(--diff); }

.eyebrow { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin: 0 0 .7rem; }
.lead { font-size: 1.15rem; line-height: 1.6; color: var(--soft); max-width: 60ch; margin: 1rem 0 0; }
.back { display: inline-block; margin-bottom: 1.2rem; font-size: .9rem; font-weight: 500; text-decoration: none; }

/* ---------- words ---------- */
.passage { font-family: var(--greek); font-size: 1.5rem; line-height: 1.25; display: flex; flex-wrap: wrap; gap: 1rem .5rem; align-items: flex-start; }
.passage[lang='he'] { font-family: var(--hebrew); font-size: 1.8rem; direction: rtl; }
.vnum { font: 700 .68rem var(--ui); color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: .1rem .45rem; align-self: flex-start; margin-top: .5rem; direction: ltr; }
.w {
  display: inline-flex; flex-direction: column; align-items: center;
  background: none; border: 0; padding: .15rem .3rem .25rem; margin: 0; border-radius: 8px;
  font: inherit; color: inherit; cursor: pointer; line-height: inherit; transition: background .12s;
}
.w:hover { background: var(--bg); }
.w.hit { background: var(--hit); }
.w.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.w .sum { font: 500 .7rem var(--mono); color: var(--faint); direction: ltr; margin-top: .2rem; }
.w.hit .sum { color: var(--ink); }
.w .cells { display: inline-flex; gap: .15rem; }
.l { display: inline-flex; flex-direction: column; align-items: center; min-width: 1.2em; padding: 0 .05em .1em; border-radius: 6px; }
.l .v { font: 500 .64rem var(--mono); color: var(--faint); direction: ltr; margin-top: .25rem; }
.w.full .sum { border-top: 1.5px solid var(--rule); padding-top: .2rem; margin-top: .25rem; font-size: .82rem; color: var(--accent); font-weight: 700; min-width: 100%; text-align: center; }
.l.pick { background: var(--hit); }
.l.pick .v { color: var(--ink); font-weight: 700; }
.passage.dim .w:not(.hit) { opacity: .32; }
.passage.letters .w.hit { background: none; }

/* ---------- home ---------- */
.hero { text-align: center; padding: clamp(.5rem, 3vw, 2rem) 0 0; }
.hero h1 { font-size: clamp(2.1rem, 5.5vw, 3.6rem); max-width: 18ch; margin: 0 auto; }
.hero .lead { margin-left: auto; margin-right: auto; }
.verse-card { background: var(--card); border: 1px solid var(--rule); border-radius: 24px; box-shadow: var(--shadow); padding: clamp(1.2rem, 4vw, 2.5rem); margin-top: 2.5rem; text-align: center; }
.verse-card .passage { justify-content: center; font-size: clamp(1.5rem, 4.4vw, 2.7rem); gap: 1.4rem 1rem; }
.verse-card .gloss { color: var(--soft); margin: 1.4rem 0 0; font-size: 1.05rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-top: 1.6rem; text-align: left; }
.fact { border-radius: 14px; padding: 1rem 1.1rem; background: var(--bg); }
.fact b { display: block; font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.fact span { font-size: .88rem; color: var(--soft); }
.fact em { font-style: normal; font: 600 .8rem var(--mono); color: var(--accent); display: block; margin-top: .35rem; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-top: 1rem; }
.step { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.2rem 1.3rem; box-shadow: var(--shadow); }
.step i { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: 700 .9rem var(--ui); margin-bottom: .7rem; }
.step h3 { font-size: 1.05rem; letter-spacing: -.01em; }
.step p { margin: .35rem 0 0; color: var(--soft); font-size: .95rem; }

.section-head { margin: 3.5rem 0 1.2rem; }
.section-head h2 { font-size: 1.7rem; }
.section-head p { color: var(--soft); margin: .5rem 0 0; max-width: 64ch; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.card { display: flex; flex-direction: column; gap: .3rem; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem 1.4rem; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card h3 { font-size: 1.3rem; }
.card .sub { color: var(--soft); font-size: .92rem; margin: 0; }
.score { margin-top: auto; padding-top: 1rem; display: grid; gap: .8rem; }
.score-row { display: grid; gap: .35rem; font-size: .85rem; color: var(--soft); }
.score-row b { color: var(--ink); font-size: 1rem; }
.bar { height: .45rem; border-radius: 999px; background: var(--rule); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.card .more { margin-top: 1rem; font-size: .9rem; font-weight: 600; color: var(--accent); }

/* ---------- study ---------- */
.study-head h1 { font-size: clamp(2rem, 4.5vw, 3rem); }
.tabs { display: inline-flex; border-radius: 999px; padding: .22rem; margin-top: 1.4rem; background: var(--rule); flex-wrap: wrap; }
.tabs a { padding: .4rem 1rem; border-radius: 999px; text-decoration: none; color: var(--soft); font-size: .9rem; font-weight: 500; }
.tabs a.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.tally { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 1.5rem 0 0; padding: 1rem 1.2rem; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); max-width: 640px; }
.tally b { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.tally span { color: var(--soft); font-size: .95rem; flex: 1; min-width: 14ch; }
.tally .bar { flex-basis: 100%; }
.study { display: grid; gap: 1.5rem; margin-top: 2rem; }
@media (min-width: 1000px) {
  .study { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .study .text-col { position: sticky; top: 5rem; max-height: calc(100vh - 6rem); overflow: auto; border-radius: var(--radius); }
}
.panel { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem 1.4rem; }
.panel + .panel { margin-top: 1rem; }
.panel h2 { font-size: 1rem; letter-spacing: -.01em; margin-bottom: 1rem; display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.panel h2 small { font-weight: 400; color: var(--soft); font-size: .82rem; letter-spacing: 0; }
.hint { color: var(--soft); font-size: .88rem; margin: 1rem 0 0; }

.col-title { font-size: 1.15rem; margin-bottom: .2rem; }
.col-help { color: var(--soft); font-size: .92rem; margin: 0 0 1rem; }
.group { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); margin: 1.8rem 0 .6rem; }
.claim { border: 1px solid var(--rule); border-radius: 14px; background: var(--card); box-shadow: var(--shadow); margin-bottom: .6rem; overflow: hidden; transition: border-color .15s; }
.claim:hover { border-color: var(--faint); }
.claim.open { border-color: var(--accent); }
.claim > button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 1rem 1.15rem; cursor: pointer; }
.claim .say { display: flex; gap: .8rem; justify-content: space-between; align-items: flex-start; font-size: 1.02rem; font-weight: 500; line-height: 1.45; }
.claim .say::after { content: ''; flex: none; width: .55rem; height: .55rem; margin-top: .45rem; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(45deg); transition: transform .15s; }
.claim.open .say::after { transform: rotate(-135deg); margin-top: .7rem; }
.cmp { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.6rem; margin-top: .8rem; }
.stat { display: grid; }
.stat small { font-size: .74rem; color: var(--soft); }
.stat b { font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.stat .eq { font: .78rem var(--mono); color: var(--soft); }
.chip { margin-left: auto; font-size: .8rem; font-weight: 600; padding: .3rem .75rem; border-radius: 999px; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.diff { background: var(--diff-soft); color: var(--diff); }
.work { border-top: 1px solid var(--rule); background: var(--bg); padding: 1rem 1.15rem 1.1rem; font-size: .92rem; }
.work p { margin: 0 0 .7rem; color: var(--soft); }
.terms { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; font-family: var(--greek); }
.terms[lang='he'] .t b { font-family: var(--hebrew); font-size: 1.2rem; }
.t { display: inline-flex; flex-direction: column; align-items: center; border: 1px solid var(--rule); border-radius: 8px; padding: .2rem .5rem; background: var(--card); }
.t b { font-weight: 400; font-size: 1.05rem; }
.t i { font: normal .72rem var(--mono); color: var(--soft); }
.total { margin-top: .9rem; font: 700 1rem var(--mono); }
.total .ok { color: var(--ok); }
.total .diff { color: var(--diff); }
.src { margin: .7rem 0 0 !important; font-size: .8rem; }

.inspect .big { font-family: var(--greek); font-size: 2.1rem; }
.inspect .big[lang='he'] { font-family: var(--hebrew); }
.inspect dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1.2rem; margin: 1rem 0 0; font-size: .9rem; }
.inspect dt { color: var(--soft); }
.inspect dd { margin: 0; }
.addition { font-family: var(--mono); font-size: .9rem; margin-top: .7rem; padding: .7rem .9rem; background: var(--bg); border-radius: 10px; overflow-wrap: anywhere; }

/* ---------- word side panel ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 30; width: min(400px, 92vw); background: var(--card); border-left: 1px solid var(--rule); box-shadow: -12px 0 40px rgb(15 23 42 / .14); padding: 1.3rem 1.5rem 2rem; overflow: auto; transform: translateX(105%); visibility: hidden; transition: transform .22s ease, visibility .22s; }
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; }
.drawer-head h2 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.drawer-head button { width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 0; background: var(--bg); color: var(--soft); cursor: pointer; font-size: .9rem; }
.drawer-head button:hover { color: var(--ink); }
.drawer .inspect dl { grid-template-columns: 1fr; gap: 0; }
.drawer .inspect dt { font-size: .78rem; margin-top: .9rem; }
.drawer .inspect dd { font-weight: 500; }
@media (min-width: 1500px) { body.drawer-open main { margin-right: 400px; margin-left: auto; } }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }

/* ---------- reader ---------- */
.controls { display: flex; flex-wrap: wrap; gap: .8rem; align-items: end; margin: 1.6rem 0 0; padding: 1rem 1.2rem; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
.controls label { display: grid; gap: .3rem; font-size: .78rem; font-weight: 500; color: var(--soft); }
.controls select, .controls input { background: var(--bg); border: 1px solid var(--rule); border-radius: 10px; padding: .45rem .7rem; min-height: 2.5rem; font-size: .95rem; color: var(--ink); }
.controls input[type='number'] { width: 5.5rem; }
.pager { margin-left: auto; display: flex; gap: .4rem; }
.pager a { border: 1px solid var(--rule); border-radius: 10px; padding: .5rem .9rem; text-decoration: none; background: var(--bg); font-size: .9rem; font-weight: 500; }
table.counts { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.counts th { text-align: left; font-weight: 600; font-size: .74rem; color: var(--soft); text-transform: uppercase; letter-spacing: .05em; padding: .4rem .5rem; border-bottom: 1px solid var(--rule); }
table.counts td { padding: .55rem .5rem; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
table.counts tr:last-child td { border-bottom: 0; }
table.counts td.n { font-weight: 700; font-size: 1rem; text-align: right; white-space: nowrap; }
table.counts td.f { font: .78rem var(--mono); color: var(--soft); }
table.counts tr.mult td { background: var(--accent-soft); }
table.counts tr.mult td:first-child { border-radius: 8px 0 0 8px; }
table.counts tr.mult td:last-child { border-radius: 0 8px 8px 0; }
table.counts tr.mult td.n, table.counts tr.mult td.f { color: var(--accent); }
.dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); margin-right: .45rem; vertical-align: middle; }

/* ---------- method ---------- */
.prose { max-width: 68ch; margin: 0 auto; }
.prose h1 { font-size: clamp(2rem, 4.5vw, 3rem); }
.prose h2 { font-size: 1.45rem; margin: 3rem 0 .7rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: .5rem; }
.alphabet { display: grid; grid-template-columns: repeat(auto-fill, minmax(3.6rem, 1fr)); gap: .45rem; margin: 1rem 0; }
.alphabet div { border: 1px solid var(--rule); border-radius: 12px; background: var(--card); text-align: center; padding: .45rem 0 .4rem; }
.alphabet b { display: block; font: 400 1.6rem var(--greek); }
.alphabet[lang='he'] b { font-family: var(--hebrew); }
.alphabet i { font: normal 600 .78rem var(--mono); color: var(--accent); }
.try { display: grid; gap: 1rem; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; }
.try input { width: 100%; font: 1.5rem var(--greek); padding: .6rem .9rem; border: 1px solid var(--rule); border-radius: 12px; background: var(--bg); }
.try .passage { min-height: 3rem; }
.try .addition { margin-top: 0; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .top nav { margin-left: 0; order: 3; width: 100%; justify-content: space-between; }
  .top nav a { flex: 1; text-align: center; }
  .switch { margin-left: auto; }
  .passage { font-size: 1.3rem; }
  .passage[lang='he'] { font-size: 1.55rem; }
  .chip { margin-left: 0; }
}
