/* Dashboard layout on top of common.css. Logical properties only, so Arabic (RTL) and English (LTR) both work. */
body { min-height: 100vh; }

/* ---------- top bar: logo, Live, the tabs, then the tools ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--topbar); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-row {
  max-width: 1480px; margin: 0 auto; padding: 0 20px; min-height: 58px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 800; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-name { display: grid; line-height: 1.1; }
.brand-name b { font-size: 16px; font-weight: 800; }
.brand-name small { font-size: 11px; font-weight: 700; color: var(--muted); }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #FFFFFF; flex: none; overflow: hidden; }
.brand-mark svg { display: block; width: 100%; height: 100%; }  /* the logo, inline (app.py LOGO): it replays when pointed at */
.live {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--panel-2); font-size: 13px; font-weight: 700; white-space: nowrap;
}
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.live.offline { color: var(--busy); }
.topbar-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; }
.lang-btn { width: auto; padding: 0 10px; gap: 6px; display: inline-flex; font-size: 14px; font-weight: 700; }
.me { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; margin-inline: 6px; }
/* the bar stops growing at 1480px, and next to every tab there is no room for the name: it stays for screen readers
   and in the tooltip (admin.js sets #me's title) */
.me .name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 380px) { .topbar .brand-name { display: none; } }
@media (min-width: 761px) and (max-width: 1400px) {  /* laptops: icon tabs (their name is the tooltip) until the 8 names fit */
  .nav > .tab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .nav > .tab { padding: 0 12px; }
}
@media (min-width: 1401px) and (max-width: 1490px) {  /* Arabic tab names are longer: icon tabs a little further */
  :root[lang="ar"] .nav > .tab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  :root[lang="ar"] .nav > .tab { padding: 0 12px; }
}
.me .chip { font-weight: 500; }
.nav { display: flex; align-self: stretch; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }  /* never wider than the bar */
.nav::-webkit-scrollbar { display: none; }
.nav .tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; color: var(--muted); text-decoration: none;
  font-weight: 700; font-size: 15px; white-space: nowrap; border-bottom: 3px solid transparent; cursor: pointer; list-style: none;
}
.nav .tab::-webkit-details-marker { display: none; }
.nav .tab:hover { color: var(--text); }
.nav .tab.active { color: var(--text); border-bottom-color: var(--accent); }
.nav .tab .i { font-size: 17px; }
.nav .more, .nav .phone-only { display: none; }

/* ---------- page ---------- */
.view { max-width: 1480px; margin: 0 auto; padding: 28px 24px 64px; display: grid; gap: var(--s6); }
/* inside the pages, spacing comes from gaps, never from paragraph margins: every card spaces its parts evenly */
.view p, .modal-box p { margin: 0; }
:where(.view) .card { display: grid; gap: var(--s3); align-content: start; }
/* grid items default to their content's width; let wide tables scroll inside .table-wrap instead */
.view > *, .section > *, .grid-2 > *, .stack > * { min-width: 0; }
.page-head { display: flex; align-items: center; gap: var(--s3) var(--s4); flex-wrap: wrap; }
.page-head h1 { font-size: 26px; line-height: 1.2; }
:root[lang="en"] .page-head h1 { letter-spacing: -0.02em; }
.page-head .spacer { margin-inline-start: auto; }
.page-head .crumb { color: var(--muted); text-decoration: none; font-weight: 700; }
.section { display: grid; gap: 14px; }
.section h2 { font-size: 18px; }
.view > .section > h2, .view > h2, .list-title, .subhead { margin-top: var(--s2); }  /* more room above a heading than below */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 8px; }
.grid-2 { display: grid; gap: var(--s5); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.center-box { max-width: 440px; width: 100%; margin: 64px auto; display: grid; gap: var(--s4); padding: 32px 28px; }
.center-box h1 { font-size: 24px; }
.empty-state { color: var(--muted); text-align: center; padding: 40px 20px; }
.empty-state .mark { margin: 0 auto var(--s3); }  /* the mascot over a large empty page (ui.js UI.mark) */
.empty-state p { margin: 0; }
.loading { color: var(--muted); padding: 24px 0; }
.hint { color: var(--muted); font-size: 14px; line-height: 1.55; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px;
  display: grid; gap: 6px; text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
a.kpi:hover { border-color: var(--primary); }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi .value { font-size: 26px; font-weight: 800; line-height: 1.2; }
.kpi .value small { font-size: 15px; color: var(--muted); font-weight: 700; }
.kpi.wide { grid-column: span 2; }
.kpi .bar { margin-top: 6px; }
.kpi.ok .value { color: var(--ok); }
.kpi.bad .value { color: var(--bad); }
.kpi.busy .value { color: var(--busy); }
@media (max-width: 560px) { .kpi.wide { grid-column: auto; } }

/* ---------- tables ---------- */
table.data td .sub { display: block; color: var(--muted); font-size: 13px; }
table.data td.num, table.data th.num { text-align: end; font-variant-numeric: tabular-nums; }
.progress-cell { min-width: 120px; display: grid; gap: 4px; }
.progress-cell .bar { height: 5px; }
.pages { font-size: 13px; color: var(--muted); max-width: 220px; }
.yes { color: var(--ok); font-weight: 800; }
.no { color: var(--muted); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input:not([type="checkbox"], [type="radio"]) { width: auto; min-width: 160px; }
.filters input[type="search"] { flex: 1 1 200px; }

/* ---------- forms ---------- */
.form { display: grid; gap: var(--s4); }
.field { display: grid; gap: 6px; align-content: start; }  /* side by side, fields line up at the top */
.field > label, .field > .label { font-weight: 700; font-size: 14px; }
.field .hint { font-weight: 400; }
.fields-3 { display: grid; gap: var(--s4); grid-template-columns: repeat(3, minmax(0, 1fr)); }  /* rows of 3, never 5 + 1 */
@media (max-width: 1100px) { .fields-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .fields-3 { grid-template-columns: 1fr; } }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.saved { color: var(--ok); font-weight: 700; font-size: 14px; }

/* ---------- new batch: sheet types ---------- */
.mix { display: grid; gap: 0; }
.mix-row {
  display: grid; grid-template-columns: 1fr 96px; gap: 4px 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.mix-row:last-child { border-bottom: 0; }
.mix-row .name { font-weight: 700; }
.mix-row .info { grid-column: 1; font-size: 13px; color: var(--muted); }
.mix-row .info.warn { color: var(--bad); font-weight: 700; }
.mix-row input { grid-row: 1 / span 2; grid-column: 2; text-align: center; }
.mix-total { display: flex; justify-content: space-between; padding-top: 10px; font-weight: 800; }
/* the batch setup (batchsetup.js): a tick before each type, the four groups, the empty pages' share */
.mix-row.bs-row { grid-template-columns: auto 1fr 96px; column-gap: 10px; }
.bs-row .bs-tick { grid-row: 1 / span 2; grid-column: 1; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.bs-row .name { grid-column: 2; cursor: pointer; }
.bs-row .info { grid-column: 2; }
.bs-row input[type="number"] { grid-column: 3; }
.bs-row .bs-two { font-weight: 700; font-size: 12px; color: var(--muted); white-space: nowrap; }
.bs-groups { flex-wrap: wrap; max-width: 100%; justify-self: start; }
.bs-groups button:disabled { opacity: .45; cursor: default; }
.bs-blank-row { align-items: center; gap: 12px; }
.bs-blank-row input { width: 96px; text-align: center; }
.bs-head { align-items: start; margin-bottom: var(--s3); }
.field.bs-same { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }

/* texts picker */
.picker { display: grid; gap: 10px; }
.picker details { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.picker summary { padding: 12px 16px; cursor: pointer; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.picker summary .count { margin-inline-start: auto; color: var(--muted); font-weight: 400; font-size: 14px; }
.picker .picker-body { padding: 4px 16px 16px; display: grid; gap: 8px; }
.picker .picker-tools { display: flex; gap: 8px; }
.picker label.check { align-items: flex-start; }
.picker label.check span.t { overflow-wrap: anywhere; }

/* preview */
.preview-frame-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); max-height: 80vh; padding: var(--s4); }
.preview-frame { display: block; width: 820px; height: 1180px; border: 0; background: #fff; margin: 0 auto; }
.summary-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.summary-grid .kpi .value { font-size: 22px; }
.generate-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

pre.log, pre.target {
  margin: 0; padding: 12px 16px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; max-height: 360px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Arabic", monospace;
}
details.target-toggle summary { cursor: pointer; color: var(--primary); font-size: 14px; font-weight: 700; padding: 4px 0; }

/* ---------- writer page ---------- */
.writer-head { display: grid; gap: 8px; }
.sheets { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.sheet {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px 14px; display: grid; gap: 8px; align-content: start;
}
.sheet.rejected { border-color: color-mix(in oklab, var(--bad) 45%, var(--line)); }  /* the chip says why; the frame hints */
.sheet.missing { border-style: dashed; }
.sheet .sheet-top { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.sheet .page-no { font-weight: 800; }
.sheet .tpl { font-size: 13px; color: var(--muted); }
.sheet .thumb {
  display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
}
.sheet .thumb.missing {
  display: grid; place-items: center; color: var(--muted); font-size: 13px;
}
.sheet .meta { font-size: 12px; color: var(--muted); }
.sheet .reason { color: var(--bad); font-size: 13px; font-weight: 700; }

/* ---------- modal: a native <dialog> (Esc, backdrop click and focus handled by the browser) ---------- */
.modal { padding: 0; border: 0; background: transparent; max-width: calc(100% - 32px); max-height: calc(100dvh - 32px); overflow: visible; }
.modal-box {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; display: grid; gap: var(--s4);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: 24px 28px;
}
.modal-box.wide { width: min(1180px, calc(100vw - 32px)); }
.modal-box h2 { font-size: 18px; }
.password-box {
  font-size: 26px; font-weight: 800; letter-spacing: 3px; text-align: center; padding: 12px;
  border: 1px dashed var(--primary); border-radius: 10px; background: var(--primary-soft);
}

/* ---------- phones: the tabs become a bar at the bottom (4 tabs + More) ---------- */
@media (max-width: 760px) {
  :root { --pad-card: 16px 16px; }
  .view { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); gap: var(--s5); }
  .page-head h1 { font-size: 22px; }
  .modal-box { padding: 20px 18px; }
  .save-bar { bottom: calc(76px + env(safe-area-inset-bottom)); }  /* above the bottom tab bar, not under it */
  .center-box { margin: 32px auto; padding: 24px 20px; }
  .topbar-row { padding: 0 12px; gap: 8px; min-height: 54px; }
  .brand-name small, .me .name, .upload-link { display: none; }  /* a phone shows just "Qalam" (not on the narrowest) */
  .lang-btn .lang-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }  /* still named for screen readers */
  .lang-btn { width: 40px; padding: 0; justify-content: center; }
  .nav {
    position: fixed; inset: auto 0 0; z-index: 20; height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom); background: var(--topbar); border-top: 1px solid var(--line);
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0;
  }
  .nav[hidden] { display: none; }
  .nav .tab {
    flex-direction: column; justify-content: center; gap: 3px; padding: 6px 2px; font-size: 12px; height: 64px;
    border-bottom: 0; border-top: 3px solid transparent;
  }
  .nav .tab.active { border-top-color: var(--accent); border-bottom: 0; }
  .nav .tab .i { font-size: 21px; }
  .nav > .tab, .nav .more > .tab { min-width: 0; }
  .nav > .tab span, .nav .more > .tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .nav .desk-only { display: none; }
  .nav .more { display: block; position: relative; }
  .more-menu {
    position: absolute; inset: auto 6px calc(100% + 8px) auto; min-width: 220px; padding: 6px; display: grid; gap: 2px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop);
  }
  [dir="rtl"] .more-menu { inset: auto auto calc(100% + 8px) 6px; }
  .more-menu .tab { flex-direction: row; justify-content: flex-start; height: 48px; padding: 0 12px; font-size: 15px; border-top: 0; border-radius: var(--radius-sm); }
  .more-menu .tab.active { background: var(--panel-2); }
  .preview-frame-wrap { max-height: 70vh; }
}

/* math drawn as on the printed sheet (Arabic right to left, English left to right) */
.math-view { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 6px 0; background: var(--card); }
.math-inline { unicode-bidi: isolate; display: inline-block; }
.math-line { font-size: 17px; line-height: 2; unicode-bidi: isolate; }
.math-line[dir="ltr"] { text-align: left; }
.math-line[dir="rtl"] { text-align: right; }
.math-preview { margin-top: 6px; padding: 4px 10px; border: 1px dashed var(--line); border-radius: 8px; }
.math-preview:empty { display: none; }
.math-bad { color: var(--bad, #b91c1c); font-size: 13px; margin: 2px 0; }

/* settings */
.fields-2 { display: grid; gap: var(--s4) var(--s5); grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }  /* wide enough for the hints */
.stack-cards { display: grid; gap: 16px; align-content: start; }
.url-box { padding: 8px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; }
.qr-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.qr-img { width: 148px; height: 148px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; background: #fff; flex: none; }
/* Settings -> Data mix: a box per group of % (rows of label + number, the live total), the weights, the batch defaults */
.dm-groups { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); margin-top: var(--s3); }
.dm-group { display: grid; gap: var(--s2); align-content: start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); min-width: 0; }
.dm-group h3, .dm-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.dm-group > .hint { margin: 0; font-size: 13px; }
.dm-rows { display: grid; gap: 6px; }
.dm-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 400; min-width: 0; }
.dm-row > span:first-child { min-width: 0; }
.dm-row input { width: 84px; min-height: 36px; padding: 6px 10px; text-align: end; flex: none; font-variant-numeric: tabular-nums; }
.dm-group .dm-row input { background: var(--card); }
.dm-pct { display: inline-flex; align-items: center; gap: 6px; flex: none; color: var(--muted); }
.dm-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding-top: var(--s2); border-top: 1px solid var(--line); }
.dm-foot .hint { margin-inline-end: auto; font-size: 13px; }
.dm-sum { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ok); }
.dm-sum.bad { color: var(--bad); }
.dm-foot .dm-sum { flex-basis: 100%; }
.dm-block { display: grid; gap: var(--s2); margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--line); }
.dm-block > .hint { margin: 0; }
.dm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dm-weights { display: grid; gap: 6px var(--s5); grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); margin-top: var(--s2); }
.dm-k { display: grid; gap: 6px; max-width: 280px; }
.save-bar { position: sticky; bottom: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; z-index: 2;
  box-shadow: var(--shadow-pop); }
.save-bar .spacer { margin-inline-start: auto; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 700; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .slider { position: relative; width: 44px; height: 24px; border-radius: 12px; background: var(--line); transition: background .2s; flex: none; }
.switch .slider::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 25%); transition: inset-inline-start .2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { inset-inline-start: 23px; }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* train / val / test */
.split-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.split-grid .label { font-weight: 700; font-size: 14px; }
.split-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-select { width: auto; min-width: 130px; padding: 4px 8px; }

/* custom sheet types */
.mix-sub { padding: 14px 0 4px; font-weight: 800; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
.mix-row .info.based { grid-column: 1; }
.type-id { font-size: 12px; color: var(--muted); }
.task-cell { max-width: 340px; font-size: 14px; }

/* who wrote a pack (writer page) */
.person-box { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; display: grid; gap: 8px; }
.person-box h3 { font-size: 15px; }
.person-line { font-weight: 700; }
.person-form .row { flex-wrap: wrap; align-items: center; }
.person-form select, .person-form input { width: auto; min-width: 200px; flex: 1 1 200px; }
.h-sub { font-size: 14px; font-weight: 400; color: var(--muted); margin-inline-start: 6px; }
/* a form or field that doesn't apply right now (e.g. details before the person is known, contact without a cover) */
.form.disabled, .field.disabled { opacity: .5; }

/* annotation (Label Studio) */
.ann { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; }
.ann-link { font-size: 13px; font-weight: 700; }
.ann-label { font-size: 12px; font-weight: 700; margin: 6px 0 2px; }
.ann-label.muted { color: var(--muted); }
.how ol { margin: 0; padding-inline-start: 22px; display: grid; gap: 6px; }
table.data tr.mine td { background: var(--primary-soft); font-weight: 700; }
.error-text { color: var(--bad); font-size: 14px; font-weight: 700; }
/* the guide's title with its export (PDF, Markdown) at the end */
.an-guide-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
.an-guide-head h2 { margin-inline-end: auto; }
.an-guide-export { display: flex; flex-wrap: wrap; gap: 8px; }
/* Save as PDF: on paper only the guide, every section open, black on white */
@media print {
  body.print-guide .topbar, body.print-guide .view > :not(#an-guide), body.print-guide .no-print,
  body.print-guide .md-toc-all { display: none !important; }
  body.print-guide { background: #fff; color: #000; min-height: 0; }
  body.print-guide .view { padding: 0; max-width: none; display: block; }
  body.print-guide #an-guide { border: 0; box-shadow: none; padding: 0; background: #fff; }
  body.print-guide #an-guide summary::before { display: none; }
  body.print-guide .md-item { break-inside: avoid; }
}

/* annotation guidelines, read-only (annotators) */
.guidelines { white-space: pre-wrap; line-height: 1.7; unicode-bidi: plaintext; }
/* the annotation guide drawn from its Markdown (admin.js mdHtml), read top to bottom: a contents list, folding sections,
   tables as cards (Arabic values right to left, as samples), Arabic examples in the page's font */
.guidelines.md { white-space: normal; unicode-bidi: normal; display: grid; gap: 12px; line-height: 1.6; max-width: 820px; }
.guidelines.md p, .guidelines.md ul, .guidelines.md ol { margin: 0; max-width: 80ch; }
.guidelines.md ul, .guidelines.md ol { padding-inline-start: 22px; display: grid; gap: 4px; }
.guidelines.md .md-note { max-width: 80ch; padding: 8px 12px; border-inline-start: 3px solid var(--primary, var(--line)); background: var(--panel-2); border-radius: 6px; color: var(--muted); }
.md-toc { display: grid; gap: 6px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.md-toc-head { display: flex; align-items: center; gap: 8px; }
.md-toc-label { font-weight: 700; font-size: 16px; }
.md-toc-all { margin-inline-start: auto; border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 999px; padding: 3px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.md-toc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.md-toc-list button { border: 0; background: none; padding: 3px 0; color: var(--link); font: inherit; font-size: 15px; text-align: start; cursor: pointer; }
.md-toc-list button:hover, .md-toc-list button:focus-visible { text-decoration: underline; }
.md-sec { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); scroll-margin-top: 80px; }
.md-sec > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.md-sec > summary::-webkit-details-marker { display: none; }
.md-sec > summary::before { content: "▸"; color: var(--muted); font-size: 14px; line-height: 1; transition: transform .15s; flex: none; }
[dir="rtl"] .md-sec > summary::before { transform: scaleX(-1); }
.md-sec[open] > summary::before { transform: rotate(90deg); }
.md-sec > summary h3 { margin: 0; font-size: 18px; }
.md-sec-body { display: grid; gap: 12px; padding: 0 16px 16px; }
.md-sec-body h4 { margin: 10px 0 0; font-size: 16px; }
.md-items { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.md-item { display: grid; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.md-item:last-child { border-bottom: 0; }
.guidelines.md .md-item-text h4 { margin: 0 0 6px; }
.md-item-ex { display: grid; gap: 6px; align-content: start; }
.guidelines.md .md-item-ex pre { max-width: none; }
.md-ex-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.md-cards { display: grid; gap: 10px; }
.md-card { display: grid; gap: 8px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.md-card-title { font-weight: 700; }
.md-field { display: grid; gap: 3px; }
.md-field-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.md-field-value.md-ar { padding: 6px 12px; border-radius: 6px; background: var(--panel-2); font-size: 16px; text-align: start; }
.md-sample { font-family: inherit; background: var(--panel-2); border-radius: 6px; padding: 1px 6px; }
pre.md-sample, pre.md-code { margin: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); max-width: 80ch; }
pre.md-sample { white-space: pre-wrap; font-family: inherit; font-size: 16px; line-height: 1.8; text-align: start; }
pre.md-code { white-space: pre; overflow-x: auto; font-family: ui-monospace, monospace; text-align: start; }
.an-guide-edit { margin-top: 12px; }
.an-guide-edit summary { cursor: pointer; font-weight: 700; }
.an-guide-edit textarea { width: 100%; margin: 10px 0; font-family: ui-monospace, monospace; }
#an-guidelines { width: 100%; font: inherit; line-height: 1.7; }
/* Label Studio and this dashboard: the totals side by side, then the difference by reason (Clean up below) */
.recon { display: grid; gap: var(--s3); }
.recon > * { margin: 0; }
.recon-top { align-items: center; }
.recon-top h2 { margin: 0; }
.recon h3 { font-size: 15px; }
table.recon-totals td.num, table.recon-totals th.num { width: 22%; }
table.recon-totals td.recon-off { color: var(--busy); font-weight: 800; }
.recon-reasons { list-style: none; margin: 0; padding: 0; display: grid; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.recon-reason { display: grid; gap: 2px; padding: 10px 14px; }
.recon-reason + .recon-reason { border-top: 1px solid var(--line); }
.recon-reason p { margin: 0; }
.recon-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.recon-nums { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; margin-inline-start: auto; font-size: 13px; color: var(--muted); }
.recon-nums bdi { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }
.recon-split { color: var(--text); }
.recon-tasks a { margin-inline-end: 6px; font-variant-numeric: tabular-nums; }
.recon-acts { display: grid; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--line); }
.recon-acts .row { flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.recon-acts .hint { flex: 1 1 260px; margin: 0; }
@media (max-width: 560px) {
  .recon-nums { margin-inline-start: 0; }
  .recon-acts .btn { width: 100%; }
}

/* batch page: deleting the batch (admins) */
.danger-zone { border-color: color-mix(in oklab, var(--bad) 50%, var(--line)); }
ul.tight { margin: 0; padding-inline-start: 22px; display: grid; gap: 4px; }

/* ---------- picking accounts for a batch ---------- */
.acc-picker { display: grid; gap: 8px; }
.acc-q { width: 100%; }
.acc-list { display: grid; gap: 2px; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; background: var(--bg); }
.acc-list label.check { align-items: flex-start; padding: 4px 0; }
.acc-list .sub { display: block; }
.chip .chip-x { border: 0; background: transparent; color: inherit; font: inherit; font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; margin-inline-start: 4px; }
.list-title { font-size: 17px; margin: 8px 0 0; }
.ended-card { background: color-mix(in oklab, var(--progress) 8%, var(--card)); border-color: color-mix(in oklab, var(--progress) 35%, var(--line)); }

/* ---------- hand-out list: on paper only the list, with a tick box per pack ---------- */
.print-only { display: none; }
.foot { max-width: 1200px; margin: -36px auto 0; padding: 0 16px 20px; color: var(--muted); font-size: 12px; text-align: center; }
.foot:empty { display: none; }
@media print {
  .foot { display: none; }
  body.print-handout .topbar, body.print-handout .view > :not(#handout), body.print-handout .no-print { display: none !important; }
  body.print-handout { background: #fff; color: #000; min-height: 0; }
  body.print-handout .view { padding: 0; max-width: none; display: block; }
  body.print-handout #handout { border: 0; box-shadow: none; padding: 0; background: #fff; }
  body.print-handout #handout .print-only { display: block; }
  body.print-handout #handout th.print-only, body.print-handout #handout td.print-only { display: table-cell; }
  body.print-handout .handout-table { width: 100%; border-collapse: collapse; font-size: 14pt; }
  body.print-handout .handout-table th, body.print-handout .handout-table td { border: 1px solid #000; padding: 6pt 8pt; text-align: start; }
  body.print-handout .handout-table tr { break-inside: avoid; }
  body.print-handout .handout-table .box { display: inline-block; width: 14pt; height: 14pt; border: 1.5pt solid #000; }
  body.print-handout .table-wrap { overflow: visible; border: 0; }
}

.subhead { font-size: 15px; margin: 18px 0 2px; }

/* writer picker (New batch, Add writers) */
.wk-picker { display: grid; gap: 10px; }
.wk-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wk-tools .wk-q { flex: 1 1 200px; min-width: 0; }
.wk-tools .wk-r { flex: 1 1 220px; min-width: 0; }
.wk-list { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; background: var(--card); }
.wk-list .wk-row { display: flex; width: 100%; padding: 6px 0; border-bottom: 1px solid var(--line); }
.wk-row:last-child { border-bottom: 0; }
.wk-row .sub { display: block; }
.wk-row.disabled { opacity: .6; }
.wk-sum { font-weight: 700; margin: 0; }
.wk-n { max-width: 160px; }

/* ---------- photos that are not from a pack ---------- */
.waiting { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.waiting-item {
  display: grid; grid-template-columns: 120px 1fr; gap: var(--s4); align-items: start;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.waiting-item .thumb {
  display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
}
.waiting-body { display: grid; gap: 8px; min-width: 0; }
.waiting-body .fields-2 { grid-template-columns: 1fr; }
@media (max-width: 560px) { .waiting-item { grid-template-columns: 90px 1fr; } }

/* ---------- layout builder ---------- */
.ly h3 { font-size: 16px; margin: 4px 0 8px; }
.ly-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 520px); align-items: start; }
.ly-edit { display: grid; gap: 10px; min-width: 0; }
.ly-prev { position: sticky; top: 0; display: grid; gap: 8px; min-width: 0; }
.ly-wrap { position: relative; width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; direction: ltr; }
.ly-frame { position: absolute; top: 0; left: 0; width: 794px; height: 1123px; border: 0; transform-origin: 0 0; background: #fff; }
.ly-status { font-size: 14px; min-height: 22px; }
.ly-ok { color: var(--ok, #15803d); font-weight: 700; }
.ly-warn { color: var(--busy); font-weight: 700; background: var(--busy-bg); border-radius: var(--radius-sm); padding: 8px 12px; }
.ly-blocks { display: grid; gap: 8px; }
.ly-block { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 8px; background: var(--card); }
.ly-block-head { display: flex; gap: 6px; align-items: center; }
.ly-block-head .spacer { margin-inline-start: auto; }
.ly-block-body { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.ly-styles { display: flex; gap: 10px; flex-wrap: wrap; }
.ly-style { display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; align-content: start; }
.ly-style pre { margin: 0; font-size: 13px; unicode-bidi: plaintext; }
.ly-add { gap: 6px; }
.ly-v { border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.ly-ticks { display: flex; gap: 14px; flex-wrap: wrap; }
.ly-cells input { width: 100%; min-width: 70px; }
@media (max-width: 980px) { .ly-grid { grid-template-columns: 1fr; } .ly-prev { position: static; } }
.ly-ref { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg); font-size: 14px; font-family: ui-monospace, monospace; min-height: 40px; }
.ly-ref > div { white-space: pre-wrap; word-break: break-word; unicode-bidi: plaintext; }

/* texts library on a phone: the text column keeps a readable width (the table scrolls sideways) */
#tx-table table.data td:nth-child(3) { min-width: 250px; }
#tx-table table.data td:nth-child(4) { min-width: 150px; }
.saved-warnings { display: grid; gap: 6px; margin: 10px 0; }
.saved-warnings .chip { white-space: normal; border-radius: 10px; line-height: 1.5; }

/* the generator prompt, shown to copy by hand when the browser refuses */
.prompt-box { width: 100%; font: 13px/1.5 ui-monospace, monospace; white-space: pre; }

.arch-group { border-top: 1px solid var(--line); padding: 12px 0; }
.arch-group > .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* Settings: long lists of cards in groups: a search box and a chip per group stay at hand while scrolling */
.cards-nav { position: sticky; top: 64px; z-index: 2; display: grid; gap: 8px; padding: 10px 0; background: var(--panel, var(--card)); }
.cards-search { width: 100%; max-width: 420px; }
.cards-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { font: inherit; font-size: 13px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); cursor: pointer; }
.chip-btn:hover { border-color: var(--primary); }
.card-group { scroll-margin-top: 180px; }
.card-group > summary { cursor: pointer; padding: 8px 0; }
.card-cell[hidden], .card-group[hidden] { display: none; }
.card-cell { display: grid; min-width: 0; }
.limit-card input[type=number], .limit-card input[type=text], .limit-card textarea { width: 100%; font: inherit; }
.limit-card .rule-title { font-weight: 700; }
.limit-effect { color: var(--text); }
/* Settings, Rules: one card per check or fix, as many columns as fit; the effect that applies now stands out */
.rules-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.rule-card {
  display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px; min-width: 0; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.rule-card:has(input[type=checkbox]:not(:checked)) { border-style: dashed; }
.rule-card .switch { min-width: 0; }
.rule-card .slider { flex: none; }
.rule-title { min-width: 0; overflow-wrap: anywhere; }
.rule-card p { margin: 0; }
.rule-effect { font-size: 13px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.rule-card:has(input:checked) .if-on, .rule-card:has(input:not(:checked)) .if-off { color: var(--text); }
.rule-id { font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.arch-details { margin-top: 8px; }
.arch-details summary { cursor: pointer; color: var(--primary); font-size: 14px; font-weight: 700; padding: 4px 0; }
.arch-texts { max-height: 420px; overflow: auto; }

/* the sample-writing agent (agent.js) */
.ag-pool { display: grid; grid-template-columns: minmax(110px, 200px) 1fr auto; gap: 10px; align-items: center; }
.ag-pool .name { font-weight: 700; }
.ag-sample .hint { margin-bottom: 4px; }
.nowrap { white-space: nowrap; }
/* the generator's form: on a phone plan, types, texts needed, Start; on a laptop the types fill the right column and
   the left one holds the plan, the texts needed (stretching to meet the types' bottom) and Start, so neither ends early */
.ag-top { display: grid; gap: var(--s5); grid-template-areas: "plan" "mix" "sum" "go"; }
.ag-plan { grid-area: plan; } .ag-mix { grid-area: mix; } .ag-sum { grid-area: sum; } .ag-go { grid-area: go; }
@media (min-width: 900px) {
  .ag-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 1fr auto; grid-template-areas: "plan mix" "sum mix" "go mix"; }
}
ul.ag-log { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.ag-err { font-size: 13px; color: var(--muted); padding-inline-start: 12px; text-align: left; }
.ag-modal-page { max-width: 520px; margin-inline: auto; }
/* the review table: the text column wraps, the warnings column is bounded and every warning is a wrapped chip cut at
   two lines ("more" opens it in place); on a phone the table scrolls inside its own box, never the page */
table.ag-review td { vertical-align: top; }
table.ag-review td.ag-text { min-width: 15rem; overflow-wrap: anywhere; }
table.ag-review td.ag-warn-cell { width: 30%; min-width: 12rem; }
table.ag-review td.ag-act { width: 1%; }
ul.ag-warns { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-width: 26rem; }
.ag-warn { display: grid; justify-items: start; gap: 2px; min-width: 0; }
.ag-warn .chip {
  display: flex; align-items: flex-start; gap: 6px; max-width: 100%; padding-block: 4px;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.45; text-align: start; border-radius: var(--radius-sm);
}
.ag-warn-text {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  min-width: 0; font-weight: 500; unicode-bidi: plaintext;
}
.ag-warn-text b { font-weight: 800; }
.ag-warn.open .ag-warn-text { display: block; -webkit-line-clamp: none; line-clamp: none; overflow: visible; }
.ag-warn-n { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; }
.ag-more {
  border: 0; background: none; padding: 2px 4px; font: inherit; font-size: 13px; font-weight: 700;
  color: var(--link); cursor: pointer; border-radius: 4px;
}
.ag-more:hover { text-decoration: underline; }
.ag-act-row { display: flex; gap: 6px; }
.ag-regen-note { display: grid; gap: 2px; justify-items: start; margin-top: 6px; font-size: 14px; }
.ag-regen-note .ag-err { padding-inline-start: 0; overflow-wrap: anywhere; }
/* a phone: each row is a card (ui.js), the text and its warnings take the card's whole width under their names */
@media (max-width: 760px) {
  table.ag-review[data-stacked="cards"] td { width: auto; min-width: 0; }
  table.ag-review[data-stacked="cards"] td.ag-text,
  table.ag-review[data-stacked="cards"] td.ag-warn-cell { grid-template-columns: 1fr; gap: 4px; align-items: start; }
  table.ag-review[data-stacked="cards"] td.ag-text > .chip { justify-self: start; }
  ul.ag-warns { max-width: none; }
  .ag-act-row { flex-wrap: wrap; }
}

/* teams */
.split-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s4); margin: var(--s2) 0 var(--s4); }
.split-total { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; }
.split-total .big { font-size: 20px; font-weight: 800; }
.split-select.sp-train { border-color: var(--train); }  /* a split is a round's colour, not a status */
.split-select.sp-val { border-color: var(--val); }
.split-select.sp-test { border-color: var(--test); }
.needs-split { margin-bottom: var(--s4); background: color-mix(in oklab, var(--busy) 8%, var(--card)); border-color: color-mix(in oklab, var(--busy) 35%, var(--line)); }
.needs-split h2 { margin: 0 0 4px; font-size: 18px; }
.notice { margin: 6px 0; }
ul.plain { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
tr.group-row td { background: var(--info-bg); padding-block: 10px; }
@media (max-width: 760px) {  /* a team's heading row among the account cards */
  table.data[data-stacked="cards"] tr.group-row { background: var(--info-bg); padding: 14px 16px; }
  table.data[data-stacked="cards"] tr.group-row td { background: transparent; }
}
#im-text { width: 100%; font-family: ui-monospace, monospace; font-size: 14px; }
.team-actions { flex-wrap: nowrap; }
.needs-list { display: grid; gap: 8px; }
.needs-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.needs-row .spacer { flex: 1; }
.needs-row b { overflow-wrap: anywhere; min-width: 0; }

/* ROUNDS inside a batch: the rounds table (New batch, Generate samples) and the round cards (batch page) */
.rounds-table input.round-input { width: 84px; text-align: center; padding: 6px 8px; }
.rounds-table input.k-input { width: 64px; }  /* each round's own k */
.rounds-table tr.muted td:not(:nth-child(2)) { opacity: .55; }
.rounds-table tfoot th { font-weight: 800; }
.round-cards { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.round-card { align-content: start; gap: 8px; }
table.data.rounds-table th { white-space: normal; }
.nb-top > .card { align-content: start; align-self: start; }  /* each card as tall as its own content */
@media (max-width: 560px) {
  table.data.rounds-table th, table.data.rounds-table td { padding: 8px 3px; }
  .rounds-table input.round-input { width: 50px; padding: 6px 2px; }
  .rounds-table input.k-input { width: 38px; }
  .rounds-table .chip { white-space: nowrap; }
  .rounds-table .rd-pages { display: none; }  /* a phone: packs, texts and k fit; the pages are in the totals below */
}

/* New batch from an AI generation: the banner (or the offer) and the needs table (needs / generated per round) */
.gen-card { background: color-mix(in oklab, var(--info) 7%, var(--card)); border-color: color-mix(in oklab, var(--info) 30%, var(--line)); }
.gen-card .row > span:first-child { flex: 1 1 320px; }
.gen-card p { margin: 6px 0; }
table.gen-needs td.gen-off, table.gen-needs th.gen-off { color: var(--bad); font-weight: 800; }

/* ---------- home: "Inkwell" (home.js, charts.js): ink to data. The headline is written on a ruled line, the batch is
   one ink stroke ending in the pen's nib, and the handwriting itself is on screen (each result's page photo) ---------- */
.home { display: grid; gap: 20px; }
.r-train { --rc: var(--train); }
.r-val { --rc: var(--val); }
.r-test { --rc: var(--test); }

/* the banner: one soft ink wash behind it, the only wash on the page */
.ho-banner {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 28px; align-items: start; padding: 26px 30px 24px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: radial-gradient(80% 140% at var(--wx, 0%) 0%, color-mix(in oklab, var(--accent) 11%, transparent), transparent 70%), var(--card);
}
[dir="rtl"] .ho-banner { --wx: 100%; }
/* ruled paper: a line under every line of the headline, at its baseline, so the descenders cross it */
.ho-banner h1 {
  font-size: 38px; font-weight: 800; line-height: 1.32; text-wrap: balance;
  background: repeating-linear-gradient(to bottom, transparent 0 calc(1lh - .3em), var(--rule) calc(1lh - .3em) calc(1lh - .3em + 1px),
    transparent calc(1lh - .3em + 1px) 1lh);
}
:root[lang="en"] .ho-banner h1 { letter-spacing: -0.02em; }
.ho-banner p { margin: 8px 0 0; font-size: 17px; color: var(--muted); text-wrap: pretty; }
.ho-banner-acts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; padding-top: 4px; }
.ho-banner > .ink, .ho-banner > .bar { grid-column: 1 / -1; }

/* the ink stroke (Charts.inkStroke): a segment per round, the nib at the end, a dashed line for what is not in yet */
.ink { display: grid; gap: 12px; margin-top: 4px; }
.ink-line { position: relative; display: flex; align-items: center; height: 8px; margin-top: 16px; }
.ink-seg { flex: none; height: 6px; margin-inline-end: 3px; border-radius: 3px; background: var(--rc); transition: width .25s ease-out; }
.ink-seg:first-child { clip-path: polygon(0 34%, 28px 0, 100% 0, 100% 100%, 28px 100%, 0 66%); border-radius: 0 3px 3px 0; }
[dir="rtl"] .ink-seg:first-child { clip-path: polygon(100% 34%, calc(100% - 28px) 0, 0 0, 0 100%, calc(100% - 28px) 100%, 100% 66%); border-radius: 3px 0 0 3px; }
.ink-rest { flex: 1; height: 0; border-top: 1.5px dashed color-mix(in oklab, var(--muted) 55%, transparent); }
.ink-nib {
  position: absolute; bottom: 2px; inset-inline-start: calc(var(--done) - 4px); width: 24px; height: 24px; color: var(--text);
  transform: scaleY(-1); transition: inset-inline-start .25s ease-out;
}
[dir="rtl"] .ink-nib { transform: scale(-1, -1); }
.ink-nib svg { display: block; width: 100%; height: 100%; }
.ink-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; font-size: 14px; }
.ink-key { display: inline-flex; align-items: center; gap: 6px; }
.ink-key .muted { font-size: 13px; }
.ink-dash { width: 18px; border-top: 1.5px dashed var(--muted); }
.ink-total { margin-inline-start: auto; font-size: 13px; }
.rb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rc); flex: none; }

/* a page's photo, small, on paper; a blank ruled page when there is no photo to show */
.ho-thumb {
  position: relative; display: block; flex: none; width: 40px; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 3px;
  background: repeating-linear-gradient(to bottom, transparent 0 6px, color-mix(in oklab, var(--muted) 35%, transparent) 6px 7px), var(--thumb-paper);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--text) 16%, transparent), var(--shadow);
}
.ho-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; display: block;
  background: var(--thumb-paper); transform: scale(1.3); }
.ho-thumb.page img { transform: none; }  /* the straightened page: already only the paper */

/* Needs you: one band, its title first, then each thing to act on */
.ho-needs-row { display: grid; grid-template-columns: auto minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.ho-needs-title { display: flex; align-items: center; padding: 14px 22px; font-size: 17px; border-inline-end: 1px solid var(--line); white-space: nowrap; }
.ho-needs-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.ho-need { display: flex; align-items: center; gap: 12px; padding: 12px 18px; min-width: 0; }
.ho-need + .ho-need { border-inline-start: 1px solid var(--line); }
.ho-need.open { background: var(--panel-2); }
.ho-need > div { flex: 1; font-size: 15px; min-width: 0; }
.ho-need > div b { font-size: 18px; margin-inline-end: 2px; }
.ho-need-sub { display: block; font-size: 13px; color: var(--muted); }
.ho-need-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-size: 17px; flex: none; }
.ho-need-icon.warn { background: var(--busy-bg); color: var(--busy); }
.ho-need-icon.bad { background: var(--bad-bg); color: var(--bad); }
.ho-need-icon.info { background: var(--info-bg); color: var(--info); }
.ho-calm { display: flex; align-items: center; gap: 8px; margin: 0; padding: 14px 18px; color: var(--muted); }
.ho-calm .i { color: var(--ok); }
#ho-panel:not(:empty) { margin-top: 12px; }

/* a card per round: the share in, its latest pages, its stroke, its packs one small bar each, three counts */
.ho-rounds { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.ho-rounds:empty { display: none; }
.ho-round { display: grid; gap: 14px; align-content: start; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card);
  container: round / inline-size; }
.ho-round > * { min-width: 0; }
@container round (max-width: 380px) { .ho-packbars.many .pb small { display: none; } }
.ho-round header { display: flex; align-items: center; gap: 8px; }
.ho-round h2 { font-size: 18px; }
.ho-round-packs { margin-inline-start: auto; font-size: 13px; text-align: end; }
.ho-round-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ho-big { font-size: 46px; font-weight: 800; line-height: 1.05; }
.ho-big span { display: inline-block; min-width: 3ch; }
.ho-round-sub { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.ho-today { color: var(--text); font-weight: 700; }
.ho-thumbs { display: grid; gap: 5px; justify-items: end; margin: 0; }
.ho-thumbs > div { display: flex; gap: 6px; }
.ho-thumbs .ho-thumb { width: 34px; }
.ho-thumbs figcaption { font-size: 11px; color: var(--muted); }
.ho-stroke { display: block; height: 5px; border-radius: 3px; background: color-mix(in oklab, var(--rc) 14%, var(--panel-2)); overflow: hidden; }
.ho-stroke i { display: block; height: 100%; border-radius: 3px; background: var(--rc); transition: width .25s ease-out; }
.ho-packs-mini { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.ho-packbars { display: flex; align-items: flex-end; gap: 3px; }
.ho-packbars .pb { display: grid; grid-template-rows: auto 30px auto; justify-items: center; gap: 3px; flex: 1; min-width: 0; max-width: 14px; }
.ho-packbars.named .pb { max-width: 34px; }
.ho-packbars .pb b { font-size: 11px; font-weight: 700; color: var(--text); }
.ho-packbars .pb small { font-size: 10px; color: var(--muted); }
.pb-track { display: flex; align-items: flex-end; width: 100%; max-width: 14px; height: 30px; border-radius: 2px; background: color-mix(in oklab, var(--panel-2) 70%, transparent); }
.pb-track i { display: block; width: 100%; border-radius: 2px; background: var(--rc); }
.pb.empty .pb-track { background: transparent; border-bottom: 1px solid var(--muted); border-radius: 0; }
.pb.empty b { color: var(--muted); }
.ho-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 0; padding-top: 12px; border-top: 1px solid var(--line); }
.ho-stats dt { font-size: 12px; color: var(--muted); }
.ho-stats dd { margin: 0; font-size: 18px; font-weight: 700; }

.ho-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; min-width: 0; }
.ho-head { display: flex; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ho-head h2 { font-size: 18px; }
.ho-head .muted { font-size: 14px; }

/* Teams: ranked bars, most in first; a team that lags carries the word "Behind" with its icon */
.ho-teams { list-style: none; margin: 0 -10px; padding: 0; display: grid; gap: 2px; }
.ho-team {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: inherit; font-size: 15px;
  text-align: start; cursor: pointer;
}
.ho-team:hover { background: var(--panel-2); }
.ho-team-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ho-team-pct { font-weight: 700; min-width: 4.5ch; text-align: end; }
.ho-team-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.ho-team-bar i { display: block; height: 100%; border-radius: 3px; background: var(--neutral-bar); transition: width .25s ease-out; }
.ho-team.lag .ho-team-bar i { background: var(--busy); }
.ho-behind { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--busy); }
.ho-team.none { color: var(--muted); }
.ho-team.none .ho-team-bar { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.ho-team.selected { background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.ho-team.selected .ho-team-bar i { background: var(--accent); }
.ho-team.dim { color: var(--muted); }
.ho-team.dim .ho-team-bar i { opacity: .5; }
.ho-team.pulse { animation: team-pulse .25s ease-out; }
@keyframes team-pulse { from { background: color-mix(in oklab, var(--accent) 18%, transparent); } }
.ho-foot { margin: 10px 0 0; font-size: 13px; }

/* Latest results: the page's photo, then what it is, who sent it, when, and what happened to it */
.ho-feed { list-style: none; margin: 0; padding: 0; display: grid; }
.ho-feed li {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "thumb what chip" "thumb meta meta";
  align-items: center; gap: 3px 14px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.ho-feed li:last-child { border-bottom: 0; }
.ho-feed li > .ho-thumb { grid-area: thumb; }
.ho-what { grid-area: what; display: grid; gap: 1px; min-width: 0; }
.ho-pack b { font-weight: 700; }
.ho-page { display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 13px; color: var(--muted); }
.ho-feed-head { display: none; }
[data-region=feed] { container: feed / inline-size; }
.ho-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; color: var(--muted); min-width: 0; }
.ho-feed li > .chip { grid-area: chip; justify-self: end; }
@container feed (min-width: 620px) {
  .ho-feed li, .ho-feed-head { grid-template-columns: 40px minmax(0, 1.6fr) minmax(0, 1fr) 96px 190px; grid-template-areas: "thumb what who when chip"; }
  .ho-feed-head { display: grid; gap: 14px; padding: 0 0 8px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
  .ho-meta { display: contents; }
  .ho-who { grid-area: who; color: var(--text); font-size: 14px; }
  .ho-when { grid-area: when; font-size: 14px; }
  .ho-feed li > .chip { justify-self: start; }
}
.ho-feed li.enter { animation: feed-in .25s ease-out; }
.ho-feed-more, .drawer .ho-feed-more { display: none !important; }
@keyframes feed-in { from { opacity: 0; transform: translateY(-6px); background: color-mix(in oklab, var(--accent) 10%, transparent); } }

/* Pages per day */
.ho-legend { margin-inline-start: auto; display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.ho-legend span, .tip-row { display: flex; align-items: center; gap: 6px; }
.dot.up, .dot.down { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.dot.up { background: var(--progress); }
.dot.down { background: var(--mark-bad); }
.act { position: relative; }
.act-plot { position: relative; display: flex; gap: 3px; height: 220px; border-radius: var(--radius-sm); }
.act-col { position: relative; flex: 1; border-radius: 4px; }
.act-col.weekend { background: color-mix(in oklab, var(--panel-2) 55%, transparent); }
.ho-legend .dot.weekend { background: color-mix(in oklab, var(--panel-2) 80%, transparent); box-shadow: inset 0 0 0 1px var(--line); }  /* the shaded columns, as drawn */
.act-ref { position: absolute; inset-inline: 0; height: 0; border-top: 1px dashed color-mix(in oklab, var(--muted) 45%, transparent); pointer-events: none; }
.act-ref span { position: absolute; inset-inline-start: 0; top: -18px; font-size: 11px; color: var(--muted); background: var(--card); padding-inline-end: 6px; }
.act-col.on { background: var(--panel-2); }
.act-up, .act-down { position: absolute; inset-inline: 16%; }
.act-up { bottom: calc(100% - var(--base) + 1px); background: var(--progress); border-radius: 3px 3px 0 0; }
.act-down { top: calc(var(--base) + 2px); background: var(--mark-bad); border-radius: 0 0 3px 3px; }
.act-col.today { box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--text) 45%, transparent); }
.act-val { position: absolute; inset-inline: 0; text-align: center; font-size: 11px; font-weight: 700; color: var(--text); pointer-events: none; }
.act-line { position: absolute; inset-inline: 0; top: var(--base); height: 1px; background: var(--muted); opacity: .45; pointer-events: none; }
.act-axis { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--muted); }
.act-tip {
  position: absolute; top: 6px; z-index: 2; min-width: 190px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-pop); font-size: 13px; pointer-events: none;
  display: grid; gap: 4px;
}
.act-tip[hidden] { display: none; }
.tip-row b { margin-inline-start: auto; padding-inline-start: 12px; }
.tip-row.sub { padding-inline-start: 16px; color: var(--muted); }

@media (max-width: 760px) {
  .home { gap: 16px; }
  .ho-banner { grid-template-columns: 1fr; padding: 20px 18px; }
  .ho-banner h1 { font-size: 28px; }
  .ho-banner p { font-size: 15px; }
  .ho-banner-acts { justify-content: flex-start; }
  .ho-updated { flex-basis: 100%; }
  .ink-total { margin-inline-start: 0; flex-basis: 100%; }
  .ho-needs-row { grid-template-columns: 1fr; }
  .ho-needs-title { border-inline-end: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  .ho-need { padding: 12px 16px; }
  .ho-need + .ho-need { border-inline-start: 0; border-top: 1px solid var(--line); }
  .ho-big { font-size: 40px; }
  .ho-sec .ho-feed li:nth-child(n+7) { display: none; }
  .ho-sec .ho-feed-more { display: inline-flex !important; margin-top: var(--s3); }
  .act-plot { height: 170px; gap: 2px; }
  .ho-legend { margin-inline-start: 0; }
}

/* home: filters, sections a person orders, clicking to filter, drawers */
.ho-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.ho-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ho-fields select { width: auto; min-width: 140px; padding: 8px 12px; }
.ho-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1; }
.ho-filters > [data-act=customize] { margin-inline-start: auto; }
.filter-chip { background: color-mix(in oklab, var(--accent) 16%, transparent); color: var(--text); padding-inline-end: 4px; }
.filter-chip button { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.filter-chip button:hover { background: color-mix(in oklab, var(--text) 10%, transparent); }
/* wide screens: Teams on the left, Latest results beside it and exactly as tall (its list scrolls inside), so the two
   sides always end on the same line */
.ho-grid { display: grid; gap: 20px; grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr); grid-auto-flow: row dense; }
.ho-sec { grid-column: 1 / -1; min-width: 0; }
.ho-sec.left { grid-column: 1; }
.ho-sec.side { grid-column: 2; grid-row: span var(--side-rows, 2); contain: size; min-height: 380px; }
.ho-grid.side-wide .ho-sec.side { grid-column: 1 / -1; grid-row: auto; contain: none; min-height: 0; }
.ho-sec.side > .ho-card { height: 100%; display: flex; flex-direction: column; }
.ho-sec.side [data-region=feed] { flex: 1; min-height: 0; overflow: hidden; }  /* whole rows only (home.js fitFeed) */
.ho-grid.side-wide .ho-sec.side [data-region=feed] { overflow: visible; }
.ho-feed li.over { display: none; }
[data-region=feed].cut .ho-feed-more { display: inline-flex !important; margin-top: var(--s3); }
.ho-head-end { margin-inline-start: auto; }
.ho-head-rest { display: contents; }

/* a whole card or row answers a click: a full-size button behind the content; links and buttons in it stay on top */
.ho-round, .ho-feed li { position: relative; }
.ho-hit { position: absolute; inset: 0; border: 0; background: transparent; border-radius: inherit; cursor: pointer; padding: 0; }
.ho-hit:hover { background: color-mix(in oklab, var(--text) 3%, transparent); }
.ho-round > :not(.ho-hit), .ho-feed li > :not(.ho-hit) { position: relative; pointer-events: none; }
.ho-round a, .ho-round button:not(.ho-hit), .ho-feed li a { pointer-events: auto; }
.ho-more { width: 32px; height: 32px; font-size: 16px; margin-inline-start: 2px; }
.ho-round.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }  /* selection is the accent's job */
.ho-round.dim > :not(.ho-hit) { opacity: .78; }
.act-plot.pickable { cursor: pointer; }
.act-col.picked { background: color-mix(in oklab, var(--accent) 14%, transparent); box-shadow: inset 0 0 0 1px var(--accent); }

/* the segmented control (range, density) */
.seg-ctl { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.seg-ctl button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 700; padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.seg-ctl button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* compact density: tighter cards, smaller numbers */
.home.compact, .home.compact .ho-grid { gap: 12px; }
.home.compact .ho-banner { padding: 18px 20px; }
.home.compact .ho-banner h1 { font-size: 28px; }
.home.compact .ho-round, .home.compact .ho-card { padding: 12px 14px; }
.home.compact .ho-big { font-size: 34px; }
.home.compact .ho-team { padding: 6px 10px; }
.home.compact .ho-feed li { padding: 6px 0; }
.home.compact .act-plot { height: 160px; }

/* drawer contents */
.dr-packs { list-style: none; margin: 0; padding: 0; display: grid; }
.dr-packs li { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dr-acc { grid-column: 2 / -1; font-size: 13px; }
.dr-prog { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.dr-tags { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.dr-tags:empty { display: none; }
.dr-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.dr-shot { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.dr-shot:hover { border-color: var(--muted); }
.dr-shot img, .dr-shot > span:first-child { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; background: var(--card); display: block; }
.dr-shot-meta { font-size: 13px; }
.dr-shot .chip { justify-self: start; }
.dr-photo { display: grid; place-items: center; min-height: 240px; background: var(--panel-2); border-radius: var(--radius); overflow: hidden; }
.dr-photo img { max-width: 100%; max-height: 70dvh; display: block; }
.dr-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.dr-order { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dr-order li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.dr-order .check { flex: 1; }
.dr-move { display: flex; gap: 2px; }
.dr-move .icon-btn:disabled { opacity: .3; cursor: default; }

@media (max-width: 980px) {
  .ho-grid { grid-template-columns: 1fr; }
  .ho-sec.left, .ho-sec.side { grid-column: 1 / -1; grid-row: auto; contain: none; min-height: 0; }
  .ho-sec.side [data-region=feed] { overflow: visible; }
}
@media (max-width: 760px) {
  .ho-fields { width: 100%; }
  .ho-fields select { flex: 1 1 140px; min-width: 0; }
  .ho-filters > [data-act=customize] { margin-inline-start: 0; }
}

/* ---------- the Dataset tab (dataset.js): key numbers, charts, the leak check, and every number in one table under
   "All numbers" (Train · Validation · Test · All; a phone keeps the grid) ---------- */
.ds-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ds-tools select { width: auto; min-width: 200px; }
.ds-kpis .value { font-variant-numeric: proportional-nums; }  /* a big number on its own: its own figures */
.ds-kpi-sub { color: var(--muted); font-size: 13px; }
.ds-grid { display: grid; gap: var(--s5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ds-grid > .ds-wide { grid-column: 1 / -1; }
.ds-col { display: grid; gap: var(--s5); align-content: start; min-width: 0; }  /* the balance, the leak check under it */
.ds-card { display: grid; gap: var(--s4); align-content: start; }
.ds-card-head { display: grid; gap: 4px; }
.ds-card h3 { font-size: 15px; }
.ds-sub-h + .cx-bars + .ds-sub-h { margin-top: var(--s2); }
.ds-funnels { display: grid; gap: var(--s5) var(--s7); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ds-fun { display: grid; gap: 8px; align-content: start; }
.ds-foot { color: var(--muted); font-size: 13px; }
.cx-name .rb-dot, .cx-head .rb-dot, .ds-fun h3 .rb-dot { display: inline-block; margin-inline-end: 7px; vertical-align: 1px; }
.ds-numbers > summary { flex-wrap: wrap; column-gap: 12px; }
.ds-numbers > summary h2 { font-size: 18px; }
.ds-numbers[open] > summary { margin-bottom: var(--s2); }

/* the charts (charts.js Charts.bars): a bar per row, its number written beside it. Split colours, else neutral ink;
   accepted and refused as on the Overview. A 2px gap in the card colour between touching segments, 4px rounded at
   the bar's end only, a target tick in ink. */
.cx-all, .cx-none { --rc: var(--muted); }
.cx-ok { --rc: var(--progress); }
.cx-bad { --rc: var(--mark-bad); }
.cx-bars, .cx-legend { --cx-lane: color-mix(in oklab, var(--muted) 16%, var(--card)); --cx-ghost: color-mix(in oklab, var(--muted) 30%, var(--card)); }
.cx-bars { display: grid; gap: 2px; }
.cx-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name val" "track track"; gap: 4px 12px;
  align-items: baseline; padding: 5px 6px; margin-inline: -6px; border-radius: var(--radius-sm); font-size: 14px;
}
.cx-row.on { background: var(--panel-2); }
.cx-name { grid-area: name; min-width: 0; overflow-wrap: anywhere; }
.cx-val { grid-area: val; white-space: nowrap; text-align: end; }
.cx-val b { font-weight: 800; }
.cx-val .muted { font-size: 13px; }
.cx-track { grid-area: track; position: relative; height: 12px; }
.cx-bars.lane .cx-track { background: var(--cx-lane); border-radius: 4px; }
.cx-ghost, .cx-bar { position: absolute; inset-block: 0; inset-inline-start: 0; border-start-end-radius: 4px; border-end-end-radius: 4px; }
.cx-ghost { background: var(--cx-ghost); }
.cx-bar { display: flex; min-width: 3px; overflow: hidden; }
.cx-bar i { flex: 1 1 0; min-width: 0; background: var(--rc); }
.cx-bar i + i { border-inline-start: 2px solid var(--card); }
.cx-track.has-target::after {
  content: ""; position: absolute; inset-block: -4px; inset-inline-start: var(--target); width: 2px; margin-inline-start: -1px;
  border-radius: 1px; background: var(--text);
}
.cx-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 0 2px; font-size: 14px; }
.cx-bars > .cx-head:first-child { padding-top: 0; }
/* inline: name, bar and value on one line, the three columns lined up over every row */
.cx-bars.inline { grid-template-columns: max-content minmax(0, 1fr) max-content; column-gap: 12px; }
.cx-bars.inline .cx-row, .cx-bars.inline .cx-head {
  grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; grid-template-areas: none; align-items: center;
}
.cx-bars.inline .cx-name { grid-area: 1 / 1; }
.cx-bars.inline .cx-track { grid-area: 1 / 2; }
.cx-bars.inline .cx-val { grid-area: 1 / 3; }
.cx-bars.inline .cx-head > :nth-child(2):last-child { grid-column: 2 / -1; }  /* a two-part heading: the rest runs on */
.cx-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; }
.cx-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cx-sw { width: 12px; height: 10px; border-radius: 2px; background: var(--rc); flex: none; }
.cx-sw.ghost { background: var(--cx-ghost); }
.cx-sw.rest { background: var(--cx-lane); box-shadow: inset 0 0 0 1px var(--line); }
.cx-tip {
  position: fixed; z-index: 30; min-width: 190px; max-width: min(340px, calc(100vw - 16px)); padding: 10px 12px;
  border-radius: var(--radius-sm); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
  font-size: 13px; pointer-events: none; display: grid; gap: 4px;
}
.cx-tip .tip-hint { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.cx-key { width: 12px; height: 3px; border-radius: 2px; background: var(--rc); flex: none; }  /* a line key, not a box */
.cx-key.rest { background: var(--muted); opacity: .5; }

/* the table under "All numbers" */
.ds-table th.num { text-align: end; }
.ds-table .rb-dot { display: inline-block; margin-inline-end: 6px; vertical-align: 1px; }
.ds-table .ds-short { display: none; }
.ds-table tbody th[scope="row"] { background: none; color: var(--text); font-size: 15px; font-weight: 500; white-space: normal; padding-block: 10px; }
.ds-table .ds-hint { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.ds-table td.num { white-space: nowrap; padding-block: 10px; }
.ds-table .ds-sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.ds-table .ds-all { border-inline-start: 1px solid var(--line); }
.ds-table td.ds-all { font-weight: 700; }
.ds-table tr.ds-group th { background: var(--panel-2); color: var(--text); font-size: 14px; font-weight: 800; padding-block: 10px; border-top: 1px solid var(--line); }
.ds-table tbody:first-of-type tr.ds-group th { border-top: 0; }
.ds-table tr.ds-group th > * + * { margin-inline-start: 10px; }
.ds-table .ds-gnote { color: var(--muted); font-size: 13px; font-weight: 400; }
.ds-table tr.ds-subhead th { background: none; color: var(--muted); font-size: 13px; font-weight: 700; white-space: normal; padding-block: 12px 4px; border-bottom: 0; }
.ds-table tr.ds-indent th[scope="row"] { padding-inline-start: 40px; color: var(--muted); font-size: 14px; }
.ds-when { color: var(--muted); white-space: nowrap; }
.ds-leak-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ds-leak-kind { display: grid; gap: 8px; }
.ds-leak-kind h3 { font-size: 15px; }
.ds-leaks { list-style: none; margin: 0; padding: 0; display: grid; }
.ds-leaks li { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ds-leaks li:last-child { border-bottom: 0; }
.ds-leak-where { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
@media (max-width: 1100px) { .ds-funnels { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 980px) { .ds-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .ds-tools { width: 100%; }
  .ds-tools select { flex: 1 1 160px; min-width: 0; }
  .ds-grid { gap: var(--s4); }
  .ds-funnels { grid-template-columns: 1fr; gap: var(--s5); }
  table.ds-table { font-size: 12px; }
  table.ds-table th, table.ds-table td { padding: 8px 4px; }  /* "table." to win over table.data's own padding */
  table.ds-table th:first-child, table.ds-table td:first-child { padding-inline-start: 10px; }
  table.ds-table th:last-child, table.ds-table td:last-child { padding-inline-end: 10px; }
  .ds-table tbody th[scope="row"] { font-size: 13px; min-width: 96px; }
  .ds-table .ds-of { display: block; }
  .ds-table .ds-sub { font-size: 11px; }
  .ds-table .ds-sub .i { width: 1em; height: 1em; margin-inline-end: 2px; }
  .ds-table .ds-hint { display: none; }  /* the row names stay; the explanations are on a wider screen and in the CSV's names */
  .ds-table .ds-long { display: none; }
  .ds-table .ds-short { display: inline; }
  .ds-table .rb-dot { display: none; }
  .ds-table tr.ds-indent th[scope="row"] { padding-inline-start: 22px; }
  .ds-table tr.ds-group th > * + * { margin-inline-start: 6px; }
  .ds-table tr.ds-group .ds-gnote { display: block; margin-inline-start: 0; }
}

/* ---------- New batch: the short page (packs, pages, the mix, Make batch; the rest under More options) ---------- */
.sb-main, .sb-more { max-width: 820px; }
.sb-top { display: grid; gap: var(--s4) var(--s5); grid-template-columns: repeat(3, minmax(0, 1fr)); }  /* packs, pages, empty % */
.sb-top input { max-width: 180px; }
.sb-modes { display: grid; gap: var(--s2); border: 0; padding: 0; margin: 0; min-width: 0; }
.sb-modes legend { font-weight: 700; font-size: 14px; padding: 0; margin-bottom: var(--s2); }
.sb-mode { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.sb-mode:has(input:checked) { border-color: var(--progress); background: var(--primary-soft); }
.sb-mode.off { opacity: .5; cursor: default; }
.sb-mode .chip { margin-inline-start: auto; }
.sb-mix { display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--panel-2); }
.sb-mixline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; line-height: 1.6; }
.sb-item { white-space: nowrap; }
.sb-item b { font-variant-numeric: tabular-nums; }
.sb-dot { color: var(--muted); }
.sb-mixline .btn.link { min-height: 0; padding: 0 4px; border: 0; background: none; color: var(--link); text-decoration: underline; font-weight: 700; }
.sb-mix .hint { margin: 0; }
.sb-after { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.sb-choose { display: grid; gap: var(--s3); }
.sb-check { display: grid; gap: var(--s2); padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.sb-check p { margin: 0; }
.sb-short { font-size: 17px; }
.sb-more > summary h2 { display: inline; margin: 0; font-size: 18px; }
.sb-more-body { display: grid; gap: var(--s4); padding-top: var(--s2); }
.sb-rounds { max-width: 380px; }
.sb-gen-opts { padding-top: var(--s3); border-top: 1px solid var(--line); }
.sb-waiting { align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .sb-top { grid-template-columns: 1fr 1fr; gap: var(--s3); }
  .sb-top input { max-width: none; }
  .sb-mode { padding: 10px 12px; }
}

/* ---------- the Split of a batch (New batch and the generator's plan): balanced, one split only, or own numbers ---------- */
.bs-split-wrap { container-type: inline-size; }
.bs-split { grid-template-columns: 1fr 1fr; }  /* Train · Validation / Test · My own numbers */
.bs-split > .sb-mode:first-of-type { grid-column: 1 / -1; }  /* Balanced (recommended) on its own row */
@container (min-width: 640px) { .bs-split { grid-template-columns: repeat(4, minmax(0, 1fr)); } }  /* the four in one row */
.sb-own { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s3) var(--s4); }
.sb-own[hidden] { display: none; }
.sb-own .field { gap: 6px; }
.sb-own input { width: 96px; text-align: center; }
.sb-own-total { padding-bottom: 10px; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .sb-own { gap: var(--s3); }
  .sb-own input { width: 76px; }
}

/* ---------- D29: Texts -> Form designs (designs.js): the grid of design cards, the side panel, the waiting badges ---------- */
.fd-intro { max-width: 82ch; }
.fd-bar { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4); align-items: center; }
.fd-seg { flex-wrap: wrap; }
.fd-seg .fd-n { color: var(--muted); font-weight: 400; margin-inline-start: 4px; }
.fd-seg button[aria-pressed="true"] .fd-n { color: var(--text); }
.fd-waiting { border: 0; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.fd-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.fd-card {
  display: grid; grid-template-rows: auto 1fr; padding: 0; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  color: var(--text); font: inherit; text-align: start; transition: border-color .15s ease-out;
}
.fd-card:hover { border-color: var(--muted); }
.fd-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fd-card.proposed { border-color: color-mix(in oklab, var(--busy) 45%, var(--line)); background: color-mix(in oklab, var(--busy) 5%, var(--card)); }
/* the form copy, cut a little at the bottom (a printed form's last tenth is its margin) */
.fd-thumb { display: block; aspect-ratio: 210 / 270; background: #fff; border-bottom: 1px solid var(--line); overflow: hidden; }
.fd-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.fd-card.rejected .fd-thumb img, .fd-card.retired .fd-thumb img { opacity: .5; filter: grayscale(1); }
.fd-body { display: grid; gap: 6px; padding: 12px 14px 14px; align-content: start; }
.fd-name { font-size: 16px; line-height: 1.3; }
.fd-meta, .fd-uses { font-size: 13px; color: var(--muted); }
.fd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fd-card .chip { max-width: 100%; white-space: normal; }  /* a narrow card (a phone): a long status wraps inside it */
.fd-region b { font-weight: 800; }
.fd-detail { display: grid; gap: var(--s4); }
.fd-detail > p { margin: 0; }
.fd-actions { gap: 10px; }
.fd-reason { display: grid; gap: var(--s3); padding: 16px; border-color: color-mix(in oklab, var(--bad) 40%, var(--line)); }
.fd-reason[hidden] { display: none; }
.fd-reason h3 { margin: 0; font-size: 16px; }
.fd-reason p { margin: 0; }
.fd-previews { display: grid; gap: var(--s4); }
.fd-previews.two { grid-template-columns: 1fr 1fr; }
.fd-sheet { margin: 0; display: grid; gap: 6px; align-content: start; }
.fd-sheet figcaption { display: grid; gap: 2px; }
.fd-sheet figcaption .hint { font-size: 13px; line-height: 1.4; }
.fd-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; margin: 0; }
.fd-facts dt { font-size: 12px; font-weight: 700; color: var(--muted); }
.fd-facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.fd-fit { display: flex; gap: 10px; align-items: flex-start; }
.fd-fit ul { margin: 4px 0; padding-inline-start: 18px; }
.fd-note p { margin: 4px 0 0; }
.fd-fgroup h4 { margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.fd-fgroup ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.fd-fgroup li { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.fd-fkind { min-width: 88px; font-size: 12px; font-weight: 700; color: var(--muted); }
.fd-history { margin: 6px 0 0; padding-inline-start: 18px; display: grid; gap: 8px; }
.fd-json { max-height: 360px; overflow: auto; font-size: 12px; }
.fd-banner {
  display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid color-mix(in oklab, var(--busy) 45%, var(--line)); background: color-mix(in oklab, var(--busy) 7%, var(--card));
}
.fd-banner > .i { color: var(--busy); }
.fd-banner > span { flex: 1 1 240px; }
.fd-count-chip { margin-inline-start: 2px; }
@media (max-width: 760px) {
  .fd-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s3); }
  .fd-body { padding: 10px 12px 12px; }
  .fd-previews.two { grid-template-columns: 1fr; }
  .fd-bar .filters select { min-width: 0; flex: 1 1 140px; }
}
