/* ---------------------------------------------------------------- reset -- */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #1a1610;
  --panel-bg: #201b14;
  --panel-ink: #d8cdb8;
  --panel-dim: #8a7d64;
  --accent: #b08d3f;
  --accent-bright: #d4aa50;
  --parchment: #f3ead8;
  --parchment-deep: #e9dcc0;
  --hl: #a33b1f;
  --hl-bg: rgba(196, 92, 43, .18);
  --serif: "Frank Ruhl Libre", "SBL Hebrew", "Ezra SIL", "David Libre",
           "Times New Roman", serif;
  --ui: -apple-system, "Segoe UI", Roboto, sans-serif;
}

html, body { height: 100%; }
body { display: flex; font-family: var(--ui); background: #2a241b; }

/* ---------------------------------------------------------------- panel -- */
#panel {
  width: 310px; min-width: 310px; height: 100vh; overflow-y: auto;
  background: var(--panel-bg); color: var(--panel-ink);
  padding: 22px 20px; border-right: 1px solid #3a3226;
}
#panel h1 {
  font-family: var(--serif); font-size: 30px; color: var(--accent-bright);
  letter-spacing: .02em; margin-bottom: 18px;
}
#panel h1 span {
  display: block; font-family: var(--ui); font-size: 11px; font-weight: 400;
  color: #8a7d64; letter-spacing: .28em; text-transform: uppercase;
  margin-top: 2px;
}
#panel section { margin-bottom: 22px; }
.modelabel {
  font-size: 10px; letter-spacing: .22em; text-transform: uppercase;
  color: #8a7d64; margin-bottom: 8px;
}
label { display: block; font-size: 11px; color: #b3a78e; }
select, input {
  width: 100%; margin-top: 3px; padding: 7px 8px;
  background: #2e281e; color: var(--panel-ink);
  border: 1px solid #463d2c; border-radius: 6px; font-size: 13px;
}
select:focus, input:focus { outline: 1px solid var(--accent); }
.nav label + label { margin-top: 10px; }

.modegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
button.mode {
  padding: 9px 4px 7px; background: #2e281e; color: var(--panel-ink);
  border: 1px solid #463d2c; border-radius: 7px; cursor: pointer;
  font-family: var(--serif); font-size: 17px; line-height: 1.15;
}
button.mode small {
  display: block; font-family: var(--ui); font-size: 9px;
  letter-spacing: .12em; text-transform: uppercase; color: #8a7d64;
}
button.mode.active {
  background: var(--accent); border-color: var(--accent); color: #241d10;
}
button.mode.active small { color: #4d3f22; }

.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
.row2 { display: grid; grid-template-columns: 1fr 84px; gap: 7px; }
.btnrow { display: flex; gap: 7px; margin-top: 9px; }
.btnrow button {
  flex: 1; padding: 8px; border-radius: 6px; border: none; cursor: pointer;
  background: var(--accent); color: #241d10; font-weight: 600; font-size: 12px;
}
.btnrow button.ghost {
  background: transparent; border: 1px solid #463d2c; color: var(--panel-ink);
}
.btnrow button:hover { filter: brightness(1.1); }

.out {
  margin-top: 10px; font-family: var(--serif); font-size: 22px;
  line-height: 1.5; color: var(--accent-bright); word-break: break-all;
  min-height: 0;
}
.out .meta { font-family: var(--ui); font-size: 11px; color: #8a7d64; direction: ltr; }

.rowpair { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }

/* ------------------------------------------------------------------ jobs -- */
.job {
  padding: 8px 9px; margin-bottom: 6px; border: 1px solid #3a3226;
  border-radius: 7px; cursor: pointer;
}
.job:hover { background: #2e281e; }
.job.active { border-color: var(--accent); background: #2e281e; }
.jrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.jterm { font-family: var(--serif); font-size: 17px; color: var(--panel-ink); }
.jstat {
  font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 9px; white-space: nowrap;
}
.jstat.queued    { background: #3a3226; color: #b3a78e; }
.jstat.running   { background: #4a3c14; color: var(--accent-bright); }
.jstat.done      { background: #23391f; color: #9fce8f; }
.jstat.error, .jstat.cancelled { background: #46201a; color: #e0a08f; }
.jmeta { font-size: 10px; color: #8a7d64; margin-top: 3px; }
.jdel { background: none; border: none; color: #6d6350; cursor: pointer; font-size: 13px; padding: 0 2px; }
.jdel:hover { color: #e0a08f; }
.pbar { height: 3px; background: #3a3226; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.pbar div { height: 100%; background: var(--accent); transition: width .4s; }
@keyframes pulse { 50% { opacity: .45; } }
.jstat.running { animation: pulse 1.2s ease-in-out infinite; }

.hits { margin-top: 4px; max-height: 340px; overflow-y: auto; }
#jobs { max-height: 260px; overflow-y: auto; }

/* collapsible section headers */
.collapser { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.collapser:hover { color: var(--panel-ink); }
.collapser .cnt { color: var(--accent-bright); letter-spacing: 0; }
.collapser .chev { margin-left: auto; transition: transform .15s; font-size: 11px; }
.collapser.closed .chev { transform: rotate(-90deg); }

.filterbox { margin: 2px 0 8px; font-size: 12px; }

/* occurrence pagination */
.pager { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.pbtn {
  min-width: 26px; padding: 4px 6px; border-radius: 5px; cursor: pointer;
  border: 1px solid #463d2c; background: transparent; color: #b3a78e; font-size: 11px;
}
.pbtn:hover { border-color: var(--accent); color: var(--panel-ink); }
.pbtn.cur { background: var(--accent); color: #241d10; border-color: var(--accent); font-weight: 700; }
.pbtn:disabled { opacity: .35; cursor: default; }
.pgap { color: #6d6350; font-size: 11px; padding: 0 1px; }
.hitwrap { border-radius: 6px; }
.hit.open { background: #2e281e; border-radius: 6px 6px 0 0; }

/* occurrence explorer card */
.hx {
  background: #2a2419; border: 1px solid #3a3226; border-top: none;
  border-radius: 0 0 7px 7px; padding: 10px 10px 11px; margin-bottom: 6px;
}
.hxword {
  font-family: var(--serif); font-size: 24px; color: var(--accent-bright);
  text-align: right; margin-bottom: 8px; letter-spacing: .05em;
}
.hxgrid {
  display: grid; grid-template-columns: auto 1fr; gap: 3px 10px;
  font-size: 11px; margin-bottom: 9px;
}
.hxgrid span { color: #8a7d64; }
.hxgrid b { color: var(--panel-ink); font-weight: 500; }
.hxpasuk {
  font-family: var(--serif); font-size: 17px; line-height: 1.7;
  color: #cfc3a9; background: #241f15; border-right: 2px solid var(--accent);
  padding: 7px 10px; border-radius: 5px; margin-bottom: 9px;
}
.ins-letter.wide { width: 52px; }
.morebtn {
  width: 100%; padding: 7px; margin-top: 4px; border-radius: 6px;
  border: 1px dashed #463d2c; background: transparent; color: #8a7d64;
  cursor: pointer; font-size: 11px;
}
.morebtn:hover { color: var(--panel-ink); border-color: var(--accent); }
.hit {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 8px; border-radius: 5px; cursor: pointer; font-size: 12px;
  color: #b3a78e;
}
.hit:hover { background: #2e281e; }
.hit b { font-family: var(--serif); font-size: 15px; color: var(--panel-ink); }
.hint { font-size: 11px; color: #6d6350; font-style: italic; }
.hitword { font-family: var(--serif); font-size: 14px; color: var(--accent-bright); }
.uierr { color: #e0a08f; font-style: normal; }

.inspector #inspOut { margin-top: 8px; }
.ins-word {
  font-family: var(--serif); font-size: 24px; color: var(--accent-bright);
  direction: rtl; text-align: right;
}
.ins-meta { font-size: 11px; color: #8a7d64; margin: 4px 0 8px; }
.ins-letters { display: flex; flex-wrap: wrap; gap: 4px; direction: rtl; }
.ins-letter {
  width: 40px; padding: 4px 0 3px; text-align: center; cursor: pointer;
  background: #2e281e; border: 1px solid #463d2c; border-radius: 5px;
}
.ins-letter:hover { border-color: var(--accent); }
.ins-letter b { display: block; font-family: var(--serif); font-size: 19px; color: var(--panel-ink); font-weight: 400; }
.ins-letter small { font-size: 9px; color: #8a7d64; }

#panel footer {
  font-size: 10px; color: #6d6350; line-height: 1.6; padding-top: 12px;
  border-top: 1px solid #3a3226;
}
#panel footer code { color: #8a7d64; }

/* --------------------------------------------------------------- reader -- */
#reader { flex: 1; height: 100vh; overflow-y: auto; }
#content {
  max-width: 780px; margin: 0 auto; padding: 56px 48px 120px;
  font-family: var(--serif); color: var(--ink);
}

/* reading modes sit on parchment */
#reader { background: var(--parchment); }

h2.bookTitle {
  font-size: 34px; font-weight: 500; text-align: center; margin-bottom: 4px;
}
.chapterHead {
  font-size: 21px; text-align: center; color: #7a6633;
  margin: 30px 0 14px; font-weight: 500;
}
.chapterHead:first-of-type { margin-top: 10px; }

.verse { display: inline; }
.vnum {
  font-size: 12px; color: #9c8a5d; vertical-align: super;
  padding: 0 3px 0 5px; user-select: none;
}
.word { cursor: pointer; border-radius: 3px; }
.word:hover { background: rgba(176, 141, 63, .18); }

#content.mode-full { font-size: 27px; line-height: 2.15; text-align: justify; }
#content.mode-nikud { font-size: 27px; line-height: 1.95; text-align: justify; }
#content.mode-letters { font-size: 26px; line-height: 1.9; letter-spacing: .02em; text-align: justify; }

/* qere/ketiv marker in reading modes */
.kq { border-bottom: 1px dotted #b08d3f; }
.kq-tip { color: #8a6d2f; font-size: 60%; vertical-align: super; user-select: none; }

/* parashah marks in reading modes */
.pmark {
  color: #b08d3f; font-size: 80%; padding: 0 10px; user-select: none;
}

/* highlighted (ELS) letters */
.hl {
  color: var(--hl); background: var(--hl-bg);
  border-radius: 3px; padding: 0 1px; font-weight: 700;
}
.hl.first { outline: 2px solid var(--hl); }

/* ---------------------------------------------------------- scroll mode -- */
#content.mode-scroll {
  max-width: none; padding: 48px 40px 120px;
  column-width: 340px; column-gap: 46px; column-rule: 1px solid #d9c9a4;
  font-size: 24px; line-height: 1.85; text-align: justify;
  color: #23180a;
}
.mode-scroll .vnum, .mode-scroll .chapterHead { display: none; }
.mode-scroll h2.bookTitle {
  column-span: all; margin-bottom: 26px; font-size: 30px;
  letter-spacing: .1em; color: #5d4a1e;
}
/* petuhah: rest of line left blank -- force a break */
.brP { display: block; height: .55em; }
/* setumah: a nine-letter gap within the line */
.brS { display: inline-block; width: 5.5em; }

#reader.scrollbg {
  background:
    radial-gradient(ellipse at 30% 8%, rgba(255,252,240,.75), transparent 55%),
    radial-gradient(ellipse at 75% 90%, rgba(122, 92, 40, .10), transparent 60%),
    var(--parchment-deep);
}

/* loading state */
.loading { text-align: center; color: #9c8a5d; padding: 80px 0; font-size: 18px; }

/* ---------------------------------------------------------- commentary -- */
#page { display: flex; align-items: flex-start; justify-content: center; gap: 0; }
#reader.withcomm #content { flex: 0 1 720px; max-width: 720px; }
#commentary {
  flex: 1 1 380px; max-width: 560px; min-width: 300px;
  padding: 72px 28px 120px 40px; font-family: var(--serif); color: #2a2218;
  border-right: 1px solid #cdbf9e; margin-right: 8px;
}
#commentary[hidden] { display: none; }
.cmv { margin-bottom: 14px; padding: 4px 6px; border-radius: 6px; }
.cmv.lit { background: rgba(176, 141, 63, .18); }
.cmv.pin { background: rgba(163, 59, 31, .14); }
.cmv .cvnum { font-size: 13px; color: #7a6633; margin-bottom: 2px; }
.cmv .cmc { font-size: 15px; line-height: 1.55; margin-bottom: 6px; text-align: justify; }
.cmv .cmc .who { font-weight: 700; color: #5a4520; font-size: 13px; margin-left: 6px; }
.cmv .cmc b, .cmv .cmc strong { font-weight: 700; }
.cmv .cmc.onkelos { font-style: normal; color: #3a2f1c; }
.cmv .cmc img { max-width: 100%; display: block; margin: 6px auto; }
.verse.lit { background: rgba(176, 141, 63, .18); border-radius: 4px; }
.verse.pin { background: rgba(163, 59, 31, .14); border-radius: 4px; }
.commlist label { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; cursor: pointer; }
.commlist label input { width: auto; margin: 0; }
.commlist label .he { font-family: var(--serif); font-size: 15px; color: var(--panel-ink); }
.commlist label .en { color: #8a7d64; font-size: 11px; margin-left: auto; }
.commlist label.na { opacity: .35; cursor: default; }
