/* Saad platform styles. Tokens live in tokens.css.

   One loud idea, everything else quiet: the ARCH. The identity guide's colour
   swatches are arch-topped, so the arch frames the thing this platform exists
   for - a hand signing a term - and the subject mascots. Nothing else gets a
   special shape, a shadow or an entrance animation. */

/* ── Base ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 1rem); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.85;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; }
p { margin: 0; }
a { color: var(--clay-strong); text-underline-offset: 0.2em; }
a:hover { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

.skip-link {
  position: absolute; inset-inline-start: 1rem; top: -4rem; z-index: 50;
  background: var(--ink); color: #fff; padding: 0.5rem 1rem; border-radius: var(--r-sm);
}
.skip-link:focus { top: 1rem; color: #fff; }

.container { width: 100%; max-width: var(--page); margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 760px; }
.stack > * + * { margin-top: var(--gap, 1rem); }
/* A section inside a .stack: tight inside, and - because it sets no --gap of
   its own - still spaced from its siblings by the parent's rhythm. */
.stack-tight > * + * { margin-top: 0.75rem; }
.section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.section-tight { padding-block: clamp(1.5rem, 4vw, 2.5rem); }
.muted { color: var(--ink-2); }
.small { font-size: var(--t-sm); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

.display { font-family: var(--font-display); font-weight: 700; line-height: 1.3; }
.page-title { font-family: var(--font-display); font-size: var(--t-2xl); color: var(--slate-deep); }
.section-title { font-size: var(--t-lg); color: var(--slate-deep); }
.lead { font-size: var(--t-md); line-height: 1.8; max-width: var(--measure); }

.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.22em; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 46px; padding: 0.4rem 1.4rem;
  border: 2px solid transparent; border-radius: var(--r-full);
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn-primary { background: var(--clay-strong); color: #fff; }
.btn-primary:hover { background: var(--ink); color: #fff; }
.btn-slate { background: var(--slate); color: #fff; }
.btn-slate:hover { background: var(--slate-deep); color: #fff; }
.btn-quiet { background: transparent; border-color: var(--rule-strong); color: var(--ink); }
.btn-quiet:hover { border-color: var(--ink); color: var(--ink); }
.btn-sm { min-height: 38px; padding: 0.2rem 1rem; font-size: var(--t-sm); }
.btn-block { width: 100%; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--paper); border-bottom: 1px solid var(--rule);
}
.header-row { display: flex; align-items: center; gap: 1.5rem; min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; }
.brand img { width: 50px; height: auto; }
.brand-words { display: flex; flex-direction: column; line-height: 1.3; font-weight: 700; font-size: 0.95rem; }
.brand-words .l1 { color: var(--clay-strong); }
.brand-words .l2 { color: var(--slate); }

.nav { display: flex; gap: 0.25rem; margin-inline-start: auto; }
.nav a {
  padding: 0.5rem 0.9rem; border-radius: var(--r-full);
  color: var(--ink); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--slate-soft); }
.nav a.active { color: var(--clay-strong); font-weight: 700; box-shadow: inset 0 -3px 0 var(--clay); border-radius: 0; }
.header-end { display: flex; align-items: center; gap: 0.5rem; }
.nav-burger { display: none; }

.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); font-weight: 700; font-size: var(--t-sm);
}
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; border-radius: 50%; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu-panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 0.5rem); min-width: 240px;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-md);
  padding: 0.5rem; z-index: 40;
}
.user-menu-head { padding: 0.5rem 0.75rem 0.75rem; border-bottom: 1px solid var(--rule); margin-bottom: 0.25rem; }
.user-menu-item {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  padding: 0.55rem 0.75rem; border: 0; background: none; cursor: pointer;
  border-radius: var(--r-sm); text-decoration: none; color: var(--ink); text-align: start;
}
.user-menu-item:hover { background: var(--slate-soft); color: var(--ink); }

/* ── Flash ────────────────────────────────────────────────────────────────── */
.flash-stack { position: fixed; inset-inline: 0; top: calc(var(--header-h) + 0.75rem); z-index: 45;
  display: grid; justify-items: center; gap: 0.5rem; pointer-events: none; padding-inline: 1rem; }
.flash { pointer-events: auto; display: flex; gap: 0.5rem; align-items: center;
  padding: 0.6rem 1.2rem; border-radius: var(--r-full); font-weight: 600; border: 2px solid; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.flash-error { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }

/* ── The arch ─────────────────────────────────────────────────────────────── */
.arch-stage {
  background: var(--slate); color: #fff;
  border-radius: 50% 50% var(--r-lg) var(--r-lg) / 110px 110px var(--r-lg) var(--r-lg);
  padding: 1.25rem clamp(0.9rem, 3vw, 1.6rem) clamp(0.9rem, 3vw, 1.6rem);
  position: relative; overflow: hidden;
}
.arch-crown { text-align: center; padding: 0.9rem 3rem 1rem; position: relative; }
.arch-crown .icon { width: 2rem; height: 2rem; color: var(--sand); }
.arch-crown strong { display: block; font-size: var(--t-md); }
.arch-crown span { color: var(--stone); font-size: var(--t-sm); }

.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden; background: var(--slate-deep); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-facade {
  position: absolute; inset: 0; width: 100%; border: 0; cursor: pointer;
  display: grid; place-content: center; justify-items: center; gap: 0.6rem;
  color: #fff; font-weight: 600; font-size: var(--t-md);
  background: var(--slate-deep) url('/static/img/logo-mark-light.svg') no-repeat 8% 120% / 46%;
}
.video-facade .play {
  width: 84px; height: 84px; border-radius: 50%; background: var(--clay);
  display: grid; place-content: center; transition: transform var(--dur) var(--ease);
}
.video-facade .play .icon { width: 2.4rem; height: 2.4rem; }
.video-facade:hover .play { transform: scale(1.06); }
.video-missing { display: grid; place-content: center; text-align: center; color: var(--stone); padding: 1rem; }

/* ── Home ─────────────────────────────────────────────────────────────────── */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: clamp(2rem, 5vw, 4.5rem); align-items: center; }
.hero-title { font-family: var(--font-display); font-size: clamp(2.3rem, 5.2vw, var(--t-3xl)); line-height: 1.35; color: var(--slate-deep); }
.hero-title .clay { color: var(--clay-strong); display: block; }

.search { display: flex; gap: 0.5rem; max-width: 560px; }
.search input {
  flex: 1; min-width: 0; min-height: 54px; padding: 0 1.4rem;
  border: 2px solid var(--rule-strong); border-radius: var(--r-full); background: var(--surface);
}
.search input:focus { border-color: var(--clay-strong); outline: none; box-shadow: none; }

/* 128px min: all seven subjects share one row at the page's full width. */
.subjects { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 1rem; }
.subject-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.35rem;
  padding: 1.6rem 0.75rem 1.1rem; border-radius: var(--arch);
  background: color-mix(in srgb, var(--tint) 38%, var(--surface));
  border: 2px solid transparent; text-decoration: none; color: var(--ink);
}
a.subject-card:hover { border-color: var(--ink); color: var(--ink); }
.subject-card img { height: 112px; width: auto; }
.subject-card strong { font-size: 1.05rem; }
.subject-card.is-empty { opacity: 0.72; }

.index-rows { border-top: 2px solid var(--slate-deep); }
.index-row {
  display: flex; align-items: baseline; gap: 1rem; padding: 0.95rem 0.25rem;
  border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink);
}
.index-row:hover { background: var(--surface); color: var(--clay-strong); }
.index-row strong { font-size: var(--t-md); }
.index-row .count { margin-inline-start: auto; color: var(--ink-2); white-space: nowrap; }
/* A row that carries an action («أوراقي»): the title is the link, the form sits at the end. */
div.index-row { flex-wrap: wrap; align-items: center; }
div.index-row > a { color: inherit; text-decoration: none; }
div.index-row > a:hover { color: var(--clay-strong); }

.band { background: var(--clay); color: #fff; border-radius: var(--r-lg); padding: clamp(1.5rem, 4vw, 2.75rem); }
.band h2 { font-family: var(--font-display); font-size: var(--t-xl); }
.band .btn-primary { background: #fff; color: var(--clay-strong); }
.band .btn-primary:hover { background: var(--ink); color: #fff; }
.band-row { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }

/* ── Dictionary index ─────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 40px; padding: 0.15rem 1rem;
  border: 2px solid var(--rule-strong); border-radius: var(--r-full);
  text-decoration: none; color: var(--ink); background: var(--surface); font-weight: 500;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active { background: var(--slate); border-color: var(--slate); color: #fff; font-weight: 700; }
.chip .count { font-size: var(--t-sm); opacity: 0.85; }

.letters { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.letter {
  width: 44px; height: 44px; display: inline-grid; place-content: center;
  border-radius: var(--r-sm); font-weight: 700; font-size: 1.15rem;
  text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--rule);
}
a.letter:hover { border-color: var(--ink); }
.letter.active { background: var(--clay-strong); border-color: var(--clay-strong); color: #fff; }
.letter.off { background: transparent; color: var(--rule-strong); border-style: dashed; }

.entries { columns: 3 260px; column-gap: 2.5rem; border-top: 2px solid var(--slate-deep); padding-top: 0.25rem; }
.entry {
  break-inside: avoid; display: block; padding: 0.8rem 0.25rem;
  border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink);
}
.entry:hover { background: var(--surface); }
.entry:hover .entry-title { color: var(--clay-strong); }
.entry-title { display: block; font-size: 1.2rem; font-weight: 700; line-height: 1.5; }
.entry-sub { display: flex; justify-content: space-between; gap: 0.75rem; color: var(--ink-2); font-size: var(--t-sm); }

.empty { border: 2px dashed var(--rule-strong); border-radius: var(--r-md); padding: 2.5rem 1.5rem; text-align: center; }

.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; }

/* ── Term page ────────────────────────────────────────────────────────────── */
.crumbs { display: flex; flex-wrap: wrap; gap: 0.4rem; font-size: var(--t-sm); color: var(--ink-2); }
.crumbs a { color: var(--ink-2); }
.term-title { font-family: var(--font-display); font-size: clamp(2.2rem, 5vw, var(--t-3xl)); color: var(--slate-deep); line-height: 1.3; }
.langs { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 0; }
.langs div { display: flex; gap: 0.5rem; align-items: baseline; }
.langs dt { color: var(--ink-2); font-size: var(--t-sm); }
.langs dd { margin: 0; font-weight: 600; font-size: var(--t-md); }

.term-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(1.5rem, 4vw, 3rem); align-items: start; }
.term-aside { position: sticky; top: calc(var(--header-h) + 1.5rem); }

.block { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: clamp(1.1rem, 3vw, 1.75rem); }
.block-head { display: flex; align-items: center; gap: 0.6rem; font-size: var(--t-md); color: var(--slate-deep);
  padding-bottom: 0.7rem; margin-bottom: 1rem; border-bottom: 2px solid var(--clay); }
.block-head .icon { color: var(--clay-strong); width: 1.5rem; height: 1.5rem; }

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 0.9rem; }
.prose img { border-radius: var(--r-sm); display: block; }
.prose table { border-collapse: collapse; margin-inline: auto; }
.prose td, .prose th { border: 1px solid var(--rule-strong); padding: 0.4rem 1rem; text-align: center; }
.prose h4, .prose h5 { font-size: var(--t-base); }

.locked { background: var(--clay-soft); border: 2px solid var(--clay); border-radius: var(--r-md); padding: clamp(1.25rem, 3vw, 2rem); }
.locked h2 { font-size: var(--t-lg); color: var(--slate-deep); display: flex; gap: 0.6rem; align-items: center; }
.locked ul { margin: 0; padding-inline-start: 1.2rem; }
.locked-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.side-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 1.25rem; }
.side-card h2 { font-size: 1.05rem; color: var(--slate-deep); margin-bottom: 0.6rem; }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid var(--rule); }
.side-list li:last-child { border-bottom: 0; }
.side-list .state { margin-inline-start: auto; color: var(--ink-2); font-size: var(--t-sm); display: inline-flex; gap: 0.25rem; align-items: center; }
.side-list .none { color: var(--rule-strong); }

.meter { display: flex; gap: 0.35rem; }
.pip { width: 26px; height: 32px; border-radius: 13px 13px 6px 6px; border: 2px solid var(--slate); }
.pip.used { background: var(--slate); }

.related { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.term-nav { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.term-nav a { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; font-weight: 600; }

.staff-bar { background: var(--ink); color: #fff; border-radius: var(--r-md); padding: 0.9rem 1.25rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.staff-bar form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-inline-start: auto; }
.staff-bar .btn-quiet { color: #fff; border-color: #fff; }
.staff-bar .btn-quiet:hover { background: #fff; color: var(--ink); }

/* ── Status pill: shape + word, never colour alone ────────────────────────── */
.status { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.1rem 0.8rem;
  border-radius: var(--r-full); border: 2px solid currentColor; font-size: var(--t-sm); font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 0.65em; height: 0.65em; background: currentColor; }
.status-draft { color: var(--ink-2); }
.status-draft::before { background: transparent; border: 2px solid currentColor; border-radius: 50%; }
.status-review { color: #8A5A00; }
.status-review::before { transform: rotate(45deg); }
.status-approved { color: var(--slate-deep); }
.status-approved::before { border-radius: 50%; }
.status-published { color: var(--ok); }
.status-published::before { border-radius: 50% 50% 2px 2px; }
.status-retired { color: var(--bad); }
.status-retired::before { height: 3px; }

/* ── Courses ──────────────────────────────────────────────────────────────── */
.course-rows { border-top: 2px solid var(--slate-deep); }
.course-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 1.25rem; align-items: center;
  padding: 1.25rem 0.25rem; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.course-row:hover { background: var(--surface); color: var(--ink); }
.course-row:hover h3 { color: var(--clay-strong); }
.course-row h3 { font-size: var(--t-md); }
.course-thumb { width: 96px; height: 96px; border-radius: var(--arch); display: grid; place-items: end center;
  background: color-mix(in srgb, var(--tint) 38%, var(--surface)); overflow: hidden; }
.course-thumb img { height: 78px; width: auto; }
.price { font-weight: 700; white-space: nowrap; }

.outline-section + .outline-section { margin-top: 1.75rem; }
.outline-section h3 { font-size: var(--t-md); color: var(--slate-deep); padding-bottom: 0.5rem; border-bottom: 2px solid var(--clay); }
.lesson-list { list-style: none; margin: 0; padding: 0; counter-reset: lesson; }
.lesson-list li { counter-increment: lesson; border-bottom: 1px solid var(--rule); }
.lesson-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.8rem 0.25rem; text-decoration: none; color: var(--ink); }
.lesson-link::before { content: counter(lesson); width: 2rem; color: var(--ink-2); font-weight: 700; text-align: center; }
a.lesson-link:hover { background: var(--surface); color: var(--clay-strong); }
.lesson-link .state { margin-inline-start: auto; font-size: var(--t-sm); color: var(--ink-2); display: inline-flex; gap: 0.3rem; align-items: center; white-space: nowrap; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: clamp(1.5rem, 4vw, 2.5rem); }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.field .hint { font-size: var(--t-sm); color: var(--ink-2); }
.input { width: 100%; min-height: 50px; padding: 0 1rem; border: 2px solid var(--rule-strong); border-radius: var(--r-sm); background: var(--surface); }
.input:focus { border-color: var(--clay-strong); outline: none; box-shadow: none; }
textarea.input { padding: 0.6rem 1rem; min-height: 90px; }

.role-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; border: 0; padding: 0; margin: 0; }
.role-picker legend { font-weight: 600; margin-bottom: 0.3rem; padding: 0; }
.role-option { position: relative; }
.role-option input { position: absolute; opacity: 0; inset: 0; }
.role-option span { display: grid; place-content: center; min-height: 56px; border: 2px solid var(--rule-strong);
  border-radius: var(--r-sm); font-weight: 600; cursor: pointer; text-align: center; }
.role-option input:checked + span { border-color: var(--clay-strong); background: var(--clay-soft); box-shadow: inset 0 0 0 1px var(--clay-strong); }
.role-option input:focus-visible + span { box-shadow: var(--focus); }

.auth-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); gap: clamp(1.5rem, 5vw, 4rem); align-items: center; }
.auth-side { background: var(--slate) url('/static/img/logo-mark-light.svg') no-repeat -12% 118% / 70%;
  color: #fff; border-radius: var(--arch); padding: 5rem 2rem 3rem; text-align: center; min-height: 440px;
  display: flex; flex-direction: column; justify-content: center; gap: 1rem; }
.auth-side .display { font-size: var(--t-xl); }

/* ── Staff tables ─────────────────────────────────────────────────────────── */
.count-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.6rem; }
.count-cell { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 0.9rem 1rem; text-decoration: none; color: var(--ink); display: block; }
a.count-cell:hover { border-color: var(--ink); color: var(--ink); }
.count-cell b { display: block; font-size: var(--t-xl); line-height: 1.2; color: var(--slate-deep); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); }
.table { width: 100%; border-collapse: collapse; font-size: 0.98rem; }
.table th { text-align: start; background: var(--slate-soft); color: var(--slate-deep); padding: 0.7rem 1rem; white-space: nowrap; }
.table td { padding: 0.7rem 1rem; border-top: 1px solid var(--rule); vertical-align: middle; }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ── Exercises («التدريب») ────────────────────────────────────────────────── */
/* Every state below is told twice: a shape or an icon AND words. The clay or
   green is the third signal, never the first. */
/* No `margin` shorthand on these lists: it would beat the owl selectors that space them. */
.exercise-list { list-style: none; margin-inline: 0; margin-bottom: 0; padding: 0; display: grid; gap: 1.25rem; }
.exercise { background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--r-md);
  padding: clamp(1rem, 3vw, 1.5rem); scroll-margin-top: calc(var(--header-h) + 1rem); }
.exercise > * + * { margin-top: 1rem; }
.exercise-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1.25rem;
  font-size: var(--t-sm); color: var(--ink-2); }
.exercise-kind { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 700;
  font-size: var(--t-base); color: var(--slate-deep); }
.tier { display: inline-flex; align-items: center; gap: 0.4rem; }
.tier-marks { display: inline-flex; gap: 3px; }
.tier-marks i { width: 0.7em; height: 0.7em; border: 2px solid var(--slate); border-radius: 2px; }
.tier-marks i.on { background: var(--slate); }

.exercise fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.exercise legend { padding: 0; margin-bottom: 0.9rem; font-size: var(--t-md); font-weight: 700;
  line-height: 1.6; color: var(--ink); }
.stimulus { max-width: 440px; margin-bottom: 1.25rem; }
.stimulus > * + * { margin-top: 0.5rem; }
/* A sign inside an exercise is one of several on screen: a smaller play button. */
.exercise .video-facade { font-size: var(--t-base); gap: 0.4rem; }
.exercise .video-facade .play { width: 56px; height: 56px; }
.exercise .video-facade .play .icon { width: 1.6rem; height: 1.6rem; }
.item-image { display: block; align-self: flex-start; max-height: 220px; width: auto; object-fit: contain; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--rule); }

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.75rem; }
.option { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.6rem 0.9rem 0.9rem;
  background: var(--surface); border: 2px solid var(--rule-strong); border-radius: var(--r-sm); }
.option-pick { display: flex; align-items: center; gap: 0.7rem; min-height: 44px;
  font-weight: 600; font-size: var(--t-md); cursor: pointer; }
.option-pick input { flex: none; width: 1.5rem; height: 1.5rem; margin: 0; accent-color: var(--clay-strong); }
.option:has(input:checked) { border-color: var(--clay-strong); background: var(--clay-soft);
  box-shadow: inset 0 0 0 1px var(--clay-strong); }
.tried { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: var(--t-sm); font-weight: 600; color: var(--bad); white-space: nowrap; }
/* Where :has() exists the whole card takes the focus ring; elsewhere the
   radio keeps its own - focus is never invisible. */
@supports selector(:has(*)) {
  .option:has(input:focus-visible) { box-shadow: var(--focus); }
  .option-pick input:focus-visible { box-shadow: none; }
}

.match > * + * { margin-top: 1rem; }
.match-bank { background: var(--slate-soft); border-radius: var(--r-sm); padding: 0.9rem; }
.match-items { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.6rem; }
.match-item { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.6rem;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-sm); }
.letter-badge { flex: none; width: 2.2rem; height: 2.2rem; display: grid; place-content: center;
  border-radius: 50%; background: var(--slate); color: #fff; font-weight: 700; }
.match-what { flex: 1; min-width: 0; }
.match-what > * + * { margin-top: 0.5rem; }
.match-rows, .order-rows { list-style: none; margin-inline: 0; margin-bottom: 0; padding: 0; display: grid; gap: 0.6rem; }
.order-rows { margin-top: 0.6rem; }
.match-row, .order-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.7rem 0.9rem;
  background: var(--surface); border: 2px solid var(--rule-strong); border-radius: var(--r-sm); }
/* Matching: a card per item, its picker right under it - three signs fit one
   row on a desktop and stack on a phone. */
.match-rows { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.match-row { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 0.7rem; }
.match-row .match-what { flex: 1 1 auto; }
.match-pick, .order-pick { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.match-pick { flex-direction: column; align-items: stretch; gap: 0.2rem; }
.match-pick .input { min-width: 0; }
.order-pick .input { width: auto; min-width: 4.5rem; }
.order-what { flex: 1 1 120px; min-width: 0; }
.order-what > * + * { margin-top: 0.5rem; }
.order-number { flex: none; width: 2.4rem; height: 2.4rem; display: grid; place-content: center;
  border-radius: 50%; background: var(--slate); color: #fff; font-weight: 700; font-size: var(--t-md); }
.order-moves { display: flex; gap: 0.4rem; margin-inline-start: auto; }
.order-move[disabled] { opacity: 0.4; cursor: default; }
/* With JavaScript the rows' order is the answer and the buttons move them;
   the selects keep submitting it, out of sight. */
.order-rows.is-enhanced .order-pick { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; }
.order-rows.is-enhanced .order-row { position: relative; }

.exercise-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.feedback { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 1rem;
  border: 2px solid; border-radius: var(--r-sm); }
.feedback .icon { width: 1.5rem; height: 1.5rem; }
.feedback-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.feedback-bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); border-style: dashed; }
.hint-box { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.8rem 1rem;
  background: var(--slate-soft); border: 2px dashed var(--slate); border-radius: var(--r-sm); }
.hint-box > .icon { width: 1.6rem; height: 1.6rem; color: var(--slate-deep); margin-top: 0.2rem; }
.again summary { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 38px; padding: 0.2rem 1rem;
  border: 2px solid var(--rule-strong); border-radius: var(--r-full); font-weight: 600; font-size: var(--t-sm);
  cursor: pointer; list-style: none; }
.again summary::-webkit-details-marker { display: none; }
.again summary:hover { border-color: var(--ink); }
.again[open] summary { margin-bottom: 1rem; }
.author-line { margin-top: 1rem; }

/* ── Mastery: filled arches + icon + word ─────────────────────────────────── */
.mastery { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0.35rem 0.7rem; }
.meter-sm { gap: 0.2rem; }
.meter-sm .pip { width: 14px; height: 18px; border-radius: 7px 7px 3px 3px; }
.mastery-word { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 700; color: var(--slate-deep); white-space: nowrap; }
.mastery-due { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0 0.7rem; white-space: nowrap;
  border: 2px dashed var(--clay-strong); border-radius: var(--r-full); color: var(--clay-strong);
  font-size: var(--t-sm); font-weight: 600; }
.mastery-line { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem 1rem; padding: 0.7rem 1rem;
  background: var(--slate-soft); border-radius: var(--r-sm); }
.mastery-line > a { margin-inline-start: auto; }
.level-key { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0.6rem; margin-inline: 0; margin-bottom: 0; }
.level-key > div { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 0.9rem 1rem; }
.level-key dt { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.level-key dt b { font-size: var(--t-xl); line-height: 1.2; color: var(--slate-deep); }
.level-key dd { margin: 0.3rem 0 0; color: var(--ink-2); font-size: var(--t-sm); }

.solution { background: var(--ok-soft); border: 2px solid var(--ok); border-radius: var(--r-md); padding: 1rem 1.25rem; }
.solution h2 { font-size: var(--t-md); color: var(--ok); display: flex; align-items: center; gap: 0.5rem; }
.solution ol, .solution ul { margin: 0.5rem 0 0; padding-inline-start: 1.4rem; }
.item-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.6rem; align-items: end; }
.pair-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.check-line { display: flex; gap: 0.6rem; align-items: center; cursor: pointer; font-weight: 600; }
.check-line input { width: 1.3rem; height: 1.3rem; accent-color: var(--clay-strong); }

/* ── The student map («خريطتي») ───────────────────────────────────────────── */
/* Three states, three SHAPES: a filled circle (done), a diamond (current), a
   dashed square (locked) - each with its own icon, and its word printed beside
   it. Nothing on the map pulses: motion here only ever answers the person. */
.map-mark { flex: none; width: 2.6rem; height: 2.6rem; display: grid; place-content: center; }
.map-mark .icon { width: 1.3rem; height: 1.3rem; }
.map-mark-done { border-radius: 50%; background: var(--slate-deep); color: #fff; }
.map-mark-current { width: 2.1rem; height: 2.1rem; margin: 0.25rem; transform: rotate(45deg);
  border: 3px solid var(--clay-strong); border-radius: 6px; background: var(--clay-soft); color: var(--clay-strong); }
.map-mark-current .icon { transform: rotate(-45deg); }
.map-mark-locked { border: 2px dashed var(--ink-2); border-radius: 4px; color: var(--ink-2); }

.map-legend { list-style: none; margin-inline: 0; margin-bottom: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 0.6rem; }
.map-legend li { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 1rem;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); line-height: 1.5; }

.map-next { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem 1.25rem; padding: clamp(1rem, 3vw, 1.5rem);
  background: var(--clay-soft); border: 2px solid var(--clay-strong); border-radius: var(--r-md); }
.map-next-body { flex: 1 1 240px; min-width: 0; }
.map-next-body > * + * { margin-top: 0.35rem; }
.map-progress { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.map-progress .meter { flex-wrap: wrap; }
.map-state { display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem 0.8rem; font-weight: 700; font-size: var(--t-sm); color: var(--slate-deep); }
.map-next-tag { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0 0.7rem; white-space: nowrap;
  border: 2px solid var(--clay-strong); border-radius: var(--r-full); color: var(--clay-strong); }
.map-plan { display: flex; align-items: flex-start; gap: 0.4rem; color: var(--ink-2); }

/* The path: a line down the side, a numbered stop per stage, and the concepts
   of a stage side by side - what can be learned in any order. */
.map-stages { list-style: none; margin-inline: 0; margin-bottom: 0; padding: 0; }
.map-stage { position: relative; padding-inline-start: 3.5rem; padding-bottom: 1.75rem; }
.map-stage::before { content: ""; position: absolute; inset-inline-start: 1.15rem; top: 0; bottom: 0; width: 4px;
  background: var(--rule-strong); border-radius: 2px; }
.map-stage:last-child { padding-bottom: 0; }
.map-stage:last-child::before { bottom: auto; height: 1.25rem; }
.map-stage-no { position: absolute; inset-inline-start: 0; top: 0; width: 2.5rem; height: 2.5rem; border-radius: 50%;
  display: grid; place-content: center; background: var(--paper); border: 3px solid var(--slate);
  font-weight: 700; color: var(--slate-deep); }
.map-stage-title { min-height: 2.5rem; display: flex; align-items: center; font-weight: 600; color: var(--ink-2); }
.map-row { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); }
.map-node { display: flex; align-items: flex-start; gap: 0.9rem; padding: 0.9rem 1rem; background: var(--surface);
  border: 2px solid var(--rule-strong); border-radius: var(--r-md); scroll-margin-top: calc(var(--header-h) + 1rem); }
.map-node-current { border-color: var(--clay-strong); }
.map-node-next { background: var(--clay-soft); box-shadow: inset 0 0 0 2px var(--clay-strong); }
.map-node-locked { background: transparent; border-style: dashed; }
.map-node:target { box-shadow: var(--focus); }
.map-node-body { flex: 1; min-width: 0; }
.map-node-body > * + * { margin-top: 0.35rem; }
.map-node-title { font-size: var(--t-md); line-height: 1.5; }
.map-node-locked .map-node-title { color: var(--ink-2); }

/* ── Short codes (join a class, link a parent) ────────────────────────────── */
.code-box { display: inline-flex; align-items: center; gap: 0.75rem; padding: 0.35rem 1.1rem;
  background: var(--surface); border: 2px dashed var(--slate); border-radius: var(--r-sm); }
.code-box strong { font-size: var(--t-md); letter-spacing: 0.18em; font-variant-numeric: tabular-nums; }
.code-box-lg strong { font-size: var(--t-xl); }
.code-inline { letter-spacing: 0.12em; font-weight: 700; color: var(--ink); }
.code-input { max-width: 16rem; text-align: center; font-size: var(--t-md); font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase; }

/* ── The class table and the error bank ───────────────────────────────────── */
.hotspots { list-style: none; margin-inline: 0; margin-bottom: 0; padding: 0; display: grid; gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.hotspot { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.8rem 1rem; line-height: 1.6;
  background: var(--bad-soft); color: var(--bad); border: 2px dashed var(--bad); border-radius: var(--r-md); }
.hotspot > .icon { width: 1.6rem; height: 1.6rem; margin-top: 0.15rem; }
.cell-flag { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0 0.5rem; white-space: nowrap;
  border: 2px dashed var(--bad); border-radius: var(--r-full); color: var(--bad); background: var(--bad-soft);
  font-size: var(--t-sm); font-weight: 700; }
.cell-note { display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap;
  font-size: var(--t-sm); font-weight: 600; color: var(--clay-strong); }
.flag-line { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--bad); font-weight: 600; }
.col-sum { display: block; font-size: var(--t-sm); font-weight: 500; color: var(--ink-2); white-space: nowrap; }

.class-table th, .class-table td { border-inline-start: 1px solid var(--rule); }
.class-table thead th { vertical-align: top; min-width: 8.25rem; white-space: normal; line-height: 1.5; }
.class-table thead th:first-child { min-width: 8.5rem; }
.class-table th[scope="row"] { position: sticky; inset-inline-start: 0; z-index: 1; min-width: 8.5rem;
  text-align: start; padding: 0.7rem 1rem; background: var(--slate-soft); border-top: 1px solid var(--rule);
  color: var(--slate-deep); line-height: 1.5; }
.class-table .cell { vertical-align: top; }
.class-table .cell > * { display: flex; }
.class-table .cell > * + * { margin-top: 0.3rem; }
.class-table .cell > .cell-flag, .class-table .cell > .cell-note { display: inline-flex; }
.cell-word { align-items: center; gap: 0.3rem; font-weight: 700; font-size: var(--t-sm); color: var(--slate-deep); white-space: nowrap; }
.cell-word.muted { font-weight: 500; color: var(--ink-2); }
.cell-struggling { background: var(--bad-soft); box-shadow: inset 0 0 0 2px var(--bad); }
.class-table-wrap:focus-visible { box-shadow: var(--focus); }

.filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.75rem; }
.filter-row label { font-weight: 600; }
.filter-row .input { width: auto; min-width: 12rem; min-height: 42px; }
/* On a narrow screen the bank scrolls inside its region; a question is never
   crushed into a column of single words. */
.bank-table .bank-what { min-width: 15rem; }
.bank-table .bank-term { min-width: 7rem; }
.rate-cell { min-width: 11rem; }
.rate { display: block; height: 0.6rem; margin-top: 0.3rem; border: 2px solid var(--bad); border-radius: var(--r-full); overflow: hidden; }
.rate-fill { display: block; height: 100%; background: var(--bad); }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.link-list .row-actions { align-items: center; justify-content: space-between; }

/* A targeted worksheet before it is created: the paper question, then its key. */
.paper-list { margin-inline: 0; margin-bottom: 0; padding-inline-start: 1.4rem; display: grid; gap: 1rem; }
.paper-q > * + * { margin-top: 0.6rem; }
.paper-prompt { white-space: pre-line; font-weight: 600; }

/* ── The parent's summary: three numbers, plain words ─────────────────────── */
.family-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 0.6rem;
  margin-inline: 0; margin-bottom: 0; }
.family-count { padding: 1rem 1.1rem; background: var(--surface); border: 2px solid var(--rule-strong); border-radius: var(--r-md); }
.family-count dt { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: var(--t-md); color: var(--slate-deep); }
.family-count dt .icon { width: 1.6rem; height: 1.6rem; }
.family-count dd { margin: 0.2rem 0 0; line-height: 1.5; }
.family-count dd b { display: block; font-size: var(--t-2xl); line-height: 1.2; color: var(--slate-deep); }
.family-strong { border-color: var(--ok); }
.family-strong dt, .family-strong dd b { color: var(--ok); }
.family-help { border: 2px dashed var(--bad); background: var(--bad-soft); }
.family-help dt, .family-help dd b { color: var(--bad); }
.family-week { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.7rem 1rem;
  background: var(--slate-soft); border-radius: var(--r-sm); }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer { margin-top: clamp(3rem, 8vw, 6rem); background: var(--slate) url('/static/img/logo-mark-light.svg') no-repeat 4% 135% / 300px;
  color: #fff; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.footer-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 2rem; padding-block: 3rem 2rem; }
.footer-tag { font-family: var(--font-display); font-size: var(--t-lg); line-height: 1.6; }
.site-footer h2 { font-size: 1.05rem; margin-bottom: 0.6rem; color: var(--sand); }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { padding: 0.15rem 0; }
.site-footer a { color: #fff; }
.footer-base { border-top: 1px solid rgba(255, 255, 255, 0.25); padding-block: 1rem; font-size: var(--t-sm); color: var(--stone); }

/* ── Error ────────────────────────────────────────────────────────────────── */
.error-page { text-align: center; padding-block: clamp(3rem, 10vw, 7rem); }
.error-code { font-family: var(--font-display); font-size: 6rem; line-height: 1; color: var(--clay); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 920px) {
  .hero, .term-layout, .auth-wrap { grid-template-columns: minmax(0, 1fr); }
  .term-aside { position: static; }
  .auth-side { display: none; }
  .footer-row { grid-template-columns: 1fr 1fr; }
  .nav-burger { display: inline-flex; margin-inline-start: auto; }
  .nav { display: none; position: absolute; inset-inline: 0; top: 100%; flex-direction: column; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--rule-strong); padding: 0.5rem var(--gutter) 1rem; margin: 0; }
  .nav.open { display: flex; }
  .nav a { border-radius: var(--r-sm); padding: 0.8rem 0.75rem; }
  .nav a.active { box-shadow: inset -4px 0 0 var(--clay); }
}
@media (max-width: 640px) {
  .brand-words { font-size: 0.82rem; }
  .brand img { width: 42px; }
  .header-end .btn-quiet { display: none; }
  .course-row { grid-template-columns: 64px minmax(0, 1fr); }
  .course-row .price { grid-column: 2; }
  .course-thumb { width: 64px; height: 64px; }
  .course-thumb img { height: 52px; }
  .footer-row { grid-template-columns: 1fr; }
  .role-picker { grid-template-columns: 1fr; }
  .search { flex-direction: column; }
  .letter { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
