/* ==========================================================================
   Noor Al-Islam — bilingual Islamic lessons & quizzes
   One stylesheet, no build step. RTL is the default; LTR gets its own tweaks.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* Greens */
  --green-950: #041f17;
  --green-900: #062b20;
  --green-800: #0b3d2e;
  --green-700: #0f5138;
  --green-600: #14684a;
  --green-500: #1b7f5a;
  --green-100: #dcefe5;
  --green-50:  #eff7f2;

  /* Gold */
  --gold-600: #b8872f;
  --gold-500: #d4a94a;
  --gold-400: #e8c86a;
  --gold-300: #f3e0a8;
  --gold-100: #fbf3d9;

  /* Neutrals */
  --ink:       #12211c;
  --ink-soft:  #34473f;
  --muted:     #6b7d76;
  --bg:        #f7f9f6;
  --bg-tint:   #edf3ee;
  --card:      #ffffff;
  --line:      #e1e8e2;
  --line-dark: #cfdad2;

  /* Status */
  --danger:      #b42318;
  --danger-soft: #fdecea;
  --success:     #157347;
  --success-soft:#e7f5ee;
  --warn:        #b45309;
  --warn-soft:   #fff4e3;
  --info:        #1d4ed8;
  --info-soft:   #eef2ff;

  /* Shape & depth */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius:    18px;
  --radius-lg: 26px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 8px rgba(6, 43, 32, .06);
  --shadow:    0 10px 28px rgba(6, 43, 32, .08);
  --shadow-lg: 0 24px 60px rgba(6, 43, 32, .16);
  --ring: 0 0 0 3px rgba(27, 127, 90, .28);

  /* Layout */
  --maxw: 1180px;
  --maxw-narrow: 860px;
  --header-h: 74px;

  /* Type */
  --font-ar: "Cairo", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font-en: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-quran: "Amiri", "Traditional Arabic", "Cairo", serif;
  --font-body: var(--font-ar);

  --transition: 180ms ease;
}

html[dir="ltr"] {
  --font-body: var(--font-en);
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 .5em;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--ink);
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--green-600); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--green-800); }

ul, ol { margin: 0 0 1em; padding-inline-start: 1.3em; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
}

code {
  background: var(--bg-tint);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .1em .4em;
  color: var(--ink-soft);
  word-break: break-all;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

::selection { background: var(--gold-300); color: var(--green-900); }

:focus-visible {
  outline: 2px solid var(--green-500);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   3. Utilities
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 22px;
}

.container.narrow { max-width: var(--maxw-narrow); }

.hidden { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-inline { font-family: var(--font-ar); }

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  top: 8px;
  z-index: 999;
  background: var(--green-800);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
}
.skip-link:focus { inset-inline-start: 16px; }

/* --------------------------------------------------------------------------
   4. Buttons
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  --btn-border: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .62rem 1.15rem;
  border: 1.5px solid var(--btn-border);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  transition: transform var(--transition), box-shadow var(--transition),
              background var(--transition), color var(--transition),
              border-color var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  --btn-bg: linear-gradient(135deg, var(--green-600), var(--green-800));
  --btn-fg: #fff;
  --btn-border: transparent;
  box-shadow: 0 6px 16px rgba(11, 61, 46, .22);
}
.btn-primary:hover { --btn-bg: linear-gradient(135deg, var(--green-500), var(--green-700)); color: #fff; }

.btn-gold {
  --btn-bg: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  --btn-fg: var(--green-950);
  box-shadow: 0 8px 20px rgba(184, 135, 47, .28);
}
.btn-gold:hover { --btn-fg: var(--green-950); filter: brightness(1.04); }

.btn-outline {
  --btn-bg: #fff;
  --btn-fg: var(--green-800);
  --btn-border: var(--line-dark);
}
.btn-outline:hover { --btn-border: var(--green-500); --btn-fg: var(--green-700); background: var(--green-50); }

.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink-soft);
}
.btn-ghost:hover { background: var(--green-50); color: var(--green-700); }

.btn-ghost-light {
  --btn-bg: rgba(255, 255, 255, .08);
  --btn-fg: #f4faf6;
  --btn-border: rgba(255, 255, 255, .35);
  backdrop-filter: blur(4px);
}
.btn-ghost-light:hover { --btn-bg: rgba(255, 255, 255, .16); --btn-fg: #fff; }

.btn-danger {
  --btn-bg: var(--danger-soft);
  --btn-fg: var(--danger);
  --btn-border: #f3c9c4;
}
.btn-danger:hover { --btn-bg: #fbdcd8; --btn-fg: #8f1c13; }

.btn-sm { padding: .34rem .75rem; font-size: .82rem; gap: .35rem; }
.btn-lg { padding: .85rem 1.6rem; font-size: 1.02rem; }
.btn-block { width: 100%; }

.btn.is-disabled,
.btn[aria-disabled="true"] {
  opacity: .72;
  pointer-events: none;
  transform: none;
}

.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 1.1em;
  height: 1.1em;
  border: 2px solid rgba(255, 255, 255, .55);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.inline-form { display: inline-flex; margin: 0; }

.link {
  font-weight: 700;
  color: var(--green-600);
  border-bottom: 1px solid transparent;
}
.link:hover { border-bottom-color: currentColor; }

/* --------------------------------------------------------------------------
   5. Header & navigation
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(6, 43, 32, .03);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink);
  flex-shrink: 0;
}
.brand:hover { color: var(--ink); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--green-700), var(--green-900));
  color: var(--gold-400);
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(232, 200, 106, .35), 0 4px 12px rgba(6, 43, 32, .18);
  flex-shrink: 0;
}
.brand-mark.big { width: 64px; height: 64px; border-radius: 20px; font-size: 2rem; }

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.06rem; font-weight: 800; letter-spacing: -.01em; }
.brand-text small { font-size: .72rem; color: var(--muted); font-weight: 600; }

.main-nav {
  display: flex;
  align-items: center;
  gap: .18rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  padding: .46rem .7rem;
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
  font-size: .92rem;
  font-weight: 650;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--green-50); color: var(--green-700); }
.nav-link.is-active { background: var(--green-100); color: var(--green-800); }
.nav-link.nav-admin { color: var(--gold-600); }
.nav-search-text { display: none; }

.nav-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin-inline: .35rem;
}

.avatar-mini {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-800);
  font-size: .76rem;
  font-weight: 800;
  flex-shrink: 0;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  border-radius: 2px;
  background: var(--green-800);
  transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .4rem .7rem;
  margin-inline-start: .3rem;
  border: 1px dashed var(--line-dark);
  border-radius: var(--radius-pill);
  font-size: .82rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.lang-switch:hover { border-color: var(--green-500); color: var(--green-700); background: var(--green-50); }

/* --------------------------------------------------------------------------
   6. Flash messages & toast
   -------------------------------------------------------------------------- */
.flash-wrap { padding-top: 18px; display: grid; gap: .6rem; }

.alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--muted);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-size: .93rem;
  transition: opacity .5s ease, transform .5s ease;
}
.alert.is-fading { opacity: .45; }
.alert-success { background: var(--success-soft); border-color: #c6e6d5; border-inline-start-color: var(--success); color: #0f5132; }
.alert-error   { background: var(--danger-soft);  border-color: #f5cdc8; border-inline-start-color: var(--danger);  color: #7f1d15; }
.alert-warning { background: var(--warn-soft);    border-color: #f2dcb7; border-inline-start-color: var(--warn);    color: #7c3d06; }
.alert-info    { background: var(--info-soft);    border-color: #d5ddfb; border-inline-start-color: var(--info);    color: #1e3a8a; }

.alert-close {
  border: 0;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0 .2rem;
  color: currentColor;
  opacity: .6;
}
.alert-close:hover { opacity: 1; }

.toast {
  position: fixed;
  inset-inline: 0;
  bottom: 24px;
  z-index: 200;
  width: max-content;
  max-width: min(92vw, 460px);
  margin-inline: auto;
  padding: .8rem 1.2rem;
  border-radius: var(--radius-pill);
  background: var(--green-900);
  color: #f4faf6;
  font-size: .92rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(14px) scale(.97);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0) scale(1); }

/* --------------------------------------------------------------------------
   7. Hero (home)
   -------------------------------------------------------------------------- */
.page-home main { overflow-x: clip; }

.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1000px 500px at 88% -10%, rgba(212, 169, 74, .22), transparent 60%),
    radial-gradient(700px 500px at 0% 110%, rgba(27, 127, 90, .35), transparent 65%),
    linear-gradient(135deg, var(--green-950), var(--green-800) 55%, var(--green-700));
  color: #eef6f1;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at 60% 40%, #000 25%, transparent 78%);
  pointer-events: none;
}

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
  align-items: center;
  gap: 3.2rem;
  padding-block: clamp(3rem, 7vw, 5.6rem);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .34rem .85rem;
  border-radius: var(--radius-pill);
  background: rgba(232, 200, 106, .14);
  border: 1px solid rgba(232, 200, 106, .35);
  color: var(--gold-300);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 1rem 0 .8rem;
  font-size: clamp(2.1rem, 4.4vw, 3.5rem);
  line-height: 1.12;
  color: #fff;
  letter-spacing: -.02em;
}

.lead {
  font-size: clamp(1rem, 1.35vw, 1.12rem);
  color: var(--ink-soft);
  line-height: 1.8;
  max-width: 62ch;
}
.hero .lead { color: #c9dcd3; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.7rem;
}

.hero-trust {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin-top: 1.4rem;
  font-size: .86rem;
  color: #a9c6b9;
}
.hero-trust span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(232, 200, 106, .2);
  color: var(--gold-300);
  font-size: .7rem;
}

.hero-visual { position: relative; display: grid; place-items: center; min-height: 340px; }

.hero-orb {
  position: absolute;
  width: 330px;
  height: 330px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(232, 200, 106, .5), rgba(212, 169, 74, .08) 55%, transparent 70%);
  filter: blur(2px);
  animation: floaty 7s ease-in-out infinite;
}

.hero-card {
  position: relative;
  z-index: 2;
  width: min(100%, 380px);
  padding: 1.5rem 1.6rem 1.7rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  transform: rotate(-1.5deg);
}
html[dir="ltr"] .hero-card { transform: rotate(1.5deg); }

.hero-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.hero-audio {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-700);
  font-size: 1rem;
}

.hero-ar {
  font-family: var(--font-quran);
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  line-height: 1.9;
  color: var(--green-900);
  margin: 0 0 .35rem;
  text-align: center;
}
.hero-en {
  margin: 0 0 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .95rem;
}

.wave-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 30px;
}
.wave-bars span {
  width: 4px;
  border-radius: 3px;
  background: linear-gradient(var(--gold-400), var(--green-500));
  animation: wave 1.1s ease-in-out infinite;
}
.wave-bars span:nth-child(1) { height: 35%; animation-delay: 0s; }
.wave-bars span:nth-child(2) { height: 65%; animation-delay: .1s; }
.wave-bars span:nth-child(3) { height: 95%; animation-delay: .2s; }
.wave-bars span:nth-child(4) { height: 55%; animation-delay: .3s; }
.wave-bars span:nth-child(5) { height: 80%; animation-delay: .4s; }
.wave-bars span:nth-child(6) { height: 45%; animation-delay: .5s; }
.wave-bars span:nth-child(7) { height: 70%; animation-delay: .6s; }

@keyframes wave {
  0%, 100% { transform: scaleY(.55); opacity: .65; }
  50%      { transform: scaleY(1);   opacity: 1; }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-16px) scale(1.03); }
}

.float-chip {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow);
  font-size: 1.3rem;
  animation: floaty 6s ease-in-out infinite;
}
.float-chip-1 { top: 8%; inset-inline-start: 6%; animation-delay: .4s; }
.float-chip-2 { bottom: 12%; inset-inline-start: 0%; animation-delay: 1.1s; }
.float-chip-3 { top: 18%; inset-inline-end: 2%; animation-delay: 1.8s; }

/* --------------------------------------------------------------------------
   8. Stats bar, sections, cards
   -------------------------------------------------------------------------- */
.stats-bar {
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding-block: 1.3rem;
}
.stat {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: .5rem;
  padding: .35rem 1rem;
  border-inline-end: 1px solid var(--line);
}
.stat:last-child { border-inline-end: 0; }
.stat strong {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--green-700);
  line-height: 1;
}
.stat span { color: var(--muted); font-size: .88rem; font-weight: 600; }

.section { padding-block: clamp(2.6rem, 5.5vw, 4.4rem); }
.section-tinted { background: linear-gradient(180deg, var(--bg-tint), var(--bg)); }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.section-head.center { justify-content: center; text-align: center; }
.section-head h2 {
  margin: 0 0 .35rem;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  color: var(--green-900);
}
.section-head p { margin: 0; color: var(--muted); max-width: 68ch; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .72rem;
  border-radius: var(--radius-pill);
  background: var(--green-50);
  border: 1px solid var(--green-100);
  color: var(--green-700);
  font-size: .8rem;
  font-weight: 700;
}
.pill-gold { background: var(--gold-100); border-color: var(--gold-300); color: var(--gold-600); }
.pill-done { background: var(--success-soft); border-color: #c6e6d5; color: var(--success); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .26rem .68rem;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--accent, var(--green-600)) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent, var(--green-600)) 22%, #fff);
  color: color-mix(in srgb, var(--accent, var(--green-600)) 82%, #000 8%);
  font-size: .77rem;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .18rem .58rem;
  border-radius: var(--radius-pill);
  background: var(--bg-tint);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: .76rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-done { background: var(--success-soft); border-color: #c6e6d5; color: var(--success); }
.badge-muted { background: #f1f3f2; border-color: var(--line); color: var(--muted); }
.badge-gold { background: var(--gold-100); border-color: var(--gold-300); color: var(--gold-600); }
.badge-wrong { background: var(--danger-soft); border-color: #f5cdc8; color: var(--danger); }

/* ---- Topic cards ---- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 1.1rem;
}

.topic-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  padding: 1.3rem 1.25rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.topic-card::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 4px;
  background: var(--accent, var(--green-600));
  opacity: .85;
}
.topic-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent, var(--green-600)) 35%, var(--line));
  box-shadow: var(--shadow);
}

.topic-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent, var(--green-600)) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent, var(--green-600)) 20%, #fff);
  font-size: 1.55rem;
  line-height: 1;
}

.topic-body h3 { margin: 0 0 .3rem; font-size: 1.06rem; color: var(--ink); }
.topic-body p {
  margin: 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: auto;
  padding-top: .8rem;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
}
.topic-arrow { margin-inline-start: auto; color: var(--accent, var(--green-600)); font-size: 1.1rem; font-weight: 800; }

/* ---- Steps ---- */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.2rem;
}
.step-card {
  position: relative;
  padding: 1.8rem 1.4rem 1.4rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.step-num {
  position: absolute;
  inset-block-start: -16px;
  inset-inline-start: 50%;
  transform: translateX(50%);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-400), var(--gold-500));
  color: var(--green-950);
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(184, 135, 47, .3);
}
html[dir="rtl"] .step-num { transform: translateX(50%); }
html[dir="ltr"] .step-num { transform: translateX(-50%); }
.step-icon { display: block; font-size: 2rem; margin-bottom: .5rem; }
.step-card h3 { font-size: 1.05rem; margin-bottom: .35rem; }
.step-card p { color: var(--muted); font-size: .9rem; margin: 0; }

/* ---- Lesson cards ---- */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.1rem;
}
.lesson-card {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.lesson-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-dark); }
.lesson-card h3 { margin: 0; font-size: 1.06rem; }
.lesson-card p {
  margin: 0;
  color: var(--muted);
  font-size: .89rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lesson-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: .75rem;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
}
.arrow { color: var(--green-600); font-weight: 800; }

/* ---- CTA banner ---- */
.cta-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: clamp(1.6rem, 4vw, 2.6rem);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(600px 260px at 90% 0%, rgba(232, 200, 106, .22), transparent 60%),
    linear-gradient(120deg, var(--green-900), var(--green-700));
  color: #eef6f1;
  box-shadow: var(--shadow-lg);
}
.cta-banner h2 { color: #fff; font-size: clamp(1.35rem, 2.4vw, 1.8rem); margin-bottom: .35rem; }
.cta-banner p { color: #bed6ca; margin: 0; max-width: 60ch; }
.cta-banner .btn { flex-shrink: 0; }

/* --------------------------------------------------------------------------
   9. Page head & breadcrumb
   -------------------------------------------------------------------------- */
.page-head {
  background:
    radial-gradient(700px 260px at 92% -20%, rgba(232, 200, 106, .16), transparent 65%),
    linear-gradient(135deg, var(--green-900), var(--green-800));
  color: #eef6f1;
  padding-block: clamp(2.2rem, 5vw, 3.4rem);
}
.page-head h1 { color: #fff; font-size: clamp(1.8rem, 3.4vw, 2.6rem); margin: .7rem 0 .5rem; }
.page-head p { color: #c3d8cd; margin: 0; max-width: 70ch; }
.page-head .eyebrow { background: rgba(232, 200, 106, .12); }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  font-size: .84rem;
  font-weight: 600;
  color: var(--muted);
}
.breadcrumb a { color: inherit; }
.breadcrumb a:hover { color: var(--green-700); }
.page-head .breadcrumb { color: #a9c6b9; margin-bottom: .4rem; }
.page-head .breadcrumb a:hover { color: #fff; }

.subtitle-alt {
  margin: .15rem 0 .8rem;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.page-head .subtitle-alt { color: #a9c6b9; }

/* --------------------------------------------------------------------------
   10. Topic detail
   -------------------------------------------------------------------------- */
.topic-hero {
  position: relative;
  overflow: hidden;
  padding-block: clamp(2rem, 4.5vw, 3.2rem);
  color: #eef6f1;
  background:
    radial-gradient(700px 320px at 88% -20%, rgba(255, 255, 255, .16), transparent 60%),
    linear-gradient(135deg,
      color-mix(in srgb, var(--accent, var(--green-800)) 88%, #000 12%),
      color-mix(in srgb, var(--accent, var(--green-800)) 62%, var(--green-950)));
}
.topic-hero .breadcrumb { color: rgba(255, 255, 255, .72); }
.topic-hero .breadcrumb a:hover { color: #fff; }
.topic-hero h1 { color: #fff; font-size: clamp(1.8rem, 3.6vw, 2.6rem); margin: .6rem 0 .3rem; }
.topic-hero .lead { color: rgba(255, 255, 255, .82); margin-top: .4rem; }
.topic-hero .pill {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .28);
  color: #fff;
}
.topic-hero .pill-gold { background: rgba(232, 200, 106, .9); border-color: transparent; color: var(--green-950); }

.topic-hero-inner {
  display: flex;
  align-items: flex-start;
  gap: 1.4rem;
  margin-top: .5rem;
}
.topic-hero-icon {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  flex-shrink: 0;
  border-radius: 24px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .3);
  font-size: 2.4rem;
  backdrop-filter: blur(4px);
}
.topic-hero-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }

/* ---- Lesson rows ---- */
.lesson-list { display: grid; gap: .8rem; }

.lesson-row {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.05rem 1.2rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.lesson-row:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-dark); }
.lesson-row.is-done { background: linear-gradient(90deg, var(--success-soft), #fff 55%); }

.lesson-index {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 13px;
  background: var(--green-50);
  border: 1px solid var(--green-100);
  color: var(--green-700);
  font-weight: 800;
  font-size: .95rem;
}
.is-done .lesson-index { background: var(--success-soft); border-color: #c6e6d5; color: var(--success); }

.lesson-row-body { flex: 1; min-width: 0; }
.lesson-row-body h3 { margin: 0 0 .2rem; font-size: 1.02rem; }
.lesson-row-body p {
  margin: 0 0 .35rem;
  color: var(--muted);
  font-size: .88rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lesson-row-meta { display: flex; flex-wrap: wrap; gap: .45rem; color: var(--muted); font-size: .79rem; font-weight: 600; }
.lesson-row-status { flex-shrink: 0; }

/* --------------------------------------------------------------------------
   11. Lesson detail & sentence cards
   -------------------------------------------------------------------------- */
.lesson-head {
  background: linear-gradient(180deg, #fff, var(--bg));
  border-bottom: 1px solid var(--line);
  padding-block: clamp(1.6rem, 3.4vw, 2.6rem);
}

.lesson-head-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 2rem;
  margin-top: 1rem;
}
.lesson-head h1 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); margin: .65rem 0 .2rem; color: var(--green-900); }
.lesson-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

.lesson-head-actions { display: grid; gap: .6rem; justify-items: end; text-align: end; }
.lesson-head-actions form { margin: 0; }
.hint { color: var(--muted); font-size: .82rem; margin: 0; }

.sentence-list { display: grid; gap: 1rem; }

.sentence-card {
  position: relative;
  display: flex;
  gap: 1rem;
  padding: 1.35rem 1.35rem 1.2rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.sentence-card:hover { box-shadow: var(--shadow); border-color: var(--line-dark); }
.sentence-card::before {
  content: "";
  position: absolute;
  inset-block: 14px;
  inset-inline-start: 0;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(var(--gold-400), var(--green-500));
  opacity: .75;
}

.sentence-num {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--green-50);
  border: 1px solid var(--green-100);
  color: var(--green-700);
  font-size: .8rem;
  font-weight: 800;
}

.sentence-main { flex: 1; min-width: 0; }

.sentence-ar {
  font-family: var(--font-quran);
  font-size: clamp(1.3rem, 2.3vw, 1.6rem);
  line-height: 2;
  color: var(--green-950);
  margin: 0 0 .4rem;
}

.sentence-pron {
  display: inline-flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin: 0 0 .5rem;
  padding: .18rem .6rem;
  border-radius: var(--radius-pill);
  background: var(--gold-100);
  border: 1px solid var(--gold-300);
  color: var(--gold-600);
  font-size: .8rem;
  font-weight: 700;
}
.sentence-pron span { color: var(--gold-600); opacity: .8; }

.sentence-en {
  margin: 0 0 .7rem;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.75;
}

.sentence-note {
  margin: 0 0 .8rem;
  padding: .55rem .8rem;
  border-radius: var(--radius-sm);
  background: var(--bg-tint);
  color: var(--ink-soft);
  font-size: .87rem;
}

.sentence-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .42rem .85rem;
  border: 1px solid var(--green-100);
  border-radius: var(--radius-pill);
  background: var(--green-50);
  color: var(--green-700);
  font-size: .82rem;
  font-weight: 700;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}
.audio-btn:hover { background: var(--green-100); border-color: var(--green-500); transform: translateY(-1px); }
.audio-btn.is-playing {
  background: var(--green-700);
  border-color: var(--green-700);
  color: #fff;
  animation: pulse-audio 1.3s ease-in-out infinite;
}
.audio-ico { font-size: .95rem; line-height: 1; }

@keyframes pulse-audio {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15, 81, 56, .35); }
  50%      { box-shadow: 0 0 0 7px rgba(15, 81, 56, 0); }
}

.lesson-footer {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  justify-content: center;
  margin-top: 2rem;
  padding-top: 1.6rem;
  border-top: 1px dashed var(--line);
}
.lesson-complete-form { margin: 0; }

.lesson-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem;
  margin-top: 1.6rem;
}
.pager-link {
  display: grid;
  gap: .2rem;
  padding: 1rem 1.2rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.pager-link:hover { border-color: var(--green-500); box-shadow: var(--shadow); transform: translateY(-2px); }
.pager-link span { color: var(--muted); font-size: .78rem; font-weight: 700; }
.pager-link strong { font-size: .96rem; line-height: 1.45; }
.pager-link.next { text-align: end; }

.related-quizzes {
  margin-top: 2.2rem;
  padding: 1.5rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--green-50), #fff);
  border: 1px solid var(--green-100);
}
.related-quizzes h2 { font-size: 1.15rem; margin-bottom: .25rem; }
.related-quizzes > p { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }

.quiz-mini-grid { display: grid; gap: .6rem; }
.quiz-mini {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  transition: border-color var(--transition), transform var(--transition);
}
.quiz-mini:hover { border-color: var(--green-500); transform: translateX(-2px); }
html[dir="ltr"] .quiz-mini:hover { transform: translateX(2px); }
.quiz-mini-icon { font-size: 1.3rem; }
.quiz-mini strong { display: block; font-size: .94rem; }
.quiz-mini small { color: var(--muted); font-size: .8rem; }
.quiz-mini > span:last-child { margin-inline-start: auto; color: var(--green-600); font-weight: 800; }

/* --------------------------------------------------------------------------
   12. Quizzes
   -------------------------------------------------------------------------- */
.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.2rem;
}

.quiz-card {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  padding: 1.35rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.quiz-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-dark); }
.quiz-card-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.quiz-card h2 { font-size: 1.12rem; margin: .1rem 0 0; }
.quiz-card > p { color: var(--muted); font-size: .9rem; margin: 0; }

.quiz-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .9rem;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
}
.quiz-meta span { display: inline-flex; align-items: center; gap: .25rem; }

.quiz-card-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: .8rem;
  margin-top: auto;
  padding-top: .9rem;
  border-top: 1px dashed var(--line);
}
.quiz-card-foot > div { display: grid; gap: .2rem; }

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .22rem .62rem;
  border-radius: var(--radius-pill);
  background: var(--gold-100);
  border: 1px solid var(--gold-300);
  color: var(--gold-600);
  font-size: .78rem;
  font-weight: 800;
}

/* ---- Quiz taking ---- */
.page-head-quiz { padding-bottom: clamp(1.6rem, 3.5vw, 2.4rem); }
.quiz-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}
.quiz-head h1 { margin: .6rem 0 .4rem; }
.quiz-head .lead { color: #c3d8cd; margin-bottom: .9rem; }
.quiz-head .pill { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .26); color: #fff; }
.quiz-head-side { display: flex; gap: .8rem; flex-wrap: wrap; }

.best-box, .timer-box {
  display: grid;
  gap: .1rem;
  min-width: 116px;
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .25);
  text-align: center;
}
.best-box span, .timer-box span { font-size: .74rem; color: #a9c6b9; font-weight: 700; }
.best-box strong { font-size: 1.35rem; color: var(--gold-300); }
.timer-box strong {
  font-size: 1.35rem;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.timer-box.is-urgent { background: rgba(180, 35, 24, .28); border-color: rgba(255, 160, 150, .5); }
.timer-box.is-urgent strong { color: #ffd2cc; }

.notice {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.3rem 1.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.notice > span { font-size: 1.6rem; line-height: 1.2; }
.notice h2 { font-size: 1.1rem; margin-bottom: .3rem; }
.notice p { color: var(--muted); margin: 0; font-size: .92rem; }
.notice-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .9rem; }
.notice-info { background: var(--info-soft); border-color: #d5ddfb; }
.notice-warn { background: var(--warn-soft); border-color: #f2dcb7; }

.quiz-progress-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 1.1rem;
  margin-bottom: 1.1rem;
  border-radius: var(--radius-pill);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: .86rem;
  font-weight: 700;
  color: var(--green-700);
}
.quiz-progress-hint { color: var(--muted); font-weight: 500; font-size: .8rem; }

.quiz-question {
  margin-bottom: 1.1rem;
  padding: 1.35rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: calc(var(--header-h) + 20px);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.quiz-question.is-answered { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(27, 127, 90, .09), var(--shadow-sm); }

.question-head {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  margin-bottom: 1rem;
}
.question-head h2 { font-size: 1.08rem; margin: .1rem 0 0; flex: 1; line-height: 1.6; }
.question-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-800);
  font-size: .8rem;
  font-weight: 800;
}
.question-points {
  flex-shrink: 0;
  font-size: .76rem;
  font-weight: 700;
  color: var(--gold-600);
  background: var(--gold-100);
  border: 1px solid var(--gold-300);
  border-radius: var(--radius-pill);
  padding: .16rem .55rem;
}

.question-image {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  background: var(--bg-tint);
}

.choices { display: grid; gap: .55rem; }

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .8rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.choice:hover { border-color: var(--green-500); background: var(--green-50); }
.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.choice-mark {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: 2px solid var(--line-dark);
  border-radius: 50%;
  background: #fff;
  transition: border-color var(--transition), background var(--transition);
}
.choice-mark::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
  transform: scale(0);
  transition: transform var(--transition);
}
.choice input:checked ~ .choice-mark { border-color: var(--green-600); background: var(--green-600); }
.choice input:checked ~ .choice-mark::after { transform: scale(1); }
.choice.is-selected { border-color: var(--green-600); background: var(--green-50); }
.choice input:focus-visible ~ .choice-mark { box-shadow: var(--ring); }
.choice-text { font-size: .95rem; line-height: 1.55; }

.quiz-submit-bar {
  position: sticky;
  bottom: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.4rem;
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}
.quiz-submit-bar strong { font-size: .9rem; color: var(--ink-soft); }

.attempts-panel { margin-top: 2.4rem; }
.attempts-panel h2 { font-size: 1.2rem; margin-bottom: .9rem; }

/* --------------------------------------------------------------------------
   13. Result & review
   -------------------------------------------------------------------------- */
.result-head { text-align: center; }
.result-head h1 { margin-top: .5rem; }

.result-card {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: clamp(1.4rem, 4vw, 2.2rem);
  border-radius: var(--radius-lg);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.result-card.is-pass { border-color: #bfe3d0; background: linear-gradient(135deg, var(--success-soft), #fff 60%); }
.result-card.is-fail { border-color: #f2cfca; background: linear-gradient(135deg, var(--danger-soft), #fff 60%); }

.score-ring {
  --pct: 0;
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  flex-shrink: 0;
  border-radius: 50%;
  background: conic-gradient(var(--green-600) calc(var(--pct) * 1%), var(--line) 0);
  padding: 9px;
}
.is-fail .score-ring { background: conic-gradient(var(--danger) calc(var(--pct) * 1%), var(--line) 0); }
.score-ring-inner {
  display: grid;
  place-items: center;
  align-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  text-align: center;
}
.score-ring-inner strong { font-size: 2rem; line-height: 1; color: var(--green-800); }
.is-fail .score-ring-inner strong { color: var(--danger); }
.score-ring-inner span { font-size: .8rem; color: var(--muted); font-weight: 700; margin-top: .3rem; }

.result-copy h2 { font-size: 1.3rem; margin: .5rem 0 .4rem; }
.result-copy p { color: var(--ink-soft); margin: 0 0 .4rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }

.review-title { margin: 2.2rem 0 1rem; font-size: 1.25rem; }
.review-list { display: grid; gap: .9rem; }

.review-card {
  padding: 1.2rem 1.3rem;
  background: #fff;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.review-card.is-correct { border-inline-start-color: var(--success); }
.review-card.is-wrong { border-inline-start-color: var(--danger); }

.review-head { display: flex; align-items: flex-start; gap: .7rem; }
.review-head h3 { flex: 1; font-size: 1rem; margin: .1rem 0 0; line-height: 1.6; }
.review-en { color: var(--muted); font-size: .88rem; margin: .45rem 0 .8rem; }

.review-answers { display: grid; gap: .5rem; }
.review-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; font-size: .9rem; }
.review-label {
  display: inline-block;
  min-width: 96px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}
.answer-ok { color: var(--success); font-weight: 700; }
.answer-bad { color: var(--danger); font-weight: 700; }
.review-line small { display: block; font-weight: 500; color: var(--muted); font-size: .8rem; }

.review-explanation {
  display: flex;
  gap: .5rem;
  margin: .8rem 0 0;
  padding: .65rem .8rem;
  border-radius: var(--radius-sm);
  background: var(--bg-tint);
  color: var(--ink-soft);
  font-size: .87rem;
}
.review-explanation .review-label { min-width: auto; color: var(--gold-600); }

.result-footer {
  display: flex;
  justify-content: center;
  gap: .7rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* --------------------------------------------------------------------------
   14. Dashboard
   -------------------------------------------------------------------------- */
.dash-head .pill { margin-top: .8rem; }

.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .9rem;
  margin-bottom: 1.4rem;
}
.dash-stat {
  display: grid;
  justify-items: center;
  gap: .15rem;
  padding: 1.2rem .9rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.dash-ico { font-size: 1.4rem; }
.dash-stat strong { font-size: 1.6rem; line-height: 1; color: var(--green-800); }
.dash-stat > span:last-child { font-size: .82rem; color: var(--muted); font-weight: 600; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 1.1rem;
  margin-bottom: 1.1rem;
}

.panel {
  padding: 1.3rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: 1.1rem; }
.dash-grid .panel + .panel,
.admin-grid-2 .panel + .panel { margin-top: 0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel-head h2 { font-size: 1.1rem; margin: 0; }

.progress-list { display: grid; gap: .75rem; }
.progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(80px, 1fr) auto;
  align-items: center;
  gap: .7rem;
  font-size: .87rem;
}
.progress-name { color: var(--ink); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-name:hover { color: var(--green-700); }
.progress-track {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-tint);
  overflow: hidden;
}
.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent, var(--green-600)), color-mix(in srgb, var(--accent, var(--green-600)) 60%, var(--gold-400)));
  transition: width .5s ease;
}
.progress-num { color: var(--muted); font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .65rem;
}
.badge-item {
  display: grid;
  justify-items: center;
  gap: .15rem;
  padding: .85rem .6rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--gold-100), #fff);
  border: 1px solid var(--gold-300);
  text-align: center;
}
.badge-item.is-locked { background: #f5f7f5; border-color: var(--line); opacity: .75; }
.badge-medal { font-size: 1.5rem; }
.badge-item strong { font-size: .84rem; }
.badge-item small { font-size: .72rem; color: var(--muted); line-height: 1.4; }

.empty-state {
  display: grid;
  justify-items: center;
  gap: .5rem;
  padding: 2.5rem 1.4rem;
  border: 1px dashed var(--line-dark);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .6);
  text-align: center;
  color: var(--muted);
}
.empty-state > span { font-size: 2.2rem; }
.empty-state h2 { margin: 0; font-size: 1.15rem; color: var(--ink); }
.empty-state p { margin: 0; max-width: 46ch; }
.empty-state.small { padding: 1.6rem 1rem; }
.empty-state.small > span { font-size: 1.7rem; }

/* --------------------------------------------------------------------------
   15. Leaderboard
   -------------------------------------------------------------------------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.leaderboard { padding: .4rem; }

.leader-table td, .leader-table th { white-space: nowrap; }
.leader-table tbody tr.is-me { background: var(--gold-100); }
.leader-table tbody tr.is-me td { font-weight: 700; }

.rank-badge {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 .4rem;
  border-radius: 50%;
  background: var(--bg-tint);
  font-size: .86rem;
  font-weight: 800;
  color: var(--ink-soft);
}
.rank-badge.rank-1 { background: linear-gradient(145deg, #fbe7a2, var(--gold-500)); color: var(--green-950); }
.rank-badge.rank-2 { background: linear-gradient(145deg, #eef1f2, #c7ced2); color: #3a464b; }
.rank-badge.rank-3 { background: linear-gradient(145deg, #f4d7bf, #c98b5a); color: #4a2a12; }

/* --------------------------------------------------------------------------
   16. Search, about, error
   -------------------------------------------------------------------------- */
.search-form {
  display: flex;
  gap: .6rem;
  margin-top: 1.2rem;
  max-width: 640px;
}
.search-form input {
  flex: 1;
  min-width: 0;
  padding: .72rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--ink);
  font-size: .95rem;
}
.search-form input:focus { border-color: var(--green-500); outline: none; box-shadow: var(--ring); }

.search-group { margin-top: 1.8rem; }
.search-group h2 { font-size: 1.1rem; margin-bottom: .7rem; }
.search-list { display: grid; gap: .55rem; }

.search-item {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color var(--transition), transform var(--transition);
}
.search-item:hover { border-color: var(--green-500); transform: translateY(-1px); }
.search-item strong { display: block; font-size: .95rem; }
.search-item small { display: block; color: var(--muted); font-size: .83rem; line-height: 1.5; }
.search-ico {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 11px;
  background: var(--green-50);
  border: 1px solid var(--green-100);
  font-size: 1.1rem;
}

.prose p { color: var(--ink-soft); font-size: 1rem; line-height: 1.9; }
.prose p + p { margin-top: 1rem; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
}
.feature-card {
  padding: 1.3rem 1.2rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.feature-card > span { font-size: 1.9rem; }
.feature-card h3 { font-size: 1rem; margin: .5rem 0 .3rem; }
.feature-card p { color: var(--muted); font-size: .87rem; margin: 0; }

.feature-grid + .cta-banner { margin-top: 1.8rem; }

.error-card {
  display: grid;
  justify-items: center;
  gap: .5rem;
  padding: clamp(2rem, 6vw, 3.5rem) 1.4rem;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.error-code {
  font-size: clamp(3.2rem, 10vw, 5rem);
  font-weight: 800;
  line-height: 1;
  color: var(--green-700);
  opacity: .28;
  letter-spacing: -.04em;
}
.error-card h1 { margin: 0; font-size: 1.4rem; }
.error-card p { color: var(--muted); margin: 0; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-top: 1rem; }

/* --------------------------------------------------------------------------
   17. Auth
   -------------------------------------------------------------------------- */
.auth-body { background: var(--bg); }

.auth-section { padding-block: clamp(2rem, 5vw, 3.6rem); }

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  gap: 2.4rem;
  align-items: center;
  max-width: 980px;
}

.auth-aside {
  padding: 2rem;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(500px 260px at 100% 0%, rgba(232, 200, 106, .2), transparent 60%),
    linear-gradient(150deg, var(--green-900), var(--green-700));
  color: #e7f2ec;
  box-shadow: var(--shadow-lg);
}
.auth-aside h2 { color: #fff; font-size: 1.5rem; margin: 1rem 0 .5rem; }
.auth-aside p { color: #bed6ca; font-size: .92rem; }

.check-list { list-style: none; padding: 0; margin: 1.2rem 0 0; display: grid; gap: .5rem; }
.check-list li { display: flex; align-items: flex-start; gap: .5rem; font-size: .88rem; color: #d6e8df; }

.auth-card {
  padding: clamp(1.5rem, 3.5vw, 2.4rem);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.55rem; margin-bottom: .3rem; }
.auth-card > p { color: var(--muted); font-size: .92rem; }

.stack { display: grid; gap: 1rem; margin-top: 1.4rem; }

.auth-switch { margin-top: 1.1rem; text-align: center; font-size: .9rem; color: var(--muted); }
.auth-switch a { font-weight: 700; }

/* --------------------------------------------------------------------------
   18. Forms
   -------------------------------------------------------------------------- */
.field { display: grid; gap: .35rem; align-content: start; }
.field > span { font-size: .86rem; font-weight: 700; color: var(--ink-soft); }
.field .hint, .field small.hint { font-size: .77rem; color: var(--muted); }

input[type="text"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="email"],
input[type="url"],
input[type="color"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: .62rem .8rem;
  border: 1.5px solid var(--line-dark);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-size: .93rem;
  line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
}
textarea { resize: vertical; min-height: 76px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: var(--ring);
}
input[type="color"] { padding: .2rem; height: 42px; }
input[type="file"] { padding: .45rem .6rem; font-size: .86rem; }
input::placeholder, textarea::placeholder { color: #9aa8a1; }

.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--green-600); }
.field-check { align-self: end; padding-bottom: .5rem; font-size: .88rem; font-weight: 600; }

.form-panel { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  padding-top: 1rem;
  margin-top: .2rem;
  border-top: 1px dashed var(--line);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filter-bar select,
.filter-bar input { max-width: 300px; }

.upload-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .8rem; }
.upload-form .field { flex: 1; min-width: 220px; }

/* --------------------------------------------------------------------------
   19. Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
thead th {
  padding: .65rem .8rem;
  text-align: start;
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg-tint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: .7rem .8rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--green-50); }
tbody tr.is-me { background: var(--gold-100); }

.table-title { display: flex; align-items: center; gap: .6rem; }
.table-title strong { display: block; font-size: .9rem; }
.table-title small { display: block; color: var(--muted); font-size: .76rem; }
.table-ico {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent, var(--green-600)) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent, var(--green-600)) 22%, #fff);
  font-size: 1rem;
}

.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.row-actions form { margin: 0; }
.row-actions.vertical { flex-direction: column; align-items: stretch; }
.row-actions.vertical .btn { width: 100%; }

/* --------------------------------------------------------------------------
   20. Admin
   -------------------------------------------------------------------------- */
.admin-body { background: var(--bg-tint); }

.admin-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 1.4rem;
  align-items: start;
  padding-block: 1.6rem 3rem;
}

.admin-side {
  position: sticky;
  top: calc(var(--header-h) + 1.2rem);
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
  border-radius: var(--radius);
  background: linear-gradient(165deg, var(--green-900), var(--green-800));
  color: #dcebe4;
  box-shadow: var(--shadow);
}
.admin-side-head { display: flex; align-items: center; gap: .6rem; padding-bottom: .9rem; border-bottom: 1px solid rgba(255, 255, 255, .14); }
.admin-side-ico {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(232, 200, 106, .16);
  border: 1px solid rgba(232, 200, 106, .3);
  font-size: 1.1rem;
}
.admin-side-head strong { display: block; color: #fff; font-size: .94rem; }
.admin-side-head small { color: #9fbfb1; font-size: .76rem; }

.admin-nav { display: grid; gap: .2rem; }
.admin-nav a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .7rem;
  border-radius: var(--radius-sm);
  color: #c8ddd2;
  font-size: .88rem;
  font-weight: 650;
  transition: background var(--transition), color var(--transition);
}
.admin-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.admin-nav a.is-active { background: rgba(232, 200, 106, .16); color: var(--gold-300); box-shadow: inset 3px 0 0 var(--gold-400); }
html[dir="ltr"] .admin-nav a.is-active { box-shadow: inset -3px 0 0 var(--gold-400); }

.admin-side-foot {
  display: grid;
  gap: .3rem;
  padding-top: .9rem;
  border-top: 1px solid rgba(255, 255, 255, .14);
}
.admin-side-foot a { color: #9fbfb1; font-size: .82rem; font-weight: 600; }
.admin-side-foot a:hover { color: #fff; }

.admin-main { min-width: 0; display: grid; gap: 1.1rem; }

.admin-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.admin-topbar h1 { font-size: clamp(1.35rem, 2.6vw, 1.8rem); margin: 0 0 .2rem; color: var(--green-900); }
.admin-topbar p { margin: 0; font-size: .87rem; }
.admin-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.admin-actions form { margin: 0; }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: .8rem;
}
.admin-stat {
  display: grid;
  justify-items: start;
  gap: .1rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition);
}
a.admin-stat:hover { transform: translateY(-2px); border-color: var(--green-500); color: var(--ink); }
.admin-stat-ico { font-size: 1.15rem; }
.admin-stat strong { font-size: 1.5rem; line-height: 1.1; color: var(--green-800); }
.admin-stat > span:last-child { font-size: .78rem; color: var(--muted); font-weight: 600; }

.admin-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }

.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.quick-action {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem .8rem;
  border-radius: var(--radius-sm);
  background: var(--green-50);
  border: 1px solid var(--green-100);
  color: var(--green-800);
  font-size: .86rem;
  font-weight: 700;
  transition: background var(--transition), transform var(--transition);
}
.quick-action:hover { background: var(--green-100); transform: translateY(-1px); }
.quick-action span { font-size: 1.05rem; }

.add-panel { padding: 0; overflow: hidden; }
.add-summary {
  padding: 1rem 1.3rem;
  cursor: pointer;
  font-weight: 800;
  color: var(--green-800);
  list-style: none;
  background: var(--green-50);
  border-bottom: 1px solid transparent;
}
.add-summary::-webkit-details-marker { display: none; }
.add-panel[open] .add-summary { border-bottom-color: var(--line); }
.add-panel .form-panel { padding: 1.3rem; border: 0; box-shadow: none; border-radius: 0; }

.admin-sentence-list { display: grid; gap: .8rem; }
.admin-sentence {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  padding: .95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.admin-sentence-body { flex: 1; min-width: 0; }
.admin-sentence-body p { margin: 0 0 .2rem; font-size: .9rem; }
.admin-sentence-body .note { color: var(--gold-600); }
.admin-sentence-body .badge { margin-top: .35rem; }

.admin-question-list { display: grid; gap: .9rem; }
.admin-question { margin: 0; }
.admin-question-head { display: flex; align-items: flex-start; gap: .7rem; margin-bottom: .8rem; padding-bottom: .7rem; border-bottom: 1px dashed var(--line); }
.admin-question-title { flex: 1; min-width: 0; }
.admin-question-title h3 { font-size: .96rem; margin: 0 0 .15rem; line-height: 1.55; }
.admin-question-title p { margin: 0; font-size: .83rem; }

.choice-list { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; gap: .4rem; }
.choice-list li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .7rem;
  border-radius: var(--radius-xs);
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: .88rem;
}
.choice-list li.is-correct { background: var(--success-soft); border-color: #c6e6d5; }
.choice-letter {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line-dark);
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted);
}
.choice-body { flex: 1; min-width: 0; }
.choice-body small { display: block; color: var(--muted); font-size: .78rem; }

.choices-editor {
  margin: 0;
  padding: 1rem;
  border: 1px dashed var(--line-dark);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.choices-editor legend { padding-inline: .4rem; font-size: .86rem; font-weight: 700; color: var(--ink-soft); }
.choice-rows { display: grid; gap: .5rem; margin-bottom: .7rem; }
.choice-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: center;
}
.choice-radio {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--line-dark);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 800;
  color: var(--muted);
  position: relative;
}
.choice-radio input { position: absolute; opacity: 0; width: 100%; height: 100%; inset: 0; cursor: pointer; }
.choice-radio:has(input:checked) { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.choice-row input[type="text"] { padding: .45rem .6rem; font-size: .86rem; }

/* ---- Media ---- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: .9rem;
}
.media-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.media-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: var(--bg-tint);
}
.media-body { display: grid; gap: .25rem; padding: .8rem; }
.media-body strong { font-size: .86rem; }
.media-body small { font-size: .75rem; }
.media-url {
  display: block;
  padding: .3rem .45rem;
  font-size: .7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-body .row-actions { margin-top: .3rem; }

/* --------------------------------------------------------------------------
   21. Footer
   -------------------------------------------------------------------------- */
.site-footer {
  margin-top: auto;
  background: linear-gradient(160deg, var(--green-950), var(--green-900));
  color: #b9d2c6;
  padding-top: 3rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, .7fr));
  gap: 2rem;
  padding-bottom: 2.2rem;
}
.footer-brand .brand { margin-bottom: .8rem; }
.brand-light { color: #fff; }
.brand-light:hover { color: #fff; }
.brand-light .brand-text small { color: #9fbfb1; }
.footer-brand p { font-size: .87rem; line-height: 1.75; color: #9fbfb1; max-width: 46ch; margin: 0; }

.footer-links { display: grid; align-content: start; gap: .35rem; }
.footer-links h4 { color: #fff; font-size: .9rem; margin: 0 0 .45rem; letter-spacing: .02em; }
.footer-links a { color: #a9c6b9; font-size: .85rem; }
.footer-links a:hover { color: var(--gold-300); }

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block: 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, .1);
  font-size: .8rem;
  color: #8fb0a1;
}

.footer-credit {
  padding-bottom: 1.2rem;
  text-align: center;
  font-size: .82rem;
  color: #8fb0a1;
}
.footer-credit strong { color: #fff; font-weight: 600; }
.footer-credit a { color: var(--gold-300); font-weight: 600; }
.footer-credit a:hover { color: #fff; }

/* --------------------------------------------------------------------------
   22. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2.4rem; }
  .hero-visual { min-height: 300px; order: -1; }
  .hero-card { transform: none; }
  html[dir="ltr"] .hero-card { transform: none; }
  .float-chip-2 { inset-inline-start: 6%; }

  .admin-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .admin-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .nav-toggle { display: flex; }

  .main-nav {
    position: absolute;
    inset-block-start: var(--header-h);
    inset-inline: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: .15rem;
    padding: 1rem 18px 1.4rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 20px 40px rgba(6, 43, 32, .14);
  }
  .main-nav.is-open { display: flex; }
  .nav-link { justify-content: flex-start; padding: .65rem .8rem; border-radius: var(--radius-sm); }
  .nav-divider { width: 100%; height: 1px; margin: .4rem 0; }
  .nav-search-text { display: inline; }
  .main-nav .btn { justify-content: center; }
  .lang-switch { margin-inline-start: 0; justify-content: center; padding: .6rem; }

  .section-head { flex-direction: column; align-items: flex-start; gap: .8rem; }
  .section-head.center { align-items: center; }

  .lesson-head-grid { grid-template-columns: 1fr; gap: 1.2rem; }
  .lesson-head-actions { justify-items: start; text-align: start; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem 0; }
  .stat:nth-child(2) { border-inline-end: 0; }

  .dash-grid { grid-template-columns: 1fr; }
  .dash-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .auth-grid { grid-template-columns: 1fr; gap: 1.4rem; max-width: 640px; }
  .auth-aside { padding: 1.5rem; }
  .check-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .admin-layout { grid-template-columns: 1fr; }
  .admin-side { position: static; }
  .admin-nav { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .admin-side-foot { grid-auto-flow: column; justify-content: start; gap: 1rem; }

  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .container { padding-inline: 16px; }

  .hero-grid { padding-block: 2.4rem; }
  .hero h1 { font-size: clamp(1.8rem, 7vw, 2.4rem); }
  .hero-actions .btn { flex: 1 1 auto; }
  .hero-visual { min-height: 260px; }
  .hero-orb { width: 240px; height: 240px; }
  .float-chip { width: 40px; height: 40px; font-size: 1.05rem; }
  .float-chip-3 { inset-inline-end: -4px; }

  .steps-grid { grid-template-columns: 1fr; }
  .cta-banner { flex-direction: column; align-items: flex-start; text-align: start; }
  .cta-banner .btn { width: 100%; }

  .topic-hero-inner { flex-direction: column; gap: 1rem; }
  .topic-hero-icon { width: 62px; height: 62px; font-size: 1.9rem; border-radius: 18px; }

  .lesson-row { flex-wrap: wrap; gap: .7rem; }
  .lesson-row-status { width: 100%; }
  .lesson-row-status .badge { width: 100%; justify-content: center; }

  .sentence-card { padding: 1.1rem; gap: .7rem; }
  .sentence-num { width: 28px; height: 28px; }

  .lesson-pager { grid-template-columns: 1fr; }
  .pager-link.next { text-align: start; }

  .quiz-grid { grid-template-columns: 1fr; }
  .quiz-head { align-items: flex-start; }
  .quiz-head-side { width: 100%; }
  .best-box, .timer-box { flex: 1; }

  .quiz-submit-bar { flex-direction: column; align-items: stretch; text-align: center; }

  .result-card { flex-direction: column; text-align: center; }
  .result-actions { justify-content: center; }

  .dash-stats { grid-template-columns: 1fr 1fr; }
  .progress-row { grid-template-columns: 1fr auto; }
  .progress-track { grid-column: 1 / -1; order: 3; }

  .search-form { flex-wrap: wrap; }
  .search-form input { flex-basis: 100%; }

  .form-grid { grid-template-columns: 1fr; }
  .choice-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .choice-row input[name="choice_en"] { grid-column: 2; }

  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-actions { grid-template-columns: 1fr; }

  .footer-grid { grid-template-columns: 1fr; gap: 1.4rem; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }

  .check-list { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat { border-inline-end: 0; justify-content: flex-start; }
  .dash-stats { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: 1fr; }
  .admin-nav { grid-template-columns: 1fr; }
  .question-head { flex-wrap: wrap; }
  .question-points { margin-inline-start: 38px; }
}

/* --------------------------------------------------------------------------
   23. Motion & print
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media print {
  .site-header, .site-footer, .toast, .flash-wrap, .quiz-submit-bar,
  .audio-btn, .lesson-head-actions, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .sentence-card, .quiz-question, .panel { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}
