/* Shura. Lapis rail, cool paper, Persian tile colours for the verdicts. Instrument Sans for the interface,
   Vazirmatn for Persian. Tokens first; dark mode redefines them. */
:root {
  --paper: #eef2f7;
  --surface: #ffffff;
  --sunk: #e3e9f2;
  --ink: #14213d;
  --muted: #5a6785;
  --faint: #8a95ad;
  --line: #d6deea;
  --rail: #13254f;
  --rail-ink: #d9e3f7;
  --rail-dim: #8fa3cf;
  --lapis: #2148a8;
  --turquoise: #0e8a8c;
  --saffron: #b97a06;
  --pomegranate: #b02a41;
  --plum: #6f45a0;
  --tint-turquoise: #d7f0ef;
  --tint-saffron: #f8ecd2;
  --tint-pomegranate: #f7dde2;
  --tint-lapis: #dfe7f8;
  --focus: #0e8a8c;
  --radius: 6px;
  --shadow: 0 1px 0 rgba(20, 33, 61, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1629; --surface: #14203a; --sunk: #1a2846; --ink: #e5ebf6; --muted: #9eabc8; --faint: #6d7b9c;
    --line: #253556; --rail: #091331; --rail-ink: #d9e3f7; --rail-dim: #7f93c2; --lapis: #86a6f2;
    --turquoise: #43c4c1; --saffron: #e7b445; --pomegranate: #f07186; --plum: #b590e0;
    --tint-turquoise: #10393f; --tint-saffron: #3d3116; --tint-pomegranate: #44202b; --tint-lapis: #1c2d57;
    --focus: #43c4c1; --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 14.5px/1.55 "Instrument Sans", system-ui, sans-serif;
  font-feature-settings: "tnum" 1;
}
a { color: var(--lapis); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 19px; margin: 34px 0 12px; }
h3 { font-size: 15px; margin: 0 0 6px; }
p { margin: 0 0 10px; max-width: 76ch; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
code, pre { font: 13px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; }
pre { background: var(--sunk); padding: 12px 14px; border-radius: var(--radius); overflow: auto; margin: 0; white-space: pre-wrap; }
.fa { direction: rtl; text-align: right; font-family: Vazirmatn, Tahoma, sans-serif; font-size: 17px; line-height: 2; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* -- frame: the lapis rail and the page ---------------------------------------------------------------------- */
.frame { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.rail {
  background: var(--rail); color: var(--rail-ink); padding: 22px 16px 18px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.mark { display: flex; align-items: baseline; gap: 10px; padding: 0 8px 18px; color: inherit; }
.mark:hover { text-decoration: none; }
.mark .fa-mark { font: 800 34px/1 Vazirmatn, sans-serif; color: #7fd6d2; letter-spacing: 0; }
.mark .lat { font-size: 13px; color: var(--rail-dim); }
.rail a.nav {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 5px; color: var(--rail-ink); font-weight: 500;
}
.rail a.nav:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.rail a.nav.on { background: rgba(127, 214, 210, .14); color: #fff; box-shadow: inset 3px 0 0 #7fd6d2; }
.rail .group { margin: 16px 10px 4px; font-size: 12px; color: var(--rail-dim); }
.rail .count { font-size: 12px; color: var(--rail-dim); }
.rail .foot { margin-top: auto; padding: 14px 10px 0; font-size: 12.5px; color: var(--rail-dim); border-top: 1px solid rgba(255,255,255,.08); }
.rail .foot button { background: none; border: 0; color: var(--rail-ink); padding: 0; cursor: pointer; font: inherit; }
.rail .foot button:hover { text-decoration: underline; }
main { padding: 30px clamp(16px, 3.2vw, 44px) 64px; max-width: 1240px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head .sub { color: var(--muted); margin-top: 6px; max-width: 70ch; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

/* -- surfaces ------------------------------------------------------------------------------------------------ */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.facts { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { margin: 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.note { border-left: 3px solid var(--turquoise); background: var(--tint-turquoise); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; }
.note.warn { border-color: var(--saffron); background: var(--tint-saffron); }
.note.bad { border-color: var(--pomegranate); background: var(--tint-pomegranate); }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* -- the funnel (the overview's centrepiece) ------------------------------------------------------------------ */
.run { padding: 22px 24px 18px; }
.run-title { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.run-title .big { font-size: 44px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.run-title .big small { font-size: 16px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
svg.funnel { width: 100%; height: 210px; display: block; margin-top: 18px; }
svg.funnel .bar { fill: var(--lapis); }
svg.funnel .bar.last { fill: var(--turquoise); }
svg.funnel .band { fill: var(--lapis); opacity: .13; }
svg.funnel .base { stroke: var(--line); }
.steps { display: grid; gap: 26px; margin-top: 10px; }
.step .name { font-weight: 600; }
.step .val { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.step .why { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.step .of { font-size: 12.5px; color: var(--turquoise); font-weight: 600; }
.aside-line { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--muted); margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }

/* -- bars, meters, tiers --------------------------------------------------------------------------------------- */
.stack { display: flex; height: 12px; border-radius: 3px; overflow: hidden; background: var(--sunk); min-width: 80px; }
.stack .seg { display: block; height: 100%; }
.seg.tA, .tier.tA { background: var(--turquoise); }
.seg.tB, .tier.tB { background: var(--lapis); }
.seg.tC, .tier.tC { background: var(--saffron); }
.seg.tD, .tier.tD { background: var(--plum); }
.seg.tR, .tier.tR { background: var(--pomegranate); }
.seg.kept { background: var(--turquoise); }
.seg.drop { background: var(--faint); }
.tier { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; color: #fff; font-weight: 700; font-size: 12.5px; }
@media (prefers-color-scheme: dark) { .tier { color: #0d1629; } }
.tier.none { background: var(--sunk); color: var(--faint); }
.meter { height: 8px; border-radius: 4px; background: var(--sunk); overflow: hidden; min-width: 90px; }
.meter span { display: block; height: 100%; background: var(--turquoise); }
.meter.hot span { background: var(--saffron); }
.meter.none { background: repeating-linear-gradient(135deg, var(--sunk) 0 6px, transparent 6px 10px); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* -- tables ------------------------------------------------------------------------------------------------------ */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--sunk) 55%, transparent); }
td.fa { font-size: 15.5px; line-height: 1.8; max-width: 560px; }
.ellipsis { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--sunk); color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.pill.good { background: var(--tint-turquoise); color: var(--turquoise); }
.pill.warn { background: var(--tint-saffron); color: var(--saffron); }
.pill.bad { background: var(--tint-pomegranate); color: var(--pomegranate); }
.pill.info { background: var(--tint-lapis); color: var(--lapis); }

/* -- forms and buttons --------------------------------------------------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.filters label { display: grid; gap: 3px; font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 5px; padding: 7px 10px; min-width: 0;
}
textarea { width: 100%; min-height: 64px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; font: 600 14px/1 "Instrument Sans", system-ui, sans-serif;
  padding: 9px 14px; border-radius: 5px; border: 1px solid var(--lapis); background: var(--lapis); color: #fff;
  cursor: pointer; text-decoration: none;
}
@media (prefers-color-scheme: dark) { .btn { color: #0d1629; } }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--lapis); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 13.5px; color: var(--muted); }

/* -- gates (a true sequence, so numbered) -------------------------------------------------------------------- */
.gates { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.gate { padding: 16px 18px; border-right: 1px solid var(--line); position: relative; }
.gate:last-child { border-right: 0; }
.gate .n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); font-weight: 700; font-size: 13px; margin-bottom: 8px; color: var(--muted); }
.gate.running .n { border-color: var(--lapis); color: var(--lapis); }
.gate.ready .n { border-color: var(--saffron); color: var(--saffron); }
.gate.approved .n { border-color: var(--turquoise); background: var(--turquoise); color: #fff; }
.gate .what { font-size: 13px; color: var(--muted); line-height: 1.4; margin: 4px 0 8px; }
.gate .prog { font-size: 13px; }

/* -- the clip page: the council's seats ---------------------------------------------------------------------- */
.player { padding: 16px 18px 12px; }
.player .controls { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.play {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--lapis); color: #fff; cursor: pointer;
  display: grid; place-items: center; flex: none;
}
@media (prefers-color-scheme: dark) { .play { color: #0d1629; } }
.play svg { width: 18px; height: 18px; fill: currentColor; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13.5px; }
svg.wave { width: 100%; height: 96px; display: block; cursor: pointer; }
.wave-bars rect { fill: var(--faint); opacity: .55; }
.wave-bars.played rect { fill: var(--lapis); opacity: 1; }
.wave-head { stroke: var(--turquoise); stroke-width: 2; vector-effect: non-scaling-stroke; }
.wave-empty { padding: 18px; color: var(--muted); }
.speed { display: flex; gap: 4px; }
.speed button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 4px; padding: 3px 8px; cursor: pointer; font: inherit; font-size: 12.5px; }
.speed button[aria-pressed="true"] { border-color: var(--lapis); color: var(--lapis); }
.decision { padding: 18px 22px; border-left: 4px solid var(--turquoise); }
.decision.tD { border-color: var(--plum); } .decision.tR { border-color: var(--pomegranate); }
.decision.tB { border-color: var(--lapis); } .decision.tC { border-color: var(--saffron); }
.decision .fa { font-size: 21px; line-height: 2.05; }
.seats { display: grid; gap: 0; }
.seat { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.seat:last-child { border-bottom: 0; }
.seat .who { display: flex; gap: 10px; align-items: flex-start; }
.seal { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; background: var(--tint-lapis); color: var(--lapis); }
.seat.out .seal { background: var(--sunk); color: var(--faint); }
.seat .who small { display: block; line-height: 1.35; }
.seat .fa { font-size: 17.5px; }
.w { border-radius: 3px; padding: 0 1px; }
.w.sub { background: var(--tint-saffron); box-shadow: inset 0 -2px 0 var(--saffron); }
.w.extra { background: var(--tint-pomegranate); text-decoration: line-through; text-decoration-color: var(--pomegranate); }
.w.missing { color: var(--turquoise); border: 1px dashed var(--turquoise); font-size: .85em; padding: 0 4px; }
.keys { font-size: 12.5px; color: var(--muted); }
kbd { font: 600 11.5px/1 "Instrument Sans", sans-serif; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: var(--surface); color: var(--ink); }
.verdicts { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.verdicts button { font: 600 14px/1 "Instrument Sans", sans-serif; padding: 10px 14px; border-radius: 5px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.verdicts button.right { border-color: var(--turquoise); color: var(--turquoise); }
.verdicts button.wrong { border-color: var(--saffron); color: var(--saffron); }
.verdicts button.audio { border-color: var(--pomegranate); color: var(--pomegranate); }
.verdicts button[aria-pressed="true"] { color: #fff; }
.verdicts button.right[aria-pressed="true"] { background: var(--turquoise); }
.verdicts button.wrong[aria-pressed="true"] { background: var(--saffron); }
.verdicts button.audio[aria-pressed="true"] { background: var(--pomegranate); }
.verdicts button.unsure[aria-pressed="true"] { background: var(--muted); }

/* -- the episode timeline and transcript --------------------------------------------------------------------- */
svg.timeline { width: 100%; height: 46px; display: block; cursor: pointer; }
.tl-bg { fill: var(--sunk); }
.tl.kept { fill: var(--turquoise); }
.tl.drop-music { fill: var(--saffron); }
.tl.drop-voices { fill: var(--plum); }
.tl.drop-noise { fill: var(--faint); }
.tl.drop-lang { fill: var(--pomegranate); }
.tl.drop-other { fill: var(--muted); opacity: .6; }
.tl:hover { opacity: .75; }
.tl-head { stroke: var(--ink); stroke-width: 2; vector-effect: non-scaling-stroke; }
.transcript { max-height: 560px; overflow-y: auto; padding: 16px 20px; }
.transcript .wd { cursor: pointer; border-radius: 3px; }
.transcript .wd.in { color: var(--ink); }
.transcript .wd.out { color: var(--faint); }
.transcript .wd.now { background: var(--tint-lapis); }
.transcript .wd.low { box-shadow: inset 0 -2px 0 var(--saffron); }

/* -- log and code panels ------------------------------------------------------------------------------------- */
.log { max-height: 360px; overflow: auto; font-size: 12.5px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* -- sign-in ----------------------------------------------------------------------------------------------- */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); }
.signin .art { background: var(--rail); color: var(--rail-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.signin .art .fa-mark { font: 800 clamp(90px, 16vw, 210px)/1 Vazirmatn, sans-serif; color: #7fd6d2; direction: rtl; }
.signin .art p { color: var(--rail-dim); max-width: 46ch; font-size: 15px; }
.signin form { align-self: center; padding: 40px clamp(20px, 5vw, 64px); display: grid; gap: 14px; max-width: 440px; width: 100%; }
.signin label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.signin input { padding: 11px 12px; font-size: 15px; }

/* -- small screens ------------------------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: minmax(0, 1fr); }
  .gates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gate:nth-child(2) { border-right: 0; }
  .gate:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 10px 12px; gap: 2px; align-items: center; }
  .rail .group, .rail .foot, .rail .count { display: none; }
  .mark { padding: 0 8px 0 0; }
  .mark .fa-mark { font-size: 26px; }
  .mark .lat { display: none; }
  .rail a.nav { white-space: nowrap; padding: 6px 9px; }
  .g2, .g4 { grid-template-columns: minmax(0, 1fr); }
  .gates { grid-template-columns: minmax(0, 1fr); }
  .gate { border-right: 0; border-bottom: 1px solid var(--line); }
  .seat { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .signin { grid-template-columns: minmax(0, 1fr); }
  .signin .art { padding: 28px 20px; }
  .run-title .big { font-size: 34px; }
  .steps { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
