/* Content dashboard — editorial studio.
 *
 * Two palettes live here and they must not be confused:
 *   · CONTENT accents (--blue … --red, --tint-*) are the APP's colours. Lessons,
 *     chapters and blocks are tagged with them and the previews render them, so
 *     they are data, not decoration — never restyle these to suit the chrome.
 *   · CHROME (--bg … --danger) is the dashboard's own skin. Everything the
 *     editor looks AT rather than edits should be built from these.
 */

:root {
  /* content accents — the app's palette (do not touch) */
  --blue: #1F4BC0; --teal: #0E9A8E; --green: #17703A;
  --plum: #6B3FA0; --amber: #B4690E; --red: #B3261E;
  --tint-blue: #EEF2FD; --tint-teal: #E6F6F4; --tint-green: #EAF4EC;
  --tint-plum: #F1ECF8; --tint-amber: #FDF6E9; --tint-red: #FBECEB;

  /* chrome — warm paper, ink, one accent */
  --bg: #F7F4ED;
  --surface: #FFFFFF;
  --surface-alt: #FBF9F4;
  --surface-2: #F2EEE4;
  --text: #1C1B18;
  --text-soft: #5A574E;
  --text-faint: #8C887C;
  --text-ghost: #A29D90;
  --border: #E4DFD3;
  --border-strong: #D2CBBB;

  --accent: #31519E;
  --accent-deep: #26407F;
  --accent-tint: #EAEEF7;
  --live: #1E7A55;
  --live-tint: #E7F2EC;
  --warn: #9A6212;
  --warn-deep: #C08A1E;
  --warn-tint: #F6EEDE;
  --danger: #B3261E;
  --danger-tint: #FBECEB;

  --font-ui: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-ar: Amiri, 'Times New Roman', serif;
  --font-ar-ui: Cairo, system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --ctl-h: 34px;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------------------
 * Shell: a permanent sidebar beside a scrolling page column.
 * ------------------------------------------------------------------------- */
#app { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  background: var(--surface-alt);
  border-inline-end: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh;
}
/* Editing screens ask for the width; the rail keeps the icons reachable. */
body.rail #sidebar { width: 64px; align-items: center; }
body.rail .sb-label, body.rail .sb-item span, body.rail .sb-item .sb-count,
body.rail .brand-name, body.rail .brand-sub, body.rail .sb-foot-text { display: none; }
body.rail .sb-item { justify-content: center; padding: 0; width: 36px; }
body.rail .sb-brand { padding: 22px 0 18px; }
body.rail .sb-nav { padding: 6px 0; align-items: center; }

.sb-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: var(--radius-sm); flex: none;
  background: var(--text); color: var(--bg);
  font-family: var(--font-display); font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand-name { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 10.5px; color: var(--text-faint); }

.sb-nav { display: flex; flex-direction: column; gap: 20px; padding: 6px 12px; flex: 1; overflow-y: auto; }
.sb-group { display: flex; flex-direction: column; gap: 2px; }
.sb-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-ghost); padding: 0 8px 7px;
}
.sb-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 8px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  color: var(--text-soft); font-size: 13px; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.sb-item:hover { background: var(--surface-2); color: var(--text); }
.sb-item.on {
  background: var(--surface); border-color: var(--border); color: var(--text);
  font-weight: 600; box-shadow: 0 1px 2px rgba(28,27,24,.05);
}
.sb-item svg { flex: none; }
.sb-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-count { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.sb-foot {
  border-top: 1px solid var(--border); padding: 13px 20px 15px;
  display: flex; flex-direction: column; gap: 9px;
}
.sb-foot-row { display: flex; align-items: center; gap: 7px; }
.sb-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--live); flex: none; }
.sb-foot-text { font-size: 11.5px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#page { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- top bar (now the page header, inside the page column) ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
#crumbs { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; overflow: hidden; }
#crumbs a { color: var(--text-faint); text-decoration: none; font-size: 12px; font-weight: 500; }
#crumbs a:hover { color: var(--accent); }
#crumbs .sep { color: var(--border-strong); font-size: 11px; }
#crumbs .cur { color: var(--text); font-size: 12px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.dirty-flag {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px; border-radius: var(--radius-sm);
  background: var(--warn-tint); color: var(--warn);
  font-size: 12px; font-weight: 600;
}
.dirty-flag::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: var(--warn-deep); }

#main { padding: 0 28px 40px; flex: 1; }
.loading { padding: 60px; text-align: center; color: var(--text-faint); }

/* ---------- page header block (used by the views) ---------- */
.page-head { padding: 24px 0 20px; }
.page-title {
  margin: 0; font-family: var(--font-display); font-weight: 400;
  font-size: 30px; line-height: 1.1; letter-spacing: -0.015em;
}
.page-lede {
  margin: 8px 0 0; font-size: 13px; line-height: 1.5;
  color: var(--text-soft); max-width: 640px; text-wrap: pretty;
}
.page-actions { display: flex; align-items: center; gap: 10px; flex: none; }

/* ---------- generic controls ---------- */
.btn {
  font-family: var(--font-ui); font-weight: 500; font-size: 12.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-soft); border-radius: var(--radius-sm);
  height: var(--ctl-h); padding: 0 13px; cursor: pointer;
}
.btn:hover { border-color: var(--border-strong); color: var(--text); }
.btn-primary {
  background: var(--text); border-color: var(--text); color: var(--surface-alt); font-weight: 600;
}
.btn-primary:hover { background: #000; border-color: #000; color: #fff; }
.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-tint); color: var(--danger); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 11.5px; border-radius: 7px; }
.btn:disabled { opacity: 0.45; cursor: default; }

input[type="text"], input[type="number"], input[type="email"], input[type="password"], textarea, select {
  font-family: var(--font-ui); font-size: 12.5px; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 11px; background: var(--surface); width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint);
}
textarea { resize: vertical; line-height: 1.7; }
textarea.rtl, input.rtl, .rtl, [dir="rtl"] {
  direction: rtl; text-align: right; font-family: var(--font-ar); font-size: 16px;
}
label.fld { display: block; margin-bottom: 10px; }
label.fld > span { display: block; font-size: 11px; font-weight: 600; color: var(--text-soft); margin-bottom: 5px; }
.fld-row { display: flex; gap: 10px; }
.fld-row > * { flex: 1; }

/* ---------- cards / grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.grid-units { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.unit-card { padding: 0; overflow: hidden; cursor: pointer; transition: box-shadow .14s ease, border-color .14s ease; }
.unit-card:hover { border-color: var(--border-strong); box-shadow: 0 6px 20px rgba(28,27,24,.07); }
.unit-card .cover { height: 132px; position: relative; background-color: var(--surface-2); }
.unit-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.unit-card .cover .num {
  position: absolute; top: 12px; inset-inline-start: 12px;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.93); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.unit-card .body { padding: 14px 15px 15px; display: flex; flex-direction: column; gap: 9px; }
.unit-card .ar { font-family: var(--font-ar); font-weight: 700; font-size: 18px; line-height: 1.45; direction: rtl; text-align: right; }
.unit-card .fr { color: var(--text-faint); font-size: 12px; line-height: 1.4; }
.unit-card .stats { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 3px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 5px; padding: 3px 8px; font-size: 10.5px; font-weight: 500;
  border: 1px solid transparent; background: var(--surface-2); color: var(--text-soft);
  cursor: pointer; user-select: none;
}
.chip.on { color: #fff; border-color: transparent; }
.chip-static { cursor: default; }

/* pill filter (subject / status filters) */
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 13px;
  border-radius: 999px; font-size: 12px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
}
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.on { background: var(--text); border-color: var(--text); color: var(--surface-alt); }

.section-title {
  font-size: 21px; font-weight: 400; font-family: var(--font-display);
  letter-spacing: -0.01em; margin: 22px 0 10px;
  display: flex; align-items: center; gap: 10px;
}
.section-title .hint { font-size: 11.5px; color: var(--text-faint); font-weight: 400; font-family: var(--font-ui); }

/* a subject / group heading with a rule under it */
.group-head {
  display: flex; align-items: baseline; gap: 12px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-top: 30px;
}
.group-code {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  color: #fff; padding: 3px 7px; border-radius: 5px;
}
.group-sub { font-size: 11.5px; font-weight: 600; color: var(--text-faint); padding: 16px 0 12px; }

/* status pills shared by every page */
.state {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}
.state-live { background: var(--live-tint); color: var(--live); }
.state-warn { background: var(--warn-tint); color: var(--warn); }
.state-off { background: var(--surface-2); color: var(--text-faint); }

/* ---------- editor layout ---------- */
.editor-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) {
  .editor-split { grid-template-columns: 1fr; }
  .left-pane, .right-pane { position: static; max-height: none; overflow-y: visible; padding-inline-end: 0; }
}
/* Left (editor) and right (preview) each pin under the topbar and scroll on
 * their own, so editing far down the block list doesn't force scrolling the
 * preview back into view (and vice versa). */
.left-pane, .right-pane {
  position: sticky; top: 62px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  padding-inline-end: 6px;
}
.preview-sticky { position: static; }
.preview-frame {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; min-height: 200px;
}
.preview-frame .pv-label { font-size: 10.5px; font-weight: 700; color: var(--text-faint); margin-bottom: 8px; letter-spacing: 0.04em; text-transform: uppercase; }

/* ---------- block list ---------- */
.block-item { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 10px; overflow: hidden; }
.block-item > .head {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--surface-alt); border-bottom: 1px solid var(--border);
}
.block-item .kind-badge { font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 7px; border-radius: 5px; color: #fff; flex: none; }
.block-item .head .spacer { flex: 1; }
.block-item .body { padding: 10px; }
.block-item textarea { min-height: 64px; }

.add-block-bar { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.add-block-bar .btn { display: flex; align-items: center; gap: 6px; }
.add-block-bar .dot { width: 9px; height: 9px; border-radius: 3px; }

/* ---------- table editor ---------- */
.tbl-editor { border-collapse: collapse; width: 100%; }
.tbl-editor td, .tbl-editor th { border: 1px solid var(--border); padding: 3px; }
.tbl-editor input { border: none; border-radius: 4px; padding: 5px 7px; font-size: 12px; }
.tbl-editor input:focus { outline: none; box-shadow: 0 0 0 2px var(--accent-tint); }

/* ---------- modal ---------- */
#modal-root .overlay {
  position: fixed; inset: 0; background: rgba(28,27,24,0.42); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(2px);
}
#modal-root .modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); max-width: 900px; width: 100%;
  max-height: 92vh; overflow: auto; padding: 22px;
  box-shadow: 0 24px 64px rgba(28,27,24,0.22);
}
#modal-root .modal.wide { max-width: 1150px; }
.modal h3 { margin: 0 0 14px; font-family: var(--font-display); font-weight: 400; font-size: 21px; letter-spacing: -0.01em; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* ---------- equation editor ---------- */
.eq-preview {
  direction: ltr; min-height: 64px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; font-size: 20px; overflow-x: auto; margin-bottom: 10px;
}
.eq-input { direction: ltr; font-family: "Cascadia Code", Consolas, monospace; font-size: 13.5px; min-height: 74px; }
.eq-palettes { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.eq-palette-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.eq-palette-row .pal-label { font-size: 10px; font-weight: 800; color: var(--text-faint); width: 86px; flex: none; }
.eq-btn {
  font-family: "Cascadia Code", Consolas, monospace; font-size: 12px;
  border: 1px solid var(--border-strong); background: var(--surface-alt);
  border-radius: 7px; padding: 4px 8px; cursor: pointer; direction: ltr;
}
.eq-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
.eq-btn .katex { font-size: 1em; }
/* empty \square slots stand out so you can see what still needs filling */
.eq-preview .katex .mord + .mord, .eq-preview .katex { color: inherit; }
.eq-error { color: var(--red); font-size: 12px; direction: ltr; font-family: Consolas, monospace; text-align: center; }
.eq-editor .eq-palettes { max-height: 220px; overflow-y: auto; padding-right: 4px; }
.eq-more-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
#modal-root .modal .eq-palettes { max-height: none; }
#modal-root .modal .eq-preview { min-height: 92px; font-size: 24px; }

/* ---------- ƒx button attached to ordinary fields ---------- */
.math-field { position: relative; width: 100%; }
.math-field.inline { display: flex; gap: 6px; align-items: center; }
.math-field.inline > input { flex: 1; min-width: 0; }
.math-bar { display: flex; justify-content: flex-end; margin-bottom: 3px; }
.eq-fx {
  font-family: "Cambria Math", Georgia, serif; font-style: italic;
  font-size: 13px; line-height: 1; padding: 3px 9px; flex: none;
  color: var(--plum); border-color: var(--border-strong);
}
.eq-fx:hover { border-color: var(--plum); color: var(--plum); background: var(--tint-plum); }
/* the ƒx affordance is quiet until you interact with the field */
.math-field .math-bar .eq-fx { opacity: 0.55; transition: opacity 0.12s; }
.math-field:hover .math-bar .eq-fx,
.math-field:focus-within .math-bar .eq-fx { opacity: 1; }

/* ---------- figure / plot editor ---------- */
.fig-editor { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); padding: 10px; }
.fe-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fe-bar .fe-label { font-size: 11px; font-weight: 800; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.fe-kind { width: auto; min-width: 120px; }
.fe-json { border: 1px solid var(--border-strong); border-radius: 8px; }
.fe-json-err { color: var(--red); font-size: 11px; font-family: Consolas, monospace; min-height: 14px; margin-top: 4px; }
.fe-raw-details { margin-top: 8px; }
.fe-raw-details summary { cursor: pointer; font-size: 11px; font-weight: 700; color: var(--text-soft); }

.pe-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
@media (max-width: 900px) { .pe-layout { grid-template-columns: 1fr; } }
.pe-preview {
  position: sticky; top: 62px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 8px;
}
.pe-preview svg { width: 100%; height: auto; display: block; }
.pe-controls { display: flex; flex-direction: column; gap: 12px; }
.pe-card { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 10px; }
.pe-card-title { font-size: 12px; font-weight: 800; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.pe-hint { font-size: 10.5px; font-weight: 600; color: var(--text-faint); }
.pe-grid { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.pe-field { display: flex; flex-direction: column; gap: 3px; font-size: 10.5px; font-weight: 700; color: var(--text-soft); }
.pe-field > span { font-size: 10px; }
.pe-field input, .pe-color, .pe-type { padding: 5px 7px; font-size: 12px; }
.pe-color, .pe-type { width: auto; }
.pe-scale { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.pe-row { border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-bottom: 8px; background: var(--surface-alt); }
.pe-row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.pe-curve-fields { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-top: 6px; }
.pe-check { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--text-soft); cursor: pointer; }
.pe-check input { width: auto; }
.pe-points-mini { display: flex; flex-direction: column; gap: 4px; }
.pe-xy { display: flex; gap: 5px; align-items: center; }

/* segmented Plot | SVG control */
.fe-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.fe-seg-btn { font-family: inherit; font-weight: 700; font-size: 12px; padding: 6px 14px; border: none; background: var(--surface); color: var(--text-soft); cursor: pointer; }
.fe-seg-btn + .fe-seg-btn { border-left: 1px solid var(--border-strong); }
.fe-seg-btn.on { background: var(--blue); color: #fff; }
.fe-svg-preview { min-height: 120px; }
.drop-zone.over { border-color: var(--accent); background: var(--accent-tint); color: var(--accent); }

/* ---------- visual table editor ---------- */
.tbl-editor { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); padding: 10px; }
.tbl-toolbar { display: flex; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.tbl-step { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; color: var(--text-soft); }
.tbl-step-n { min-width: 20px; text-align: center; font-size: 13px; color: var(--text); }
.tbl-wrap { overflow-x: auto; }
.tbl-editor-grid { border-collapse: separate; border-spacing: 4px; }
.tbl-editor-grid th, .tbl-editor-grid td { padding: 0; vertical-align: top; position: relative; }
.tbl-cell { position: relative; }
.tbl-input { width: 150px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 22px 6px 8px; font-size: 13px; background: var(--surface); }
.tbl-cell.head .tbl-input { font-weight: 700; background: var(--tint-blue); }
.tbl-cell .eq-fx { position: absolute; top: 3px; inset-inline-end: 3px; padding: 1px 5px; font-size: 11px; opacity: 0; transition: opacity 0.1s; }
.tbl-cell:focus-within .eq-fx, .tbl-cell:hover .eq-fx { opacity: 1; }
.tbl-colx, .tbl-rowx {
  border: none; background: transparent; color: var(--text-faint); cursor: pointer;
  font-size: 14px; font-weight: 800; padding: 0 4px;
}
.tbl-colx { position: absolute; top: -2px; inset-inline-end: 2px; }
.tbl-colx:hover, .tbl-rowx:hover { color: var(--red); }
.tbl-corner, .tbl-rowx-cell { width: 22px; }
.tbl-add-row { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- card cover + edit affordances ---------- */
.card-edit-btn, .card-cover-btn {
  position: absolute; top: 12px; border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 7px; font-size: 13px;
  background: rgba(28,27,24,0.5); color: #fff;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .12s ease, background .12s ease;
}
.unit-card:hover .card-edit-btn, .unit-card:hover .card-cover-btn,
.card-edit-btn:focus-visible, .card-cover-btn:focus-visible { opacity: 1; }
.card-edit-btn { right: 12px; }
.card-cover-btn { right: 46px; }
.card-edit-btn:hover, .card-cover-btn:hover { background: rgba(28,27,24,0.82); }
/* the destructive one only goes red once it is actually under the cursor */
.card-cover-btn.danger { right: 80px; background: rgba(28,27,24,0.5); }
.card-cover-btn.danger:hover { background: var(--danger); }
.cover-thumb {
  width: 100%; background-size: cover; background-position: center;
  background-color: var(--surface-2); border-radius: var(--radius-sm); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cover-thumb-empty { color: var(--text-faint); font-weight: 700; font-size: 12px; background: rgba(255,255,255,0.7); padding: 4px 10px; border-radius: 8px; }

/* ---------- simulation editor ---------- */
.sim-type { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.sim-type-btn { font-family: inherit; font-weight: 700; font-size: 12px; padding: 5px 14px; border: none; background: var(--surface); color: var(--text-soft); cursor: pointer; }
.sim-type-btn + .sim-type-btn { border-left: 1px solid var(--border-strong); }
.sim-type-btn.on { background: var(--plum); color: #fff; }
.sim-children-wrap { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
.sim-children-label { font-size: 11px; font-weight: 800; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.sim-children { display: flex; flex-direction: column; gap: 8px; }
.sim-child { background: var(--surface-alt); padding: 10px; }
.sim-html-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sim-html-state { font-size: 11px; font-weight: 700; color: var(--text-soft); }

/* ---------- plot / shapes editors ---------- */
.fig-canvas-wrap { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.fig-canvas-wrap svg { width: 100%; height: auto; display: block; user-select: none; }
.fig-canvas-wrap svg .draggable { cursor: grab; }
.fig-canvas-wrap svg .draggable:active { cursor: grabbing; }
.fig-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.series-row, .el-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 7px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: var(--surface); }
.series-row input[type="number"] { width: 74px; }
.series-row input[type="text"] { width: 110px; }
.fig-note { font-size: 11px; color: var(--text-faint); margin-top: 6px; }

/* ---------- images manager ---------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.img-cell { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.img-cell img { width: 100%; height: 90px; object-fit: cover; display: block; }
.img-cell .meta { padding: 7px 9px; font-size: 10.5px; color: var(--text-soft); }
.img-cell .meta b { color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-cell.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.drop-zone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 26px;
  text-align: center; color: var(--text-soft); font-size: 12.5px; cursor: pointer;
  background: var(--surface-alt);
}
.drop-zone:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }

/* ---------- lists ---------- */
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 8px; }
.list-row:hover { border-color: var(--border-strong); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .ar-text { font-family: var(--font-ar); direction: rtl; text-align: right; font-size: 15.5px; }
.muted { color: var(--text-faint); font-size: 11.5px; }
.mono { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.warn-box {
  background: var(--warn-tint); border: 1px solid #EBDCBF; border-radius: var(--radius-sm);
  padding: 11px 14px; font-size: 12px; line-height: 1.55; color: var(--warn); margin: 10px 0;
}

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--surface-alt); border-radius: var(--radius-sm); padding: 11px 16px; font-size: 12.5px; font-weight: 500; box-shadow: 0 10px 30px rgba(28,27,24,0.28); }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--live); color: #fff; }

/* tabs inside a view */
.tab-bar { display: flex; align-items: center; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tab-bar .tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 0 0 11px; font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; background: none; color: var(--text-faint); text-decoration: none;
}
.tab-bar .tab:hover { color: var(--text); }
.tab-bar .tab.on { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--text); }
/* a tab bar that also carries buttons keeps them off the baseline */
.tab-bar .btn { margin-bottom: 8px; }

.katex { font-size: 1.05em; }

/* Rich editor — nested ordered lists number with Arabic abjad (أ ب ج د…);
   top-level ordered stays 1. 2., bulleted stays •. Mirrors the app shell. */
@counter-style abjad-ar {
  system: fixed;
  symbols: "أ" "ب" "ج" "د" "هـ" "و" "ز" "ح" "ط" "ي" "ك" "ل" "م" "ن" "س" "ع" "ف" "ص" "ق" "ر" "ش" "ت" "ث" "خ" "ذ" "ض" "ظ" "غ";
  suffix: ") ";
}
.rich-edit ol, .rich-edit ul { padding-inline-start: 1.7em; margin: 4px 0; }
.rich-edit ol { list-style-type: decimal; }
.rich-edit ol ol { list-style-type: abjad-ar; }
.rich-edit ul { list-style-type: disc; }

/* ---------------------------------------------------------------------------
 * Login gate (auth.js)
 * ------------------------------------------------------------------------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(28, 27, 24, 0.72);
  backdrop-filter: blur(6px);
}
.auth-card {
  width: min(360px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(28, 27, 24, 0.3);
}
.auth-card h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 24px; letter-spacing: -0.015em; }
.auth-hint { margin: 0 0 4px; font-size: 13px; opacity: 0.65; }
.auth-card .input { width: 100%; box-sizing: border-box; }
.auth-err {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-tint);
}
.auth-who { font-size: 12px; opacity: 0.6; margin-inline-end: 8px; }

/* Material Symbols — the app's icon set, so the Subjects page's icon picker can
   preview the real glyph. Google's css2 endpoint ships only the @font-face; the
   class rule (and the `liga` feature that turns the name into the glyph) is ours. */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

/* sidebar account row */
.sb-avatar {
  width: 24px; height: 24px; border-radius: 999px; flex: none;
  background: var(--surface-2); color: var(--text-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 600;
}
.sb-signout { height: 24px; padding: 0 8px; font-size: 11px; border-radius: 6px; flex: none; }
body.rail .sb-signout { display: none; }

/* ---------------------------------------------------------------------------
 * Wording & icons (visualEditorView)
 *
 * Three columns: the screens to walk through, the phone you edit on, and the
 * inspector that shows the selected string in BOTH languages at once — which is
 * the thing the old single-column editor could never do.
 * ------------------------------------------------------------------------- */
.ve-layout {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr) 300px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; min-height: 640px;
}
@media (max-width: 1240px) { .ve-layout { grid-template-columns: 190px minmax(0, 1fr); } .ve-inspect { display: none; } }

.ve-rail {
  border-inline-end: 1px solid var(--border); background: var(--surface-alt);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 1px;
}
.ve-rail-label { font-size: 10px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-ghost); padding: 0 10px 8px; }
.ve-rail-sep { height: 1px; background: var(--border); margin: 10px 0; }
.ve-screen {
  display: flex; align-items: center; gap: 9px; height: 33px; padding: 0 10px;
  border: 1px solid transparent; border-radius: 7px; cursor: pointer;
  font-size: 12.5px; color: var(--text-soft);
}
.ve-screen:hover { background: var(--surface-2); color: var(--text); }
.ve-screen.on { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(28,27,24,.05); }
.ve-screen-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ve-screen-n { font-size: 10.5px; font-weight: 600; color: var(--warn); font-variant-numeric: tabular-nums; }
.ve-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--border-strong); flex: none; }
.ve-dot.hot { background: var(--warn-deep); }

.ve-stage { background: var(--surface-2); padding: 18px 20px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; overflow: auto; }
.ve-hint { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-soft); }
.ve-hint-swatch { width: 22px; height: 11px; border-radius: 3px; background: #FFF4D6; box-shadow: inset 0 -1.5px 0 var(--warn-deep); }

.ve-phone {
  width: 320px; background: #fff; border-radius: 24px;
  border: 1px solid var(--border-strong); box-shadow: 0 18px 44px rgba(28,27,24,.13);
  overflow: hidden; display: flex; flex-direction: column; min-height: 560px;
}

/* the editable affordance — and the variant that survives a filled button */
.ve-text { cursor: text; border-radius: 5px; padding: 2px 5px; background: #FFF9E8; }
.ve-text:hover { background: #FFF4D6; box-shadow: inset 0 -1.5px 0 var(--warn-deep); }
.ve-text.sel { background: #FFF4D6; box-shadow: inset 0 -1.5px 0 var(--warn-deep), 0 0 0 2px #F0D79A; }
.ve-text.on-dark { background: rgba(255,255,255,.17); }
.ve-text.on-dark:hover { background: rgba(255,255,255,.32); box-shadow: inset 0 -1.5px 0 rgba(255,255,255,.85); }
.ve-text.on-dark.sel { background: rgba(255,255,255,.34); box-shadow: inset 0 -1.5px 0 #fff, 0 0 0 2px rgba(255,255,255,.5); }
.ve-inline {
  width: auto; min-width: 70px; padding: 1px 5px; border-radius: 5px;
  border: 1px solid var(--accent); box-shadow: 0 0 0 2px var(--accent-tint);
  font-size: inherit; font-family: inherit; color: inherit;
}

.ve-icon {
  font-family: var(--font-mono); font-size: 9px; line-height: 1.3; color: var(--text-soft);
  border: 1px dashed var(--border-strong); background: transparent;
  border-radius: 6px; padding: 3px 6px; cursor: pointer;
  /* icon names run long (qr_code_scanner); the slot must not blow out the
     phone's tab bar, so it truncates and keeps the full name in the tooltip. */
  max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ve-icon:hover { border-color: var(--accent); background: var(--accent-tint); color: var(--accent); }
.ve-icon.changed { border-style: solid; border-color: var(--accent); background: var(--accent-tint); color: var(--accent); }
.ve-icon-pick { width: auto; font-size: 11px; padding: 2px 4px; }

.ve-inspect { border-inline-start: 1px solid var(--border); background: var(--surface-alt); display: flex; flex-direction: column; }
.ve-inspect-head { padding: 15px 18px 12px; border-bottom: 1px solid var(--border); }
.ve-inspect-title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.ve-inspect-key { display: block; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); margin-top: 5px; }
.ve-inspect-body { flex: 1; padding: 16px 18px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.ve-inspect-foot { border-top: 1px solid var(--border); padding: 12px 18px 14px; font-size: 11px; color: var(--text-faint); line-height: 1.55; }
.ve-inspect-empty { padding: 34px 20px; text-align: center; color: var(--text-faint); font-size: 12px; line-height: 1.6; }
.ve-inspect-empty-t { font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }

.ve-field { display: flex; flex-direction: column; gap: 6px; }
.ve-field-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ve-field-label { font-size: 11px; font-weight: 600; color: var(--text-soft); }
.ve-default { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 7px; }
.ve-default-ar { font-family: var(--font-ar); font-size: 15px; line-height: 1.6; direction: rtl; text-align: right; color: var(--text-faint); }
.ve-default-fr { font-size: 12px; color: var(--text-faint); }
.ve-where { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.ve-where-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.ve-lang-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.ve-lang { height: var(--ctl-h); padding: 0 14px; border: none; background: none; font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; color: var(--text-soft); cursor: pointer; }
.ve-lang + .ve-lang { border-inline-start: 1px solid var(--border); }
.ve-lang.on { background: var(--text); color: var(--surface-alt); }

.ve-table { width: 100%; align-self: stretch; display: flex; flex-direction: column; }
.ve-table-top { display: flex; align-items: center; gap: 12px; padding: 0 0 14px; }
.ve-table-top input { flex: 1; }
.ve-table-head, .ve-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) minmax(0, 1fr) 108px; gap: 12px; align-items: center; }
.ve-table-head {
  padding: 10px 14px; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint);
}
.ve-table-body {
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--surface); max-height: 54vh; overflow-y: auto;
}
.ve-row { padding: 8px 14px; border-bottom: 1px solid var(--surface-2); cursor: default; }
.ve-row:last-child { border-bottom: none; }
.ve-row:hover { background: var(--surface-alt); }
.ve-row.edited { background: #FFFCF3; }
.ve-row-key { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ve-row input { font-size: 12px; padding: 5px 8px; }

/* ---------- unit section cards ---------- */
.unit-ar-title { font-family: var(--font-ar); font-weight: 700; font-size: 28px; line-height: 1.35; direction: rtl; text-align: right; }

.sec-card {
  display: flex; flex-direction: column; gap: 8px; padding: 15px 16px;
  text-decoration: none; color: inherit; cursor: pointer;
  transition: box-shadow .14s ease, border-color .14s ease;
}
.sec-card:hover { border-color: var(--border-strong); box-shadow: 0 6px 20px rgba(28,27,24,.07); }
.sec-card.off { opacity: 0.6; }
.sec-top { display: flex; align-items: center; gap: 10px; }
.sec-rule { width: 3px; height: 18px; border-radius: 2px; background: var(--sec); flex: none; }
.sec-name { font-size: 14px; font-weight: 600; flex: 1; }
.sec-count { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-soft); }
.sec-desc { font-size: 12px; line-height: 1.5; color: var(--text-faint); }
.sec-toggle {
  font-family: var(--font-ui); font-size: 10.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-faint);
  border-radius: 999px; padding: 4px 10px; cursor: pointer; flex: none;
}
.sec-toggle.on { background: var(--live-tint); border-color: transparent; color: var(--live); }
.sec-toggle:hover { border-color: var(--border-strong); }

/* ---------------------------------------------------------------------------
 * Form kit (js/fields.js)
 *
 * The rule that drives all of it: a field's LABEL must be the most legible
 * thing in the row. Before this, labels were 11px at --text-soft above a 12.5px
 * control at --text — fainter and smaller than the value they named, which is
 * how staff ended up typing the profession into the workplace box.
 * ------------------------------------------------------------------------- */

.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f-label {
  font-size: 12px; font-weight: 650; letter-spacing: .005em;
  color: var(--text); line-height: 1.3;
}
.f-req { color: var(--danger); font-style: normal; margin-inline-start: 3px; }
.f-hint { font-size: 11px; line-height: 1.5; color: var(--text-faint); }

.f-group { margin-bottom: 22px; }
.f-group-title {
  margin: 0 0 12px; padding-bottom: 7px;
  font-family: var(--font-display); font-size: 15px; font-weight: 500;
  color: var(--text); border-bottom: 1px solid var(--border);
}
.f-grid { display: flex; flex-direction: column; gap: 14px; }
.f-row { display: flex; gap: 12px; flex-wrap: wrap; }
.f-row > * { flex: 1 1 180px; min-width: 0; }
.f-wide { flex-basis: 100%; }

/* Controls get a touch more presence than the browser default so the label
 * above them is clearly a label and not a heading floating over nothing. */
.fld {
  font-family: var(--font-ui); font-size: 13px; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 11px; background: var(--surface); width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.fld:hover:not(:focus) { border-color: var(--text-ghost); }
.fld:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.fld::placeholder { color: var(--text-ghost); }
textarea.fld { resize: vertical; line-height: 1.7; min-height: 64px; }
select.fld { cursor: pointer; }

.f-toggle {
  display: flex; align-items: flex-start; gap: 9px; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.f-toggle:hover { border-color: var(--border-strong); }
.f-toggle input { margin-top: 2px; width: 15px; height: 15px; accent-color: var(--accent); flex: none; }
.f-toggle > span { display: flex; flex-direction: column; gap: 3px; }
.f-toggle-label { font-size: 12.5px; font-weight: 600; color: var(--text); }

/* ---------- colour picker ---------- */
.cp { display: flex; flex-direction: column; gap: 9px; }
.cp-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.cp-dot {
  width: 28px; height: 28px; padding: 0; cursor: pointer;
  border-radius: 50%; background: var(--dot);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  transition: transform .1s ease, box-shadow .1s ease;
}
.cp-dot:hover { transform: scale(1.08); }
/* The selected swatch is marked by a ring in the CHROME accent, not by a tick:
 * a tick has to be light or dark and would vanish on half the palette. */
.cp-dot.on { box-shadow: 0 0 0 2px var(--accent); transform: scale(1.06); }
.cp-custom { display: flex; align-items: center; gap: 8px; }
.cp-native {
  width: 34px; height: 34px; padding: 2px; flex: none; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}
.cp-hex { max-width: 120px; font-family: var(--font-mono); text-transform: uppercase; }

/* ---------- image drop / preview ---------- */
.imgfld { display: flex; align-items: center; gap: 12px; }
.imgfld-preview {
  width: 76px; height: 76px; flex: none; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2) center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; color: var(--text-ghost); text-align: center;
}
.imgfld-preview.round { border-radius: 50%; }
.imgfld-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.imgfld-name { font-size: 11px; color: var(--text-faint); word-break: break-all; }

/* ---------------------------------------------------------------------------
 * Sessions page (js/views/sessionsView.js)
 *
 * Master/detail rather than a stack of expanded cards: a term has ten or twenty
 * sessions, and a stack of twenty full forms is a page nobody can navigate.
 * The list carries only what tells one session from another — when, who, and
 * whether it is live.
 * ------------------------------------------------------------------------- */

.sess-page { max-width: 1180px; margin: 1.5rem auto; padding: 0 4px; }
.sess-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sess-split { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 940px) { .sess-split { grid-template-columns: 1fr; } }

.sess-list {
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 16px; max-height: calc(100vh - 120px); overflow: auto;
  padding-inline-end: 4px;
}
.sess-group {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-faint); margin: 12px 0 2px;
}
.sess-group:first-child { margin-top: 0; }

.sess-row {
  display: flex; flex-direction: column; gap: 4px; width: 100%;
  text-align: start; font: inherit; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .12s ease, background .12s ease;
}
.sess-row:hover { border-color: var(--border-strong); }
/* The selected row is marked with a solid inline edge, which survives beside a
 * LIVE badge that is already red — a coloured background would fight it. */
.sess-row.on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); background: var(--accent-tint); }
.sess-row-head { display: flex; align-items: center; gap: 6px; }
.sess-badge {
  font-size: 9.5px; font-weight: 700; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 999px; white-space: nowrap;
}
.sess-when { margin-inline-start: auto; font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.sess-title {
  font-family: var(--font-ar); font-size: 15px; line-height: 1.5;
  direction: rtl; text-align: right; color: var(--text);
}
.sess-meta { font-size: 11px; color: var(--text-faint); }

.sess-pane {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
}
.sess-detail-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.sess-empty {
  padding: 28px 20px; text-align: center; font-size: 12.5px; color: var(--text-faint);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
}

/* ---------- notifications page ---------- */
.notif-page { max-width: 860px; margin: 1.5rem auto; padding: 0 4px; }
.notif-list { display: flex; flex-direction: column; gap: 16px; }
.notif-card { padding: 18px 20px; }
.notif-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
/* The type control is the one field that changes what every other field means,
 * so it is sized and weighted like a heading rather than like a form input. */
.notif-type { width: auto; min-width: 190px; font-weight: 650; font-size: 13.5px; }
.notif-active {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-soft); cursor: pointer;
}
.notif-active input { width: 15px; height: 15px; accent-color: var(--accent); }
.live-box {
  padding: 9px 13px; border-radius: var(--radius-sm); font-size: 12.5px;
  background: var(--live-tint); color: var(--live);
}

/* ---------- section card: visible / locked / hidden ---------- */
.sec-states { display: inline-flex; gap: 0; border: 1px solid var(--border-strong); border-radius: 999px; overflow: hidden; }
.sec-state {
  font: inherit; font-size: 10.5px; font-weight: 650; cursor: pointer;
  padding: 3px 9px; border: 0; background: var(--surface); color: var(--text-faint);
  border-inline-end: 1px solid var(--border);
}
.sec-state:last-child { border-inline-end: 0; }
.sec-state:hover { background: var(--surface-2); color: var(--text); }
.sec-state.on { color: #fff; }
.sec-state.on.visible { background: var(--live); }
.sec-state.on.locked { background: var(--warn-deep); }
.sec-state.on.hidden { background: var(--text-faint); }
/* Locked reads as "held back", not as "off": a dashed edge in the warning
 * colour, where hidden stays fully faded out. */
.sec-card.locked { border-style: dashed; border-color: var(--warn-deep); }
.sec-card.locked .sec-name { color: var(--warn); }

/* ---------- subject card preview ---------- */
.subj-preview {
  height: 92px; border-radius: var(--radius-sm); overflow: hidden;
  background-size: cover; background-position: center;
  display: flex; align-items: flex-end; padding: 10px 12px;
  border: 1px solid var(--border);
}
.subj-preview > span {
  font-family: var(--font-ar); font-size: 17px; font-weight: 700; color: #fff;
  direction: rtl; text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

/* ---------------------------------------------------------------------------
 * Equation-aware fields (js/smartField.js)
 *
 * The chip has to read as ONE object: a formula the caret steps over rather
 * than walks into. A tinted, bordered pill does that; underlining or colouring
 * the maths alone would still look like text.
 * ------------------------------------------------------------------------- */

.smartf-wrap { display: flex; flex-direction: column; gap: 6px; }
.smartf-bar { display: flex; gap: 6px; }

.smartf {
  min-height: 42px; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: var(--font-ui); font-size: 13px; line-height: 2.1;
  overflow-wrap: anywhere;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.smartf:hover:not(:focus) { border-color: var(--text-ghost); }
.smartf:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.smartf.rtl { direction: rtl; text-align: right; font-family: var(--font-ar); font-size: 16px; }
.smartf.multi { min-height: 96px; }
.smartf:empty::before {
  content: attr(data-placeholder);
  color: var(--text-ghost);
  /* Not selectable, so clicking the placeholder puts the caret in the field
   * rather than selecting the hint. */
  pointer-events: none;
}

.eqchip {
  display: inline-block; vertical-align: middle; cursor: pointer;
  margin: 0 2px; padding: 2px 7px;
  border: 1px solid var(--accent-tint); border-radius: 6px;
  background: var(--accent-tint); color: var(--text);
  /* The chip's own maths is LTR whatever the sentence around it is doing. */
  direction: ltr; text-align: left;
  transition: border-color .1s ease, background .1s ease;
}
.eqchip:hover { border-color: var(--accent); background: #fff; }
.eqchip.block { display: block; margin: 6px 0; padding: 8px 10px; text-align: center; }
.eqchip.bad {
  background: var(--danger-tint); border-color: var(--danger); color: var(--danger);
  font-family: var(--font-mono); font-size: 11.5px;
}
.eqchip .katex { font-size: 1.02em; }

/* The raw-source escape hatch is hidden until asked for. */
.smartf-raw { display: none; font-family: var(--font-mono); font-size: 12px; }
.smartf-wrap.showing-source .smartf { display: none; }
.smartf-wrap.showing-source .smartf-raw { display: block; }
