/* Tawjihi — design tokens
   ink: the colour of the exam pen. marker: the highlighter students use on notes.
   The answer-sheet bubble is the one signature element; everything else stays quiet. */
:root {
  --ink: #1B2A4A;
  --ink-2: #2D4270;
  --marker: #F4C430;
  --marker-soft: #FFF4CC;
  --ok: #2F7D4F;
  --ok-soft: #E3F2E8;
  --bad: #B3261E;
  --bad-soft: #FBE9E7;
  --warn: #9A6700;
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --line: #DDE3EA;
  --text: #1E2430;
  --muted: #5F6B7A;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 2px rgba(27, 42, 74, .06), 0 4px 16px rgba(27, 42, 74, .05);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  /* form controls: one place to retheme every input, select and textarea */
  --field-bg: #FFFFFF;
  --field-bg-muted: #F4F6F9;
  --field-border: #C9D2DD;
  --field-placeholder: #8792A2;
  --field-ring: rgba(45, 66, 112, .15);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.65; color: var(--text); background: var(--bg); }
img { max-width: 100%; height: auto; }
/* no underlined links anywhere (owner's choice): links are told apart by colour and change colour on hover */
a { color: var(--ink-2); text-decoration: none; }
a:hover { color: var(--ink); }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.3; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; max-width: 72ch; }
:focus-visible { outline: 3px solid var(--marker); outline-offset: 2px; border-radius: 3px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* keyboard users jump past the menu; visible only while focused */
.skip-link { position: absolute; inset-block-start: .5rem; inset-inline-start: .5rem; z-index: 100; padding: .5rem 1rem; border-radius: var(--radius-s); background: var(--marker); color: var(--ink); font-weight: 600; transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.page:focus { outline: none; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #DCE3F0; padding: 1.25rem 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 1.25rem 1.25rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.2rem; }
.brand:hover, .brand:focus-visible { color: #fff; opacity: .92; }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid var(--marker); display: grid; place-items: center; font-size: .95rem; color: var(--marker); }
.side nav a { display: flex; align-items: center; gap: .65rem; padding: .55rem 1.25rem; color: #C5CFE0; text-decoration: none; border-inline-start: 3px solid transparent; }
.side nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.side nav a.active { color: #fff; background: rgba(255,255,255,.08); border-inline-start-color: var(--marker); }
.side nav .group { padding: 1rem 1.25rem .3rem; font-size: .8rem; color: #8A97B0; }
.side .count { margin-inline-start: auto; background: var(--marker); color: var(--ink); border-radius: 99px; font-size: .75rem; padding: 0 .45rem; font-weight: 600; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.75rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none !important; }
.page { padding: 1.75rem; max-width: 1200px; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 260px; z-index: 50; transform: translateX(-105%); transition: transform .2s; }
  [dir="rtl"] .side { transform: translateX(105%); }
  .side.open { transform: none !important; }
  .menu-btn { display: inline-flex !important; }
  .page { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
}

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-flat { background: transparent; border: 0; padding: 0; }
.grid { display: grid; gap: 1rem; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1rem 1.1rem; }
.stat b { display: block; font-size: 1.6rem; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .9rem; }

.subject-tile { display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1rem 1.1rem; border-inline-start: 5px solid var(--c, var(--ink)); }
.subject-tile:hover { border-color: var(--c, var(--ink)); }
.subject-tile strong { display: block; color: var(--ink); font-size: 1.1rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
/* wide tables and any [data-drag-scroll] row: no scrollbar; swipe, trackpad, or press and drag (js/drag-scroll.js) */
.table-wrap, [data-drag-scroll] { scrollbar-width: none; }
.table-wrap::-webkit-scrollbar, [data-drag-scroll]::-webkit-scrollbar { display: none; }
@media (pointer: fine) {
  .table-wrap.is-dragging, [data-drag-scroll].is-dragging { cursor: grabbing; user-select: none; }
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem .85rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .875rem; background: #F8FAFC; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* ---------- forms ---------- */
label { display: block; font-weight: 500; margin-bottom: .3rem; color: var(--ink); }
.field { margin-bottom: 1rem; }
.hint { font-size: .85rem; color: var(--muted); margin-top: .25rem; }
/* Every text-like control shares one look, wherever it sits (inside .field or not).
   An <input> with no type attribute is a text box too, so the rule is written as
   "every input except the non-text kinds" instead of a list of types that misses some.
   :where() keeps the specificity of a plain element selector, so any class rule
   (exam sheet, print page, .check …) still wins without !important. */
input:where(:not([type=checkbox], [type=radio], [type=hidden], [type=file], [type=range], [type=color],
  [type=submit], [type=button], [type=reset], [type=image])), select, textarea {
  width: 100%; min-width: 0; font: inherit; line-height: 1.4; color: var(--text); background-color: var(--field-bg);
  border: 1px solid var(--field-border); border-radius: var(--radius-s); padding: .55rem .7rem; margin: 0;
}
input::placeholder, textarea::placeholder { color: var(--field-placeholder); opacity: 1; }
textarea { min-height: 7rem; resize: vertical; line-height: 1.6; }
textarea[rows="2"], textarea[rows="3"] { min-height: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--field-ring); }
input:disabled, select:disabled, textarea:disabled, input[readonly], textarea[readonly] { background-color: var(--field-bg-muted); }
input:disabled, select:disabled, textarea:disabled { color: var(--muted); cursor: not-allowed; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); }
/* file picker: a framed box whose button looks like a ghost .btn */
input[type=file] { width: 100%; max-width: 100%; font: inherit; font-size: .9rem; color: var(--muted); background: var(--field-bg);
  border: 1px dashed var(--field-border); border-radius: var(--radius-s); padding: .4rem; }
input[type=file]::file-selector-button { font: inherit; font-weight: 500; color: var(--ink); background: var(--field-bg-muted);
  border: 1px solid var(--field-border); border-radius: var(--radius-s); padding: .35rem .8rem; margin-inline-end: .75rem; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: #E6EBF2; }
input[type=file]:focus-visible { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--field-ring); }
/* colour swatch */
input[type=color] { inline-size: 3rem; block-size: 2.6rem; flex: none; border: 1px solid var(--field-border); border-radius: var(--radius-s);
  padding: 3px; background: var(--field-bg); cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 4px; }
input[type=color]::-moz-color-swatch { border: 0; border-radius: 4px; }
input[type=color]:focus-visible { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--field-ring); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }
.error { color: var(--bad); font-size: .875rem; margin-top: .25rem; }
.inline-form { display: inline; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 500; line-height: 1.2; padding: .6rem 1rem; border-radius: var(--radius-s); border: 1px solid transparent; cursor: pointer; text-decoration: none; background: var(--ink); color: #fff; white-space: nowrap; }
.btn:hover { background: var(--ink-2); }
.btn-ghost { background: transparent; color: var(--ink); border-color: #C9D2DD; }
.btn-ghost:hover { background: #EEF2F7; }
.btn-ok { background: var(--ok); } .btn-ok:hover { background: #276B43; }
.btn-bad { background: var(--bad); } .btn-bad:hover { background: #962019; }
.btn-marker { background: var(--marker); color: var(--ink); } .btn-marker:hover { background: #E5B520; }
.btn-sm { padding: .35rem .65rem; font-size: .875rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--ink-2); padding: 0; font: inherit; cursor: pointer; text-decoration: none; }
.link-btn:hover { color: var(--ink); }

/* ---------- badges & alerts ---------- */
.badge { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 99px; background: #E8ECF2; color: var(--ink); white-space: nowrap; font-weight: 500; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-warn { background: var(--marker-soft); color: var(--warn); }
/* sample data shown before launch (Admin → Settings → demo_previews) */
.demo-badge { border: 1px dashed currentColor; vertical-align: middle; font-size: .74rem; }
.demo-note { display: flex; justify-content: center; margin: 0 0 1rem; }
.alert { padding: .75rem 1rem; border-radius: var(--radius-s); margin-bottom: 1rem; border: 1px solid; }
.alert-ok { background: var(--ok-soft); border-color: #B7DCC4; color: #1E5535; }
.alert-bad { background: var(--bad-soft); border-color: #F0C2BD; color: #7D1B15; }
.alert-warn { background: var(--marker-soft); border-color: #F0DC99; color: #6B4A00; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: .25rem; }

.progress { height: 8px; background: #E4E9F0; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); }

/* ---------- curriculum tree ---------- */
.tree details { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); margin-bottom: .6rem; }
.tree summary { padding: .8rem 1rem; cursor: pointer; font-weight: 600; color: var(--ink); list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.tree summary::-webkit-details-marker { display: none; }
.tree ul { list-style: none; margin: 0; padding: 0 1rem .6rem; }
.tree li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-top: 1px dashed var(--line); }

/* ---------- lesson content ---------- */
.reader { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.5rem 1.75rem; }
.reader .body { font-size: 1.075rem; line-height: 1.9; max-width: 72ch; }
.video { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius-m); overflow: hidden; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* click-to-play player (partials/video-player) and the lesson page around it */
.video-play { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: #000; cursor: pointer; display: grid; place-items: center; }
.video-play img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-play-icon { position: relative; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); transition: transform .15s; }
.video-play:hover .video-play-icon, .video-play:focus-visible .video-play-icon { transform: scale(1.1); }
.video-noscript { position: absolute; inset-block-end: .75rem; inset-inline-start: .75rem; color: #fff; }
.video-locked { display: grid; place-items: center; text-align: center; color: #fff; background: linear-gradient(135deg, var(--ink), var(--ink-2)); }
.video-locked p { margin: .5rem 0 .9rem; }
.lesson-player { margin-bottom: 1.25rem; }
.lesson-player .video { max-width: 1100px; box-shadow: var(--shadow); }
.lesson-player-cap { margin-top: .5rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-bottom: .4rem; }
.lesson-items > h2 { font-size: 1.15rem; }
.lesson-item { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.lesson-item-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.type-icon { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #E8ECF2; color: var(--ink); }
.type-icon.type-video { background: var(--bad-soft); color: var(--bad); }
.type-icon.type-pdf { background: var(--marker-soft); color: var(--warn); }
.lesson-nav { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.lesson-nav .btn { max-width: 100%; white-space: normal; }
.accordion .acc-chevron::before { content: "▸"; display: inline-block; margin-inline-end: .45rem; color: var(--muted); transition: transform .15s; }
[dir="rtl"] .accordion .acc-chevron::before { content: "◂"; }
.accordion details[open] .acc-chevron::before { transform: rotate(90deg); }
[dir="rtl"] .accordion details[open] .acc-chevron::before { transform: rotate(-90deg); }
.lesson-row { display: inline-flex; align-items: center; gap: .45rem; flex-wrap: wrap; min-width: 0; }
.lesson-admin > details { flex: 1; min-width: 0; }
.lesson-edit > summary { cursor: pointer; list-style: none; }
.tree .lesson-edit { border: 0; margin: 0; background: none; }
.tree .lesson-edit > summary { padding: 0; font-weight: 500; justify-content: flex-start; display: flex; }
.lesson-edit > summary::-webkit-details-marker { display: none; }
.lesson-edit-form { padding: .6rem 0 .2rem; }
.lesson-edit-form .btn { margin-top: .5rem; }
.video-badge { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--bad-soft); color: var(--bad); flex: none; }
.pdf-frame { width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: var(--radius-m); }
.protected { -webkit-user-select: none; user-select: none; }

/* ---------- exam: the answer sheet ---------- */
.exam-body { background: #EEF1F5; }
.exam-bar { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .7rem 1.25rem; }
.exam-bar h1 { color: #fff; font-size: 1.05rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer { font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 700; letter-spacing: .02em; padding: .1rem .75rem; border-radius: var(--radius-s); border: 2px solid rgba(255,255,255,.25); direction: ltr; }
.timer.low { background: var(--marker); color: var(--ink); border-color: var(--marker); }
.save-state { font-size: .85rem; color: #C5CFE0; min-width: 7rem; }
.save-state.offline { color: var(--marker); }

.exam-layout { display: grid; grid-template-columns: 1fr 260px; gap: 1.25rem; max-width: 1100px; margin: 1.25rem auto; padding: 0 1rem; align-items: start; }
@media (max-width: 860px) { .exam-layout { grid-template-columns: 1fr; } .sheet-nav { order: -1; } }

.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.5rem; margin-bottom: 1rem; scroll-margin-top: 5rem; }
.q-head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; color: var(--muted); font-size: .9rem; }
.q-body { font-size: 1.1rem; line-height: 1.85; color: var(--text); white-space: pre-line; margin-bottom: 1rem; }
.q-img { max-height: 320px; border-radius: var(--radius-s); border: 1px solid var(--line); margin-bottom: 1rem; }

.bubbles { display: grid; gap: .5rem; }
.bubble { display: flex; align-items: center; gap: .9rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-m); cursor: pointer; background: #fff; font-weight: 400; color: var(--text); margin: 0; }
.bubble:hover { border-color: #AEB9C7; }
.bubble input { position: absolute; opacity: 0; pointer-events: none; }
.bubble .dot { flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 600; color: var(--ink); font-size: .95rem; transition: background .12s, color .12s; }
.bubble input:checked + .dot { background: var(--ink); color: #fff; box-shadow: inset 0 0 0 3px #fff; }
.bubble input:focus-visible + .dot { outline: 3px solid var(--marker); outline-offset: 2px; }
.bubble:has(input:checked) { border-color: var(--ink); background: #F5F7FB; }
.bubble.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.bubble.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
/* multiple-answer question on result/review pages: the same "more than one answer" line, square letters */
.multi-badge { display: inline-flex; align-items: center; gap: .45rem; margin: 0 0 .6rem; padding: .3rem .8rem; border-radius: 8px; background: var(--marker-soft, #FFF4CC); color: var(--text); font-weight: 600; font-size: .92rem; }
.bubbles.is-multi .dot { border-radius: 6px; }
.bubble.is-correct .dot { border-color: var(--ok); color: var(--ok); }
.bubble.is-wrong .dot { border-color: var(--bad); color: var(--bad); }

.sheet-nav { position: sticky; top: 4.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1rem; }
.sheet-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; margin: .75rem 0; }
.sheet-grid a { aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid #AEB9C7; text-decoration: none; color: var(--ink); font-size: .85rem; font-variant-numeric: tabular-nums; position: relative; }
.sheet-grid a.answered { background: var(--ink); border-color: var(--ink); color: #fff; }
.sheet-grid a.flagged::after { content: ""; position: absolute; top: -2px; inset-inline-end: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--marker); border: 1.5px solid #fff; }
.legend { display: flex; flex-wrap: wrap; gap: .75rem; font-size: .8rem; color: var(--muted); }
.flag-btn { background: none; border: 1px solid var(--line); border-radius: 99px; padding: .15rem .6rem; font: inherit; font-size: .85rem; cursor: pointer; color: var(--muted); }
.flag-btn[aria-pressed="true"] { background: var(--marker-soft); border-color: var(--marker); color: var(--warn); }

.score-ring { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--ring, var(--ok)) calc(var(--p) * 1%), #E4E9F0 0); margin-inline: auto; }
.score-ring > div { width: 118px; height: 118px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.score-ring b { font-size: 1.8rem; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1; }

/* ---------- guest ---------- */


.lang-switch { font-size: .9rem; text-decoration: none; border: 1px solid var(--line); border-radius: 99px; padding: .15rem .7rem; color: var(--ink); }
.bell { position: relative; text-decoration: none; color: var(--ink); display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; }
.bell:hover { background: #EEF2F7; }
.bell .dot { position: absolute; top: 4px; inset-inline-end: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); border: 2px solid #fff; }
.toast { position: fixed; inset-block-end: 1rem; inset-inline-end: 1rem; background: var(--ink); color: #fff; padding: .8rem 1rem; border-radius: var(--radius-m); box-shadow: var(--shadow); max-width: 340px; z-index: 100; }
.toast a { color: var(--marker); }

.pagination { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: 1rem; list-style: none; padding: 0; }
.pagination a, .pagination span { display: inline-block; padding: .3rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; text-decoration: none; color: var(--ink); font-variant-numeric: tabular-nums; }
.pagination .current { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination .disabled { color: #AAB3BF; }

.katex-display { overflow-x: auto; overflow-y: hidden; }

@media print { .side, .topbar, .no-print { display: none !important; } .shell { display: block; } body { background: #fff; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.with-aside { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
@media (max-width: 900px) { .with-aside { grid-template-columns: 1fr; } }
.opt-row { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; margin-bottom: .5rem; }

/* ---------- drawer ---------- */
.side-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 45; }

/* ---------- exam: one question at a time ---------- */
.q-card[hidden] { display: none; }
.exam-progress { height: 4px; background: rgba(255,255,255,.2); border-radius: 99px; overflow: hidden; flex: none; width: 90px; }
.exam-progress > i { display: block; height: 100%; background: var(--marker); }
.q-steps { display: flex; justify-content: space-between; gap: .75rem; align-items: center; margin-top: 1rem; }
.exam-layout, .exam-bar { position: relative; z-index: 10; }
.sheet-grid a.current { outline: 3px solid var(--marker); outline-offset: 1px; }

/* ---------- landing sections ---------- */
.l-faq details { border: 1px solid var(--line); border-radius: var(--radius-m); background: #fff; margin-bottom: .6rem; }
.l-faq summary { padding: .9rem 1.1rem; cursor: pointer; font-weight: 600; color: var(--ink); }
.l-faq p { padding: 0 1.1rem 1rem; margin: 0; }
.l-band { background: var(--ink); color: #fff; padding: 2.5rem clamp(1rem, 5vw, 4rem); }
.l-band h2, .l-band h3 { color: #fff; }
.l-band .stat { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.15); }
.l-band .stat b { color: #fff; } .l-band .stat span { color: #C5CFE0; }
.l-step { counter-increment: step; position: relative; padding-inline-start: 3rem; }
.l-step::before { content: counter(step); position: absolute; inset-inline-start: 0; top: 0; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--marker); color: var(--ink); display: grid; place-items: center; font-weight: 700; }
.l-steps { counter-reset: step; }
.l-social a { display: inline-block; margin-inline-end: .75rem; color: var(--ink-2); }

/* ===========================================================
   Responsive refinements — phone first, then tablet, then desktop.
   Everything below overrides earlier rules on purpose.
   =========================================================== */

/* fluid type: 15px on a phone, 16px from tablet up */
html { font-size: 15px; }
@media (min-width: 720px) { html { font-size: 16px; } }

h1 { font-size: clamp(1.4rem, 1.15rem + 1.2vw, 1.85rem); }
h2 { font-size: clamp(1.15rem, 1rem + .6vw, 1.4rem); }
.stat b { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); }

/* the page never scrolls sideways; wide things scroll inside their own box */
html, body { max-width: 100%; overflow-x: hidden; }
/* clip (unlike hidden) keeps position:sticky working: topbar, exam timer bar, answer sheet */
@supports (overflow-x: clip) { html, body { overflow-x: clip; } }
.table-wrap { -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 560px; }
.reader .body, .q-body { overflow-wrap: anywhere; }

/* topbar wraps instead of squashing the search box */
.topbar { flex-wrap: wrap; row-gap: .5rem; }
.topbar form[role="search"] { order: 3; flex: 1 1 100%; max-width: none; }
@media (min-width: 720px) { .topbar form[role="search"] { order: 0; flex: 1 1 320px; max-width: 420px; } }

/* header actions stack under the title on small screens */
.page-head { align-items: start; }
@media (max-width: 560px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .row, .page-head form { width: 100%; }
  .page-head .btn { flex: 1; }
}

/* filter bars: inputs go full width rather than overflowing */
@media (max-width: 720px) {
  .panel.row > input, .panel.row > select, form.row > input, form.row > select { max-width: none !important; width: 100%; }
  .panel.row > .btn, form.row > .btn { width: 100%; }
}

/* cards and tiles breathe better on a phone */
@media (max-width: 480px) {
  .panel { padding: 1rem; }
  .cols-4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .cols-3, .cols-2 { grid-template-columns: 1fr; }
  .reader { padding: 1.1rem; }
}

/* ---------- exam screen on a phone ---------- */
@media (max-width: 720px) {
  .exam-bar { flex-wrap: wrap; row-gap: .4rem; padding: .6rem .9rem; }
  .exam-bar h1 { flex: 1 1 100%; font-size: .95rem; order: -1; }
  .timer { font-size: 1.25rem; }
  .exam-progress { flex: 1; width: auto; }
  .save-state { min-width: 0; }
  .exam-layout { margin: .9rem auto; gap: .9rem; }
  .q-card { padding: 1.1rem; }
  .bubble { padding: .6rem .7rem; gap: .7rem; }
  .bubble .dot { width: 1.9rem; height: 1.9rem; }
  .q-steps { flex-direction: column-reverse; gap: .5rem; }
  .q-steps .btn { width: 100%; }
  .sheet-nav { position: static; padding: .8rem; }
  .sheet-grid { grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr)); }
}

/* ---------- landing ---------- */
@media (max-width: 720px) {
  .l-hero { padding-bottom: 2.5rem; }
  .l-sec, .l-band { padding-inline: 1rem; }
  .l-nav { gap: .5rem; }
  .l-card { padding: 1rem; }
}

/* ---------- footer: only on the pages that opt in ---------- */
.site-footer { display: flex; justify-content: center; margin-top: 3rem; padding: 1.25rem 0 .5rem; border-top: 1px solid var(--line); }
.site-footer .inner { display: flex; flex-wrap: wrap; gap: .35rem 1rem; align-items: center; justify-content: space-between; width: 100%; font-size: .85rem; color: var(--muted); }
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* ---------- small polish ---------- */
.badge + .badge { margin-inline-start: .3rem; }
.panel > .table-wrap { border: 0; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-inline-end: 2rem; }
[dir="rtl"] select { background-position: 13px 55%, 18px 55%; background-image: linear-gradient(135deg, transparent 50%, var(--muted) 50%), linear-gradient(45deg, var(--muted) 50%, transparent 50%); padding-inline-end: .7rem; padding-inline-start: 2rem; }
.btn:active { transform: translateY(1px); }
a.subject-tile:hover strong { color: var(--ink-2); }

/* ===========================================================
   Visual polish pass
   =========================================================== */
@media (max-width: 900px) { .menu-btn { display: inline-flex !important; padding: .45rem .6rem; } }

.panel { box-shadow: 0 1px 2px rgba(27, 42, 74, .04); }
.panel:has(> h2:first-child) > h2:first-child,
.panel > h3:first-child { letter-spacing: -.01em; }
.stat { display: flex; flex-direction: column; justify-content: center; min-height: 84px; }
.badge { line-height: 1.7; }
th { position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #FAFBFD; }

/* buttons feel like one family */
.btn { transition: background .15s, border-color .15s, box-shadow .15s; }
.btn-ghost { background: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- exam screen ---------- */
.exam-body { background: #EDF0F5; }
.exam-bar { box-shadow: 0 2px 12px rgba(15, 23, 42, .18); }
.exam-layout { max-width: 1040px; }
.q-card { box-shadow: 0 1px 3px rgba(27,42,74,.06), 0 12px 28px rgba(27,42,74,.05); border-radius: 14px; padding: 1.75rem; }
.q-head { align-items: center; }
.q-body { font-size: 1.15rem; font-weight: 500; }
.bubbles { gap: .6rem; }
.bubble { padding: .8rem 1rem; border-width: 1.5px; font-size: 1.02rem; }
.bubble:has(input:checked) { box-shadow: inset 0 0 0 1px var(--ink); }
.q-steps { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.sheet-nav { box-shadow: 0 1px 3px rgba(27,42,74,.06); }
.sheet-grid a { font-weight: 600; transition: transform .1s; }
.sheet-grid a:hover { transform: scale(1.06); }
.flag-btn { white-space: nowrap; }
.save-state { text-align: center; }

/* ---------- forms ---------- */
.field label { font-size: .92rem; }
input, select, textarea { transition: border-color .15s, box-shadow .15s; }
fieldset legend { font-size: .9rem; }

/* controls placed straight in a flex .row share the line instead of each taking 100% and wrapping */
.row > input:where(:not([type=checkbox], [type=radio], [type=hidden], [type=file], [type=color])), .row > select { width: auto; flex: 1 1 9rem; }
.row > input[type=file] { width: auto; flex: 1 1 14rem; }
.row > label:not(.check) { margin-bottom: 0; }
/* width caps for controls in a row (replace ad-hoc style="max-width:…") */
.w-xs { max-width: 5.5rem; }
.w-s { max-width: 8.5rem; }
.w-m { max-width: 12rem; }
.w-l { max-width: 16rem; }
.w-xl { max-width: 24rem; }
.row > .w-xs { flex-basis: 4.5rem; }
.row > .w-s { flex-basis: 6.5rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.code-input { letter-spacing: .12em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.code-input::placeholder { letter-spacing: .08em; }
@media (max-width: 720px) {
  .row > :is(.w-m, .w-l, .w-xl) { max-width: none; flex-basis: 100%; }
}

/* compact controls: inline forms in table cells, filter bars, anything marked .compact */
:is(td, .compact) :where(input:not([type=checkbox], [type=radio], [type=hidden], [type=file], [type=color]), select, textarea) {
  padding-block: .35rem; font-size: .9rem;
}
:is(td, .compact) :where(input:not([type=checkbox], [type=radio], [type=hidden], [type=file], [type=color]), textarea) { padding-inline: .55rem; }
:is(td, .compact) input[type=color] { block-size: 2.1rem; inline-size: 2.6rem; }

/* repeated rows of inputs (landing-page videos, stats, FAQ …): a grid that stacks on phones */
.rep-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem .75rem; margin-bottom: .75rem; align-items: start; }
.rep-row.rep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rep-row.rep-lead { grid-template-columns: minmax(5rem, 9rem) repeat(2, minmax(0, 1fr)); }
.rep-row .span-2 { grid-column: span 2; }
.rep-row .span-all { grid-column: 1 / -1; }
.rep-card { border: 1px solid var(--line); border-radius: var(--radius-m); padding: .75rem 1rem 1rem; margin: 0 0 .75rem; min-width: 0; }
.rep-card > legend { padding-inline: .35rem; }
.rep-card > .rep-row { margin-bottom: 0; }
@media (max-width: 720px) {
  .rep-row, .rep-row.rep-2, .rep-row.rep-lead { grid-template-columns: minmax(0, 1fr); }
  .rep-row .span-2 { grid-column: auto; }
  .rep-row + .rep-row { border-top: 1px dashed var(--line); padding-top: .75rem; }
}

/* ---------- guest pages (login / register / reset) ---------- */
.guest-body { background: var(--bg); }
.guest { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 42%) 1fr; }
.guest-art { background: var(--ink); color: #fff; }
.guest-art-inner { position: sticky; top: 0; min-height: 100vh; max-height: 100vh; box-sizing: border-box; padding: clamp(1.5rem, 4vw, 3rem); display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; overflow: hidden; }
.guest-art .brand { color: #fff; padding: 0; }
.guest-art h2 { color: #fff; font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.2rem); max-width: 18ch; line-height: 1.3; }
.guest-art p { color: #C5CFE0; max-width: 40ch; }
.guest-ticks { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .5rem; color: #C5CFE0; font-size: .95rem; }
.guest-ticks li::before { content: "✓"; color: var(--marker); font-weight: 700; margin-inline-end: .5rem; }
.guest-form { display: grid; place-items: start center; padding: clamp(1.25rem, 4vw, 3rem) 1rem; }
.guest-form .box { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(1.25rem, 3vw, 2rem); box-shadow: var(--shadow); }
.brand-mobile { display: none; color: var(--ink); padding: 0; font-size: 1.05rem; }
.brand-mobile:hover, .brand-mobile:focus-visible { color: var(--ink); }
@media (max-width: 860px) {
  .guest { grid-template-columns: 1fr; }
  .guest-art { display: none; }
  .brand-mobile { display: inline-flex; }
  .guest-form { place-items: start stretch; }
}
.brand-logo { max-height: 38px; width: auto; }
/* default brand mark (partials/brand): the designer's colour mark on a white disc, so it reads on the dark bars */
.brand-badge { width: 40px; height: 40px; flex: none; display: grid; place-items: center; }
.brand-badge img { width: 40px; height: 40px; display: block; }


/* ---------- sign-in / registration on one page (auth/page.blade.php) ---------- */
.auth [hidden] { display: none !important; }
.auth-switch { margin-bottom: 1.25rem; }
.acct-type { display: flex; flex-wrap: wrap; gap: .5rem; border: 0; padding: 0; margin-inline: 0; }
.acct-type legend { width: 100%; margin-bottom: .35rem; font-weight: 600; padding: 0; }
.acct-type .check { flex: 1 1 8rem; border: 1px solid #C9D2DD; border-radius: 10px; padding: .55rem .75rem; cursor: pointer; margin: 0; }
.acct-type .check:has(input:checked) { border-color: var(--ink); background: #EEF2F7; font-weight: 600; }

/* ---------- sidebar collapses earlier, so zoomed screens behave ---------- */
@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 262px; z-index: 50; transform: translateX(-105%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  [dir="rtl"] .side { transform: translateX(105%); }
  .side.open { transform: none !important; }
  .side:not(.open) { visibility: hidden; }
  .side { transition: transform .2s, visibility .2s; }
  .menu-btn { display: inline-flex !important; }
  .page { padding: 1rem; }
}
@media (min-width: 1025px) { .menu-btn, .side-backdrop { display: none !important; } .side { transform: none !important; } }

/* ---------- landing preview card (hero) ---------- */
.l-preview { background: #fff; color: var(--text); border-radius: 16px; padding: 1.35rem; box-shadow: 0 24px 60px rgba(0,0,0,.32); }
.l-preview-head { display: flex; align-items: center; gap: .6rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.l-preview-head strong { color: var(--ink); flex: 1; }
.l-preview-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.l-preview-score { display: flex; align-items: center; gap: 1.25rem; padding: 1.2rem 0; }
.l-preview-score .score-ring { width: 120px; height: 120px; flex: none; margin: 0; }
.l-preview-score .score-ring > div { width: 94px; height: 94px; }
.l-preview-score .score-ring b { font-size: 1.5rem; }
.l-preview-list { list-style: none; margin: 0; padding: 0; flex: 1; display: grid; gap: .7rem; }
.l-preview-list li { display: grid; grid-template-columns: 5.5rem 1fr auto; align-items: center; gap: .6rem; font-size: .92rem; }
.l-preview-list i { display: block; height: 7px; border-radius: 99px; background: #E4E9F0; position: relative; }
.l-preview-list i::after { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--w); border-radius: 99px; background: var(--ink); }
.l-preview-list b { font-variant-numeric: tabular-nums; color: var(--ink); }
.l-preview-foot { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; border-top: 1px solid var(--line); padding-top: .9rem; text-align: center; }
.l-preview-foot b { display: block; font-size: 1.3rem; color: var(--ink); }
.l-preview-foot span { font-size: .8rem; color: var(--muted); }
@media (max-width: 480px) { .l-preview-score { flex-direction: column; } .l-preview-list { width: 100%; } }

/* subject tiles: icon badge */
.l-subject-dot { display: grid; place-items: center; font-size: 1.15rem; color: var(--c, var(--ink)); font-weight: 700; }
.subject-tile .tile-badge { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--bg); background: color-mix(in srgb, var(--c) 14%, #fff); color: var(--c); font-weight: 700; margin-bottom: .4rem; }

/* ---------- result page ---------- */
.verdict { display: flex; gap: 1rem; align-items: center; border-radius: var(--radius-m); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; border: 1px solid; }
.verdict-high { background: var(--ok-soft); border-color: #B7DCC4; }
.verdict-mid { background: var(--marker-soft); border-color: #F0DC99; }
.verdict-low { background: #EEF2F7; border-color: #D3DCE7; }
.verdict-emoji { font-size: 2rem; line-height: 1; }
.verdict strong { display: block; color: var(--ink); font-size: 1.08rem; }
.verdict p { margin: .2rem 0 0; }

.compare { display: grid; gap: .75rem; }
.compare-row { display: grid; grid-template-columns: 7.5rem 1fr auto; gap: .7rem; align-items: center; font-size: .92rem; }
.compare-bar { height: 9px; border-radius: 99px; background: #E4E9F0; position: relative; }
.compare-bar > i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 99px; background: var(--ink-2); }
.compare-bar.is-me > i { background: var(--ok); }
.compare-row b { font-variant-numeric: tabular-nums; color: var(--ink); }

details.fold { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); margin-bottom: 1rem; }
details.fold > summary { padding: .9rem 1.1rem; cursor: pointer; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
details.fold[open] > summary { border-bottom: 1px solid var(--line); }
details.fold .fold-body { padding: 1rem 1.1rem; }

/* ---------- modal (welcome / rating) ---------- */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 1rem; background: rgba(15,23,42,.55); }
.modal[hidden] { display: none; }
.modal-card { background: var(--surface); border-radius: 16px; max-width: 560px; width: 100%; max-height: 88vh; overflow: auto; padding: clamp(1.25rem, 3vw, 2rem); box-shadow: 0 30px 70px rgba(0,0,0,.35); }
.modal-card h2 { margin-top: 0; }
.modal-close { background: none; border: 0; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); padding: .2rem .4rem; }
/* welcome pop-up (components/welcome-dialog): text + picture side by side, one column without a picture */
.welcome-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.welcome-head h2 { margin: 0; }
.welcome-body { white-space: pre-line; line-height: 1.9; }
.welcome-actions { margin-top: 1.25rem; }
.welcome-actions .welcome-main { flex: 1; }
.welcome-card.has-image { max-width: 920px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); overflow: hidden; }
.welcome-card.has-image .welcome-text { padding: clamp(1.25rem, 3vw, 2rem); overflow: auto; max-height: 88vh; }
.welcome-card.has-image .welcome-media { padding: .75rem; min-height: 0; }
.welcome-card.image-end .welcome-media { order: 2; }
.welcome-media img { display: block; width: 100%; height: 100%; min-height: 260px; max-height: calc(88vh - 1.5rem); object-fit: cover; border-radius: 12px; }
.modal-close:focus-visible { outline: 3px solid var(--marker); outline-offset: 2px; border-radius: 6px; }
/* phones: one column, the picture on top */
@media (max-width: 720px) {
  .welcome-card.has-image { grid-template-columns: 1fr; overflow: auto; }
  .welcome-card.has-image .welcome-media, .welcome-card.image-end .welcome-media { order: 0; padding: .75rem .75rem 0; }
  .welcome-card.has-image .welcome-text { max-height: none; overflow: visible; }
  .welcome-media img { min-height: 0; height: auto; aspect-ratio: 16 / 9; max-height: 34vh; }
}
/* "pick on map" dialog (partials/map-modal) */
.map-modal .modal-card { max-width: 860px; max-height: 94vh; }
.map-modal .map-tools { margin-top: .75rem; flex-wrap: wrap; }
.map-modal .map-tools input { flex: 1 1 220px; min-width: 0; }
.map-canvas { width: 100%; height: min(60vh, 520px); min-height: 260px; border-radius: var(--radius-m, 10px); background: var(--line); }
.map-canvas img { max-width: none; } /* the map tiles must not be squeezed by a global img rule */
.stars { display: flex; gap: .25rem; direction: ltr; justify-content: center; margin: 1rem 0; }
.stars button { background: none; border: 0; font-size: 2rem; line-height: 1; cursor: pointer; filter: grayscale(1); opacity: .45; transition: transform .12s, opacity .12s, filter .12s; }
.stars button.on { filter: none; opacity: 1; }
.stars button:hover { transform: scale(1.12); }

/* ---------- honour board ---------- */
.honor { display: grid; gap: .5rem; }
.honor-row { display: grid; grid-template-columns: 2.4rem 1fr auto; gap: .8rem; align-items: center; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.honor-rank { width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #EEF2F7; color: var(--ink); font-variant-numeric: tabular-nums; }
.honor-row:nth-child(1) .honor-rank { background: #F4C430; color: #5A4300; }
.honor-row:nth-child(2) .honor-rank { background: #D8DEE7; }
.honor-row:nth-child(3) .honor-rank { background: #E6C7A8; color: #6B4423; }
.honor-name { font-weight: 600; color: var(--ink); }
.honor-meta { font-size: .82rem; color: var(--muted); }
.honor-score { font-weight: 700; color: var(--ok); font-variant-numeric: tabular-nums; }

/* ---------- "where to revise" box, shown under a wrong answer ---------- */
.revise { display: flex; gap: .9rem; align-items: flex-start; margin-top: 1rem; padding: 1rem 1.1rem;
  background: var(--marker-soft); border: 1px solid #F0DC99; border-inline-start-width: 4px; border-radius: var(--radius-m); }
.revise-icon { font-size: 1.4rem; line-height: 1.3; flex: none; }
.revise strong { color: var(--ink); display: block; }
.revise p { margin: .25rem 0 0; }
.revise .revise-ref { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed #E0C97A; font-variant-numeric: tabular-nums; }
.revise .revise-ref strong { display: inline; }

/* tap-to-zoom question pictures (partials/q-image, app.js [data-zoom]) */
.zoomable { cursor: zoom-in; max-width: 100%; height: auto; }
.opt-img { display: block; max-width: 100%; max-height: 160px; margin-top: .4rem; border-radius: 6px; }
.zoom-box { position: fixed; inset: 0; z-index: 2147483001; background: rgba(0, 0, 0, .9); display: flex; align-items: center; justify-content: center; overflow: auto; padding: 1rem; cursor: zoom-out; }
.zoom-box img { max-width: 96vw; max-height: calc(100vh - 10rem); object-fit: contain; background: #fff; border-radius: 6px; touch-action: pinch-zoom; cursor: zoom-in; }
.zoom-box img.zoomed { max-width: none; max-height: none; width: 200vw; cursor: zoom-out; }
/* big, obvious ways out (phones): "✕ Close" at the top, "Back to the question" at the bottom; ≥44px, clear of notches */
.zoom-close, .zoom-back { font: inherit; font-weight: 700; cursor: pointer; border: 2px solid #fff; border-radius: 999px; background: #fff; color: #111; box-shadow: 0 2px 12px rgba(0, 0, 0, .5); }
.zoom-close { position: fixed; z-index: 1; top: calc(.75rem + env(safe-area-inset-top, 0px)); inset-inline-end: calc(.75rem + env(safe-area-inset-right, 0px));
  display: inline-flex; align-items: center; gap: .45rem; min-height: 52px; min-width: 52px; padding: .4rem 1.1rem .4rem .8rem; font-size: 1.1rem; }
.zoom-x { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: #111; color: #fff; font-size: 1.1rem; line-height: 1; }
.zoom-bar { position: fixed; z-index: 1; inset-inline: 0; bottom: 0; display: flex; justify-content: center;
  padding: .75rem calc(1rem + env(safe-area-inset-right, 0px)) calc(.75rem + env(safe-area-inset-bottom, 0px)) calc(1rem + env(safe-area-inset-left, 0px));
  background: linear-gradient(to top, rgba(0, 0, 0, .85), rgba(0, 0, 0, 0)); }
.zoom-back { width: min(100%, 26rem); min-height: 52px; padding: .6rem 1.2rem; font-size: 1.15rem; }
.zoom-close:hover, .zoom-back:hover { background: #F2F2F2; }
.zoom-close:focus-visible, .zoom-back:focus-visible { outline: 3px solid #FFD54A; outline-offset: 3px; }
@media (max-width: 600px) { .opt-row { grid-template-columns: auto 1fr; } .opt-row .opt-pic { grid-column: 1 / -1; } }
/* teacher exam builder steps */
.steps { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.steps li { padding: .35rem .8rem; border-radius: 999px; background: var(--line); font-size: .9rem; }
.steps li.done { background: var(--ok); color: #fff; }
.steps li.now { outline: 2px solid var(--ink); }

/* "back" button at the top of the exam info, result and print pages (partials/back-button) */
.back-btn { margin-bottom: .75rem; font-weight: 600; font-size: 1rem; padding: .5rem 1rem; border-color: var(--line); background: var(--surface); color: var(--ink); }
.back-btn:hover { background: var(--bg); color: var(--ink); }
[dir="rtl"] .back-btn svg { transform: scaleX(-1); }

/* why an exam cannot be started: one coloured box, big icon, one simple line (student/exams/show) */
.block-box { display: flex; gap: 1rem; align-items: flex-start; padding: 1rem 1.15rem; border-radius: var(--radius-m); border: 2px solid; margin-bottom: 1.25rem; }
.block-box .block-icon { flex: none; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: #fff; }
.block-box .block-title { display: block; font-size: 1.2rem; line-height: 1.4; margin-bottom: .25rem; }
.block-box p { margin: 0 0 .5rem; font-size: 1.05rem; }
.block-bad { background: var(--bad-soft); border-color: var(--bad); color: #7D1B15; }
.block-bad .block-icon, .block-bad .block-title { color: var(--bad); }
.block-warn { background: var(--marker-soft); border-color: #E0B020; color: #6B4A00; }
.block-warn .block-icon, .block-warn .block-title { color: var(--warn); }
.block-info { background: #E8EEF9; border-color: var(--ink-2); color: var(--ink); }
.block-info .block-icon, .block-info .block-title { color: var(--ink-2); }
@media (max-width: 600px) { .block-box .block-icon { width: 44px; height: 44px; } .block-box .block-icon svg { width: 30px; height: 30px; } }
/* the start button's place when the exam cannot be started: red, clearly "not available" */
.btn.btn-unavailable, .btn.btn-unavailable:disabled { opacity: 1; background: var(--bad-soft); color: var(--bad); border: 2px solid var(--bad); font-weight: 700; cursor: not-allowed; }

/* "print my results" summary (student/results-print) */
.print-filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.print-filters label { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; }

/* ---------- Admin → Clean test data (admin/cleanup) ---------- */
.cl-demo { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.cl-demo h2 { margin: 0 0 .25rem; font-size: 1.05rem; }
.cl-demo p { margin: 0; }
.cl-demo-form { display: flex; align-items: center; gap: .6rem; }
.cl-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin: 1.5rem 0 .75rem; }
.cl-head h2 { margin: 0; }
.cl-all { padding: .45rem .75rem; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface); }
.cl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: .75rem; margin-bottom: 1rem; }
.cl-card { margin: 0; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: border-color .15s, box-shadow .15s; min-width: 0; }
.cl-card.is-on { border-color: var(--bad, #B3261E); box-shadow: 0 0 0 3px rgba(179, 38, 30, .12); }
.cl-card.is-empty { opacity: .55; }
.cl-card.is-audit { border-style: dashed; }
.cl-card-head { display: flex; align-items: center; gap: .55rem; cursor: pointer; }
.cl-card.is-empty .cl-card-head { cursor: default; }
.cl-card-head input { width: 1.15rem; height: 1.15rem; flex: none; }
.cl-card-head strong { flex: 1; min-width: 0; }
.cl-total { flex: none; font-size: .8rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: var(--bad-soft, #FCE8E6); color: #7D1B15; }
.cl-total.is-zero { background: var(--surface-2, #EEF1F5); color: var(--muted); font-weight: 500; }
.cl-desc { margin: .4rem 0 .5rem; line-height: 1.55; }
.cl-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.cl-chips li { font-size: .78rem; padding: .15rem .5rem; border-radius: 6px; background: var(--surface-2, #EEF1F5); color: var(--ink-2); }
.cl-chips b { color: var(--ink); }
.cl-options { display: grid; gap: .5rem; margin-top: .65rem; padding-top: .65rem; border-top: 1px dashed var(--line); }
.cl-options .field { margin: 0; }
.cl-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1rem; margin: 0 -.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 -6px 18px rgba(20, 33, 61, .08); }
.cl-bar .btn:disabled { opacity: .5; cursor: not-allowed; }
.cl-report-row { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.cl-report-row:last-child { border-bottom: 0; }
.cl-report-row .cl-chips { margin-top: .35rem; }
.cl-grand { font-size: 1.05rem; margin: 0 0 .75rem; }

/* Admin → Logo & branding: the designer's logo files */
.brand-defaults { margin-bottom: 1rem; padding: .75rem; border: 1px dashed var(--line); border-radius: 12px; }
.brand-defaults-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.brand-default { width: 72px; height: 72px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.brand-default.is-dark { background: var(--ink); }
.brand-default img { max-width: 56px; max-height: 56px; }
/* Help center (/help, /help/{slug}, Admin → Help center → Articles) */
.guest-form .box.box-wide { max-width: 820px; }
.help-search { display: flex; gap: .5rem; max-width: 560px; margin: 0 0 1rem; }
.help-search input { flex: 1; min-width: 0; }
.help-tabs { margin-bottom: 1rem; }
.help-list { list-style: none; margin: 0; padding: 0; }
.help-list li { padding: .6rem 0; border-top: 1px solid var(--line); }
.help-list li:first-child { border-top: 0; padding-top: 0; }
.help-list a { font-weight: 600; }
.help-list p { margin: .15rem 0 0; }
.help-cta { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.help-cta h2 { margin: 0 0 .25rem; font-size: 1.1rem; }
.help-cta p { margin: 0; }
.help-title { margin: .25rem 0 .5rem; }
.help-video { max-width: 760px; margin-bottom: 1.25rem; }
.help-body { line-height: 1.85; overflow-wrap: anywhere; }
.help-body > :first-child { margin-top: 0; }
.help-body h2 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; }
.help-body h3 { font-size: 1.05rem; margin: 1.25rem 0 .4rem; }
.help-body ul, .help-body ol { padding-inline-start: 1.4rem; }
.help-body li + li { margin-top: .25rem; }
.help-body a { font-weight: 600; }
.help-body code { direction: ltr; unicode-bidi: embed; background: #F1F3F6; padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }
.help-body blockquote { margin: 1rem 0; padding: .6rem 1rem; border-inline-start: 4px solid var(--marker); background: var(--marker-soft); }
.help-preview { border: 1px dashed var(--line); border-radius: var(--radius-s); padding: 1rem; }
/* numbered steps, each followed by its phone screenshot (HelpArticle::screenshots) */
.help-body ol > li { margin-top: 1rem; }
.help-body ol > li::marker { font-weight: 700; }
.help-shot { margin: .75rem 0 1.25rem; max-width: 300px; }
.help-shot a { display: block; cursor: zoom-in; border-radius: 18px; }
.help-shot img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 6px 18px rgba(16, 32, 64, .10); background: #fff; }
.help-shot figcaption { margin-top: .45rem; font-size: .9rem; line-height: 1.6; color: var(--muted); text-align: center; }
.help-body img { max-width: 100%; height: auto; }
@media (max-width: 480px) { .help-shot { max-width: 82%; margin-inline: auto; } }

/* ---------- Admin → Content readiness ---------- */
.rd-summary { margin-bottom: 1.25rem; }
.rd-stat { border-top: 4px solid var(--line); }
.rd-green { border-top-color: var(--ok); }
.rd-amber { border-top-color: var(--marker); }
.rd-red { border-top-color: var(--bad); }
.rd-checks { list-style: none; margin: 0; padding: 0; }
.rd-checks > li { padding: .55rem 0; border-top: 1px solid var(--line); }
.rd-checks > li:first-child { border-top: 0; }
.rd-items { margin: .35rem 0 0; padding-inline-start: 1.25rem; max-height: 14rem; overflow-y: auto; }
/* the wrapper scrolls on its own so the sticky header stays on top of long tables */
.rd-table { max-height: 70vh; overflow-y: auto; }
.rd-table th { background: var(--surface); box-shadow: inset 0 -1px 0 var(--line); white-space: nowrap; }
.rd-low { color: var(--bad); font-weight: 600; }

/* help center card on the student and teacher dashboards (partials/help-card) */
.help-card { margin-top: 1.25rem; }
.help-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.help-card-head h2 { margin: 0 0 .2rem; font-size: 1.1rem; }
.help-card-head p { margin: 0; }
.help-card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.help-card-list { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: .6rem; }
.help-card-list a { display: flex; flex-direction: column; gap: .2rem; height: 100%; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); }
.help-card-list a:hover { border-color: var(--ink-2); color: var(--ink); }
.brand-wm { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; padding: .75rem; border: 1px dashed var(--line); border-radius: 12px; }

/* show / hide password (js/password-toggle.js) */
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { width: 100%; padding-inline-end: 2.9rem; }
.pw-toggle { position: absolute; inset-block: 0; inset-inline-end: .35rem; margin-block: auto; width: 2.3rem; height: 2.3rem; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.pw-toggle:hover { color: var(--ink); background: var(--surface-2, #EEF1F5); }
.pw-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.pw-toggle[aria-pressed="true"] { color: var(--ink); }

/* student exams list: pick the subject first (student/exams/index) */
.ex-pick h2 { margin: 0 0 .25rem; font-size: 1.15rem; }
.ex-kind { margin: 1rem 0 .5rem; font-size: .9rem; color: var(--muted); font-weight: 600; }
.ex-subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: .6rem; }
@media (max-width: 480px) { .ex-subjects { grid-template-columns: 1fr 1fr; } }
.ex-subject { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; padding: .8rem .85rem; border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: 12px; background: var(--surface); color: var(--ink); min-height: 44px; transition: box-shadow .15s, transform .15s; }
.ex-subject:hover { color: var(--ink); box-shadow: 0 6px 16px rgba(12,44,72,.1); transform: translateY(-1px); }
.ex-subject.is-on { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 35%, transparent); background: color-mix(in srgb, var(--c) 7%, var(--surface)); }
.ex-subject.is-empty { opacity: .65; }
.ex-subject strong { font-size: .98rem; line-height: 1.35; }
.ex-badge { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); font-weight: 700; }
.ex-list-h { margin: 1.25rem 0 .75rem; font-size: 1.1rem; }

/* date pickers: Android Chrome mirrors the Arabic placeholder («يوم/شهر/سنة» shows as «موي/رهش/ةنس») inside RTL pages; the field itself reads left to right */
input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"] { direction: ltr; text-align: start; unicode-bidi: plaintext; }
[dir="rtl"] input[type="date"], [dir="rtl"] input[type="datetime-local"], [dir="rtl"] input[type="month"], [dir="rtl"] input[type="time"] { text-align: right; }

/* «نتائجي للطباعة»: filters and, on phones, one card per attempt */
.print-filters { display: grid; grid-template-columns: 1.3fr 2fr 1fr 1fr; gap: .75rem; align-items: end; }
.print-filters label { display: grid; gap: .3rem; margin: 0; font-weight: 600; min-width: 0; }
.print-filters select { width: 100%; }
.print-filters .btn { min-height: 44px; }
.print-filters .print-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem; }
.print-filters .print-hint { grid-column: 1 / -1; margin: 0; }
@media (max-width: 720px) {
  .print-filters { grid-template-columns: 1fr 1fr; }
  .print-filters .print-pick { grid-column: 1 / -1; }
  .print-filters .print-actions .btn { flex: 1 1 100%; justify-content: center; }
  .print-table { border: 0; background: none; overflow: visible; }
  .print-table table, .print-table tbody, .print-table tr, .print-table td { display: block; width: 100%; }
  .print-table thead { display: none; }
  .print-table tr { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .85rem; margin-bottom: .7rem; }
  .print-table td { border: 0; padding: .3rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: start; }
  .print-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .85rem; flex: none; }
  .print-table td:first-child { font-weight: 700; font-size: 1rem; border-bottom: 1px dashed var(--line); padding-bottom: .5rem; margin-bottom: .2rem; }
  .print-table td:first-child::before { display: none; }
  .print-table td.no-print { justify-content: flex-end; padding-top: .5rem; }
}
/* ----- questions on the review pages (result, teacher grading, printable report): the question
   and its options in black ink, like the exam screen; badges and hints keep their muted colours ----- */
.q-card .q-body, .q-card .bubble, .passage-body, .essay-answer { color: #000; }
/* a written answer keeps every paragraph and line break, exactly as typed (escaped text, no HTML) */
.essay-answer { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.9; font-size: 1.05rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1rem 1.1rem; }
/* a shared reading passage (partials/passage) shown once above its questions */
.passage-card { background: #FBFAF6; border: 1px solid #E3DCC8; border-inline-start: 4px solid var(--marker, #E0B23A);
  border-radius: var(--radius-m); padding: .8rem 1.1rem; margin: 0 0 1rem; }
.passage-card > summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.passage-body { font-size: 1.08rem; line-height: 1.95; overflow-wrap: anywhere; margin-top: .6rem; }
.passage-body p { margin: 0 0 .8rem; }
.passage-body table { border-collapse: collapse; margin: .5rem 0; }
.passage-body th, .passage-body td { border: 1px solid #C9C2AE; padding: .3rem .6rem; }
.passage-img { display: block; max-width: 100%; height: auto; margin-top: .6rem; border-radius: 8px; }
@media print { .passage-card { break-inside: avoid; background: #fff; } .passage-card > summary { list-style: none; } }

/* «كن شريكاً»: highlighted in the side menu and a «how you earn» banner on the partner page */
.side nav a.nav-partner { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: .55rem; margin: .35rem .6rem; padding: .6rem .8rem; border-radius: 12px; color: #0C2C48; font-weight: 700; background: linear-gradient(135deg, #F4D27A, #D7A64B); box-shadow: 0 6px 16px rgba(215, 166, 75, .35); }
.side nav a.nav-partner small { grid-column: 2; font-weight: 500; font-size: .74rem; opacity: .85; }
.side nav a.nav-partner:hover, .side nav a.nav-partner.active { color: #0C2C48; background: linear-gradient(135deg, #F8DD95, #E0B25A); }
.nav-partner-dot { grid-row: 1 / span 2; width: .6rem; height: .6rem; border-radius: 50%; background: #F22F33; box-shadow: 0 0 0 0 rgba(242, 47, 51, .6); animation: partner-pulse 1.6s ease-out infinite; }
@keyframes partner-pulse { 0% { box-shadow: 0 0 0 0 rgba(242, 47, 51, .55); } 70% { box-shadow: 0 0 0 .55rem rgba(242, 47, 51, 0); } 100% { box-shadow: 0 0 0 0 rgba(242, 47, 51, 0); } }
@media (prefers-reduced-motion: reduce) { .nav-partner-dot { animation: none; } }
.partner-hero { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1.25rem; align-items: center; margin-bottom: 1.25rem; padding: clamp(1.1rem, 3vw, 1.75rem); border-radius: 16px; color: #fff; background: linear-gradient(135deg, #0C2C48, #0D3C5C 55%, #1B7FC2); }
.partner-hero h2 { color: #fff; margin: .4rem 0; font-size: clamp(1.25rem, 1rem + 1.2vw, 1.7rem); }
.partner-hero p { margin: 0; color: #D7E3F0; line-height: 1.8; }
.partner-hero-tag { display: inline-flex; align-items: center; gap: .45rem; padding: .25rem .7rem; border-radius: 999px; background: #D7A64B; color: #0C2C48; font-weight: 700; font-size: .85rem; }
.partner-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.partner-steps li { display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .85rem; border-radius: 12px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); }
.partner-steps b { flex: none; width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; background: #D7A64B; color: #0C2C48; }
.partner-steps strong { display: block; color: #fff; }
.partner-steps span { color: #C9D6E6; font-size: .9rem; line-height: 1.6; }
@media (max-width: 760px) { .partner-hero { grid-template-columns: 1fr; } }

/* «رجوع» / «الرئيسية» at the end of every inner page (partials/page-end-nav) */
.page-end-nav { display: flex; gap: .75rem; justify-content: center; margin: 2rem 0 .5rem; padding-top: 1.25rem; border-top: 1px dashed var(--line); }
.page-end-nav .btn { min-height: 48px; min-width: 9.5rem; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; border-radius: 12px; font-weight: 700; }
.page-end-back { background: linear-gradient(135deg, #1B7FC2, #0D3C5C); color: #fff; border: 0; box-shadow: 0 6px 16px rgba(27, 127, 194, .28); }
.page-end-back:hover, .page-end-back:focus-visible { color: #fff; filter: brightness(1.08); }
[dir="ltr"] .page-end-back svg { transform: scaleX(-1); }
@media (max-width: 520px) { .page-end-nav .btn { flex: 1; min-width: 0; } }

/* sign-in / sign-up: the colour mark as a large watermark behind the form (client request) */
.guest-form .box { position: relative; overflow: hidden; isolation: isolate; }
.guest-form .box::before { content: ""; position: absolute; z-index: -1; width: min(110%, 520px); aspect-ratio: 1; inset-inline-start: 50%; top: 52%; transform: translate(-50%, -50%); background: url("/assets/brand/mark.svg") center / contain no-repeat; opacity: .07; pointer-events: none; }
[dir="rtl"] .guest-form .box::before { transform: translate(50%, -50%); }
.guest-form .box input, .guest-form .box select, .guest-form .box textarea { background-color: rgba(255, 255, 255, .88); }
/* ---------- book-cover cards (partials/book-card): library and the landing academic track ---------- */
.subject-group-title { font-size: 1.05rem; margin: 1.25rem 0 .75rem; }
.book-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem .85rem; margin-bottom: 1rem; }
@media (min-width: 640px) { .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .book-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem 1rem; } }
@media (min-width: 1200px) { .book-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.book-card { display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .6rem; box-shadow: 0 4px 14px rgba(20,33,61,.05); }
.book-cover { position: relative; aspect-ratio: 5 / 7; border-radius: 8px; }
.book-cover img, .book-cover-ph { position: relative; z-index: 1; display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 8px; box-shadow: 0 6px 16px rgba(20,33,61,.18); background: #EEF1F5; }
/* a spine shadow on the binding edge, like a real book */
.book-cover::after { content: ""; position: absolute; z-index: 2; inset-block: 0; inset-inline-start: 0; width: 7px; border-start-start-radius: 8px; border-end-start-radius: 8px; background: linear-gradient(90deg, rgba(0,0,0,.18), transparent); pointer-events: none; }
[dir="rtl"] .book-cover::after { background: linear-gradient(-90deg, rgba(0,0,0,.18), transparent); }
/* several books: more covers peek out behind the first */
.book-card.is-stack .book-cover::before { content: ""; position: absolute; z-index: 0; inset: 0; border-radius: 8px; background: #DCE3EC; transform: translate(5px, -5px) rotate(2deg); box-shadow: 0 4px 10px rgba(20,33,61,.12), 5px -5px 0 -1px #C9D2DD; }
[dir="rtl"] .book-card.is-stack .book-cover::before { transform: translate(-5px, -5px) rotate(-2deg); box-shadow: 0 4px 10px rgba(20,33,61,.12), -5px -5px 0 -1px #C9D2DD; }
.book-count { position: absolute; z-index: 3; top: .4rem; inset-inline-end: .4rem; min-width: 1.6rem; padding: 0 .4rem; border-radius: 99px; background: var(--ink); color: #fff; font-size: .78rem; line-height: 1.6rem; text-align: center; }
/* no cover: the subject name on a brand-coloured card */
.book-cover-ph { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: .9rem; text-align: center; color: #fff;
  background: linear-gradient(160deg, var(--c, #0C2C48) 0%, #0C2C48 100%); }
.book-cover-icon { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%; background: rgba(255,255,255,.16); font-size: 1.5rem; }
.book-cover-name { font-weight: 700; line-height: 1.5; font-size: .95rem; overflow-wrap: anywhere; }
.book-body { display: flex; flex-direction: column; gap: .35rem; flex: 1; padding-top: .7rem; min-width: 0; }
.book-title { margin: 0; font-size: .98rem; line-height: 1.45; color: var(--ink); overflow-wrap: anywhere; }
.book-streams { display: block; line-height: 1.4; overflow-wrap: anywhere; }
.subject-streams { display: block; font-size: .82rem; color: var(--muted, #6b7280); line-height: 1.4; }
.book-progress { height: 6px; border-radius: 99px; background: #EEF1F5; overflow: hidden; }
.book-progress i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.book-actions { display: grid; grid-template-columns: 1fr; gap: .4rem; margin-top: auto; padding-top: .35rem; }
.book-actions .btn, .book-menu > summary { width: 100%; min-height: 44px; padding-inline: .5rem; white-space: normal; text-align: center; }
.book-menu { position: relative; }
.book-menu > summary { list-style: none; cursor: pointer; }
.book-menu > summary::-webkit-details-marker { display: none; }
.book-menu > summary::after { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.book-menu[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.book-menu ul { position: absolute; z-index: 5; inset-inline: 0; bottom: calc(100% + .35rem); list-style: none; margin: 0; padding: .35rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 28px rgba(20,33,61,.18); }
.book-menu a { display: flex; align-items: center; min-height: 44px; padding: .4rem .6rem; border-radius: 8px; color: var(--ink); font-size: .92rem; line-height: 1.35; }
.book-menu a:hover, .book-menu a:focus-visible { background: #F1F4F9; }
/* Admin → Curriculum → Books */
.admin-book { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 1rem; align-items: start; }
.admin-book.is-off { opacity: .75; }
.admin-book-cover img, .admin-book-cover .book-cover-ph { width: 96px; height: 134px; object-fit: cover; border-radius: 6px; box-shadow: 0 4px 12px rgba(20,33,61,.15); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-block; padding: .15rem .6rem; border-radius: 99px; background: #EEF2F7; color: var(--ink); font-size: .85rem; }
.subject-cover-thumb { width: 72px; height: 100px; object-fit: cover; border-radius: 6px; display: block; margin-bottom: .4rem; }
@media (max-width: 480px) { .admin-book { grid-template-columns: 72px minmax(0, 1fr); } .admin-book-cover img, .admin-book-cover .book-cover-ph { width: 72px; height: 100px; } }

/* Student dashboard: big quick actions right after the greeting (2 per row on phones, one row on wide screens) */
.dash-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin: 0 0 1.25rem; }
.dash-action { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: .6rem; min-height: 4.5rem; padding: .85rem 1rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; box-shadow: 0 2px 8px rgba(27, 42, 74, .06); transition: transform .12s, box-shadow .12s; }
.dash-action:hover { color: var(--ink); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(27, 42, 74, .12); }
.dash-action:focus-visible { outline: 3px solid var(--marker); outline-offset: 2px; }
.dash-action-icon { grid-row: 1 / span 2; font-size: 1.6rem; line-height: 1; }
.dash-action strong { font-size: 1.02rem; }
.dash-action small { grid-column: 2; color: var(--muted); font-size: .78rem; }
.dash-action-partner { color: #0C2C48; border-color: #D7A64B; background: linear-gradient(135deg, #F4D27A, #D7A64B); box-shadow: 0 6px 16px rgba(215, 166, 75, .35); position: relative; }
.dash-action-partner:hover { color: #0C2C48; background: linear-gradient(135deg, #F8DD95, #E0B25A); }
.dash-action-partner small { color: #0C2C48; opacity: .85; }
.dash-action-partner::after { content: ""; position: absolute; top: .6rem; inset-inline-end: .6rem; width: .55rem; height: .55rem; border-radius: 50%; background: #F22F33; animation: partner-pulse 1.6s ease-out infinite; }
.dash-invite { grid-column: 1 / -1; padding: 1rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--marker); }
.dash-invite h2 { margin: 0; font-size: 1.15rem; }
.dash-invite p { margin: .4rem 0 .7rem; }
.dash-invite .btn, .dash-invite input { min-height: 48px; }
.dash-action-exams { grid-column: 1 / -1; }
.dash-library-link { margin: 1rem 0; }
.dash-library-link a { font-weight: 600; }
@media (min-width: 1000px) {
    .dash-actions { grid-template-columns: 1fr 1fr 2.2fr 1fr; align-items: stretch; }
    .dash-invite, .dash-action-exams { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) { .dash-action { transition: none; } .dash-action-partner::after { animation: none; } }

/* sign-in / sign-up: a bigger, clearer logo and name (client request) */
.guest-art .brand { gap: .85rem; font-size: clamp(1.4rem, 1.1rem + 1vw, 1.75rem); }
.guest-art .brand .brand-badge, .guest-art .brand .brand-badge img { width: 76px; height: 76px; }
.guest-art .brand .brand-logo { max-height: 76px; }
.brand-mobile { gap: .7rem; font-size: 1.3rem; font-weight: 800; }
.brand-mobile .brand-badge, .brand-mobile .brand-badge img { width: 60px; height: 60px; }
.brand-mobile .brand-logo { max-height: 60px; }

/* sign-up: «use your real details» notice */
.real-data-note { display: flex; gap: .65rem; align-items: flex-start; margin: 0 0 1.1rem; padding: .8rem .95rem; border-radius: 12px; background: #FFF6E0; border: 1px solid #E9C46A; color: #5C4310; font-size: .92rem; line-height: 1.7; }
.real-data-note svg { flex: none; margin-top: .2rem; color: #C98A0B; }
.real-data-note strong { color: #3E2C05; }

/* every delete button is red (client request): DELETE forms, "drop-…" image removal, .btn-delete (set by app.js too) */
.btn-delete,
form:has(> input[name="_method"][value="DELETE"]) button:not([type="button"]),
form:has(input[name="_method"][value="DELETE"]) > button:not([type="button"]),
button[form^="drop-"] {
  background: var(--bad) !important; border-color: var(--bad) !important; color: #fff !important; text-decoration: none !important;
}
.btn-delete:hover, .btn-delete:focus-visible,
form:has(input[name="_method"][value="DELETE"]) button:not([type="button"]):hover,
button[form^="drop-"]:hover { background: #8F1D17 !important; border-color: #8F1D17 !important; color: #fff !important; }
.link-btn.btn-delete, button.link-btn[form^="drop-"] { padding: .3rem .7rem; border-radius: 8px; }

/* ----- Admin → Registrations report: filters stack on a phone, a row on wide screens; rows become cards (.print-table) ----- */
.regrep-filters { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; align-items: end; }
.regrep-filters label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
.regrep-filters input, .regrep-filters select { width: 100%; }
.regrep-filters .regrep-search, .regrep-filters .regrep-actions { grid-column: 1 / -1; }
.regrep-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.regrep-actions .btn { min-height: 44px; flex: 1 1 auto; }
.regrep-contact { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .35rem .6rem; }
.btn-wa { background: #1F8B4C; color: #fff; } .btn-wa:hover { background: #18703D; }
.regrep-totals .stat small { font-size: .8rem; }
@media (min-width: 900px) {
  .regrep-filters { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .regrep-filters .regrep-search { grid-column: span 4; }
  .regrep-filters .regrep-actions { grid-column: span 2; }
  .regrep-contact { flex-direction: column; align-items: flex-start; justify-content: flex-start; }
}
.stat-link { color: inherit; text-decoration: none; } .stat-link:hover, .stat-link:focus-visible { border-color: var(--ink-2); }

/* Admin → Curriculum: rename subjects (one row per subject; stacked on phones) */
.rename-subjects summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.rename-row { display: grid; grid-template-columns: 1fr; gap: .4rem; padding: .6rem 0; border-top: 1px solid var(--line); }
@media (min-width: 700px) { .rename-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; } }
.rename-row .subject-streams { grid-column: 1 / -1; }

/* student exams: the list the subject links jump to (#exams-list) stays clear of the sticky top bar */
.ex-list { scroll-margin-top: 5rem; }
@media (prefers-reduced-motion: no-preference) { html:has(#exams-list) { scroll-behavior: smooth; } }

/* Question text with formatting (App\Support\RichText, public/js/rich-text.js).
   The editor: a toolbar of 40px buttons that wraps on a phone, over a contenteditable box. */
.rt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; padding: .3rem; background: var(--field-bg-muted);
  border: 1px solid var(--field-border); border-bottom: 0; border-radius: var(--radius-s) var(--radius-s) 0 0; }
.rt-toolbar[hidden], .rt-palette[hidden] { display: none; }
.rt-btn { min-width: 40px; min-height: 40px; padding: 0 .45rem; display: inline-grid; place-items: center; font: inherit; font-size: 1rem; line-height: 1;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; touch-action: manipulation; }
.rt-btn:hover { border-color: var(--ink-2); }
.rt-btn:focus-visible, .rt-swatch:focus-visible { outline: 3px solid var(--field-ring); outline-offset: 1px; border-color: var(--ink-2); }
.rt-btn[aria-pressed="true"], .rt-btn[aria-expanded="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.rt-u { text-decoration: underline; text-underline-offset: 2px; }
.rt-hl-icon { background: #FFF176; color: #000; padding: 0 .2rem; border-radius: 3px; }
.rt-color-icon { font-weight: 700; border-bottom: 3px solid #C62828; padding: 0 .15rem; }
.rt-clear-icon small { font-size: .7em; margin-inline-start: 1px; }
.rt-sep { width: 1px; align-self: stretch; margin: .2rem .15rem; background: var(--line); }
.rt-palette { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .4rem; padding: .25rem 0 .1rem; }
.rt-swatch { width: 40px; height: 40px; padding: 0; border-radius: 50%; border: 2px solid var(--field-border); background: var(--surface); cursor: pointer;
  font: inherit; font-weight: 700; font-size: 1.1rem; touch-action: manipulation; }
.rt-swatch-text { border-radius: var(--radius-s); }
.rt-editor { min-height: 7rem; max-height: 60vh; overflow-y: auto; padding: .55rem .7rem; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere;
  color: var(--text); background: var(--field-bg); border: 1px solid var(--field-border); border-radius: 0 0 var(--radius-s) var(--radius-s); }
.rt-editor:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--field-ring); }
.rt-editor[aria-invalid="true"] { border-color: var(--bad); }
.rt-editor p, .rt p { margin: 0; }
.rt mark, .rt-editor mark { color: inherit; padding: 0 .1em; }
/* the shown text: highlights and colours survive printing (the full exam print, the browser's print) */
.rt [style], .rt mark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* an empty-table message inside a narrow table: wrap instead of being clipped (partner page) */
.table-wrap td .empty { white-space: normal; min-width: min(18rem, 80vw); }

/* teacher exam page on phones (teacher/exams/show): the wide tables become cards, nothing scrolls sideways */
@media (min-width: 721px) { .st-remove-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }
@media (max-width: 720px) {
  .exam-head-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .exam-head-actions > a, .exam-head-actions > form, .exam-head-actions > form .btn { width: 100%; }
  .exam-head-actions .btn { min-height: 44px; justify-content: center; }
  .bank-filter { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .bank-filter > input[type="search"], .bank-filter .btn { grid-column: 1 / -1; }
  .bank-filter > * { max-width: none; width: 100%; }
  .bank-filter .btn { min-height: 44px; }
  .share-row { display: grid; grid-template-columns: 1fr auto; }
  .share-row > code { grid-column: 1 / -1; text-align: center; }
  .share-row > input { max-width: none; width: 100%; }

  .stack-table { border: 0; background: none; overflow: visible; }
  .stack-table table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; min-width: 0; }
  .stack-table thead { display: none; }
  .stack-table tr { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem .85rem; margin-bottom: .65rem; }
  .stack-table td { border: 0; padding: .25rem 0; max-width: none !important; min-width: 0; white-space: normal; overflow-wrap: anywhere; box-sizing: border-box; }
  .stack-table tr { min-width: 0; max-width: 100%; box-sizing: border-box; }
  .stack-table td[data-label] > * { min-width: 0; }
  .stack-table td[data-label] { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
  .stack-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .85rem; flex: none; }
  .stack-table td[data-label] select, .stack-table td[data-label] input { max-width: 62%; }
  .stack-table tr.st-empty { padding: 0; border: 0; background: none; }
  .eq-table td[data-label] input { max-width: 7rem; }
  .avail-table table { min-width: 0; }
  .avail-table th, .avail-table td { padding-inline: .5rem; }

  /* questions in the exam: number badge + text, then type / points / remove */
  .eq-table tr { display: grid; grid-template-columns: auto 1fr; column-gap: .65rem; }
  .eq-table td.st-no { grid-row: 1; width: auto; }
  .eq-table td.st-main { grid-row: 1; grid-column: 2; font-weight: 600; line-height: 1.6; }
  .eq-table td[data-label], .eq-table td.st-remove { grid-column: 1 / -1; }
  .eq-table td.st-remove { border-top: 1px dashed var(--line); margin-top: .35rem; padding-top: .55rem; }
  .eq-table td.st-remove .check { color: var(--bad); font-weight: 600; min-height: 40px; }
  .st-badge { display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; border-radius: 50%; background: #1B7FC2; color: #fff; font-weight: 700; font-size: .9rem; }

  /* question bank: the whole text ticks the box; unit / type / level as small chips */
  .bank-table tr { display: grid; grid-template-columns: auto 1fr; column-gap: .65rem; align-items: start; }
  .bank-table td.st-pick { grid-row: 1 / span 4; width: auto; padding-top: .3rem; }
  .bank-table td.st-pick input { width: 1.35rem; height: 1.35rem; }
  .bank-table td.st-main { grid-column: 2; }
  .bank-table .st-pick-label { display: block; cursor: pointer; line-height: 1.6; }
  .bank-table tr:has(input:checked) { border-color: #1B7FC2; box-shadow: 0 0 0 2px rgba(27, 127, 194, .3); }
  .bank-table td.st-chip { grid-column: 2; justify-content: flex-start; gap: .4rem; padding: .1rem 0; font-size: .85rem; }
  .bank-table td.st-chip::before { font-size: .8rem; }
}

/* teacher lists on phones (exams, results, question bank): one card per row, label : value */
@media (max-width: 720px) {
  .list-cards td.st-main { font-size: 1rem; line-height: 1.6; padding-bottom: .45rem; margin-bottom: .2rem; border-bottom: 1px dashed var(--line); }
  .list-cards td[data-label] { padding: .3rem 0; }
  .list-cards td[data-label] > .small, .list-cards td[data-label] > div { text-align: end; }
  .list-cards td.st-actions { display: flex !important; flex-wrap: wrap !important; gap: .5rem; justify-content: flex-end; padding-top: .55rem; }
  .list-cards td.st-actions .btn, .list-cards td.st-actions form { min-height: 40px; }
  .with-aside > .stack-table { min-width: 0; }
}

/* Admin → المنهاج: subject cards with the ministry book cover (like the knowledge bank) */
.subject-tile-cover { display: flex; gap: .9rem; align-items: center; }
.subject-tile .tile-cover { flex: none; width: 72px; height: 100px; object-fit: cover; border-radius: 6px; box-shadow: 0 4px 12px rgba(12, 44, 72, .18); background: var(--bg); }
.subject-tile .tile-text { display: block; min-width: 0; }
.subject-tile-cover:hover .tile-cover { transform: translateY(-2px); transition: transform .15s; }

/* Admin → Email accounts (Hostinger mailboxes): one card per mailbox, phone first */
.hm-gap { margin-top: .75rem; }
.hm-last { margin-bottom: 0; }
.hm-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.hm-shown { border-color: var(--ok); }
.hm-address { display: flex; align-items: stretch; }
.hm-address > input { flex: 1 1 auto; min-width: 0; border-start-end-radius: 0; border-end-end-radius: 0; }
.hm-at { display: flex; align-items: center; padding: 0 .6rem; background: #EEF2F7; border: 1px solid var(--line); border-inline-start: 0; border-radius: 0 var(--radius-s) var(--radius-s) 0; color: var(--muted); max-width: 55%; overflow-wrap: anywhere; font-size: .9rem; }
.hm-create { border: 1px dashed var(--line); border-radius: var(--radius-s); padding: 1rem; }
.hm-create > h3 { margin-top: 0; }
.hm-list { display: grid; gap: .9rem; }
.hm-card { border: 1px solid var(--line); border-radius: var(--radius-s); padding: .9rem; background: var(--surface); }
.hm-card > header { justify-content: space-between; }
.hm-details { margin-top: .5rem; }
.hm-details > summary { cursor: pointer; padding: .35rem 0; font-weight: 500; min-height: 40px; display: flex; align-items: center; }
.hm-details > summary.btn { display: inline-flex; }
.hm-danger > summary { color: var(--bad); }
.hm-fw { margin: .4rem 0; }
.hm-connect { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .8rem; margin: .5rem 0 0; }
.hm-connect dd { margin: 0; overflow-wrap: anywhere; }
.hm-connect a { text-decoration: none; }
tr.hm-site td { background: var(--ok-soft); }
@media (min-width: 900px) { .hm-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .hm-connect { grid-template-columns: 1fr; } .hm-connect dd { margin-bottom: .3rem; } }
