/* =========================================================================
   منصة الطالب — DESIGN SYSTEM v1
  مصدر واحد للهوية البصرية. إعادة كتابة كاملة، دون بقايا من التصميم القديم.
   Primary: Indigo #4F46E5 · Accent: Amber #F59E0B
   ========================================================================= */

/* -----------------------------------------------------------------
   1. TOKENS
   ----------------------------------------------------------------- */
:root {
  --primary:        #4F46E5;
  --primary-hover:  #4338CA;
  --primary-active: #3730A3;
  --primary-soft:   #EEF2FF;
  --primary-border: #C7D2FE;
  --on-primary:     #FFFFFF;

  --accent:         #F59E0B;
  --accent-hover:   #D97706;
  --accent-soft:    #FEF3C7;

  --bg:             #FAFAFB;
  --surface:        #FFFFFF;
  --surface-2:      #F4F4F5;
  --surface-3:      #E9E9EC;
  --border:         #E4E4E7;
  --border-strong:  #D4D4D8;

  --text:           #09090B;
  --text-2:         #52525B;
  --muted:          #A1A1AA;

  --success:        #059669;
  --success-soft:   #ECFDF5;
  --warning:        #D97706;
  --warning-soft:   #FFFBEB;
  --danger:         #DC2626;
  --danger-soft:    #FEF2F2;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 999px;

  --sh-1: 0 1px 2px rgb(9 9 11 / .05);
  --sh-2: 0 2px 8px rgb(9 9 11 / .06), 0 1px 2px rgb(9 9 11 / .04);
  --sh-3: 0 8px 24px rgb(9 9 11 / .08), 0 2px 6px rgb(9 9 11 / .04);
  --sh-4: 0 20px 48px rgb(9 9 11 / .14);
  --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);

  --d-1: 120ms;
  --d-2: 200ms;
  --d-3: 320ms;
  --d-4: 560ms;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --container: 1200px;
  --gutter: 32px;
  --header-h: 64px;
  --z-header: 900;
  --z-drawer: 950;
  --z-overlay: 940;
  --z-toast: 970;
  --z-modal: 980;

  color-scheme: light;
}

html[data-theme="dark"] {
  --primary:        #818CF8;
  --primary-hover:  #A5B4FC;
  --primary-active: #C7D2FE;
  --primary-soft:   #1E1B4B;
  --primary-border: #3730A3;
  --on-primary:     #0B0B0F;

  --accent:         #FBBF24;
  --accent-hover:   #F59E0B;
  --accent-soft:    #451A03;

  --bg:             #09090B;
  --surface:        #131316;
  --surface-2:      #1C1C20;
  --surface-3:      #26262C;
  --border:         #2A2A31;
  --border-strong:  #3A3A44;

  --text:           #FAFAFA;
  --text-2:         #A1A1AA;
  --muted:          #71717A;

  --success:        #34D399;
  --success-soft:   #052E23;
  --warning:        #FBBF24;
  --warning-soft:   #3A2506;
  --danger:         #F87171;
  --danger-soft:    #3B0A0A;

  --sh-1: 0 1px 2px rgb(0 0 0 / .40);
  --sh-2: 0 2px 8px rgb(0 0 0 / .45);
  --sh-3: 0 8px 24px rgb(0 0 0 / .50);
  --sh-4: 0 20px 48px rgb(0 0 0 / .60);
  --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 26%, transparent);

  color-scheme: dark;
}

/* -----------------------------------------------------------------
   2. RESET + BASE
   ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-block-start: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  min-block-size: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", "Rubik", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color var(--d-3) var(--ease), color var(--d-3) var(--ease);
}

body.no-scroll { overflow: hidden; }

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -.02em;
  text-wrap: balance;
}
h1 { font-size: clamp(30px, 4.4vw, 50px); letter-spacing: -.035em; }
h2 { font-size: clamp(23px, 3vw, 34px); letter-spacing: -.028em; }
h3 { font-size: 19px; }
h4 { font-size: 16px; }
h5 { font-size: 14.5px; }

p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; }
a { color: var(--primary); text-decoration: none; transition: color var(--d-1) var(--ease); }
a:hover { color: var(--primary-hover); }
img, svg, video, canvas { display: block; max-inline-size: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
/* Doubled attribute raises specificity above component rules such as
   .player / .loading-state (which would otherwise override the UA hidden style),
   while staying below inline styles so script.js can still reveal elements
   via el.style.display. */
[hidden][hidden] { display: none; }
hr { border: 0; border-block-start: 1px solid var(--border); margin-block: 24px; }

::selection { background: var(--primary); color: var(--on-primary); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-xs); }

::-webkit-scrollbar { inline-size: 10px; block-size: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.screen {
  inline-size: min(var(--container), 100% - (var(--gutter) * 2));
  margin-inline: auto;
}
main > section { padding-block: clamp(44px, 6vw, 84px); }

/* -----------------------------------------------------------------
   3. TYPOGRAPHY HELPERS
   ----------------------------------------------------------------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary);
}
html[dir="rtl"] .eyebrow { letter-spacing: 0; }

.lead { font-size: 17.5px; color: var(--text-2); max-inline-size: 58ch; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12.5px; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: grid; gap: 12px; }
.stack-sm { display: grid; gap: 8px; }
.stack-lg { display: grid; gap: 24px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cluster-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

.section-head {
  display: grid;
  gap: 12px;
  margin-block-end: clamp(24px, 3vw, 40px);
  max-inline-size: 70ch;
}
.section-head p { color: var(--text-2); font-size: 16.5px; }
.section-head.is-centered { justify-items: center; text-align: center; margin-inline: auto; }

/* -----------------------------------------------------------------
   4. GRIDS
   ----------------------------------------------------------------- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
.bento > * { grid-column: span 6; }
.span-3  { grid-column: span 3; }
.span-4  { grid-column: span 4; }
.span-5  { grid-column: span 5; }
.span-7  { grid-column: span 7; }
.span-8  { grid-column: span 8; }
.span-12 { grid-column: span 12; }

/* -----------------------------------------------------------------
   5. SURFACES
   ----------------------------------------------------------------- */
.card, .panel, .tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card { padding: 24px; display: grid; gap: 12px; align-content: start; }
.panel { padding: clamp(20px, 2.4vw, 28px); }

.card.is-interactive {
  cursor: pointer;
  transition:
    transform var(--d-2) var(--ease-out),
    box-shadow var(--d-2) var(--ease),
    border-color var(--d-2) var(--ease);
}
.card.is-interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--sh-3);
  border-color: var(--primary-border);
}
.card.is-interactive:active { transform: translateY(-1px); box-shadow: var(--sh-2); }

.tile {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: clamp(22px, 2.5vw, 30px);
  background: var(--surface-2);
  border-color: transparent;
  box-shadow: none;
  transition: background-color var(--d-2) var(--ease), transform var(--d-2) var(--ease-out);
}
.tile:hover { background: var(--primary-soft); transform: translateY(-3px); }
.tile h3 { font-size: 17.5px; }
.tile p { font-size: 14.5px; color: var(--text-2); }

.tile-icon {
  inline-size: 42px;
  block-size: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
  transition: transform var(--d-3) var(--ease-out);
}
.tile:hover .tile-icon { transform: scale(1.1) rotate(-4deg); }
.tile-icon svg { inline-size: 20px; block-size: 20px; }

/* -----------------------------------------------------------------
   6. BUTTONS
   ----------------------------------------------------------------- */
.btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-block-size: 42px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  /* labels must be able to wrap: a nowrap long label has a min-content width
     equal to the whole sentence and stretches its whole grid/flex column */
  white-space: normal;
  overflow-wrap: anywhere;
  max-inline-size: 100%;
  cursor: pointer;
  user-select: none;
  transition:
    transform var(--d-1) var(--ease),
    background-color var(--d-1) var(--ease),
    border-color var(--d-1) var(--ease),
    box-shadow var(--d-1) var(--ease),
    color var(--d-1) var(--ease);
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--sh-1);
}
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); box-shadow: var(--sh-2); transform: translateY(-2px); }
.btn-primary:active { background: var(--primary-active); transform: translateY(0) scale(.98); }

.btn-secondary, .btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover, .btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--muted);
  transform: translateY(-2px);
}
.btn-secondary:active, .btn-ghost:active { transform: translateY(0) scale(.98); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; transform: translateY(-2px); }

.btn:disabled, .btn[disabled], .btn-primary:disabled, .btn-secondary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

.btn-sm { min-block-size: 34px; padding: 6px 12px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn-lg { min-block-size: 50px; padding: 13px 26px; font-size: 16.5px; }
.btn-block { inline-size: 100%; }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  inline-size: 16px;
  block-size: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-block-start-color: var(--on-primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
html[dir="rtl"] .btn.is-loading::after { margin: -8px -8px 0 0; }

.close-btn {
  inline-size: 34px;
  block-size: 34px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.close-btn:hover { background: var(--surface-3); color: var(--text); transform: rotate(90deg); }

/* -----------------------------------------------------------------
   7. FORMS
   ----------------------------------------------------------------- */
.field { display: grid; gap: 7px; }
.field > label, .label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="search"],
input[type="url"], input[type="date"], input[type="time"],
select, textarea {
  inline-size: 100%;
  min-block-size: 44px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 15px;
  transition: border-color var(--d-1) var(--ease), box-shadow var(--d-1) var(--ease), background-color var(--d-1) var(--ease);
}
textarea { min-block-size: 100px; resize: vertical; line-height: 1.6; }
select {
  appearance: none;
  padding-inline-end: 38px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  cursor: pointer;
}
html[dir="rtl"] select { background-position: left 13px center; }

input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

input[type="checkbox"], input[type="radio"] {
  inline-size: 18px;
  block-size: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex: 0 0 auto;
}
label.check, .check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14.5px;
  cursor: pointer;
  color: var(--text-2);
}

input[type="range"] {
  inline-size: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

input[type="file"] {
  inline-size: 100%;
  padding: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
input[type="file"]:hover { border-color: var(--primary); background: var(--primary-soft); }

.field-error { font-size: 13px; color: var(--danger); }
.field-hint  { font-size: 13px; color: var(--muted); }
input.is-invalid, textarea.is-invalid, select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent);
}

.form-actions { display: grid; gap: 10px; margin-block-start: 8px; }

/* -----------------------------------------------------------------
   8. BADGES / CHIPS
   ----------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent-hover); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }

html[data-theme="dark"] .badge-accent { color: var(--accent); }

/* -----------------------------------------------------------------
   9. TABS / SEGMENTED
   ----------------------------------------------------------------- */
.tabs, .week-nav, .segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tab, .week-nav button, .segmented button {
  min-block-size: 38px;
  padding: 7px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.tab:hover, .week-nav button:hover, .segmented button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.tab.is-active, .tab[aria-selected="true"],
.week-nav button.active, .segmented button.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.segmented {
  gap: 3px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.segmented button { border-color: transparent; background: transparent; }
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* -----------------------------------------------------------------
   10. PROGRESS
   ----------------------------------------------------------------- */
.progress, .bar {
  block-size: 8px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress > i, .bar > i {
  display: block;
  block-size: 100%;
  inline-size: 0;
  background: var(--primary);
  border-radius: var(--r-full);
  transition: inline-size var(--d-4) var(--ease-out), background-color var(--d-2) var(--ease);
}
.progress.is-success > i { background: var(--success); }
.progress.is-accent > i  { background: var(--accent); }

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  margin-block-start: 8px;
}

/* -----------------------------------------------------------------
   11. HEADER
   ----------------------------------------------------------------- */
.header {
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-header);
  background: var(--header-surface, var(--surface));
  border-block-end: 1px solid transparent;
  transition: border-color var(--d-2) var(--ease), box-shadow var(--d-2) var(--ease), background-color var(--d-2) var(--ease);
}
.header.is-scrolled {
  border-block-end-color: var(--border);
  box-shadow: var(--sh-2);
}
/* translucent header/sidebar — kept subtle so text contrast is unaffected */
@supports ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .header {
    --header-surface: color-mix(in srgb, var(--surface) 78%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    backdrop-filter: blur(14px) saturate(150%);
  }
  .sidebar {
    --sidebar-surface: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
  }
}
.header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  min-block-size: var(--header-h);
}

.logo { display: flex; align-items: center; flex: 0 0 auto; }
.logo:hover { color: inherit; }
.logo-mark {
  inline-size: 34px;
  block-size: 34px;
  border-radius: var(--r-sm);
  transition: transform var(--d-2) var(--ease-out);
}
.logo:hover .logo-mark { transform: rotate(-6deg) scale(1.06); }
.logo-text {
  margin-inline-start: 10px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--text);
  white-space: nowrap;
}

.nav {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-inline-size: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  position: relative;
  padding: 8px 13px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  transition: color var(--d-1) var(--ease), background-color var(--d-1) var(--ease);
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); }
.nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  inset-block-end: 1px;
  inset-inline: 13px;
  block-size: 2px;
  border-radius: var(--r-full);
  background: var(--primary);
  animation: nav-underline var(--d-2) var(--ease-out) both;
}

.header-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.header-auth { display: flex; align-items: center; gap: 8px; }

.ha, .ha-btn {
  min-block-size: 36px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.ha-login, .ha-btn.ha-login  { background: var(--primary); color: var(--on-primary); }
.ha-login:hover, .ha-btn.ha-login:hover  { background: var(--primary-hover); color: var(--on-primary); transform: translateY(-1px); }
.ha-signup, .ha-btn.ha-signup { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.ha-signup:hover, .ha-btn.ha-signup:hover { border-color: var(--muted); color: var(--text); }
.ha-logout, .ha-btn.ha-logout { background: transparent; color: var(--text-2); border-color: var(--border); }
.ha-logout:hover, .ha-btn.ha-logout:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.ha-btn.is-hidden { display: none; }

.icon-btn, .theme-toggle, .menu-btn {
  inline-size: 38px;
  block-size: 38px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.icon-btn:hover, .theme-toggle:hover, .menu-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.icon-btn svg, .theme-toggle svg { inline-size: 17px; block-size: 17px; }

.theme-toggle .i-moon { display: none; }
html[data-theme="dark"] .theme-toggle .i-sun  { display: none; }
html[data-theme="dark"] .theme-toggle .i-moon { display: block; }

.menu-btn { display: none; }
.menu-btn > span, .menu-btn > i {
  display: block;
  inline-size: 17px;
  block-size: 2px;
  background: currentColor;
  border-radius: var(--r-full);
  transition: transform var(--d-2) var(--ease-out), opacity var(--d-1) var(--ease);
}
.menu-btn > * + * { margin-block-start: 4px; }
.menu-btn.is-open > *:nth-child(1),
.menu-btn.active > *:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-btn.is-open > *:nth-child(2),
.menu-btn.active > *:nth-child(2) { opacity: 0; }
.menu-btn.is-open > *:nth-child(3),
.menu-btn.active > *:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* -----------------------------------------------------------------
   12. SIDEBAR / DRAWER
   ----------------------------------------------------------------- */
.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: var(--z-drawer);
  inline-size: min(320px, 88vw);
  max-inline-size: 100%;
  display: flex;
  flex-direction: column;
  padding-block: var(--header-h) 0;
  background: var(--sidebar-surface, var(--surface));
  border-inline-start: 1px solid var(--border);
  box-shadow: var(--sh-4);
  overscroll-behavior: contain;
  transform: translateX(101%);
  visibility: hidden;
  transition: transform var(--d-3) var(--ease-out), visibility var(--d-3);
}
/* RTL closed state slides out to the left (the drawer is anchored inline-end). */
html[dir="rtl"] .sidebar { transform: translateX(-101%); }
/* The open state must out-specify `html[dir="rtl"] .sidebar` above, otherwise
   the drawer can never open in RTL and stays stranded mid-screen. */
.sidebar.is-open,
.sidebar.open,
.sidebar.active,
html[dir="rtl"] .sidebar.is-open,
html[dir="rtl"] .sidebar.open,
html[dir="rtl"] .sidebar.active { transform: none; visibility: visible; }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: rgb(9 9 11 / .45);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--d-2) var(--ease), visibility var(--d-2);
}
.sidebar-overlay.is-active,
.sidebar-overlay.active { opacity: 1; visibility: visible; }

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-block-end: 1px solid var(--border);
}
.sidebar-body { flex: 1; min-block-size: 0; overflow-y: auto; padding: 14px 12px; display: grid; gap: 2px; align-content: start; }
.sidebar-foot { margin-block-start: auto; padding: 12px; border-block-start: 1px solid var(--border); }

.menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
  transition: background-color var(--d-1) var(--ease), color var(--d-1) var(--ease), padding-inline-start var(--d-1) var(--ease);
}
.menu-item:hover {
  background: var(--surface-2);
  color: var(--text);
  padding-inline-start: 16px;
}
.menu-item[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.menu-item svg { inline-size: 18px; block-size: 18px; flex: 0 0 auto; }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-soft); color: var(--danger); }

.menu-label {
  padding: 12px 12px 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
html[dir="rtl"] .menu-label { letter-spacing: 0; }
.menu-divider { block-size: 1px; margin: 8px 0; border: 0; background: var(--border); }

/* -----------------------------------------------------------------
   13. HERO
   ----------------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  align-items: center;
  gap: clamp(28px, 4vw, 60px);
}
.hero-copy { display: grid; gap: 20px; justify-items: start; }
.hero-copy h1 { max-inline-size: 22ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-trust { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13.5px; color: var(--muted); }
.hero-trust li { display: flex; align-items: center; gap: 7px; }
.hero-trust svg { inline-size: 15px; block-size: 15px; color: var(--success); }

.hero-visual {
  display: grid;
  gap: 10px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
}
.mock-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: 14px;
  color: var(--text-2);
  transition: background-color var(--d-2) var(--ease), transform var(--d-2) var(--ease-out);
}
.mock-row:hover { background: var(--surface-3); transform: translateX(-3px); }
html[dir="rtl"] .mock-row:hover { transform: translateX(3px); }
.mock-row strong { color: var(--text); font-weight: 600; }
.mock-row .mock-label { flex: 1; }
.mock-row.is-done { background: var(--success-soft); color: var(--success); }
.mock-row.is-done strong { color: var(--success); }
.mock-dot {
  inline-size: 18px;
  block-size: 18px;
  flex: 0 0 auto;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  transition: all var(--d-3) var(--ease-out);
}
.mock-row.is-done .mock-dot { border-color: var(--success); background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 18%, transparent); }

/* -----------------------------------------------------------------
   14. STEPS / STATS
   ----------------------------------------------------------------- */
.steps { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 28px; counter-reset: step; }
.step { position: relative; counter-increment: step; }
.step::before {
  content: counter(step);
  display: grid;
  place-items: center;
  inline-size: 34px;
  block-size: 34px;
  margin-block-end: 14px;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: transform var(--d-2) var(--ease-out), background-color var(--d-2) var(--ease);
}
.step:hover::before { transform: translateY(-3px); background: var(--primary-hover); }
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-block-start: 17px;
  inset-inline-start: 46px;
  inline-size: calc(100% - 30px);
  block-size: 1px;
  background: var(--border);
}
.step h4 { margin-block-end: 6px; }
.step p { font-size: 14.5px; color: var(--text-2); }

.stat-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.stat-item { display: grid; gap: 3px; padding: 26px 16px; text-align: center; }
.stat-item + .stat-item { border-inline-start: 1px solid var(--border); }
.stat-number {
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}
.stat-label { font-size: 13.5px; color: var(--muted); }

/* -----------------------------------------------------------------
   15. FEATURE SECTION
   ----------------------------------------------------------------- */
.feature {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.feature-item {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: transform var(--d-2) var(--ease-out), box-shadow var(--d-2) var(--ease), border-color var(--d-2) var(--ease);
}
.feature-item:hover { transform: translateY(-4px); box-shadow: var(--sh-3); border-color: var(--primary-border); }
.feature-item h3 { font-size: 17px; }
.feature-item p { font-size: 14.5px; color: var(--text-2); }

/* -----------------------------------------------------------------
   16. TABLES
   ----------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
table { inline-size: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { padding: 12px 14px; text-align: start; border-block-end: 1px solid var(--border); vertical-align: middle; }
th { font-weight: 600; font-size: 13.5px; color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
tbody tr { transition: background-color var(--d-1) var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-block-end: 0; }

/* -----------------------------------------------------------------
   17. MODALS
   ----------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(9 9 11 / .55);
  animation: fade-in var(--d-2) var(--ease) both;
}
.modal.is-closing { animation: fade-out var(--d-2) var(--ease) both; }
.modal-card {
  box-sizing: border-box;
  inline-size: min(470px, 100%);
  max-block-size: 86dvh;
  overflow-y: auto;
  padding: clamp(20px, 2.6vw, 28px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-4);
  animation: modal-in var(--d-3) var(--ease-out) both;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-block-end: 12px;
}
.modal-title { font-size: 19px; font-weight: 700; }
.modal-sub { font-size: 14.5px; color: var(--text-2); margin-block-end: 20px; }
.modal-actions { display: flex; gap: 10px; margin-block-start: 22px; }
.modal-actions > * { flex: 1; }

/* --- interactive exam shell (must be a body-level overlay so position:fixed
       resolves against the viewport, not a transformed [data-reveal] ancestor) --- */
#interactive-exam-modal { display: none; overflow-y: auto; overscroll-behavior: contain; }
#interactive-exam-modal.is-open { display: grid; }
#interactive-exam-modal .modal-card { inline-size: min(840px, 100%); max-block-size: 88dvh; }

/* -----------------------------------------------------------------
   18. TOASTS / NOTIFICATIONS
   ----------------------------------------------------------------- */
.toast {
  position: fixed;
  z-index: var(--z-toast);
  inset-block-start: calc(var(--header-h) + 14px);
  inset-inline-end: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  inline-size: fit-content;
  max-inline-size: min(420px, calc(100vw - 40px));
  padding: 15px 18px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--muted);
  border-radius: var(--r-md);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.65;
  box-shadow: var(--sh-3);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-14px) scale(.98);
  transition: opacity var(--d-3) var(--ease-out), transform var(--d-3) var(--ease-out);
}
.toast-text { min-inline-size: 0; overflow-wrap: anywhere; }
.toast.show { opacity: 1; transform: none; }
.toast::before {
  content: '';
  flex: 0 0 auto;
  inline-size: 10px;
  block-size: 10px;
  margin-block-start: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: toast-pulse 1s var(--ease) infinite;
}
.toast-success { border-inline-start-color: var(--success); }
.toast-success::before { background: var(--success); }
.toast-danger, .toast-error { border-inline-start-color: var(--danger); }
.toast-danger::before, .toast-error::before { background: var(--danger); }
.toast-warning { border-inline-start-color: var(--warning); }
.toast-warning::before { background: var(--warning); }
.toast-info { border-inline-start-color: var(--primary); }
.toast-info::before { background: var(--primary); }
@keyframes toast-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .3; transform: scale(.72); }
}

.notif { position: relative; }
.notif-trigger {
  inline-size: 38px;
  block-size: 38px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 17px;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.notif-trigger:hover { background: var(--surface-2); color: var(--text); }
.notif-dot {
  position: absolute;
  inset-block-start: -5px;
  inset-inline-end: -5px;
  min-inline-size: 18px;
  block-size: 18px;
  display: grid;
  place-items: center;
  padding-inline: 4px;
  background: var(--danger);
  color: #fff;
  border: 2px solid var(--surface);
  border-radius: var(--r-full);
  font-size: 10.5px;
  font-weight: 700;
}
.notif-panel {
  position: absolute;
  inset-block-start: calc(100% + 8px);
  inset-inline-end: 0;
  inline-size: min(340px, 88vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  overflow: hidden;
  animation: modal-in var(--d-2) var(--ease-out) both;
}
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-block-end: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}
.notif-head button { background: none; border: 0; color: var(--primary); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.notif-list { display: grid; max-block-size: 340px; overflow-y: auto; }
.notif-item { padding: 12px 14px; border-block-end: 1px solid var(--border); font-size: 14px; }
.notif-item:last-child { border-block-end: 0; }

/* -----------------------------------------------------------------
   19. STATES
   ----------------------------------------------------------------- */
.empty-state {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state svg { inline-size: 42px; block-size: 42px; opacity: .45; }
.empty-state h3 { color: var(--text-2); }
.empty-state p { font-size: 14.5px; max-inline-size: 42ch; }

.loading-state { display: flex; align-items: center; gap: 12px; padding: 18px; color: var(--text-2); font-size: 14.5px; }
.spinner {
  inline-size: 18px;
  block-size: 18px;
  flex: 0 0 auto;
  border: 2px solid var(--surface-3);
  border-block-start-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  animation: shimmer 1.4s ease-in-out infinite;
}

/* hidden until the app is ready — toggled by setReadyControls().
   Kept in flow (not visibility) so surrounding layout does not jump when it appears. */
[data-show-on-ready] {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--d-2) var(--ease);
}
[data-show-on-ready].ready-on { opacity: 1; pointer-events: auto; }

/* -----------------------------------------------------------------
   20. AUDIO / PLAYER / RECORDER
   ----------------------------------------------------------------- */
.audio-stack { display: grid; gap: 16px; }
.audio-card { display: grid; gap: 16px; }
.audio-hint {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 15px 17px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--text-2);
}
.audio-hint svg { inline-size: 18px; block-size: 18px; color: var(--primary); flex: 0 0 auto; margin-block-start: 3px; }
.audio-hint strong { color: var(--primary); }

.recorder {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-align: center;
}
.rec-dot {
  inline-size: 14px;
  block-size: 14px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.4s ease-in-out infinite;
}
.btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}
.rec-status { font-size: 14.5px; font-weight: 600; color: var(--text-2); }
.rec-status.is-recording { color: var(--danger); }
.rec-timer { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.player { display: grid; gap: 12px; }
.player-media {
  inline-size: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--r-md);
  object-fit: cover;
}
.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--r-md);
}
.player-time { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.player-btn {
  inline-size: 34px;
  block-size: 34px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.player-btn:hover { background: var(--surface-3); color: var(--text); transform: translateY(-1px); }
.player-btn.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* -----------------------------------------------------------------
   21. EXAM / QUIZ
   ----------------------------------------------------------------- */
.quiz { display: grid; gap: 18px; }
.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13.5px;
  color: var(--muted);
}
.quiz-question { font-size: 17.5px; font-weight: 600; }
.quiz-options { display: grid; gap: 10px; }
.quiz-option {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: 15px;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.quiz-option:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateX(-3px); }
html[dir="rtl"] .quiz-option:hover { transform: translateX(3px); }
.quiz-option.is-selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.quiz-option.is-correct { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.quiz-option.is-wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.quiz-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quiz-result { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 28px 20px; }

/* -----------------------------------------------------------------
   22. DASHBOARD / CARDS LISTS
   ----------------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-box {
  display: grid;
  gap: 4px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: transform var(--d-2) var(--ease-out), box-shadow var(--d-2) var(--ease);
}
.stat-box:hover { transform: translateY(-3px); box-shadow: var(--sh-2); }
.stat-box dt { font-size: 13px; color: var(--muted); }
.stat-box dd {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.stat-box.is-primary dd { color: var(--primary); }
.stat-box.is-success dd { color: var(--success); }
.stat-box.is-warning dd { color: var(--warning); }
.stat-box.is-danger  dd { color: var(--danger); }

.card-list { display: grid; gap: 14px; }
.media-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: transform var(--d-2) var(--ease-out), box-shadow var(--d-2) var(--ease), border-color var(--d-2) var(--ease);
}
.media-card:hover { transform: translateY(-3px); box-shadow: var(--sh-2); border-color: var(--border-strong); }
.media-thumb {
  inline-size: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.media-title { font-size: 15.5px; font-weight: 600; line-height: 1.45; }
.media-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.media-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-block-start: 4px; }

.log-list { display: grid; gap: 8px; max-block-size: 400px; overflow-y: auto; }
.log-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-size: 13.5px;
}
.log-item time { color: var(--muted); font-size: 12px; margin-inline-start: auto; white-space: nowrap; }

.tabs-panel { display: grid; gap: 16px; }
.tabs-panel[hidden] { display: none; }

/* utility: hide a block until JS reveals it via inline display */
.is-hidden { display: none; }

/* -----------------------------------------------------------------
   23. PROFILE
   ----------------------------------------------------------------- */
.profile-head {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
  padding: clamp(24px, 3vw, 34px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.avatar {
  inline-size: 76px;
  block-size: 76px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 50%;
  font-size: 28px;
  font-weight: 700;
}
.detail-list { display: grid; gap: 0; }
.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-block-end: 1px solid var(--border);
  font-size: 14.5px;
}
.detail-row:last-child { border-block-end: 0; }
.detail-row dt { color: var(--muted); }
.detail-row dd { margin: 0; font-weight: 600; text-align: end; }

/* -----------------------------------------------------------------
   24. SUBSCRIPTION / PLANS
   ----------------------------------------------------------------- */
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.plan {
  position: relative;
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: transform var(--d-2) var(--ease-out), box-shadow var(--d-2) var(--ease), border-color var(--d-2) var(--ease);
}
.plan:hover { transform: translateY(-5px); box-shadow: var(--sh-3); }
.plan.is-featured { border-color: var(--primary); box-shadow: var(--sh-2); }
.plan.is-featured::before {
  content: "الأكثر اختياراً";
  position: absolute;
  inset-block-start: -11px;
  inset-inline-start: 24px;
  padding: 3px 11px;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
}
.plan.is-current { border-color: var(--success); }
.plan-name { font-size: 17px; font-weight: 700; }
.plan-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.plan-price small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.plan-desc { font-size: 14px; color: var(--text-2); }
.plan-features { display: grid; gap: 9px; list-style: none; padding: 0; }
.plan-features li { display: flex; align-items: flex-start; gap: 9px; font-size: 14.5px; color: var(--text-2); }
.plan-features svg { inline-size: 16px; block-size: 16px; flex: 0 0 auto; margin-block-start: 4px; color: var(--success); }

.billing-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.billing-toggle button {
  min-block-size: 34px;
  padding: 6px 16px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.billing-toggle button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* -----------------------------------------------------------------
   25b. UTILITIES
   the only permitted escape hatch, kept deliberately small.
   Anything not covered here must become a semantic component class.
   ----------------------------------------------------------------- */

/* colour */
.u-text   { color: var(--text); }
.u-text-2 { color: var(--text-2); }
.u-muted  { color: var(--muted); }
.u-primary { color: var(--primary); }
.u-success { color: var(--success); }
.u-danger  { color: var(--danger); }
.u-warning { color: var(--warning); }

/* type */
.u-sm      { font-size: 13px; }
.u-md      { font-size: 15px; }
.u-lg      { font-size: 17px; }
.u-xl      { font-size: 22px; }
.u-2xl     { font-size: 30px; }
.u-strong  { font-weight: 700; }
.u-normal  { font-weight: 400; }

/* layout */
.u-row         { display: flex; align-items: center; gap: 10px; }
.u-row-start   { display: flex; align-items: flex-start; gap: 10px; }
.u-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.u-col         { display: grid; gap: 8px; }
.u-flex-1      { flex: 1; min-inline-size: 0; }
.u-wrap        { flex-wrap: wrap; }
.u-center     { text-align: center; }
.u-start      { text-align: start; }
.u-end        { text-align: end; }

/* spacing */
.u-mt-1 { margin-block-start: 6px; }
.u-mt-2 { margin-block-start: 10px; }
.u-mt-3 { margin-block-start: 16px; }
.u-mt-4 { margin-block-start: 24px; }
.u-mb-1 { margin-block-end: 6px; }
.u-mb-2 { margin-block-end: 10px; }
.u-mb-3 { margin-block-end: 16px; }
.u-mb-4 { margin-block-end: 24px; }
.u-px-2 { padding-inline: 10px; }
.u-py-1 { padding-block: 7px; }
.u-py-2 { padding-block: 12px; }
.u-py-3 { padding-block: 18px; }

/* misc */
.u-hidden  { display: none; }
.u-border-b { border-block-end: 1px solid var(--border); }
.u-divider { block-size: 1px; border: 0; background: var(--border); margin-block: 16px; }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-scroll-x { overflow-x: auto; }

/* -----------------------------------------------------------------
   26. AUTH
   ----------------------------------------------------------------- */
#login-section, #signup-section, #forgot-section, #reset-section {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding-block: clamp(32px, 5vw, 60px);
  min-block-size: 100dvh;
  align-content: center;
}
.auth-card {
  inline-size: min(440px, 100%);
  display: grid;
  gap: 16px;
  padding: clamp(24px, 3vw, 34px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.auth-logo { display: grid; justify-items: center; gap: 6px; text-align: center; }
.auth-logo svg { inline-size: 68px; block-size: 68px; border-radius: var(--r-lg); }
.auth-brand { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.auth-title { font-size: 20px; font-weight: 700; text-align: center; }
.auth-sub { font-size: 14.5px; color: var(--text-2); text-align: center; }
.auth-form { display: grid; gap: 14px; }
.auth-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.auth-sep::before, .auth-sep::after {
  content: "";
  flex: 1;
  block-size: 1px;
  background: var(--border);
}
.auth-alt { font-size: 14.5px; color: var(--text-2); text-align: center; }
.auth-link { font-size: 13.5px; }
.auth-back { inline-size: 100%; margin-block-end: 4px; }

.btn-google {
  inline-size: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-weight: 600;
}
.btn-google:hover { background: var(--surface-2); border-color: var(--muted); transform: translateY(-2px); }
.btn-google svg { inline-size: 20px; block-size: 20px; flex: 0 0 auto; }

.verify-box {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: var(--r-md);
  font-size: 14px;
  text-align: center;
}

/* -----------------------------------------------------------------
   26b. RUNTIME COMPONENTS
   markup injected by script.js / audio-studio.js at runtime
   ----------------------------------------------------------------- */

/* --- list items (archive / channels) --- */
.archive-item, .channel-item, .followed-channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: transform var(--d-2) var(--ease-out), box-shadow var(--d-2) var(--ease), border-color var(--d-2) var(--ease);
}
.archive-item:hover, .channel-item:hover, .followed-channel-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-2);
  border-color: var(--primary-border);
}
.archive-item > div:first-child,
.channel-item > div:first-child { flex: 1; min-inline-size: 0; }

/* --- video card (list row) --- */
.video-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-block-end: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: transform var(--d-2) var(--ease-out), box-shadow var(--d-2) var(--ease);
}
.video-card:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.video-card > div:first-child { flex: 1; min-inline-size: 0; }

.vbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-block-size: 34px;
  padding: 6px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--d-1) var(--ease);
}
.vbtn:hover { background: var(--surface-3); color: var(--text); transform: translateY(-1px); }
.vbtn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.vbtn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.vbtn-report { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.vbtn-report:hover { background: var(--warning); color: #fff; }

/* --- loading --- */
.loading-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  color: var(--text-2);
  font-size: 14.5px;
}
.spinner-svg {
  inline-size: 18px;
  block-size: 18px;
  flex: 0 0 auto;
  animation: spin .7s linear infinite;
}

/* --- audio result states --- */
.audio-success {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 15px 17px;
  background: var(--success-soft);
  border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
  border-radius: var(--r-md);
  color: var(--success);
  font-size: 14.5px;
  font-weight: 600;
}
.audio-warn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 15px 17px;
  background: var(--warning-soft);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  border-radius: var(--r-md);
  color: var(--warning);
  font-size: 14.5px;
  font-weight: 600;
}

/* --- notifications (script.js variant) --- */
.notif-bell {
  position: relative;
  inline-size: 38px;
  block-size: 38px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 17px;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.notif-bell:hover { background: var(--surface-2); color: var(--text); }
.notif-badge {
  position: absolute;
  inset-block-start: -5px;
  inset-inline-end: -5px;
  min-inline-size: 18px;
  block-size: 18px;
  display: grid;
  place-items: center;
  padding-inline: 4px;
  background: var(--danger);
  color: #fff;
  border: 2px solid var(--surface);
  border-radius: var(--r-full);
  font-size: 10.5px;
  font-weight: 700;
}
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-block-end: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}

/* --- password field wrapper (attachPwdEye) --- */
.pwd-wrapper { position: relative; display: block; }
.pwd-wrapper input { padding-inline-end: 44px; }
.pwd-toggle {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: 10px;
  transform: translateY(-50%);
  inline-size: 30px;
  block-size: 30px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--r-xs);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: color var(--d-1) var(--ease), background-color var(--d-1) var(--ease);
}
.pwd-toggle:hover { color: var(--text); background: var(--surface-2); }

/* --- field validation message --- */
.error-message {
  font-size: 13px;
  color: var(--danger);
  display: block;
  margin-block-start: 2px;
}

/* --- print / export body --- */
.pdf-body {
  padding: 24px;
  background: #fff;
  color: #111;
  font-size: 15px;
  line-height: 1.8;
}
.pdf-body h1, .pdf-body h2, .pdf-body h3 { color: #111; margin-block: 14px 6px; }
.pdf-body p, .pdf-body li { color: #222; }
.pdf-body ul, .pdf-body ol { padding-inline-start: 22px; }

/* --- QR payment box --- */
.qrp-box {
  display: grid;
  gap: 16px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  text-align: center;
}
.qrp-brand { display: grid; justify-items: center; gap: 8px; }
.qrp-brand img { inline-size: 44px; block-size: 44px; border-radius: var(--r-md); }
.qrp-steps { display: grid; gap: 10px; counter-reset: qrp; text-align: start; }
.qrp-step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--text-2);
  counter-increment: qrp;
}
.qrp-step::before {
  content: counter(qrp);
  inline-size: 24px;
  block-size: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}
.qrp-qr-wrap {
  inline-size: fit-content;
  margin-inline: auto;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.qrp-qr { inline-size: 190px; block-size: 190px; }
.qrp-price {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}
.qrp-price small { font-size: 14px; font-weight: 500; color: var(--muted); }
.qrp-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  text-align: start;
}
.qrp-summary-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.qrp-summary-desc { font-size: 12.5px; color: var(--muted); }
.qrp-ref { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qrp-paid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  background: var(--success-soft);
  color: var(--success);
  border-radius: var(--r-md);
  font-weight: 700;
}
.qrp-discount {
  justify-self: center;
  padding: 3px 11px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-radius: var(--r-full);
  font-size: 12.5px;
  font-weight: 700;
}
html[data-theme="dark"] .qrp-discount { color: var(--accent); }
.qrp-label { font-size: 13px; font-weight: 600; color: var(--text-2); text-align: start; }
.qrp-head { display: grid; gap: 6px; }
.qrp-secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
}
.qrp-cancel {
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.qrp-cancel:hover { color: var(--danger); }
.qrp-phone-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.qrp-phone { font-variant-numeric: tabular-nums; font-weight: 600; direction: ltr; }

/* --- video controls popup (vc-*) --- */
.vc-section { display: grid; gap: 10px; }
.vc-title, .vc-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
}
.vc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-block-end: 10px;
  border-block-end: 1px solid var(--border);
}
.vc-close {
  inline-size: 28px;
  block-size: 28px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 0;
  border-radius: var(--r-xs);
  color: var(--text-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.vc-close:hover { background: var(--surface-3); color: var(--text); }
.vc-desc, .vc-hint { font-size: 13px; color: var(--muted); }
.vc-field-grid { display: grid; gap: 12px; }
.vc-field { display: grid; gap: 6px; }
.vc-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.vc-input, .vc-select {
  inline-size: 100%;
  min-block-size: 40px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  transition: border-color var(--d-1) var(--ease), box-shadow var(--d-1) var(--ease);
}
.vc-input:focus, .vc-select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.vc-input-row { display: flex; align-items: center; gap: 8px; }
.vc-mode-row { display: flex; gap: 6px; }
.vc-mode-btn {
  flex: 1;
  min-block-size: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--d-1) var(--ease);
}
.vc-mode-btn:hover { border-color: var(--border-strong); color: var(--text); }
.vc-mode-btn.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.vc-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
}
.vc-start, .vc-clear-btn { inline-size: 100%; }

/* --- runtime button variants --- */
.btn-flat { background: var(--border); color: var(--text-2); border-color: transparent; }
.btn-flat:hover { background: var(--surface-3); color: var(--text); }
.btn-dark { background: var(--text); color: var(--on-primary); border-color: transparent; }
.btn-dark:hover { background: var(--text); color: var(--on-primary); box-shadow: var(--sh-2); transform: translateY(-2px); }

.link-btn,
.ghost-btn {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color var(--d-1) var(--ease);
}
.link-btn { color: var(--primary); }
.link-btn:hover { color: var(--primary-hover); }
.ghost-btn { color: var(--muted); }
.ghost-btn:hover { color: var(--text); }

/* --- runtime modal helpers --- */
.modal-stack { display: flex; flex-direction: column; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* --- exam / quiz runtime --- */
.exam-shell { inline-size: min(840px, 100%); max-block-size: 88dvh; overflow-y: auto; }
.exam-panel { inline-size: min(680px, 100%); }
.exam-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 20px;
  background: var(--text);
  color: var(--on-primary);
}
/* the close control sits on a dark bar, so it needs a light chip instead of btn-dark */
.exam-bar .btn-dark {
  background: rgb(255 255 255 / .16);
  color: var(--on-primary);
  border-color: rgb(255 255 255 / .3);
}
.exam-bar .btn-dark:hover { background: rgb(255 255 255 / .26); color: var(--on-primary); }
.quiz-panel {
  min-block-size: 120px;
  padding: 16px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.quiz-choice {
  display: block;
  margin: 4px 0;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  cursor: pointer;
}
.quiz-outcome {
  margin-block-start: 12px;
  padding: 16px;
  border: 2px solid var(--primary);
  border-radius: var(--r-md);
  text-align: center;
}
.star-picker {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-block-end: 12px;
  font-size: 30px;
  letter-spacing: 6px;
  cursor: pointer;
  user-select: none;
}
.score-line {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.mistakes-list {
  margin-block-start: 14px;
  padding-block-start: 12px;
  border-block-start: 1px dashed var(--border);
  text-align: start;
}
.mistake-item {
  margin-block-end: 8px;
  padding: 10px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: var(--r-sm);
}
.scroll-box { max-block-size: 320px; overflow-y: auto; }

/* --- payment reference --- */
.ref-code {
  margin: 14px 0;
  padding: 12px;
  border: 2px dashed var(--text);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
}

/* --- inline notice box --- */
.info-box { padding: 11px 14px; background: var(--surface-2); border-radius: var(--r-sm); color: var(--text); }
.info-box-primary { color: var(--primary); }

/* --- thumbnails / avatars --- */
.video-thumb { inline-size: 120px; block-size: 70px; object-fit: cover; border-radius: var(--r-sm); flex: 0 0 auto; }
.channel-avatar { inline-size: 40px; block-size: 40px; object-fit: cover; border-radius: 50%; flex: 0 0 auto; }
.avatar-lg {
  inline-size: 58px;
  block-size: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: 50%;
  font-size: 24px;
  font-weight: 700;
}

/* --- list rows --- */
.week-label { align-self: center; margin-inline-end: 6px; font-size: 13.5px; }
.admin-item {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

/* --- pdf export chrome --- */
.pdf-cover { text-align: center; padding: 46px 30px 30px; }
.pdf-title { color: var(--text); font-size: 30px; font-weight: 700; }
.pdf-rule {
  display: inline-block;
  inline-size: 96px;
  block-size: 5px;
  margin-block-start: 16px;
  background: var(--text);
  border-radius: var(--r-full);
}
.pdf-spacer { block-size: 12px; }

/* hidden-by-default must outrank the display-setting components above,
   while still losing to the inline display JS writes when revealing */
.btn.is-hidden, .btn-primary.is-hidden, .btn-secondary.is-hidden, .btn-ghost.is-hidden,
.btn-flat.is-hidden, .btn-dark.is-hidden, .vbtn.is-hidden, .notif-badge.is-hidden,
.link-btn.is-hidden, .close-btn.is-hidden { display: none; }

/* -----------------------------------------------------------------
   27. DOCS
   ----------------------------------------------------------------- */
.doc { display: grid; gap: 16px; max-inline-size: 78ch; }
.doc-head { display: grid; gap: 8px; }
.doc-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  width: fit-content;
}
.doc-updated { font-size: 13.5px; color: var(--muted); }
.doc h2 { font-size: 20px; margin-block-start: 14px; }
.doc p, .doc li { color: var(--text-2); }
.doc ul, .doc ol { padding-inline-start: 22px; display: grid; gap: 8px; }

/* -----------------------------------------------------------------
   26. FOOTER
   ----------------------------------------------------------------- */
.footer {
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
  padding-block: 44px 28px;
  margin-block-start: 48px;
  background: var(--surface);
  border-block-start: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-2);
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-brand img { inline-size: 30px; block-size: 30px; border-radius: var(--r-xs); }
.footer-title { font-size: 16px; font-weight: 700; color: var(--text); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; }
.footer-links a { color: var(--text-2); font-weight: 500; }
.footer-links a:hover { color: var(--primary); }
.footer-note { font-size: 13px; color: var(--muted); max-inline-size: 60ch; }
.footer hr { inline-size: 100%; max-inline-size: 220px; margin-block: 4px; }

/* -----------------------------------------------------------------
   27. GOOGLE BRAND (identity, not site palette)
   ----------------------------------------------------------------- */
.g-blue   { color: #4285F4; font-weight: 700; }
.g-red    { color: #EA4335; font-weight: 700; }
.g-yellow { color: #FBBC05; font-weight: 700; }
.g-green  { color: #34A853; font-weight: 700; }

/* -----------------------------------------------------------------
   28. MOTION
   ----------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes nav-underline { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 45%, transparent); }
  50%      { box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 0%, transparent); }
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.hero-visual { animation: rise var(--d-4) var(--ease-out) both, float 7s ease-in-out 1.2s infinite; }
.hero-copy > * { animation: rise var(--d-4) var(--ease-out) both; }
.hero-copy > *:nth-child(1) { animation-delay: 60ms; }
.hero-copy > *:nth-child(2) { animation-delay: 130ms; }
.hero-copy > *:nth-child(3) { animation-delay: 200ms; }
.hero-copy > *:nth-child(4) { animation-delay: 270ms; }
.hero-copy > *:nth-child(5) { animation-delay: 340ms; }

[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity var(--d-4) var(--ease-out),
    transform var(--d-4) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
[data-reveal].is-revealed { opacity: 1; transform: none; }

/* readiness beats scroll-reveal: an element that is both must stay hidden
   until its operation finishes, even if it has already been scrolled into view. */
[data-reveal][data-show-on-ready]:not(.ready-on) { opacity: 0; }

/* -----------------------------------------------------------------
   28b. PROGRESS PANEL / ARCHIVE VIEWER
   ----------------------------------------------------------------- */
.progress-panel { display: grid; gap: 18px; }
.progress-empty { margin: 0; padding: 22px 4px; text-align: center; }

.progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.progress-stat {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--border-strong);
  border-radius: var(--r-md);
}
.progress-stat-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.progress-stat-value { font-size: 24px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.progress-stat.is-good { border-inline-start-color: var(--success); }
.progress-stat.is-good .progress-stat-value { color: var(--success); }
.progress-stat.is-mid { border-inline-start-color: var(--primary); }
.progress-stat.is-mid .progress-stat-value { color: var(--primary); }
.progress-stat.is-low { border-inline-start-color: var(--danger); }
.progress-stat.is-low .progress-stat-value { color: var(--danger); }

.progress-bars { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.progress-row { display: grid; gap: 7px; }
.progress-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}
.progress-row-title {
  flex: 1 1 160px;
  min-inline-size: 0;
  font-size: 14.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.progress-row-meta { font-size: 12.5px; color: var(--muted); }
.progress-row-pct { font-size: 14px; font-weight: 800; }
.progress-row-pct.is-good { color: var(--success); }
.progress-row-pct.is-mid { color: var(--primary); }
.progress-row-pct.is-low { color: var(--danger); }

.progress-track {
  block-size: 9px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  display: block;
  block-size: 100%;
  inline-size: var(--p, 0%);
  border-radius: inherit;
  background: var(--primary);
  transition: inline-size var(--d-4) var(--ease-out);
}
.progress-fill.is-good { background: var(--success); }
.progress-fill.is-mid { background: var(--primary); }
.progress-fill.is-low { background: var(--danger); }

/* --- archive viewer: fixed bottom dock, not a toast --- */
.viewer {
  position: fixed;
  z-index: var(--z-modal);
  inset-inline: 0;
  inset-block-end: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-block-size: min(72dvh, 620px);
  background: var(--surface);
  border-block-start: 1px solid var(--border);
  border-start-start-radius: var(--r-lg);
  border-start-end-radius: var(--r-lg);
  box-shadow: var(--sh-4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px);
  transition: opacity var(--d-3) var(--ease-out), transform var(--d-3) var(--ease-out), visibility var(--d-3) step-end;
}
.viewer.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity var(--d-3) var(--ease-out), transform var(--d-3) var(--ease-out), visibility 0s;
}
.viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 14px 18px;
  background: var(--surface-2);
  border-block-end: 1px solid var(--border);
}
.viewer-bar-info { display: grid; gap: 3px; min-inline-size: 0; flex: 1 1 200px; }
.viewer-title { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.viewer-meta { font-size: 12.5px; color: var(--muted); }
.viewer-body {
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* -----------------------------------------------------------------
   29. RESPONSIVE
   ----------------------------------------------------------------- */
@media (max-width: 1080px) {
  .nav, .header-auth { display: none; }
  .menu-btn { display: grid; }
  .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .hero-visual { order: 2; animation: none; }
  .bento > *, .span-3, .span-4, .span-5, .span-7, .span-8 { grid-column: span 12; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-auto-flow: row; grid-auto-columns: auto; }
  .step:not(:last-child)::after { display: none; }
  .stat-strip { grid-auto-flow: row; }
  .stat-item + .stat-item { border-inline-start: 0; border-block-start: 1px solid var(--border); }
  .plans { grid-template-columns: 1fr; }
  /* tablets: bump icon targets too */
  .icon-btn, .theme-toggle, .menu-btn, .notif-trigger, .notif-bell { inline-size: 44px; block-size: 44px; }
}

.logo, .logo-text { min-inline-size: 0; }
.logo-text { overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 560px) {
  :root { --gutter: 20px; --header-h: 58px; }
  .grid-2, .grid-3, .grid-4, .stat-grid { grid-template-columns: 1fr; }
  .btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger { inline-size: 100%; }
  .hero-cta > * { inline-size: 100%; }
  .header-auth { display: flex; inline-size: 100%; }
  .modal-actions { flex-direction: column-reverse; }
  .toast { inset-inline: 16px; max-inline-size: none; }
  .card, .panel { padding: 18px; }
  .detail-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .detail-row dd { text-align: start; }

  /* touch targets: 44px minimum on small screens */
  .icon-btn, .theme-toggle, .menu-btn, .notif-trigger, .notif-bell { inline-size: 44px; block-size: 44px; }
  .btn-sm { min-block-size: 44px; }
  .close-menu-btn, #closeMenuBtn { min-inline-size: 44px; min-block-size: 44px; }
  input[type="checkbox"], input[type="radio"] {
    inline-size: 22px;
    block-size: 22px;
  }
  label.check, .check { min-block-size: 44px; }

  /* header: brand + bell stay on row 1, auth buttons get their own row.
     Without this the rigid .header-actions (flex:0 0 auto) overflows the bar. */
  .header-bar { flex-wrap: wrap; row-gap: 10px; }
  .header-actions { inline-size: 100%; order: 3; }
  .notif-wrap { order: 2; margin-inline-start: auto; }

  .viewer { max-block-size: min(80dvh, 560px); }
  .viewer-bar { padding: 12px 14px; }
  .viewer-bar .btn { inline-size: auto; }
  .viewer-body { padding: 15px; font-size: 14.5px; }
}

@media (hover: none) {
  .card.is-interactive:hover,
  .tile:hover,
  .feature-item:hover,
  .plan:hover,
  .media-card:hover,
  .stat-box:hover { transform: none; }
}

/* -----------------------------------------------------------------
   30. A11Y / PRINT
   ----------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
  .hero-visual { animation: none; }
}

@media print {
  .header, .footer, .sidebar, .sidebar-overlay,
  .menu-btn, .theme-toggle, .toast, .modal { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .panel, .tile, .plan { border: 0; box-shadow: none; padding: 0; }
}