/* Layout: sticky filter bar over a single reading column of question cards; level ledger on top. */
:root {
  --bg: #f6f6fa;
  --surface: #ffffff;
  --ink: #0d0a33;
  --muted: #5d5b78;
  --line: #e1e0ec;
  --navy: #070138;
  --gold: #e8901a;
  --gold-soft: #fff1dc;
  --good: #137a4a;
  --good-soft: #e3f4ea;
  --bad: #a8322a;
  --chip: #eceaf6;
  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --body: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --arabic: 'IBM Plex Sans Arabic', 'Geeza Pro', 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0920; --surface: #15122f; --ink: #ecebf7; --muted: #a09dbd; --line: #2a2650;
    --navy: #cfcaf5; --gold: #ffa92c; --gold-soft: #3a2a10; --good: #56d394; --good-soft: #10301f;
    --bad: #ff8a80; --chip: #221e45; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.55; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.wrap { max-width: 960px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
header.top { padding-block: 32px 20px; display: grid; gap: 6px; }
.eyebrow { font: 600 12px/1 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
h1 { font: 800 clamp(28px, 5vw, 42px)/1.05 var(--display); margin: 0; color: var(--navy); text-wrap: balance; }
.lede { color: var(--muted); margin: 4px 0 0; max-width: 65ch; }
.warn { display: inline-flex; gap: 8px; align-items: center; margin-top: 10px; padding: 6px 10px; border-radius: 6px; background: var(--gold-soft); color: var(--ink); font-size: 13px; width: fit-content; max-width: 100%; }

.top-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.btn { font: 600 13px var(--body); padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn.primary { background: var(--navy); color: var(--bg); border-color: transparent; }

[dir="rtl"] body, [dir="rtl"] .btn, [dir="rtl"] .seg button, [dir="rtl"] .bar input, [dir="rtl"] .bar select { font-family: var(--arabic); }
[dir="rtl"] h1 { font-family: var(--arabic); font-weight: 700; }
[dir="rtl"] .eyebrow, [dir="rtl"] .lg-name { letter-spacing: 0; }
.ar-ui .ar { text-align: start; }
.login-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.login { min-height: 70vh; display: grid; place-items: center; }
.login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; gap: 12px; }
.login h1 { font-size: 28px; }
.login label { font-size: 13px; font-weight: 500; }
.login input { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.login input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.err { color: var(--bad); font-size: 13px; min-height: 1.2em; margin: 0; }

.ledger { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 18px; }
.ledger button { all: unset; cursor: pointer; background: var(--surface); padding: 12px 14px; display: grid; gap: 2px; }
.ledger button:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.ledger button[aria-pressed="true"] { background: var(--navy); color: var(--bg); }
.ledger button[aria-pressed="true"] .lg-sub { color: inherit; opacity: .75; }
.lg-name { font: 600 12px/1 var(--body); letter-spacing: .08em; text-transform: uppercase; }
.lg-num { font: 800 24px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.lg-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .ledger { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding-block: 10px; border-bottom: 1px solid var(--line); }
.bar .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bar input, .bar select { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.bar input:focus-visible, .bar select:focus-visible, .seg button:focus-visible, .more:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
#q { flex: 1 1 220px; }
.bar select { flex: 0 1 auto; max-width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: 500 13px var(--body); border: 0; background: var(--surface); color: var(--muted); padding: 8px 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--navy); color: var(--bg); }
.count { font-size: 13px; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }

.list { display: grid; gap: 12px; padding-block: 16px 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; display: grid; gap: 10px; min-width: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.id { font: 500 12px var(--mono); color: var(--muted); margin-inline-end: 4px; }
.pill { padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--ink); white-space: nowrap; }
.pill.lvl { background: var(--navy); color: var(--bg); font-weight: 600; }
.diff { display: inline-flex; gap: 2px; align-items: center; margin-inline-start: 2px; }
.diff i { width: 6px; height: 10px; border-radius: 1px; background: var(--line); }
.diff i.on { background: var(--gold); }
.stat { margin-inline-start: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.qt { font-weight: 500; font-size: 16px; overflow-wrap: anywhere; }
.ar { font-family: var(--arabic); direction: rtl; text-align: right; }
.qt.ar { font-size: 17px; }
ol.opts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ol.opts li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; align-items: start; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line); }
ol.opts li.ok { background: var(--good-soft); border-color: transparent; }
.key { font: 500 12px/22px var(--mono); text-align: center; border-radius: 5px; background: var(--chip); color: var(--muted); }
li.ok .key { background: var(--good); color: var(--surface); }
.otext { display: grid; gap: 2px; overflow-wrap: anywhere; }
.otext .ar { color: var(--muted); }
li.ok .otext { font-weight: 500; }
details.ex { font-size: 14px; color: var(--muted); }
details.ex summary { cursor: pointer; color: var(--ink); font-weight: 500; width: fit-content; }
details.ex div { display: grid; gap: 6px; margin-top: 6px; }
details.ex p { margin: 0; }
.more { justify-self: center; font: 600 14px var(--body); padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.empty, .loading { text-align: center; color: var(--muted); padding: 40px 0; }
a.btn { text-decoration: none; }
.rv-note { font-size: 13px; color: var(--muted); }
.rv-field { display: grid; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.rv-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.rv-same { color: var(--muted); font-weight: 400; }
.rv-en { font-family: var(--body); font-size: 13px; color: var(--muted); text-align: left; }
.rv-before, .rv-after { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; padding: 6px 10px; border-radius: 7px; overflow-wrap: anywhere; }
.rv-before { background: var(--chip); color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.rv-after { background: var(--good-soft); }
.rv-tag { font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; display: inline-block; padding-top: 2px; }
.pill.rv-bad { background: var(--bad); color: var(--surface); white-space: normal; }
.pill.rv-warn { background: var(--gold-soft); white-space: normal; }
.count input { vertical-align: middle; }
mark { background: var(--gold-soft); color: inherit; border-radius: 2px; }
