:root {
  --bg: #0D0F14;
  --bg2: #11141B;
  --surface: #151821;
  --surface2: #1C2030;
  --line: #222632;
  --line2: #2A2F3D;
  --text: #F2EEE6;
  --muted: #A3A9B6;
  --dim: #8A91A0;
  --gold: #E7B75F;
  --gold-2: #F3CF8A;
  --gold-ink: #1A1408;
  --heat1: #6B5A30;
  --heat2: #A8853F;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
  --hebrew: "Frank Ruhl Libre", "Times New Roman", "David", serif;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--gold); }
a:hover { color: var(--gold-2); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.he { font-family: var(--hebrew); direction: rtl; unicode-bidi: isolate; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: var(--gold-ink); padding: 8px 14px; z-index: 10; }
.skip:focus { left: 12px; top: 12px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 40px; }
main:focus { outline: none; }

/* ------------------------------------------------------------------ header */
.topbar { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.topbar-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--gold); color: var(--gold-ink); display: grid; place-items: center; font: 700 22px var(--hebrew); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font: 600 18px var(--display); }
.brand-he { font: 14px var(--hebrew); color: var(--muted); }
.topnav { display: flex; flex-wrap: wrap; gap: 4px 24px; font-size: 15px; }
.topnav a { color: var(--muted); text-decoration: none; padding: 8px 0; }
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--text); }

/* ------------------------------------------------------------------ common */
.eyebrow { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.lead { color: var(--muted); font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); font-size: 13px; }
.section { padding: 64px 0; }
.section-alt { background: var(--bg2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.section-head h2 { font-size: 40px; }
.panel { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.panel h2 { font-size: 20px; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.banner { background: #2A2210; color: var(--gold-2); border: 1px solid #4A3D22; border-radius: 12px; padding: 10px 16px; font-size: 14px; margin: 16px 0 0; }
.loading { padding: 120px 40px; text-align: center; color: var(--muted); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line2); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line2); background: var(--surface); color: var(--text); text-decoration: none; font-size: 15px; }
.btn:hover { border-color: var(--gold); color: var(--text); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 600; }
.btn-gold:hover { background: var(--gold-2); color: var(--gold-ink); }

.pill { height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line2); background: var(--surface); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.pill:hover { border-color: var(--gold); }
.pill[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 600; }
.seg { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line2); border-radius: 14px; }
.seg button { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--text); color: var(--bg); font-weight: 600; }
.seg.gold button[aria-selected="true"] { background: var(--gold); color: var(--gold-ink); }
.count-chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
[aria-selected="true"] .count-chip { background: rgba(26, 20, 8, .15); color: var(--gold-ink); }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }

/* ------------------------------------------------------------------ search */
.hero { padding: 80px 0 48px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.hero h1 { font-size: clamp(36px, 5vw, 60px); line-height: 1.05; letter-spacing: -0.02em; max-width: 880px; }
.hero .lead { max-width: 640px; }
.searchform { width: 100%; max-width: 860px; margin-top: 18px; display: flex; flex-direction: column; gap: 16px; }
.searchbar { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line2); border-radius: 18px; padding: 10px; position: relative; }
.searchbar:focus-within { border-color: var(--gold); }
.searchbar input { flex: 1; min-width: 0; height: 56px; background: transparent; border: 0; font: 26px var(--hebrew); padding: 0 12px; direction: rtl; }
.searchbar input:focus { outline: none; }
.searchbar input::placeholder { color: #6E7584; }
.searchbar .go { height: 56px; padding: 0 26px; border-radius: 12px; border: 0; background: var(--gold); color: var(--gold-ink); font-weight: 600; font-size: 17px; display: inline-flex; align-items: center; gap: 8px; flex: none; }
.searchbar .go:hover { background: var(--gold-2); }
.searchbar .kbd-toggle { height: 56px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line2); background: var(--surface2); font: 18px var(--hebrew); flex: none; }
.searchbar .kbd-toggle[aria-expanded="true"] { border-color: var(--gold); }
.searchbar.compact { border-radius: 14px; padding: 6px; }
.searchbar.compact input { height: 44px; font-size: 24px; }
.searchbar.compact .go, .searchbar.compact .kbd-toggle { height: 44px; font-size: 15px; padding: 0 16px; }
.controls { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.scope-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.scope-row select { height: 40px; border-radius: 999px; border: 1px solid var(--line2); background: var(--surface); padding: 0 14px; font-size: 14px; max-width: 240px; }
.scope-row select.on { border-color: var(--gold); background: var(--gold); color: var(--gold-ink); font-weight: 600; }
.mode-help { margin: 0; font-size: 14px; color: var(--muted); min-height: 22px; }
.mode-help .he { font-size: 16px; color: var(--text); }

.kbd { background: var(--surface); border: 1px solid var(--line2); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 6px; direction: rtl; }
.kbd-row { display: flex; justify-content: center; gap: 6px; }
.kbd button { min-width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line2); background: var(--surface2); font: 22px var(--hebrew); }
.kbd button:hover { border-color: var(--gold); }
.kbd button.wide { min-width: 120px; font: 14px var(--sans); }

/* ------------------------------------------------------------------ home */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--bg2); padding: 24px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font: 600 38px var(--display); letter-spacing: -0.02em; }
.stat span { font-size: 14px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line2); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 8px; min-height: 150px; text-decoration: none; color: var(--text); }
.card:hover { border-color: #4A4F5E; color: var(--text); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.badge { font-size: 12px; color: var(--dim); font-weight: 500; padding: 3px 8px; border: 1px solid var(--line2); border-radius: 999px; white-space: nowrap; }
.card .word { font: 34px/1.15 var(--hebrew); text-align: right; }
.card .gloss { font-size: 15px; }
.card .refs { margin-top: auto; font-size: 13px; color: var(--gold); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.empty { border: 1px dashed #4A4F5E; border-radius: 18px; padding: 28px; color: var(--muted); background: var(--surface); }
.empty strong { display: block; color: var(--text); font: 600 22px var(--display); margin-bottom: 4px; }
.center { display: flex; justify-content: center; margin-top: 24px; }
.books { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.book-col { background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.book-col h3 { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; padding: 0 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.book-col h3 a { color: var(--text); text-decoration: none; }
.book-col h3 .he { font-size: 18px; color: var(--muted); font-weight: 400; }
.book-col > a { display: flex; justify-content: space-between; align-items: center; min-height: 36px; padding: 0 8px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; }
.book-col > a:hover { background: var(--surface2); color: var(--text); }
.book-col > a .he { font-size: 15px; }

/* ------------------------------------------------------------------ results */
.results-top { padding: 32px 0 0; }
.results-top .searchform, .wrap > div > .searchform { margin-left: auto; margin-right: auto; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 28px 0 24px; }
.crumbs .sep { color: var(--dim); }
.crumbs .pill { height: 36px; }
.headline { display: flex; flex-direction: column; gap: 6px; }
.bignum { display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap; }
.bignum b { font: 600 clamp(80px, 11vw, 128px)/0.95 var(--display); letter-spacing: -0.04em; }
.bignum span { font-size: 22px; color: var(--muted); }
.bignum .he { font-size: 34px; color: var(--text); }
.modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.modecard { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 18px 20px; border-radius: 16px; text-align: left; background: var(--surface); border: 1px solid var(--line2); }
.modecard:hover { border-color: var(--gold); }
.modecard[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.modecard .row { display: flex; justify-content: space-between; align-items: baseline; }
.modecard .label { font-size: 15px; font-weight: 600; }
.modecard .n { font: 600 40px/1 var(--display); }
.modecard .help { font-size: 13px; opacity: .85; }
.stack { display: flex; flex-direction: column; gap: 32px; padding: 32px 0 80px; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 0 10px; border-radius: 10px; border: 1px solid transparent; background: transparent; width: 100%; text-align: left; }
button.bar-row:hover { background: var(--surface2); }
.bar-row[aria-pressed="true"] { border-color: var(--gold); background: var(--surface2); }
.bar-row .name { width: 104px; font-size: 15px; flex: none; }
.bar-row .track { flex: 1; height: 14px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.bar-row .fill { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.bar-row .num { width: 44px; text-align: right; font: 600 18px var(--display); flex: none; }
.forms .bar-row { min-height: 40px; padding: 0; }
.forms .he { width: 150px; text-align: right; font-size: 24px; flex: none; }
.forms .track { height: 8px; }
.forms .fill { background: var(--heat2); }
.forms .tag { font-size: 12px; color: var(--muted); padding: 2px 8px; border: 1px solid var(--line2); border-radius: 999px; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.lemmas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.lemma { background: var(--surface); border: 1px solid var(--line2); border-radius: 16px; padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lemma .he { font-size: 30px; }
.lemma b { font: 600 30px var(--display); color: var(--gold); }
.heat { display: flex; gap: 10px; }
.heat-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.heat-cells { display: flex; gap: 3px; }
.heat-cells button, .heat-cells span { flex: 1 1 0; min-width: 0; height: 44px; border-radius: 4px; border: 0; padding: 0; background: var(--surface2); }
.heat-cells button:hover { outline: 2px solid var(--text); outline-offset: 1px; }
.heat-cells .on { box-shadow: inset 0 0 0 2px var(--text); }
.heat-group .dim { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--dim); }
.legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.verses { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.verse { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 16px 22px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.verse:last-child { border-bottom: 0; }
.verse .ref { width: 180px; display: flex; flex-direction: column; flex: none; }
.verse .ref b { font-size: 15px; }
.verse .txt { flex: 1; min-width: 280px; margin: 0; font: 22px/1.7 var(--hebrew); color: #C9CDD6; text-align: right; }
.verse mark { background: rgba(231, 183, 95, .18); color: var(--gold-2); border-radius: 4px; padding: 0 3px; }
.verse .src { font-size: 14px; white-space: nowrap; text-decoration: none; }
.includes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.includes .tagpill { border: 1px solid var(--line2); border-radius: 999px; padding: 2px 10px; color: var(--text); }
.includes .tagpill .he { font-size: 16px; }

/* ------------------------------------------------------------------ parsha */
.parsha-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 24px; padding-top: 48px; }
.parsha-head h1 { font-size: clamp(48px, 7vw, 72px); line-height: 1; letter-spacing: -0.03em; }
.parsha-head .he { font-size: clamp(40px, 5vw, 56px); color: var(--muted); }
.title-row { display: flex; align-items: baseline; gap: 24px; flex-wrap: wrap; margin-top: 8px; }
.strip { display: flex; gap: 3px; margin: 32px 0 8px; }
.strip a { flex: 1 1 0; height: 22px; border-radius: 3px; background: #252A38; }
.strip a.alt { background: var(--surface2); }
.strip a.gap { margin-left: 8px; }
.strip a.on { background: var(--gold); }
.strip a:hover { outline: 2px solid var(--text); }
.strip-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); margin-bottom: 32px; }
.list-rows > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--line); }
.list-rows .he { font-size: 22px; }
.about { max-width: 760px; padding: 56px 0 80px; }
.about h1 { font-size: 44px; margin-bottom: 16px; }
.about h2 { font-size: 22px; margin: 32px 0 8px; }
.about p, .about li { color: var(--muted); }
.about strong { color: var(--text); }

.footer { border-top: 1px solid var(--line); }
.footer-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; padding-top: 28px; padding-bottom: 28px; font-size: 13px; color: var(--dim); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1000px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .books { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lemmas { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .wrap { padding: 0 18px; }
  .topnav { gap: 4px 16px; font-size: 14px; }
  .hero { padding: 48px 0 32px; }
  .cards, .books, .modes { grid-template-columns: minmax(0, 1fr); }
  .stats, .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .searchbar { flex-wrap: wrap; }
  .searchbar input { flex-basis: 100%; order: -1; }
  .searchbar .go { flex: 1; }
  .section-head h2 { font-size: 30px; }
  .heat { flex-direction: column; }
  .verse .ref { width: auto; }
  .kbd button { min-width: 30px; font-size: 18px; }
}
