/* Base styles. Every colour comes from the design tokens (tokens.css: html[data-design] × html.dark),
   so nothing here needs a dark-mode twin. */
:root { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-padding-top: env(safe-area-inset-top, 0px); background: var(--page); }
* { font-family: var(--f-body); }
h1, h2, h3, h4, .font-head { font-family: var(--f-head); }
body { background: var(--bg); color: var(--text); font-size: 17.5px; line-height: 1.7; -webkit-font-smoothing: antialiased; }
input, textarea { background-color: var(--surface); color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[dir="rtl"] .mirror { transform: scaleX(-1); }
.ph-duotone, .ph-fill { line-height: 1; vertical-align: -0.125em; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 60; background: var(--primary); }
.glass-card { background: var(--surface); border: var(--bw) solid var(--card-border); box-shadow: var(--card-shadow); }
.pink-glow { box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 24px 48px -12px var(--lift); }
.btn-hover-effect { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.btn-hover-effect:hover { transform: translateY(-3px) scale(1.02); }
.btn-hover-effect:active { transform: translateY(1px) scale(0.95); }
.pulse-soft { animation: pulseSoft 2s infinite; }
@keyframes pulseSoft { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes popIn { 0% { transform: scale(0.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.pop-in { animation: popIn 0.25s ease-out; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.floaty { animation: floaty 2.6s ease-in-out infinite; }
.podium-1 { background: linear-gradient(145deg, #fef3c7, #fde68a); border-color: #f59e0b !important; }
.podium-2 { background: linear-gradient(145deg, #f1f5f9, #e2e8f0); border-color: #94a3b8 !important; }
.podium-3 { background: linear-gradient(145deg, #ffedd5, #fed7aa); border-color: #f97316 !important; }
#toast-box { transition: all 0.3s ease; }

/* ===================== Press, hover, ripple ===================== */
:where(button, .btn) { transition: transform .18s cubic-bezier(.4, 0, .2, 1), box-shadow .2s ease; -webkit-tap-highlight-color: transparent; }
@media (hover: hover) {
    :where(button, .btn):where(:not(:disabled)):hover { transform: translateY(-2px); }
}
:where(button, .btn):where(:not(:disabled)):active { transform: scale(.95); }
.ripple-host { overflow: hidden; isolation: isolate; }
.ripple {
    position: absolute; border-radius: 9999px; pointer-events: none; z-index: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, .25) 45%, rgba(255, 255, 255, 0) 70%);
    transform: scale(0); opacity: 1;
    animation: ripple .6s cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ===================== Reveal, flash ===================== */
@keyframes revealIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
/* "backwards" (not "both") so hover/press transforms work once the item has landed */
.reveal { animation: revealIn .45s cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: var(--d, 0ms); }
@keyframes flashBg { 0% { background-color: rgb(var(--c-primary-500) / .28); } 100% { background-color: transparent; } }
.flash { animation: flashBg 1.1s ease-out; }

/* Smooth colors only while the theme is being switched (theme.js adds .theme-anim for 350 ms) */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
    transition: background-color .3s ease, color .3s ease, border-color .3s ease !important;
}

/* ===================== School logo ===================== */
.logo-card {
    position: relative; overflow: hidden; display: block;
    background: #fff; border-radius: 1rem; padding: 12px; /* the logo is a white JPEG: its card stays white in every mode */
    box-shadow: 0 10px 30px -12px rgb(var(--c-primary-900) / .35), 0 2px 6px rgba(15, 23, 42, .08);
    animation: logoIn .6s cubic-bezier(.2, .8, .2, 1) backwards, floaty 2.6s ease-in-out .6s infinite;
}
.logo-card img { display: block; width: 100%; height: auto; }
.logo-card::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .85) 48%, rgba(255, 255, 255, .85) 52%, transparent 70%);
    transform: translateX(-120%);
    animation: shimmer 4s ease-in-out 1s infinite;
}
@keyframes logoIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes shimmer { 0% { transform: translateX(-120%); } 30%, 100% { transform: translateX(120%); } }
.logo-card--login { width: 100%; max-width: 320px; margin-inline: auto; }
.logo-card--header { width: 112px; padding: 8px; border-radius: .875rem; }
@media (min-width: 640px) { .logo-card--header { width: 180px; padding: 12px; border-radius: 1rem; } }

/* ===================== Larger student type ===================== */
#quiz-question-text { font-size: 24px; }
#quiz-options-container .opt-btn { font-size: 20px; }


/* ===================== Reduced motion ===================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after,
    html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
    .logo-card::after { display: none; }
    .ripple { display: none; }
}

/* ===================== Teacher dashboard ===================== */
.theme-toggle--inline { background: rgb(var(--c-primary-100)); border-color: rgb(var(--ln-primary-300)); }

.teacher-tabs { gap: 2px; isolation: isolate; }
.teacher-tab {
    position: relative; z-index: 1; flex: 1 1 0; min-width: 0; min-height: 48px; padding: 0 6px;
    border-radius: 12px; font-size: 17.5px; font-weight: 900; color: rgb(var(--tx-primary-800)); white-space: nowrap;
    transition: color .25s ease, transform .18s cubic-bezier(.4, 0, .2, 1);
}
.teacher-tab[aria-selected="true"] { color: var(--on-primary); }
.teacher-tab:focus-visible { outline: 3px solid rgb(var(--ln-primary-300)); outline-offset: 1px; }
.teacher-tab-indicator {
    position: absolute; z-index: 0; top: 6px; bottom: 6px; left: 0; width: 0; border-radius: 12px;
    background: linear-gradient(to left, rgb(var(--c-primary-600)), rgb(var(--c-primary-600))); box-shadow: 0 6px 16px -6px rgb(var(--c-primary-600) / .6);
    transition: left .35s cubic-bezier(.2, .8, .2, 1), width .35s cubic-bezier(.2, .8, .2, 1);
}
.teacher-tab-indicator.no-anim { transition: none; }

/* Podium: bars rise, the crown shimmers */
@keyframes podiumRise { from { clip-path: inset(100% 0 0 0); opacity: .3; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
.podium-rise .podium-bar { animation: podiumRise .8s cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: var(--d, 0ms); }
@keyframes crownShimmer { 0%, 100% { filter: drop-shadow(0 0 0 rgba(245, 158, 11, 0)); } 50% { filter: drop-shadow(0 0 8px rgba(245, 158, 11, .95)); } }
.crown-shimmer { display: inline-block; animation: floaty 2.6s ease-in-out infinite, crownShimmer 2s ease-in-out infinite; }

/* ===================== Choice chips / stage picker (replace <select>) ===================== */
.choice-chips { display: flex; gap: 10px; padding: 6px 4px 10px; }
.choice-chips--scroll {
    overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 4px; overscroll-behavior-x: contain;
    scrollbar-width: thin; scrollbar-color: rgb(var(--c-primary-300)) transparent;
}
.choice-chips--wrap { flex-wrap: wrap; }
.choice-chips--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .choice-chips--grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.choice-chips--icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.cc-chip {
    position: relative; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px 14px;
    border-radius: 16px; border: 2px solid rgb(var(--ln-primary-200)); background: var(--surface); color: rgb(var(--tx-primary-900));
    font-size: 17.5px; font-weight: 900; text-align: start; cursor: pointer;
    box-shadow: 0 2px 6px rgb(var(--c-primary-900) / .06);
}
.cc-chip--card {
    flex: 0 0 auto; width: 9.5rem; flex-direction: column; align-items: center; justify-content: flex-start;
    gap: 4px; padding: 12px 10px; text-align: center; scroll-snap-align: start; border-radius: 20px;
}
.choice-chips--icons .cc-chip { justify-content: center; padding: 6px; min-height: 56px; }
.cc-icon { font-size: 26.5px; line-height: 1; }
.cc-chip--card .cc-icon { font-size: 38px; margin-bottom: 2px; }
.choice-chips--icons .cc-icon { font-size: 29.5px; }
.cc-text { display: flex; flex-direction: column; min-width: 0; }
.cc-label { line-height: 1.3; }
.cc-sub {
    font-size: 15.5px; font-weight: 700; color: var(--muted); line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cc-count {
    margin-top: 2px; padding: 1px 10px; border-radius: 9999px; font-size: 15.5px; font-weight: 900;
    background: rgb(var(--c-primary-100)); color: rgb(var(--tx-primary-800));
}
.cc-chip:not(.cc-chip--card) .cc-count { margin: 0 auto 0 0; }
@media (hover: hover) { .cc-chip:not(.is-on):hover { border-color: rgb(var(--ln-primary-300)); background: var(--tint); } }
.cc-chip.is-on {
    background: linear-gradient(to left, rgb(var(--c-primary-600)), rgb(var(--c-primary-600))); border-color: transparent; color: var(--on-primary);
    transform: translateY(-3px); box-shadow: 0 10px 22px -10px rgb(var(--c-primary-600) / .75);
}
.cc-chip.is-on .cc-sub { color: rgba(255, 255, 255, .9); }
.cc-chip.is-on .cc-count { background: rgba(255, 255, 255, .25); color: var(--on-primary); }
.cc-chip:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; }
@keyframes pressPop { 0% { transform: translateY(-3px) scale(.9); } 55% { transform: translateY(-3px) scale(1.06); } 100% { transform: translateY(-3px) scale(1); } }
.press-pop { animation: pressPop .32s cubic-bezier(.3, 1.4, .5, 1); }

/* ===================== Question bank ===================== */
.bank-stage-icon {
    flex: 0 0 auto; width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center;
    font-size: 32px; border-radius: 16px; background: linear-gradient(145deg, rgb(var(--c-primary-100)), rgb(var(--c-primary-100)));
    box-shadow: inset 0 0 0 2px rgb(var(--c-primary-200));
}
.bank-q.is-hidden { opacity: .78; border-style: dashed; }
.bank-switch { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px; border-radius: 12px; font-size: 17.5px; font-weight: 900; color: var(--muted); }
.bank-switch:disabled { opacity: .6; cursor: progress; }
.bank-switch-track { position: relative; width: 52px; height: 30px; border-radius: 9999px; background: var(--border); transition: background-color .25s ease; flex-shrink: 0; }
.bank-switch-thumb {
    position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 9999px; background: var(--surface);
    box-shadow: 0 2px 4px rgba(15, 23, 42, .25); transition: right .25s cubic-bezier(.3, 1.3, .5, 1);
}
.bank-switch.is-on { color: var(--success); }
.bank-switch.is-on .bank-switch-track { background: linear-gradient(to left, var(--ok-solid), rgb(var(--c-primary-500))); }
.bank-switch.is-on .bank-switch-thumb { right: 25px; }
.bank-switch:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; }
.bank-counter { direction: ltr; unicode-bidi: isolate; font-size: 15.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.bank-counter.is-near { color: var(--warn); font-weight: 900; }
.bank-counter.is-max { color: var(--error); }
.bank-counter--opt { display: none; text-align: right; padding-right: 52px; }
.bank-counter--opt.is-near { display: block; }
.bank-opt-radio { flex: 0 0 auto; width: 44px; height: 48px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 12px; }
.bank-opt-radio input { width: 24px; height: 24px; accent-color: var(--ok-solid); cursor: pointer; }
.bank-opt.is-correct input[type="text"] { border-color: var(--success); background-color: var(--success-tint); }

/* ===================== Math text + math symbols pad ===================== */
/* Each paragraph/field takes its direction from its first strong letter, so "2x + 3 = 7" stays LTR and Arabic stays RTL. */
.math-text { unicode-bidi: plaintext; }
.math-pad-toggle {
    min-height: 44px; padding: 0 14px; border-radius: 12px; font-size: 17.5px; font-weight: 900;
    background: rgb(var(--c-primary-100)); color: rgb(var(--tx-primary-800)); border: 2px solid rgb(var(--ln-primary-200));
}
.math-pad-toggle[aria-expanded="true"] { background: linear-gradient(to left, rgb(var(--c-primary-600)), rgb(var(--c-primary-600))); color: var(--on-primary); border-color: transparent; }
.math-pad-toggle:focus-visible, .math-key:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; }
.math-pad { margin-top: 8px; padding: 10px; border-radius: 16px; background: rgb(var(--c-primary-50)); border: 2px solid rgb(var(--ln-primary-200)); display: grid; gap: 8px; }
.math-pad.hidden { display: none; }
.math-pad-label { display: block; font-size: 15.5px; font-weight: 900; color: rgb(var(--tx-primary-800)); margin-bottom: 4px; }
.math-pad-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.math-key {
    min-width: 44px; min-height: 44px; padding: 0 8px; border-radius: 12px; background: var(--surface); color: rgb(var(--tx-primary-950));
    border: 2px solid rgb(var(--ln-primary-200)); font-size: 22px; font-weight: 800; line-height: 1;
    box-shadow: 0 2px 0 rgb(var(--c-primary-200));
}
@media (hover: hover) { .math-key:hover { border-color: rgb(var(--ln-primary-300)); background: var(--tint); } }
.math-key:active { transform: translateY(2px) scale(.94); box-shadow: none; }
.math-key.press-pop { animation: keyPop .25s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes keyPop { 0% { transform: scale(.88); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
.math-pad-msg { font-size: 15.5px; font-weight: 800; color: var(--error); min-height: 0; }
.math-pad-msg:empty { display: none; }

/* ===================== Answer countdown (task 14) ===================== */
.countdown { position: relative; display: flex; width: 56px; height: 56px; align-items: center; justify-content: center; }
.countdown.hidden { display: none; }
.countdown svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.countdown-track { fill: none; stroke: rgb(var(--c-primary-100)); stroke-width: 4; }
.countdown-bar {
    fill: none; stroke: rgb(var(--c-primary-600)); stroke-width: 4; stroke-linecap: round;
    stroke-dasharray: 100; stroke-dashoffset: 0; transition: stroke-dashoffset .3s linear, stroke .3s ease;
}
.countdown-num { position: relative; font-size: 20px; font-weight: 900; color: rgb(var(--tx-primary-900)); font-variant-numeric: tabular-nums; }
.quiz-timeout {
    padding: 10px 14px; border-radius: 16px; border: 2px solid rgb(var(--error-rgb) / .3); background: var(--error-tint);
    color: var(--error); font-size: 17.5px; font-weight: 900; text-align: center;
}
.quiz-timeout.hidden { display: none; }
.opt-btn.opt-reveal { border-color: var(--success) !important; box-shadow: 0 0 0 4px rgba(16, 185, 129, .35); }
.opt-btn:disabled { cursor: not-allowed; }
.opt-btn:disabled:not(.opt-reveal) { opacity: .55; }

/* Teacher: answer time limits in the question bank */
.tl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tl-label { font-size: 17.5px; font-weight: 900; color: rgb(var(--tx-primary-800)); }
.tl-input-wrap { display: inline-flex; align-items: center; gap: 6px; }
.tl-input {
    width: 5.5rem; min-height: 44px; padding: 0 10px; border-radius: 12px; border: 2px solid rgb(var(--ln-primary-200)); background: var(--surface);
    font-size: 17.5px; font-weight: 900; color: rgb(var(--tx-primary-950)); text-align: center; outline: none;
}
.tl-input:focus { border-color: rgb(var(--ln-primary-400)); box-shadow: 0 0 0 4px rgb(var(--c-primary-400) / .2); }
.tl-input[aria-invalid="true"] { border-color: var(--error); }
.tl-unit { font-size: 17.5px; font-weight: 800; color: var(--muted); }
.tl-quick { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tl-chip {
    min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 12px; border: 2px solid rgb(var(--ln-primary-200)); background: var(--surface);
    color: rgb(var(--tx-primary-900)); font-size: 17.5px; font-weight: 900;
}
@media (hover: hover) { .tl-chip:not([aria-pressed="true"]):hover { border-color: rgb(var(--ln-primary-300)); background: var(--tint); } }
.tl-chip[aria-pressed="true"] { background: linear-gradient(to left, rgb(var(--c-primary-600)), rgb(var(--c-primary-600))); color: var(--on-primary); border-color: transparent; }
.tl-chip:focus-visible, .tl-toggle:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; }
.tl-msg { flex-basis: 100%; font-size: 15.5px; font-weight: 800; color: var(--error); }
.tl-msg:empty { display: none; }
.tl-toggle {
    min-height: 44px; padding: 0 10px; border-radius: 12px; font-size: 17.5px; font-weight: 900; white-space: nowrap;
    background: var(--surface-2); color: var(--muted); border: 2px dashed var(--border);
}
.tl-toggle.has-limit { background: rgb(var(--c-primary-50)); color: rgb(var(--tx-primary-800)); border: 2px solid rgb(var(--ln-primary-200)); }
.tl-editor { padding: 10px; border-radius: 16px; background: rgb(var(--c-primary-50)); border: 2px solid rgb(var(--ln-primary-200)); }
.tl-editor.hidden { display: none; }
.tl-badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 9999px; background: var(--error-tint); color: var(--error); font-size: 15.5px; font-weight: 900; white-space: nowrap; }

/* ===================== Appearance (task 15) ===================== */
/* Motion off from the dashboard: the same as the device's "reduce motion". */
html.no-motion *, html.no-motion *::before, html.no-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
html.no-motion .logo-card::after, html.no-motion .ripple { display: none; }

/* Feature switches: elements carry data-feat="<name>" and hide when it is off. */
html[data-feat-leaderboard="off"] [data-feat="leaderboard"],
html[data-feat-hints="off"] [data-feat="hints"],
html[data-feat-stars="off"] [data-feat="stars"],
html[data-feat-dark-toggle="off"] [data-feat="darkToggle"] { display: none !important; }


/* Countdown: amber in the last 10 s, red with a gentle pulse in the last 5 s (colour always changes). */
.countdown-bar { transition: stroke-dashoffset .3s linear, stroke .3s ease; }
.countdown-num { transition: color .3s ease; }
.countdown.is-warn .countdown-bar { stroke: var(--warn); }
.countdown.is-warn .countdown-num { color: var(--warn); }
.countdown.is-warn:not(.is-over) { animation: none; }
.countdown.is-danger .countdown-bar { stroke: var(--error); }
.countdown.is-danger .countdown-num { color: var(--error); }
.countdown.is-danger:not(.is-over) { animation: countdownDanger 1s ease-in-out infinite; }
@keyframes countdownDanger { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .countdown.is-danger { animation: none !important; } }
html.no-motion .countdown.is-danger { animation: none !important; }
html.no-motion .countdown-bar, html.no-motion .countdown-num { transition: stroke .3s ease, color .3s ease !important; }
.teacher-tab-icon { margin-inline-end: 4px; }
@media (max-width: 440px) { .teacher-tab-icon { display: none; } }
/* Preview frame: no logins from inside it */
html.is-preview [onclick="openTeacherAuthModal()"] { display: none !important; }
.greeting-banner p { white-space: pre-line; }

/* ===================== Settings screen: appearance cards (task 15) ===================== */

.ap-msg { font-size: 17.5px; font-weight: 800; color: var(--error); }
.ap-msg:empty { display: none; }
.ap-switch { width: 100%; justify-content: flex-start; text-align: start; color: rgb(var(--tx-primary-900)); }
.ap-switch.is-on { color: rgb(var(--tx-primary-900)); }
.ap-box { padding: 14px; border-radius: 18px; background: var(--surface-2); border: 2px solid rgb(var(--ln-primary-100)); }
.ap-dates { display: flex; flex-wrap: wrap; gap: 10px; }
.ap-dates label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 9rem; font-size: 17.5px; font-weight: 900; color: var(--text); }
.ap-dates input { min-height: 48px; padding: 0 10px; border-radius: 12px; border: 2px solid rgb(var(--ln-primary-200)); font-size: 17.5px; font-weight: 700; }
.ap-btn { min-height: 48px; padding: 0 16px; border-radius: 14px; font-size: 17.5px; font-weight: 900; }
.ap-btn:disabled { opacity: .6; cursor: progress; }
.ap-btn--primary { color: var(--on-primary); background: linear-gradient(to left, rgb(var(--c-primary-600)), rgb(var(--c-primary-600))); box-shadow: 0 8px 18px -10px rgb(var(--c-primary-600) / .8); }
.ap-btn--soft { background: rgb(var(--c-primary-100)); color: rgb(var(--tx-primary-800)); }
.ap-btn--ghost { background: var(--surface-2); color: var(--text); }
.ap-btn:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; }
.ap-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--surface); border: 1px solid rgb(var(--ln-primary-100)); }
.ap-row-swatch { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12); }
.cc-dsw { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12); }
.ap-actions { position: sticky; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 30; padding: 4px 10px; border-radius: 20px; border: 1px solid rgb(var(--ln-primary-200)); box-shadow: 0 14px 30px -14px rgba(15, 23, 42, .45); }
.ap-actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-actions-row .ap-btn { flex: 1 1 auto; }
.ap-dirty { font-size: 15.5px; font-weight: 800; color: var(--success); margin-bottom: 3px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-dirty.is-dirty { color: var(--warn); }

/* ---- Settings screen: compact layout (side-by-side cards, folding, small tiles) ---- */
.ap-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 768px) { .ap-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ap-grid > #ap-themes, .ap-grid > #ap-history { grid-column: 1 / -1; }
.ap-card { padding: 14px 16px; }
.ap-card > .ap-fold-body { margin-top: 12px; }
.ap-card-head { display: flex; flex-direction: column; gap: 2px; }
.ap-fold-bar { display: flex; justify-content: flex-end; }
.ap-btn--sm { min-height: 44px; padding: 0 14px; font-size: 16.5px; }
.ap-fold-btn {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 0; text-align: start;
    font: inherit; color: inherit; background: none; border: 0; cursor: pointer; border-radius: 12px;
}
.ap-fold-btn:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; }
.ap-fold-title { flex-shrink: 0; }
.ap-fold-sum { flex: 1 1 auto; min-width: 0; font-size: 16.5px; font-weight: 800; color: rgb(var(--tx-primary-700)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-card:not(.is-folded) .ap-fold-sum { visibility: hidden; }
.ap-fold-chev {
    flex-shrink: 0; margin-inline-start: auto; width: 32px; height: 32px; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center;
    font-size: 17.5px; background: rgb(var(--c-primary-100)); color: rgb(var(--tx-primary-800)); transition: transform .2s;
}
.ap-card.is-folded .ap-fold-chev { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .ap-fold-chev { transition: none; } }

.phone-frame { margin: 0 auto; width: min(100%, 340px); height: min(68vh, 640px); border-radius: 32px; padding: 10px; background: var(--ink); box-shadow: 0 20px 40px -20px rgba(15, 23, 42, .7); }
.phone-frame iframe { display: block; width: 100%; height: 100%; border: 0; border-radius: 24px; background: var(--surface); }

/* ===================== Plain help lines under titles and controls (help-texts.js) ===================== */
.help-text { font-size: 15.5px; line-height: 1.65; font-weight: 700; color: var(--muted); }
.help-text:empty { display: none; }
.ap-actions-row .ap-action { flex: 1 1 14rem; display: flex; flex-direction: column; gap: 4px; }
.ap-action .ap-btn { flex: none; }

/* ===== Task 15b: PIN management ===== */
/* row actions: icon with a short word under it */
.row-act { min-height: 48px; min-width: 4rem; padding: 4px 6px; border-radius: 12px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.15; }
.row-act-icon { font-size: 20px; }
.row-act-text { font-size: 14.5px; font-weight: 800; white-space: nowrap; }
.row-acts { display: grid; grid-template-columns: repeat(3, 4.25rem); gap: 4px; }
.row-acts-card .row-act { width: 100%; }
.row-act:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; }
/* selection ticks: the whole 44px box is the target */
.sel-box { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; cursor: pointer; flex: none; }
.sel-box input { width: 22px; height: 22px; accent-color: rgb(var(--c-primary-600)); cursor: pointer; }
.pins-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .pins-grid { grid-template-columns: 1fr 1fr; } }
/* «🔐 الأمان»: strength meter */
.key-meter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.key-meter span { height: 8px; border-radius: 99px; background: var(--surface-2); transition: background-color .2s; }
.key-meter[data-score="1"] span:nth-child(1) { background: var(--danger-solid); }
.key-meter[data-score="2"] span:nth-child(-n+2) { background: var(--reward); }
.key-meter[data-score="3"] span { background: var(--ok-solid); }
/* PIN slips: on screen a paper preview over a dark backdrop, in print A4 3 × 8 */
.slips-overlay { position: fixed; inset: 0; z-index: 80; overflow-y: auto; padding: 16px; background: rgba(15, 23, 42, .92); }
.slips-bar { max-width: 760px; margin: 0 auto 16px; padding: 16px; border-radius: 22px; }
.slips-warn { font-size: 18.5px; font-weight: 900; color: var(--error); background: var(--error-tint); border: 2px solid rgb(var(--error-rgb) / .4); border-radius: 14px; padding: 8px 12px; }
.slips-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slips-sheet { max-width: 760px; margin: 0 auto; }
.slip-page { display: grid; grid-template-columns: repeat(2, 1fr); background: #fff; color: #1e1b4b; margin-bottom: 16px; border-radius: 6px; overflow: hidden; }
@media (min-width: 560px) { .slip-page { grid-template-columns: repeat(3, 1fr); } }
.slip { border: 1px dashed #a78bfa; padding: 8px 6px; text-align: center; display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 128px; overflow: hidden; }
.slip-name { font-weight: 900; font-size: 16.5px; line-height: 1.3; }
.slip-class { font-size: 13px; font-weight: 700; color: var(--muted); }
.slip-pin span { display: block; font-size: 12px; font-weight: 800; color: #6b21a8; }
.slip-pin b { display: block; font-size: 29.5px; font-weight: 900; letter-spacing: .25em; font-family: ui-monospace, Consolas, monospace; color: #1e1b4b; }
.slip-how { font-size: 11.5px; font-weight: 700; color: var(--text); }
.slip-url { font-size: 11px; font-weight: 700; color: var(--muted); word-break: break-all; }
@media print {
    @page { size: A4; margin: 8mm; }
    html:has(body.slips-open), body.slips-open { background: var(--surface) !important; }
    body.slips-open > *:not(#pin-slips) { display: none !important; }
    body.slips-open #pin-slips { position: static; padding: 0; background: var(--surface); overflow: visible; }
    body.slips-open .slips-bar { display: none !important; }
    body.slips-open .slips-sheet { max-width: none; }
    body.slips-open .slip-page { width: 194mm; height: 280mm; margin: 0; border-radius: 0; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(8, 1fr); break-after: page; page-break-after: always; }
    body.slips-open .slip-page:last-child { break-after: auto; page-break-after: auto; }
    body.slips-open .slip { min-height: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.pins-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 44px; cursor: pointer; list-style: none; }
.pins-summary::-webkit-details-marker { display: none; }
.pins-chev { margin-inline-start: auto; font-size: 20px; color: rgb(var(--tx-primary-700)); transition: transform .2s; }
.pins-box[open] .pins-chev { transform: rotate(180deg); }
.pins-badge { font-size: 15.5px; font-weight: 900; padding: 2px 10px; border-radius: 99px; background: rgb(var(--c-primary-600)); color: var(--on-primary); }
.pins-badge:empty { display: none; }
.pins-summary:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; border-radius: 10px; }
.pins-sub { flex-basis: 100%; }

/* ===================== 💌 Teacher messages (task 17) ===================== */
.msg-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-preset {
    min-height: 44px; padding: 6px 12px; border-radius: 14px; font-size: 16.5px; font-weight: 800; text-align: start; line-height: 1.5;
    background: rgb(var(--c-primary-50)); color: rgb(var(--tx-primary-800)); border: 1.5px solid rgb(var(--ln-primary-200));
}
.msg-preset:hover { background: rgb(var(--c-primary-100)); }
.msg-preset:focus-visible, .msg-del:focus-visible, .msg-who summary:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; }
.msg-row {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; padding: 10px; border-radius: 14px;
    background: var(--surface); border: 1.5px solid rgb(var(--ln-primary-100));
}
.msg-row-icon { font-size: 29.5px; line-height: 1.1; flex: none; }
.msg-row-info { flex: 1 1 10rem; min-width: 0; }
.msg-row-text { font-size: 17.5px; font-weight: 800; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; line-height: 1.6; }
.msg-row-meta { font-size: 15.5px; font-weight: 700; color: var(--muted); margin-top: 2px; }
.msg-status { font-weight: 900; color: var(--muted); white-space: nowrap; }
.msg-status--read { color: var(--success); }
.msg-del {
    flex: none; min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 12px; font-size: 16.5px; font-weight: 900;
    background: var(--error-tint); color: var(--error); margin-inline-start: auto;
}
.msg-who { margin-top: 6px; }
.msg-who summary { cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; font-weight: 900; font-size: 16.5px; color: rgb(var(--tx-primary-700)); }
.msg-who ul { display: grid; gap: 4px; max-height: 16rem; overflow-y: auto; }
.msg-who li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; font-size: 16.5px; font-weight: 700; padding: 4px 8px; border-radius: 10px; background: rgb(var(--c-primary-50)); }
/* the student's «💌 رسائل معلمتي» */
.my-msg {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 16px;
    background: linear-gradient(to left, rgb(var(--c-primary-50)), rgb(var(--c-primary-50))); border: 1.5px solid rgb(var(--ln-primary-200));
}
.my-msg--new { border-width: 2px; border-color: rgb(var(--ln-primary-400)); }
.my-msg-icon { font-size: 34px; line-height: 1.1; flex: none; }
.my-msg-info { flex: 1 1 auto; min-width: 0; }
.my-msg-text { font-size: 18.5px; font-weight: 800; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; line-height: 1.7; }
.my-msg-meta { font-size: 15.5px; font-weight: 700; color: var(--muted); margin-top: 2px; }
.my-msg-badge { padding: 1px 8px; border-radius: 99px; background: rgb(var(--c-primary-600)); color: var(--on-primary); font-weight: 900; }
/* 📎 attachments (task 17, spec 7.7.1) */
.att-card {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px; margin-top: 8px; border-radius: 14px; text-align: start;
    background: var(--surface); border: 1.5px dashed rgb(var(--ln-primary-300));
}
.att-card--gone { opacity: .75; border-style: dotted; }
.att-icon { font-size: 29.5px; line-height: 1; flex: none; }
.att-info { flex: 1 1 8rem; min-width: 0; }
.att-name { font-size: 17.5px; font-weight: 900; color: rgb(var(--tx-primary-900)); overflow-wrap: anywhere; line-height: 1.5; }
.att-meta { font-size: 15.5px; font-weight: 700; color: var(--muted); }
.att-btn { display: inline-flex; align-items: center; justify-content: center; flex: 1 1 9rem; text-decoration: none; }
.att-btn:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; }
.att-lightbox-img { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 14px; object-fit: contain; background: var(--surface); }
.msg-attach-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.msg-progress { height: 12px; border-radius: 99px; background: rgb(var(--c-primary-100)); overflow: hidden; }
.msg-progress span, .msg-meter span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(to left, rgb(var(--c-primary-500)), rgb(var(--c-primary-600))); transition: width .2s; }
.msg-row-att { font-size: 16.5px; font-weight: 800; color: rgb(var(--tx-primary-700)); overflow-wrap: anywhere; margin-top: 2px; }
.msg-meter { height: 14px; border-radius: 99px; background: rgb(var(--c-primary-100)); overflow: hidden; }
.msg-file-acts { display: flex; gap: 6px; margin-inline-start: auto; }
.msg-dl { min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 12px; font-size: 16.5px; font-weight: 900; background: var(--surface-2); color: var(--text); }
.msg-dl:focus-visible { outline: 3px solid rgb(var(--ln-primary-400)); outline-offset: 2px; }
.msg-files[open] .pins-chev { transform: rotate(180deg); }
.my-msg .att-card .att-btn { flex-basis: 100%; }

/* ===================== Redesign (spec 7.17): shared components ===================== */
/* Every rule reads the tokens of the active design (html[data-design]) and mode (html.dark). */
.st-view .hidden, .login-modal .hidden, .dlg-scrim .hidden, .site-head .hidden { display: none !important; }
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--card-shadow); border: var(--bw) solid var(--card-border); }
html.dark .card { box-shadow: inset 0 1px 0 rgb(255 255 255 / .04); }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 52px; padding-inline: var(--s5);
    border-radius: var(--r-btn); border: 0; font-family: var(--f-head); font-weight: 600; font-size: 17.5px; white-space: nowrap; cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, background-color .16s ease;
}
.btn i { font-size: 24px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--btn-shadow); }
html[data-design="c"] .btn-primary:not(:disabled):active { transform: translateY(4px); box-shadow: 0 0 0 var(--deep); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 18.5px; }
.btn-sm { min-height: 44px; padding-inline: var(--s3); font-size: 15.5px; gap: 6px; }
.btn-sm i { font-size: 22px; }
.btn-tonal { background: var(--tint); color: var(--on-tint); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-icon { width: 44px; min-height: 44px; padding: 0; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding-inline: var(--s3); border-radius: var(--r-pill); font-family: var(--f-head); font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.chip i { font-size: 17.5px; }
.chip-tint { background: var(--tint); color: var(--on-tint); }
.chip-gold { background: var(--reward-tint); color: var(--on-reward); }
.chip-gold i { color: var(--warn); }
html.dark .chip-gold i { color: var(--reward); }
.chip-plain { background: var(--surface-2); color: var(--text); }
.chip-unit { font-weight: 400; }
.field { display: flex; align-items: center; gap: var(--s3); min-height: 52px; padding-inline: var(--s4); border-radius: var(--r-btn); background: var(--surface); border: 1.5px solid var(--border); transition: border-color .15s, box-shadow .15s; }
.field i { font-size: 24px; color: var(--muted); flex: none; }
.field input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 17.5px; color: var(--text); outline: 0; padding-block: 10px; }
.field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--tint); }
.field--pin input { text-align: center; font-family: var(--f-head); font-size: 22px; letter-spacing: .3em; direction: ltr; }
html[data-design="b"] .field { border-width: 1px; }
html[data-design="c"] .field { border-width: 2px; border-block-end-width: 4px; }
.label { display: block; font-family: var(--f-head); font-weight: 600; font-size: 15.5px; margin-block-end: var(--s2); color: var(--text); }
.av { width: 40px; height: 40px; flex: none; white-space: nowrap; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-head); font-weight: 600; font-size: 15.5px; background: var(--tint); color: var(--on-tint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- header, footer, toast, sync line ---- */
.site-head { background: var(--surface); border-block-end: 1px solid var(--border); }
.site-head-in { max-width: 72rem; margin-inline: auto; padding: 8px 16px; display: flex; align-items: center; gap: 12px; }
.site-head-txt { min-width: 0; flex: 1; }
.site-title { font-family: var(--f-head); font-weight: var(--hw); font-size: 17.5px; line-height: 1.35; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-sub { font-size: 14.5px; color: var(--muted); }
@media (max-width: 479px) { .site-sub { display: none; } .site-title { font-size: 15.5px; } }
.logo-card--header { width: 96px; padding: 6px; border-radius: 10px; animation: none; box-shadow: 0 0 0 1px var(--border); }
.logo-card--header::after { display: none; }
@media (min-width: 640px) { .logo-card--header { width: 132px; padding: 8px; border-radius: 12px; } }
/* the see-through logo sits on the bar itself (2026-11-06) */
.site-head .logo-card--header { background: transparent; box-shadow: none; padding: 0; width: 112px; }
@media (min-width: 640px) { .site-head .logo-card--header { width: 150px; padding: 0; } }
.theme-toggle {
    min-width: 44px; min-height: 44px; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex: none;
    border-radius: var(--r-btn); font-size: 24px; line-height: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); cursor: pointer;
}
.theme-toggle--card { position: absolute; top: 12px; inset-inline-end: 12px; z-index: 2; }
.site-foot { background: var(--surface); color: var(--muted); border-block-start: 1px solid var(--border); font-size: 14.5px; text-align: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
.toast { position: fixed; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 70; max-width: calc(100vw - 32px); padding: 12px 20px; border-radius: var(--r-btn); box-shadow: 0 12px 30px -8px rgb(0 0 0 / .35); font-family: var(--f-head); font-weight: 600; font-size: 15.5px; color: #fff; text-align: center; }
.toast.bg-ink { background: var(--ink); }
html.dark .toast.bg-ink { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--border), 0 12px 30px -8px rgb(0 0 0 / .6); }
.sync-line { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 14.5px; color: var(--muted); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); display: inline-block; }
.sync-dot.is-online { background: var(--ok-solid); }
.sync-dot.is-local { background: var(--reward); }
.greeting-banner { display: flex; align-items: center; gap: 12px; padding: 8px 12px; }
.greeting-banner-icon { font-size: 26.5px; flex: none; }

/* ---- 1. login: the ORIGINAL look the teacher asked to keep (a rosy glass card over a blurred purple page) ----
   Fixed colours on purpose: this screen does not follow the A/B/C design tokens. The backdrop paints the old
   page (pink body + purple/pink/teal header bar), blurs it and lays the old purple-950/70 veil on top. */
.login-modal { isolation: isolate; background: none; }
/* before student.js runs (see the <head> script in index.html): the sign-in card is up from the first paint */
html.boot-login #modal-student-login.hidden { display: flex !important; }
.login-modal :where(:not(i)) { font-family: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif; }
.login-modal .backdrop {
    position: fixed; inset: -24px; z-index: -1; overflow: hidden; filter: blur(12px);
    background: linear-gradient(to left, #581c87, #db2777, #14b8a6) top / 100% var(--ol-bar, 88px) no-repeat, linear-gradient(135deg, #fdf4ff 0%, #fae8ff 50%, #f0f9ff 100%);
}
.login-modal .backdrop::after { content: ""; position: absolute; inset: 0; background: rgb(59 7 100 / .7); }
@media (min-width: 640px) { .login-modal .backdrop { --ol-bar: 114px; } }
.ol-card {
    position: relative; width: 100%; max-width: 28rem; margin: auto; padding: 24px; border-radius: 24px; text-align: center;
    display: flex; flex-direction: column; gap: 24px; color: #1e293b;
    background: rgb(255 255 255 / .94); backdrop-filter: blur(16px); border: 2px solid #d8b4fe;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);
}
@media (min-width: 768px) { .ol-card { padding: 32px; } }
.login-modal .theme-toggle--card { top: 14px; inset-inline-end: 14px; border-radius: 9999px; font-size: 20px; background: #f3e8ff; border: 1px solid #d8b4fe; color: #1e293b; }
.ol-owl {
    position: relative; width: 96px; height: 96px; margin-inline: auto; border-radius: 9999px; display: flex; align-items: center; justify-content: center;
    font-size: 48px; line-height: 1; background: linear-gradient(to top right, #a855f7, #f472b6); border: 4px solid #fff;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1); animation: pulseSoft 2s infinite;
}
.ol-spark { position: absolute; top: -4px; right: -4px; font-size: 24px; line-height: 32px; }
/* the school logo at the top of the login card (the teacher asked for it back in place of the owl) */
.ol-card .ol-logo { max-width: 240px; padding: 10px 14px; animation: none; box-shadow: 0 0 0 1px #e9d5ff, 0 10px 20px -12px rgb(88 28 135 / .35); }
/* the new see-through logo (2026-11-06): no white card, it sits on the sign-in card itself; dark mode shows the
   version with white lettering */
.ol-card .ol-logo.logo-card { background: transparent; box-shadow: none; padding: 4px 0; max-width: 260px; }
.ol-card .ol-logo.logo-card::after { display: none; }
.logo-card .lg-dark { display: none; }
html.dark .logo-card .lg-light { display: none; }
html.dark .logo-card .lg-dark { display: block; }
.ol-title { font-size: 24px; line-height: 32px; font-weight: 900; color: #581c87; }
.ol-sub { margin-top: 4px; font-size: 12px; line-height: 16px; font-weight: 700; color: #9333ea; }
.ol-form { display: flex; flex-direction: column; gap: 12px; text-align: right; }
.ol-ta { position: relative; }
.ol-label { display: block; margin-bottom: 4px; font-size: 12px; line-height: 16px; font-weight: 700; color: #581c87; }
.ol-input {
    display: block; width: 100%; padding: 12px 16px; border-radius: 16px; border: 2px solid #e9d5ff; background: #fff; outline: 0;
    font-size: 14px; line-height: 20px; font-weight: 700; color: #581c87; transition: border-color .15s, box-shadow .15s;
}
.ol-input::placeholder { color: #9ca3af; opacity: 1; }
.ol-input:focus { border-color: #ec4899; box-shadow: 0 0 0 4px #fce7f3; }
.ol-input--pin { text-align: center; font-size: 20px; line-height: 28px; font-weight: 900; letter-spacing: .1em; direction: ltr; }
.ol-hint { margin-top: -8px; font-size: 10px; line-height: 14px; font-weight: 700; color: #94a3b8; }
.ol-msg { min-height: 16px; font-size: 12px; line-height: 16px; font-weight: 700; color: #e11d48; }
.ol-msg--warn { color: #b45309; }
.ol-step { font-size: 16px; line-height: 24px; font-weight: 900; text-align: center; color: #581c87; }
.ol-name { color: #db2777; }
.ol-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ol-row--start { justify-content: flex-start; }
.ol-row--center { justify-content: center; }
.ol-link { padding-block: 6px; background: none; border: 0; font-size: 12px; line-height: 16px; font-weight: 700; color: #9333ea; cursor: pointer; }
.ol-link:hover { color: #6b21a8; text-decoration: underline; }
.ol-submit {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 16px 0; border: 0; border-radius: 16px; cursor: pointer;
    background: linear-gradient(to right, #9333ea, #ec4899, #2dd4bf); color: #fff; font-size: 16px; line-height: 24px; font-weight: 900;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);
}
.ol-submit:hover { box-shadow: 0 25px 50px -12px rgb(0 0 0 / .25); }
.ol-submit i { font-size: 20px; }
.ol-submit:disabled { opacity: .5; cursor: wait; }
.ol-foot { padding-top: 12px; border-top: 1px solid #f3e8ff; }
.ol-tlink { display: inline-flex; align-items: center; gap: 4px; padding-block: 6px; background: none; border: 0; font-size: 14px; line-height: 20px; font-weight: 700; color: #db2777; cursor: pointer; }
.ol-tlink i { font-size: 16px; }
.ol-tlink:hover { color: #9d174d; text-decoration: underline; }
#modal-student-login .ta-list { margin-top: 4px; padding: 0; border-radius: 16px; background: #fff; border: 2px solid #e9d5ff; box-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1); }
#modal-student-login .ta-list li { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; min-height: 48px; padding: 10px 16px; border-radius: 0; text-align: right; color: #581c87; }
#modal-student-login .ta-list li + li { border-top: 1px solid #faf5ff; }
#modal-student-login .ta-list li:hover, #modal-student-login .ta-list li[aria-selected="true"] { background: #faf5ff; color: #581c87; }
#modal-student-login .ta-list .av { display: none; }
#modal-student-login .ta-name { max-width: 100%; font-size: 14px; line-height: 20px; font-weight: 900; }
#modal-student-login .ta-list small, #modal-student-login .ta-list li[aria-selected="true"] small { margin: 0; font-size: 12px; line-height: 16px; font-weight: 700; color: #64748b; }
/* the original dark mode (lavender) */
html.dark .login-modal .backdrop { background: linear-gradient(to left, #3b0764, #9d174d, #0f766e) top / 100% var(--ol-bar, 88px) no-repeat, linear-gradient(135deg, #2b2540 0%, #3a3152 55%, #2c3047 100%); }
html.dark .login-modal .backdrop::after { background: rgb(30 26 46 / .55); }
html.dark .ol-card { background: rgb(62 52 88 / .92); border-color: rgb(216 180 254 / .25); color: #f1ecfa; box-shadow: 0 0 30px rgb(236 72 153 / .18); }
html.dark .login-modal .theme-toggle--card { background: #4b4268; border-color: rgb(216 180 254 / .35); color: #fcd34d; }
html.dark .ol-title, html.dark .ol-label, html.dark .ol-step { color: #f3e8ff; }
html.dark .ol-sub, html.dark .ol-link { color: #e9d5ff; }
html.dark .ol-link:hover { color: #faf5ff; }
html.dark .ol-input { background: #433a5e; border-color: rgb(216 180 254 / .3); color: #f3e8ff; }
html.dark .ol-input::placeholder { color: #c9bfdc; }
html.dark .ol-input:focus { border-color: #ec4899; box-shadow: 0 0 0 4px rgb(236 72 153 / .35); }
html.dark .ol-hint { color: #c6cdda; }
html.dark .ol-msg { color: #fecdd3; }
html.dark .ol-msg--warn { color: #fde68a; }
html.dark .ol-name, html.dark .ol-tlink { color: #fbcfe8; }
html.dark .ol-tlink:hover { color: #fdf2f8; }
html.dark .ol-foot { border-top-color: rgb(216 180 254 / .25); }
html.dark #modal-student-login .ta-list { background: #433a5e; border-color: rgb(216 180 254 / .3); }
html.dark #modal-student-login .ta-list li { color: #f3e8ff; }
html.dark #modal-student-login .ta-list li + li { border-top-color: rgb(216 180 254 / .18); }
html.dark #modal-student-login .ta-list li:hover, html.dark #modal-student-login .ta-list li[aria-selected="true"] { background: rgb(168 85 247 / .16); color: #f3e8ff; }
html.dark #modal-student-login .ta-list small, html.dark #modal-student-login .ta-list li[aria-selected="true"] small { color: #d3d9e4; }

/* the teacher sign-in dialog keeps the new card */
.lcard { position: relative; background: var(--surface); border-radius: var(--r-sheet); padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 24px 48px -12px var(--lift); }
.l-title { font-family: var(--f-head); font-weight: var(--hw); font-size: 24px; line-height: 1.4; color: var(--text); }
.lsub { color: var(--muted); font-size: 15.5px; line-height: 1.6; }
.l-msg { font-size: 15.5px; font-weight: 500; color: var(--error); min-height: 1.25rem; }
.ta { position: relative; }
.ta-list { position: absolute; inset-inline: 0; z-index: 10; list-style: none; margin: var(--s2) 0 0; padding: 4px; max-height: 16rem; overflow-y: auto; border-radius: var(--r-btn); background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
html.dark .ta-list { background: var(--surface-2); }
.ta-list li { display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding-inline: var(--s2); border-radius: 8px; font-size: 15px; cursor: pointer; color: var(--text); }
.ta-list li:hover, .ta-list li[aria-selected="true"] { background: var(--tint); color: var(--on-tint); }
.ta-list .av { width: 30px; height: 30px; font-size: 12px; }
.ta-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ta-list small { margin-inline-start: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.ta-list li[aria-selected="true"] small { color: var(--on-tint); }
html[data-design="b"] .lcard { border: 1px solid var(--border); box-shadow: 0 24px 48px -16px var(--lift); }
html[data-design="c"] .lcard { border: 2px solid var(--text); box-shadow: 0 8px 0 var(--deep); }
html.dark[data-design="c"] .lcard { border-color: var(--border); }
html[data-design="c"] .l-title { font-size: 26.5px; }

/* ---- 2. challenge ---- */
.st-view { max-width: 640px; margin-inline: auto; padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: var(--s4); }
.st-view.hidden { display: none; }
.st-panel { display: flex; flex-direction: column; gap: var(--s4); }
/* ---- the student's top bar: one soft card. Row 1: her avatar (gradient ring), name and class, and on the
   inline-end (left) «تغيير الرقم السري» · «تسجيل خروج» · ليلي. Row 2: stage / stars / time cards. Row 3: progress. ---- */
.ch-top { --av-ring: linear-gradient(135deg, var(--primary), var(--deep)); display: flex; flex-direction: column; gap: var(--s3); padding: var(--s3) var(--s4) var(--s4); background: var(--surface); border: var(--bw) solid var(--card-border); border-radius: var(--r-card); box-shadow: var(--card-shadow); }
html.dark .ch-top { background: var(--surface); box-shadow: inset 0 1px 0 rgb(255 255 255 / .04); }
.ch-head { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.ch-row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-width: 0; }
.ring-slot { flex: none; display: flex; align-items: center; }
.me { display: inline-flex; align-items: center; gap: 10px; min-height: 60px; padding: 4px; padding-inline-end: 12px; border-radius: var(--r-pill); border: 1px solid transparent; background: transparent; color: var(--muted); flex: 0 1 auto; min-width: 0; cursor: pointer; text-align: start; transition: background-color .15s, border-color .15s; }
.me:hover { background: var(--tint); }
.me:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.me .av { width: 54px; height: 54px; font-size: 20px; font-weight: 800; border: 3px solid transparent; background: linear-gradient(var(--tint), var(--tint)) padding-box, var(--av-ring) border-box; color: var(--on-tint); box-shadow: 0 6px 14px -8px rgb(var(--primary-rgb) / .7); }
.me .av i { font-size: 26.5px; }
.me > i { font-size: 14.5px; flex: none; }
.ch-id { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.ch-id b { font-family: var(--f-head); font-weight: 800; font-size: 20px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-id small { font-size: 14.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-id b:empty { display: none; }
html[data-design="c"] .me { border-width: 2px; }
/* the left group: compact pill buttons; the ليلي toggle sits with them */
.ch-acts { display: flex; align-items: center; gap: 6px; flex: none; margin-inline-start: auto; }
.ch-act { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px; padding-inline: 12px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-family: var(--f-head); font-weight: 600; font-size: 14.5px; white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s, transform .12s; }
.ch-act i { font-size: 22px; color: var(--on-tint); }
html.dark .ch-act i { color: var(--primary); }
.ch-act:hover { background: var(--tint); border-color: var(--primary); }
.ch-act:active { transform: scale(.97); }
.ch-act:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.ch-act.ch-theme { width: 44px; height: 44px; padding: 0; border-radius: var(--r-pill); font-size: 22px; }
/* before sign-in (behind the login window) the PIN / logout buttons have nothing to act on */
.st-view:not(.st-signed) .ch-act[data-me] { display: none; }
/* the page header's own ليلي toggle steps aside while the student bar (which has one) is on screen */
html:has(#view-student:not(.hidden) .ch-theme) .site-head .theme-toggle { display: none; }
/* «واجباتي» / «شهاداتي»: no stage, timer or «سؤال ١ من ٢» (only the avatar and the stars stay) */
.st-view.st-no-quiz-head [data-quiz-only] { display: none !important; }
/* stage / stars / time: pill cards with the icon in a soft circle and a bold number */
.ch-row .chip { height: 48px; gap: 8px; padding-inline: 6px 16px; font-size: 16.5px; font-weight: 700; border: 1px solid transparent; }
.ch-row .chip-ic { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: rgb(var(--surface-rgb) / .75); }
html.dark .ch-row .chip-ic { background: rgb(255 255 255 / .1); }
.ch-row .chip-ic i { font-size: 21px; }
.ch-row .chip-v { font-family: var(--f-head); font-weight: 800; font-size: 18.5px; }
.ch-row .chip-v:empty { display: none; }
.ch-row .chip-unit { font-weight: 600; }
.ch-row .chip-tint { border-color: rgb(var(--primary-rgb) / .18); }
.ch-row .chip-gold { border-color: rgb(var(--reward-rgb) / .35); }
.ch-row .chip-plain { border-color: var(--border); }
.ch-row .chip-plain i { color: var(--on-tint); }
html.dark .ch-row .chip-plain i { color: var(--primary); }
@media (max-width: 640px) {
    .ch-act-l { display: none; }
    .ch-act { padding: 0; width: 44px; }
}
@media (max-width: 440px) {
    .ch-top { padding: var(--s3); }
    .ch-head { gap: 6px; }
    .me { gap: 6px; padding-inline-end: 4px; min-height: 52px; }
    .me .av { width: 44px; height: 44px; font-size: 16.5px; }
    .ch-id b { font-size: 17.5px; }
    .ch-acts { gap: 4px; }
    /* one row of three cards: the stage card drops its icon, the others keep theirs a little smaller */
    .ch-row { gap: 4px; }
    .ch-row .chip { height: 44px; gap: 5px; padding-inline: 4px 10px; font-size: 15.5px; }
    .ch-row .chip-tint { padding-inline: 10px; }
    .ch-row .chip-tint .chip-ic { display: none; }
    .ch-row .chip-ic { width: 28px; height: 28px; }
    .ch-row .chip-ic i { font-size: 18.5px; }
    .ch-row .chip-v { font-size: 16.5px; }
}
.countdown.ring { width: 52px; height: 52px; }
.countdown-track { stroke: var(--tint); stroke-width: 5; }
.countdown-bar { stroke: var(--primary); stroke-width: 5; }
.countdown-num { font-family: var(--f-head); font-weight: 700; font-size: 17.5px; color: var(--text); }
.prog { display: flex; flex-direction: column; gap: 6px; }
.prog-h { display: flex; justify-content: space-between; font-size: 15.5px; color: var(--text); }
.prog-h strong { font-family: var(--f-head); font-weight: 600; }
.prog-h span { color: var(--muted); }
.bar { height: 8px; border-radius: var(--r-pill); background: var(--tint); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width .4s var(--spring); }
/* her progress in the bar: a bolder line and a slightly thicker, rounded bar with a soft glow */
.ch-top .prog { gap: 8px; }
.ch-top .prog-h { align-items: baseline; }
.ch-top .prog-h strong { font-size: 17.5px; font-weight: 800; }
.ch-top .bar { height: 12px; box-shadow: inset 0 1px 2px rgb(0 0 0 / .06); }
.ch-top .bar i { box-shadow: 0 0 10px rgb(var(--primary-rgb) / .35); }
html[data-design="b"] .bar { height: 4px; }
html[data-design="c"] .bar { height: 12px; }
.eqcard { position: relative; overflow: hidden; isolation: isolate; padding: var(--s5) var(--s4); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--s2); }
.eqcard::before { content: ""; position: absolute; inset: 0; z-index: -1; background-image: linear-gradient(currentColor 1px, transparent 1px), linear-gradient(90deg, currentColor 1px, transparent 1px); background-size: 22px 22px; background-position: center; color: var(--primary); opacity: .06; -webkit-mask-image: radial-gradient(closest-side, #000, transparent); mask-image: radial-gradient(closest-side, #000, transparent); }
.eqcard .ask { display: inline-flex; align-items: center; gap: 6px; font-size: 16.5px; color: var(--muted); }
.eqcard .ask i { font-size: 20px; }
.eqcard .big, #quiz-question-text { font-family: var(--f-math); font-weight: var(--dw); font-size: clamp(27.5px, 7vw, 42.5px); line-height: 1.4; color: var(--text); overflow-wrap: anywhere; }
#quiz-question-text.is-note { font-family: var(--f-head); font-size: 22px; }
.eqcard .sub { display: inline-flex; align-items: center; gap: var(--s2); font-family: var(--f-head); font-weight: 600; font-size: 16.5px; color: var(--on-tint); }
.steps { display: inline-flex; gap: 4px; }
.steps i { width: 18px; height: 6px; border-radius: 3px; background: currentColor; opacity: .35; }
.steps i:first-child { opacity: 1; }
html[data-design="a"] .eqcard { background: radial-gradient(100% 80% at 50% 0%, var(--surface) 0%, var(--tint) 75%); box-shadow: none; }
html.dark[data-design="a"] .eqcard { background: radial-gradient(100% 80% at 50% 0%, #40366A 0%, var(--tint) 75%); }
html[data-design="a"]:not(.dark) .eqcard .ask { color: var(--on-tint); }
html.dark .eqcard .sub { color: var(--primary); }
html[data-design="b"] .eqcard { padding-block: var(--s6); }
html[data-design="b"] .eqcard .big { color: var(--primary); }
html[data-design="b"] .eqcard .sub { color: var(--muted); font-weight: 400; font-family: var(--f-body); }
html[data-design="c"] .eqcard { background: radial-gradient(90% 90% at 100% 0%, var(--deep), transparent 70%), var(--primary); border: 0; box-shadow: 0 6px 0 var(--deep); }
html.dark[data-design="c"] .eqcard { background: radial-gradient(90% 90% at 100% 0%, #FDBA74, transparent 70%), var(--primary); }
html[data-design="c"] .eqcard::before { color: var(--on-primary); opacity: .12; }
html[data-design="c"] .eqcard .ask, html[data-design="c"] .eqcard .big, html[data-design="c"] .eqcard .sub, html[data-design="c"] #quiz-question-text { color: var(--on-primary); }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.ans { position: relative; min-height: 64px; border-radius: var(--r-btn); background: var(--surface); border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; gap: var(--s2); font-family: var(--f-math); font-size: 22px; color: var(--text); padding: 8px var(--s5); cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background-color .16s ease, border-color .16s ease; }
.ans-txt { overflow-wrap: anywhere; }
.ans .mk { display: none; }
.ans .ok { position: absolute; inset-block-start: 6px; inset-inline-end: 6px; font-size: 22px; color: var(--primary); display: none; }
.ans[aria-pressed="true"] { border-color: var(--primary); background: var(--tint); box-shadow: 0 0 0 1px var(--primary) inset; }
.ans[aria-pressed="true"] .ok { display: block; }
.ans:not(:disabled):active { transform: scale(.98); }
.ans.opt-reveal { border-color: var(--success); background: var(--success-tint); box-shadow: 0 0 0 2px var(--success) inset; }
.ans.opt-reveal .ok { display: block; color: var(--success); }
.ans:disabled { cursor: not-allowed; }
.ans:disabled:not(.opt-reveal) { opacity: .55; }
html[data-design="a"] .ans { border-color: transparent; box-shadow: var(--card-shadow); }
html.dark[data-design="a"] .ans { border-color: var(--border); }
html[data-design="a"] .ans[aria-pressed="true"] { border-color: var(--primary); }
html[data-design="b"] .answers { grid-template-columns: 1fr; gap: var(--s2); }
html[data-design="b"] .ans { min-height: 52px; justify-content: flex-start; border-width: 1px; font-size: 21px; padding-inline: var(--s3) 44px; }
html[data-design="b"] .ans .mk-letter { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); font-family: var(--f-head); font-size: 14.5px; font-weight: 600; color: var(--muted); }
html[data-design="b"] .ans[aria-pressed="true"] .mk-letter { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
html[data-design="b"] .ans .ok { inset-block-start: 50%; translate: 0 -50%; inset-inline-end: var(--s4); }
html[data-design="c"] .ans { border-width: 2px; border-block-end-width: 5px; min-height: 68px; font-size: 24px; }
html[data-design="c"] .ans .mk-shape { display: block; font-size: 20px; color: var(--primary); position: absolute; inset-block-start: 8px; inset-inline-start: 10px; }
html[data-design="c"] .ans:not(:disabled):active { transform: translateY(3px); border-block-end-width: 2px; }
@media (max-width: 360px) { .answers { grid-template-columns: 1fr; } }
.answers-done { grid-column: 1 / -1; text-align: center; padding: var(--s4) 0; color: var(--muted); font-size: 15.5px; }
.answers-done-emoji { font-size: 51px; }
.confirm { margin-block-start: var(--s1); }
.hint { background: var(--reward-tint); color: var(--on-reward); border-radius: var(--r-card); padding: var(--s3) var(--s4); font-size: 16.5px; }
.hint-h { display: flex; align-items: center; gap: 6px; font-family: var(--f-head); font-weight: 600; }
.hint-h i { font-size: 22px; color: var(--warn); }
html.dark .hint-h i { color: var(--reward); }
.quiz-timeout { padding: 10px 14px; border-radius: var(--r-btn); border: 1px solid rgb(var(--error-rgb) / .3); background: var(--error-tint); color: var(--error); font-family: var(--f-head); font-weight: 600; font-size: 17.5px; text-align: center; }

/* panels */
.st-card { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.st-h { display: flex; align-items: center; gap: var(--s2); font-family: var(--f-head); font-weight: var(--hw); font-size: 22px; color: var(--text); }
.st-h i { font-size: 26.5px; color: var(--primary); }
.st-sub { color: var(--muted); font-size: 15.5px; margin-top: calc(var(--s2) * -1); }
.st-empty { color: var(--muted); font-size: 15.5px; text-align: center; padding: var(--s3) 0; }
.lb-list { display: flex; flex-direction: column; gap: var(--s2); }
.lb-row { display: flex; align-items: center; gap: var(--s3); min-height: 52px; padding: 6px var(--s3); border-radius: var(--r-btn); background: var(--surface-2); }
.lb-row.is-me { box-shadow: 0 0 0 2px var(--primary) inset; }
.lb-medal { font-size: 26.5px; line-height: 1; }
.lb-name { flex: 1; min-width: 0; font-family: var(--f-head); font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-time { font-family: var(--f-head); font-weight: 600; color: var(--on-tint); white-space: nowrap; }
html.dark .lb-time { color: var(--primary); }
.my-rank { text-align: center; font-family: var(--f-head); font-weight: 600; font-size: 15.5px; color: var(--on-tint); background: var(--tint); border-radius: var(--r-btn); padding: 8px; }
.badge-list { display: flex; flex-wrap: wrap; gap: var(--s2); }
.badge-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px; border-radius: var(--r-pill); background: var(--reward-tint); color: var(--on-reward); font-family: var(--f-head); font-weight: 600; font-size: 15.5px; }
.badge-chip i { font-size: 20px; color: var(--warn); }
html.dark .badge-chip i { color: var(--reward); }
.empty-state { align-items: center; text-align: center; color: var(--muted); padding-block: var(--s6); }
.empty-state i { font-size: 46.5px; color: var(--primary); opacity: .6; }
#my-certs:not(.hidden) + .empty-state, #my-msgs:not(.hidden) + .empty-state { display: none; }

/* bottom bar: one row */
.nav { position: fixed; z-index: 30; inset-inline: 0; bottom: 0; max-width: 640px; margin-inline: auto; display: flex; flex-wrap: nowrap; background: var(--surface); border-block-start: 1px solid var(--border); padding: var(--s2) var(--s2) calc(10px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 672px) { .nav { border-inline: 1px solid var(--border); border-radius: var(--r-card) var(--r-card) 0 0; } }
.nav button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 52px; background: none; border: 0; color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.3; cursor: pointer; white-space: nowrap; }
.nav .pill { position: relative; width: 56px; height: 32px; border-radius: var(--r-pill); display: grid; place-items: center; font-size: 26.5px; transition: background-color .16s ease, transform .12s ease; }
.nav button[aria-current="page"] { color: var(--text); }
.nav button[aria-current="page"] .pill { background: var(--tint); color: var(--on-tint); }
html[data-design="c"] .nav button[aria-current="page"] .pill { background: var(--primary); color: var(--on-primary); }
.nav button:active .pill { transform: scale(.92); }
.nav-dot { position: absolute; top: 2px; inset-inline-end: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--error); box-shadow: 0 0 0 2px var(--surface); }
@media (max-width: 360px) { .nav .pill { width: 44px; } .nav button { font-size: 12px; } }

/* avatar menu (bottom sheet) + sign-out confirm */
.scrim { position: fixed; inset: 0; z-index: 45; background: var(--scrim); -webkit-backdrop-filter: blur(6px) saturate(.8); backdrop-filter: blur(6px) saturate(.8); }
.sheet { position: fixed; z-index: 46; inset-inline: 0; bottom: 0; max-width: 640px; margin-inline: auto; background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0; padding: var(--s2) var(--s4) calc(28px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 32px rgb(0 0 0 / .18); animation: sheetUp .2s cubic-bezier(.2, .8, .2, 1); }
html.dark .sheet { background: var(--surface-2); }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto var(--s3); }
.sheet-h { display: flex; align-items: center; gap: var(--s3); padding-block-end: var(--s3); border-block-end: 1px solid var(--border); margin-block-end: var(--s2); }
.sheet-h b { font-family: var(--f-head); font-weight: 600; color: var(--text); }
.sheet-h small { display: block; color: var(--muted); font-size: 14.5px; line-height: 1.4; }
.sheet ul { list-style: none; margin: 0; padding: 0; }
.sheet li button { width: 100%; display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding-inline: var(--s2); border: 0; background: none; border-radius: var(--r-btn); font-size: 17.5px; text-align: start; color: var(--text); cursor: pointer; }
.sheet li button i { font-size: 24px; color: var(--on-tint); }
html.dark .sheet li button i { color: var(--primary); }
.sheet li button:hover { background: var(--tint); }
.sheet li.sep { border-block-start: 1px solid var(--border); margin-block-start: var(--s2); padding-block-start: var(--s2); }
.confirm-dlg { position: fixed; inset: 0; z-index: 47; display: grid; place-items: center; padding: var(--s5); background: var(--scrim); -webkit-backdrop-filter: blur(6px) saturate(.8); backdrop-filter: blur(6px) saturate(.8); }
.confirm-dlg .dlg { max-width: 360px; }
/* «تغيير الرقم السري»: three 4-digit fields, labels on the start side */
.pin-dlg .dlg { max-width: 380px; max-height: calc(100dvh - 2 * var(--s5)); overflow-y: auto; align-items: stretch; text-align: start; gap: 6px; }
.pin-dlg .dlg-ic, .pin-dlg .dlg-q, .pin-dlg .dlg > small { align-self: center; text-align: center; }
.pin-dlg .dlg > small { margin-block-end: var(--s2); }
.pin-dlg .label { margin-block: var(--s2) 0; }
.pin-dlg .field { min-height: 48px; }
.pin-dlg .field input[aria-invalid="true"] { color: var(--error); }
.pin-dlg .field:has(input[aria-invalid="true"]) { border-color: var(--error); }
.pin-dlg .ap-msg { font-size: 15.5px; text-align: center; margin-block-start: var(--s1); }
.dlg { width: 100%; padding: var(--s5) var(--s4) var(--s4); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--s2); animation: dlgIn .18s ease-out; }
html.dark .dlg { background: var(--surface-2); }
@keyframes dlgIn { from { transform: scale(.94); opacity: 0; } }
.dlg-ic { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--tint); color: var(--on-tint); font-size: 27.5px; margin-block-end: var(--s1); }
.dlg-q { font-family: var(--f-head); font-weight: var(--hw); font-size: 21px; color: var(--text); }
.dlg small { color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.dlg-acts { display: flex; flex-wrap: nowrap; gap: var(--s2); width: 100%; margin-block-start: var(--s3); }
.dlg-acts .btn { flex: 1; }
.dlg-acts--stack { flex-direction: column; }

/* celebration + message windows */
.dlg-scrim { background: var(--scrim); -webkit-backdrop-filter: blur(6px) saturate(.8); backdrop-filter: blur(6px) saturate(.8); }
.dlg-scrim .dlg { padding: var(--s5); border-radius: var(--r-sheet); }
.dlg-emoji { font-size: 59.5px; line-height: 1.1; }
.dlg-title { font-family: var(--f-head); font-weight: var(--hw); font-size: 22px; line-height: 1.4; color: var(--text); }
.dlg-title.text-success { color: var(--success); }
.dlg-text { color: var(--muted); font-size: 16.5px; line-height: 1.7; }
.dlg-text--lg { color: var(--text); font-size: 18.5px; }
.dlg-num { font-family: var(--f-head); font-weight: 700; color: var(--on-tint); }
html.dark .dlg-num { color: var(--primary); }
.dlg-pill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 40px; padding: 6px 12px; border-radius: var(--r-btn); font-family: var(--f-head); font-weight: 600; font-size: 15.5px; }
.dlg-pill i { font-size: 20px; }
.dlg-pill--gold { background: var(--reward-tint); color: var(--on-reward); }
.dlg-pill--gold i { color: var(--warn); }
html.dark .dlg-pill--gold i { color: var(--reward); }
.dlg-pill--err { background: var(--error-tint); color: var(--error); }
.dlg-more { font-size: 15.5px; font-weight: 600; color: var(--on-tint); }
.dlg-more:empty { display: none; }
#modal-teacher-auth .lcard { gap: var(--s3); }
@media (prefers-reduced-motion: reduce) { .sheet, .dlg, .bar i { animation: none; transition: none; } }
html.no-motion .sheet, html.no-motion .dlg { animation: none; }
html.is-preview .ol-foot { display: none !important; }
.cc-swatch { display: inline-block; flex: none; }
/* a power's exponent, at the top left of its base as the book prints it (math-text.js) */
.math-text .m-pow { font-size: .7em; vertical-align: .55em; line-height: 0; }

/* the login screen keeps its size (frozen): the site-wide text size rise stops here */
.login-modal, #modal-teacher-auth { font-size: 16px; }
/* «رمز الفصل» above the name on the login card */
.ol-code { margin-bottom: 6px; }
.ol-code-row { display: flex; align-items: center; gap: 8px; }
.ol-input--code { letter-spacing: .3em; text-align: center; font-weight: 800; font-size: 20px; direction: ltr; }
.ol-input--code.is-ok { border-color: #15803d; background: #f0fdf4; }
.ol-code-row .ol-link { flex: none; }
.ol-msg.is-ok { color: #15803d; }
#login-name-input:disabled { opacity: .55; cursor: not-allowed; }
html.dark .ol-input--code.is-ok { background: rgb(21 128 61 / .15); }
/* the class's names under the code: she taps hers */
.ol-code-go { flex: none; min-height: 44px; padding-inline: 18px; }
.ol-class { margin-top: 4px; display: flex; flex-direction: column; gap: 8px; }
.ol-class-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #581c87; font-size: 14px; }
.ol-names { list-style: none; margin: 0; padding: 2px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 300px; overflow-y: auto; }
.ol-name-btn { width: 100%; display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 6px 10px; border-radius: 12px; border: 1.5px solid #e9d5ff;
    background: #fff; color: #3b0764; font: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer; text-align: start; }
.ol-name-btn:hover, .ol-name-btn:focus-visible { border-color: #9333ea; background: #faf5ff; }
.ol-name-btn .av { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #f3e8ff; color: #7e22ce; font-size: 12px; font-weight: 900; }
.ol-names-empty { padding: 10px; color: #6b7280; font-size: 13px; }
html.dark .ol-class-h { color: #f3e8ff; }
html.dark .ol-name-btn { background: rgb(255 255 255 / .06); border-color: rgb(216 180 254 / .3); color: #f3e8ff; }
