/* English with Mounia — shared styles. Tangier palette: Mediterranean blue, whitewash, terracotta, mint. */

:root {
  --bg: #f6f3ed;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1c2839;
  --muted: #5a6677;
  --line: #e6e0d4;

  --blue: #1d5fa7;
  --blue-700: #154a85;
  --blue-50: #eaf2fb;
  --blue-100: #d3e3f5;
  --terra: #b95a36;
  --terra-50: #fbeee7;
  --mint: #1f8a65;
  --mint-700: #17704f;
  --mint-50: #e2f4ec;
  --gold: #e3a21a;
  --gold-50: #fdf4dc;
  --red: #c23a43;
  --red-50: #fce8e9;

  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(28, 40, 57, .05), 0 8px 24px rgba(28, 40, 57, .07);
  --shadow-lg: 0 2px 4px rgba(28, 40, 57, .06), 0 18px 40px rgba(28, 40, 57, .12);

  --font-ar: 'Noto Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
  --font-head: 'Noto Kufi Arabic', 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --font-en: 'Nunito', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;

  --sidebar: 292px;
  --zellige: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='white' stroke-width='1.6'%3E%3Crect x='18' y='18' width='28' height='28'/%3E%3Crect x='18' y='18' width='28' height='28' transform='rotate(45 32 32)'/%3E%3Ccircle cx='32' cy='32' r='6'/%3E%3Cpath d='M0 0 L8 8 M64 0 L56 8 M0 64 L8 56 M64 64 L56 56'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ar);
  font-size: 17px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.45; margin: 0; font-weight: 700; }
p { margin: 0 0 .6em; }
a { color: var(--blue); }
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 10px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* English text: always left-to-right, clean Latin font. */
.en { font-family: var(--font-en); direction: ltr; unicode-bidi: isolate; font-weight: 700; }

.skip-link { position: absolute; top: -60px; inset-inline-start: 12px; background: var(--blue); color: #fff; padding: 8px 14px; border-radius: 10px; z-index: 100; }
.skip-link:focus { top: 12px; }

noscript p { padding: 24px; text-align: center; }

/* ------------------------------------------------------------------ layout */
.sidebar {
  position: fixed; top: 0; bottom: 0; inset-inline-start: 0;
  width: var(--sidebar);
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column;
  z-index: 50;
  overflow-y: auto;
}
.main { margin-inline-start: var(--sidebar); padding: 32px 40px 80px; min-height: 100vh; outline: none; }
.container { max-width: 900px; margin: 0 auto; }

.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 18px 14px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-logo { width: 44px; height: 44px; flex: none; display: block; }
.brand-logo svg { width: 100%; height: 100%; display: block; }
.brand-logo.sm { width: 32px; height: 32px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-en { font-size: 16px; font-weight: 800; color: var(--blue-700); }
.brand-ar { font-size: 13px; color: var(--muted); }
.icon-btn { border: 0; background: transparent; width: 44px; height: 44px; border-radius: 12px; font-size: 22px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--blue-50); }
.sb-close { display: none; }

.nav { list-style: none; margin: 0; padding: 6px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 14px;
  text-decoration: none; color: var(--ink);
  min-height: 56px;
  transition: background .15s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--blue-50); box-shadow: inset -4px 0 0 var(--blue); }
.nav-badge {
  width: 36px; height: 36px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line);
  font-family: var(--font-en); font-weight: 800; font-size: 16px; color: var(--blue-700);
}
.nav-item.active .nav-badge { background: var(--blue); color: #fff; border-color: var(--blue); }
.nav-item.done .nav-badge { background: var(--mint-50); border-color: #bfe5d3; color: var(--mint-700); }
.nav-item.is-test .nav-badge { background: var(--gold-50); border-color: #f3dca2; }
.nav-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.45; }
.nav-label { font-weight: 700; font-size: 15.5px; }
.nav-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-sub .en { font-weight: 600; }
.nav-check {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--mint); color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 800;
}

.sb-foot { margin-top: auto; padding: 16px 20px 22px; border-top: 1px solid var(--line); font-size: 14px; }
.sb-row { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--muted); }
.sb-row b { color: var(--ink); font-family: var(--font-en); }
.sb-stats { display: flex; gap: 14px; margin-top: 10px; color: var(--muted); }

.bar { height: 10px; background: #ece6da; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), #3bb58b); border-radius: 99px; transition: width .4s ease; }
[dir="rtl"] .bar i { margin-inline-start: 0; }

.topbar { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(20, 30, 45, .45); z-index: 45; }
.scrim[hidden] { display: none; }

@media (max-width: 959px) {
  .topbar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 40;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 8px 10px; min-height: 60px;
  }
  .topbar-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--blue-700); font-size: 16px; flex: 1; }
  .topbar-streak { font-weight: 700; font-size: 15px; padding: 4px 10px; background: var(--gold-50); border-radius: 99px; }
  .sidebar { transform: translateX(105%); transition: transform .25s ease; box-shadow: var(--shadow-lg); width: min(320px, 88vw); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open { overflow: hidden; }
  .sb-close { display: grid; }
  .main { margin-inline-start: 0; padding: 16px 16px 72px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ------------------------------------------------------------------ building blocks */
.card, .block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 22px;
}
.block-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.block-head h2 { font-size: 22px; }
.chip { font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 99px; }
.chip-blue { background: var(--blue-50); color: var(--blue-700); }
.chip-terra { background: var(--terra-50); color: var(--terra); }
.chip-mint { background: var(--mint-50); color: var(--mint-700); }
.chip-gold { background: var(--gold-50); color: #9a6a00; }

.prose { color: #2c3a4d; margin-bottom: 16px; }
.prose p { margin-bottom: .55em; }
.prose .en, .lead .en, .goals-list .en, .tip .en, .wc-note .en, .q-ask .en, .steps .en, .pk-ar .en, .scene .en, .result .en {
  color: var(--blue-700); font-size: 1.08em;
}
.note-small { font-size: 14.5px; color: var(--muted); margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  border-radius: 14px; border: 1px solid transparent;
  font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer;
  transition: transform .08s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(29, 95, 167, .25); }
.btn-primary:hover { background: var(--blue-700); }
.btn-mint { background: var(--mint); color: #fff; box-shadow: 0 4px 12px rgba(31, 138, 101, .25); }
.btn-mint:hover { background: var(--mint-700); }
.btn-again { background: var(--terra-50); color: var(--terra); border-color: #f1cdbd; }
.btn-again:hover { background: #f8e0d4; }
.btn-soft { background: var(--blue-50); color: var(--blue-700); border-color: var(--blue-100); }
.btn-soft:hover { background: var(--blue-100); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-light { background: #fff; color: var(--blue-700); box-shadow: 0 6px 18px rgba(0, 0, 0, .15); }
.btn-light:hover { background: var(--blue-50); }
.btn-xl { min-height: 56px; font-size: 18px; padding: 12px 26px; border-radius: 16px; }
.link-btn { border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; padding: 8px; }

/* audio buttons: hidden unless an English voice exists */
.audio-row { display: none; gap: 8px; flex-wrap: wrap; justify-content: center; }
.has-audio .audio-row { display: inline-flex; }
.audio-only { display: none !important; }
.has-audio .audio-only { display: inline-flex !important; }
.audio-btn {
  min-width: 48px; min-height: 44px; padding: 6px 12px;
  border-radius: 12px; border: 1px solid var(--blue-100); background: var(--blue-50); color: var(--blue-700);
  font-size: 18px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.audio-btn.slow { font-size: 14px; font-weight: 700; }
.audio-btn:hover { background: var(--blue-100); }
.audio-btn:active { transform: scale(.96); }

/* ------------------------------------------------------------------ hero */
.hero {
  position: relative; overflow: hidden;
  border-radius: 26px;
  background: linear-gradient(135deg, #16508f 0%, #1d5fa7 45%, #2a7cc4 100%);
  color: #fff;
  padding: 32px;
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
  margin-bottom: 22px;
  box-shadow: var(--shadow-lg);
}
.hero::before { content: ""; position: absolute; inset: 0; background-image: var(--zellige); background-size: 64px; opacity: .09; pointer-events: none; }
.hero::after { content: ""; position: absolute; inset-inline-end: -80px; bottom: -120px; width: 300px; height: 300px; border-radius: 50%; background: rgba(255, 255, 255, .07); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-size: 34px; margin-bottom: 10px; }
.hero .kicker { color: #cfe3f7; font-size: 15px; margin-bottom: 6px; }
.hero .kicker .en { font-weight: 700; color: #fff; }
.hero .lead { font-size: 18px; color: #eef5fc; margin-bottom: 18px; max-width: 580px; }
.hero .lead .en { color: #fff; background: rgba(255, 255, 255, .14); padding: 0 6px; border-radius: 6px; }
.hero .lead strong { color: #fff; }
.hero-art { width: 170px; height: 170px; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .2)); }
.hero-art svg { width: 100%; height: 100%; }
.test-hero { background: linear-gradient(135deg, #8a3d20 0%, #b95a36 50%, #d27a4f 100%); }
.words-hero { background: linear-gradient(135deg, #125a43 0%, #1f8a65 55%, #33a57c 100%); }

@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; padding: 24px 20px; text-align: start; }
  .hero-art { width: 110px; height: 110px; grid-row: 1; }
  .hero h1 { font-size: 27px; }
  .hero .lead { font-size: 16.5px; }
  .hero .btn-xl { width: 100%; }
  .card, .block { padding: 18px 16px; border-radius: 18px; }
  .block-head h2 { font-size: 19px; }
}

/* goals */
.goals h2 { font-size: 21px; margin-bottom: 10px; }
.goals-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.goals-list li { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; padding-inline-start: 44px; position: relative; }
.goals-list li::before { content: "✓"; position: absolute; inset-inline-start: 12px; top: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--mint-50); color: var(--mint-700); font-weight: 800; font-size: 13px; display: grid; place-items: center; }

/* ------------------------------------------------------------------ word cards */
.word-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.word-grid.wide { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.word-card {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform .15s, box-shadow .15s;
}
.word-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.wc-img { width: 104px; height: 104px; margin-bottom: 4px; }
.wc-img svg { width: 100%; height: 100%; display: block; }
.wc-en { font-size: 27px; line-height: 1.3; color: var(--ink); }
.wc-en .en { font-weight: 800; }
.word-grid.wide .wc-en { font-size: 23px; }
.wc-pron { color: var(--blue); font-size: 17px; font-weight: 500; }
.wc-ar { font-size: 18px; font-weight: 700; color: var(--terra); }
.wc-msa { font-weight: 400; color: var(--muted); font-size: 14.5px; }
.wc-note { font-size: 14px; color: var(--muted); line-height: 1.65; margin: 4px 0 6px; }
.word-card .audio-row { margin-top: auto; padding-top: 6px; }

@media (max-width: 480px) {
  .word-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .word-grid.wide { grid-template-columns: 1fr; }
  .word-card { padding: 12px 8px; }
  .wc-img { width: 84px; height: 84px; }
  .wc-en { font-size: 23px; }
  .wc-ar { font-size: 16px; }
}

/* alphabet */
.ltr-demo { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--blue-50); border-radius: 18px; padding: 16px; margin-bottom: 18px; }
.ltr-demo p { margin: 0; color: var(--blue-700); font-weight: 700; }
.ltr-word { display: flex; gap: 14px; }
.ltr-word span { font-size: 44px; line-height: 1; position: relative; color: var(--ink); }
.ltr-word small { position: absolute; top: -8px; right: -12px; font-size: 13px; background: var(--gold); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; }
.ltr-arrow { display: flex; align-items: center; gap: 8px; width: 170px; color: var(--blue); font-family: var(--font-en); font-weight: 800; font-size: 13px; }
.ltr-arrow i { flex: 1; height: 3px; background: var(--blue); position: relative; border-radius: 3px; }
.ltr-arrow i::after { content: ""; position: absolute; right: -2px; top: -5px; border: 6.5px solid transparent; border-left-color: var(--blue); border-right: 0; }

.letter-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.letter {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 16px;
  padding: 10px 6px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0; line-height: 1.4;
  min-height: 118px;
}
.letter:hover { background: var(--blue-50); border-color: var(--blue-100); }
.letter:active { transform: scale(.97); }
.lt-big { font-size: 30px; font-weight: 800; color: var(--blue-700); }
.lt-big span { color: var(--terra); }
.lt-name { font-size: 15px; font-weight: 700; }
.lt-sound { font-size: 12px; color: var(--muted); }
.lt-ex { font-size: 13px; color: var(--muted); font-weight: 600; }
.letter.vowel { background: var(--mint-50); border-color: #bfe5d3; }
.letter.vowel .lt-big { color: var(--mint-700); }
@media (max-width: 480px) { .letter-grid { grid-template-columns: repeat(3, 1fr); } }

/* pronunciation key */
.pron-key { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pron-key li { display: grid; grid-template-columns: 52px 56px 1fr; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.pk-sym { font-size: 28px; font-weight: 700; color: var(--terra); text-align: center; }
.pk-en { font-size: 20px; color: var(--blue-700); text-align: center; }
.pk-ar { font-size: 15.5px; }

/* grammar table */
.table-wrap { overflow-x: auto; }
.be-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.be-table th { text-align: start; font-size: 14px; color: var(--muted); font-weight: 500; padding: 0 12px; }
.be-table td { background: var(--surface-2); padding: 10px 12px; border-block: 1px solid var(--line); vertical-align: middle; }
.be-table td:first-child { border-inline-start: 1px solid var(--line); border-start-start-radius: 14px; border-end-start-radius: 14px; }
.be-table td:last-child { border-inline-end: 1px solid var(--line); border-start-end-radius: 14px; border-end-end-radius: 14px; }
.be-table .en.big { font-size: 24px; color: var(--blue-700); }
.be-table td .en { font-size: 19px; }
.be-table .wc-pron { font-size: 15px; }
@media (max-width: 560px) {
  .be-table th:nth-child(2), .be-table td:nth-child(2) { display: none; }
  .be-table .audio-btn.slow { display: none; }
  .be-table td { padding: 8px; }
}

/* tip */
.tip {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--terra-50); border: 1px solid #f1cdbd; border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 22px;
}
.tip-icon { font-size: 28px; line-height: 1; background: #fff; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none; box-shadow: var(--shadow); }
.tip h3 { font-size: 19px; color: var(--terra); margin-bottom: 6px; }
.tip p { margin: 0; }

/* dialogue */
.scene { background: var(--surface-2); border-radius: 14px; padding: 10px 14px; color: var(--muted); }
.play-all { margin-bottom: 14px; }
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 88%; }
.msg.me { align-self: flex-start; }
.msg.them { align-self: flex-end; flex-direction: row-reverse; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--terra); }
.msg.them .avatar { background: var(--blue); }
.bubble { background: var(--terra-50); border: 1px solid #f1cdbd; border-radius: 18px; border-end-start-radius: 6px; padding: 10px 14px; transition: box-shadow .2s, transform .2s; }
.msg.them .bubble { background: var(--blue-50); border-color: var(--blue-100); border-radius: 18px; border-end-end-radius: 6px; }
.msg.speaking .bubble { box-shadow: 0 0 0 3px var(--gold); transform: scale(1.01); }
.who { font-size: 13px; font-weight: 700; color: var(--muted); }
.msg-en { font-size: 20px; margin: 2px 0 0; line-height: 1.45; }
.msg-en .en { display: block; text-align: left; }
.msg-pron { color: var(--blue); font-size: 15px; margin: 2px 0 0; }
.msg-ar { font-size: 15.5px; margin: 0 0 6px; color: #3a4658; }
.bubble .audio-row { justify-content: flex-start; }
.bubble .audio-btn { min-height: 38px; font-size: 15px; }
@media (max-width: 560px) { .msg { max-width: 100%; } .msg-en { font-size: 18px; } }

/* ------------------------------------------------------------------ exercises */
.exercise { border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 16px; background: var(--surface-2); }
.exercise:last-child { margin-bottom: 0; }
.ex-title { font-size: 18px; margin-bottom: 12px; }

.q-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.q-top .bar { flex: 1; }
.q-count { font-size: 14px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.q-ask { font-weight: 700; font-size: 17px; margin-bottom: 10px; outline: none; }
.q-prompt { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 16px; text-align: center; }
.q-img { width: 130px; height: 130px; }
.q-img svg { width: 100%; height: 100%; }
.q-en { font-size: 32px; color: var(--ink); line-height: 1.3; }
.q-en .en { font-weight: 800; letter-spacing: .5px; }
.q-ar { font-size: 20px; font-weight: 700; color: var(--terra); }
.q-listen { display: flex; align-items: center; gap: 12px; }
.listen-big {
  width: 88px; height: 88px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--blue); color: #fff; font-size: 38px;
  box-shadow: 0 8px 20px rgba(29, 95, 167, .3), inset 0 -4px 0 rgba(0, 0, 0, .15);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { box-shadow: 0 8px 20px rgba(29, 95, 167, .3), 0 0 0 0 rgba(29, 95, 167, .35); } 50% { box-shadow: 0 8px 20px rgba(29, 95, 167, .3), 0 0 0 12px rgba(29, 95, 167, 0); } }
@media (prefers-reduced-motion: reduce) { .listen-big { animation: none; } }

.options { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.options.opt-img { grid-template-columns: repeat(auto-fit, minmax(110px, 150px)); justify-content: center; }
.opt {
  min-height: 60px; padding: 10px 14px;
  border: 2px solid var(--line); background: var(--surface); border-radius: 16px;
  cursor: pointer; font-size: 20px; transition: border-color .15s, background .15s, transform .1s;
}
.opt .en { font-weight: 800; }
.opt-ar .opt { font-size: 19px; font-weight: 700; }
.opt-img .opt { padding: 8px; aspect-ratio: 1; }
.opt-img .opt svg { width: 100%; height: 100%; display: block; }
.opt:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-50); }
.opt:active:not(:disabled) { transform: scale(.98); }
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--mint); background: var(--mint-50); box-shadow: 0 0 0 3px rgba(31, 138, 101, .15); }
.opt.wrong { border-color: var(--red); background: var(--red-50); animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .opt.wrong, .match-item.nope { animation: none; } }

.q-feedback { min-height: 0; margin-top: 12px; border-radius: 14px; font-size: 17px; }
.q-feedback.ok, .q-feedback.bad { padding: 12px 16px; }
.q-feedback.ok { background: var(--mint-50); color: var(--mint-700); }
.q-feedback.bad { background: var(--red-50); color: var(--red); }
.q-feedback .en { font-size: 1.1em; }
.q-feedback .btn { margin-inline-start: 8px; min-height: 40px; }
.fb-pic { display: inline-block; width: 44px; height: 44px; vertical-align: middle; }
.fb-pic svg { width: 100%; height: 100%; }
.q-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.q-actions:empty { display: none; }
.q-done, .fc-done { text-align: center; padding: 10px; }
.q-done h3, .fc-done h3 { font-size: 22px; margin-bottom: 6px; }
.big-emoji { font-size: 48px; line-height: 1.2; }

/* tiles (spell + build) */
.tiles-answer {
  min-height: 70px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
  border: 2px dashed var(--blue-100); border-radius: 16px; padding: 10px; margin-bottom: 12px; background: var(--surface);
}
.tiles-answer.correct { border-style: solid; border-color: var(--mint); background: var(--mint-50); }
.tiles-answer.wrong { border-style: solid; border-color: var(--red); background: var(--red-50); }
.tiles-hint { color: var(--muted); font-size: 15px; }
.tiles-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
.tile {
  min-width: 52px; min-height: 52px; padding: 6px 14px;
  border: 2px solid var(--blue-100); border-bottom-width: 4px; background: #fff; border-radius: 14px;
  font-size: 22px; cursor: pointer; color: var(--blue-700);
}
.tile.in { background: var(--blue-50); }
.tile:disabled { opacity: .25; cursor: default; }
.tile.in:disabled { opacity: 1; }
.tiles-answer.spell .slot { width: 52px; height: 52px; border-bottom: 3px solid var(--blue-100); }
.tile-ctrl { display: flex; gap: 10px; justify-content: center; }

/* matching */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-col { display: flex; flex-direction: column; gap: 8px; }
.match-item {
  min-height: 56px; padding: 8px 12px; border: 2px solid var(--line); background: var(--surface); border-radius: 14px;
  cursor: pointer; font-size: 19px; font-weight: 700; transition: all .15s;
}
.match-item:hover:not(:disabled) { border-color: var(--blue-100); background: var(--blue-50); }
.match-item.selected { border-color: var(--blue); background: var(--blue-50); box-shadow: 0 0 0 3px rgba(29, 95, 167, .15); }
.match-item.matched { border-color: var(--mint); background: var(--mint-50); color: var(--mint-700); cursor: default; opacity: .8; }
.match-item.nope { border-color: var(--red); background: var(--red-50); animation: shake .4s; }

/* ------------------------------------------------------------------ flashcards */
.flashcards { max-width: 460px; margin: 0 auto; }
.fc-top { display: flex; align-items: center; gap: 12px; }
.fc-top .bar { flex: 1; }
.fc-count { font-family: var(--font-en); font-weight: 700; font-size: 17px; color: var(--muted); direction: ltr; unicode-bidi: isolate; }
.fc-count b { color: var(--mint-700); font-size: 20px; }
.fc-card { perspective: 1200px; height: 340px; margin: 14px 0; cursor: pointer; border-radius: 26px; outline: none; }
.fc-card:focus-visible { box-shadow: 0 0 0 4px var(--gold); }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.3, .7, .3, 1); transform-style: preserve-3d; }
.fc-card.is-flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  border-radius: 26px; padding: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.fc-front { background: linear-gradient(170deg, #fff 0%, var(--surface-2) 100%); }
.fc-back { transform: rotateY(180deg); background: linear-gradient(170deg, #fff 0%, var(--blue-50) 100%); }
.fc-card:not(.is-flipped) .fc-back .audio-row { visibility: hidden; }
.fc-img { width: 150px; height: 150px; }
.fc-img.sm { width: 90px; height: 90px; }
.fc-img svg { width: 100%; height: 100%; }
.fc-ar { font-size: 26px; font-weight: 700; color: var(--terra); line-height: 1.5; }
.fc-hint { font-size: 14px; color: var(--muted); }
.fc-en { font-size: 40px; line-height: 1.2; color: var(--ink); }
.fc-en .en { font-weight: 800; }
.fc-pron { color: var(--blue); font-size: 19px; }
.fc-actions { display: flex; gap: 10px; justify-content: center; }
.fc-actions .btn { flex: 1; min-height: 56px; font-size: 18px; max-width: 220px; }
.fc-actions .btn[hidden] { display: none; }
.fc-keys { text-align: center; font-size: 13px; color: var(--muted); margin-top: 10px; }
.fc-keys .en { font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
@media (hover: none) { .fc-keys { display: none; } }
@media (prefers-reduced-motion: reduce) { .fc-inner { transition: none; } }
@media (max-width: 480px) { .fc-card { height: 310px; } .fc-en { font-size: 34px; } .fc-img { width: 128px; height: 128px; } }

/* ------------------------------------------------------------------ finish + pager */
.finish { text-align: center; padding: 30px 24px; }
.finish h2 { font-size: 23px; margin-bottom: 6px; }
.finish p { color: var(--muted); }
.finish .btn-xl { margin-top: 8px; }
.finish-done { animation: pop .4s ease; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.pager { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 30px); opacity: 0;
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 14px; box-shadow: var(--shadow-lg);
  z-index: 200; transition: all .3s ease; font-weight: 700; max-width: calc(100vw - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: fall 2.6s ease-in forwards; }
@keyframes fall { to { top: 110%; transform: translateX(40px) rotate(540deg); } }

/* ------------------------------------------------------------------ home */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; align-items: center; gap: 14px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 14px; color: var(--muted); }
.stat-icon { font-size: 30px; width: 60px; height: 60px; border-radius: 18px; background: var(--gold-50); display: grid; place-items: center; flex: none; }
.ring {
  --p: 0;
  width: 64px; height: 64px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--mint) calc(var(--p) * 1%), #ece6da 0);
  display: grid; place-items: center;
}
.ring span { width: 50px; height: 50px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-family: var(--font-en); font-weight: 800; font-size: 15px; color: var(--ink); }
.ring.big { width: 150px; height: 150px; margin: 0 auto 12px; background: conic-gradient(var(--terra) calc(var(--p) * 1%), #ece6da 0); }
.ring.big.pass { background: conic-gradient(var(--mint) calc(var(--p) * 1%), #ece6da 0); }
.ring.big span { width: 122px; height: 122px; font-size: 36px; }
@media (max-width: 720px) { .stats { grid-template-columns: 1fr; } }

.path { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.path-card {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.path-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--blue-100); }
.path-card.next { border: 2px solid var(--blue); background: var(--blue-50); }
.path-card.done { border-color: #bfe5d3; }
.path-card.test { background: var(--gold-50); border-color: #f3dca2; }
.pc-img { width: 64px; height: 64px; flex: none; }
.pc-img svg { width: 100%; height: 100%; }
.pc-emoji { display: grid; place-items: center; font-size: 34px; background: #fff; border-radius: 50%; }
.pc-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.5; }
.pc-kicker { font-size: 13px; color: var(--muted); }
.pc-kicker .en { font-weight: 600; }
.pc-text h3 { font-size: 17px; }
.pc-status { font-size: 14px; font-weight: 700; color: var(--blue-700); }
.path-card.done .pc-status { color: var(--mint-700); }

.steps { margin: 0; padding-inline-start: 22px; display: grid; gap: 8px; }
.steps li::marker { color: var(--blue); font-weight: 800; }
.reset-row { text-align: center; }

/* ------------------------------------------------------------------ test */
.test-card h2 { font-size: 22px; margin-bottom: 10px; }
.test-facts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.test-facts li { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.best { color: var(--muted); }
.result { text-align: center; }
.result h2 { font-size: 26px; }
.result-msg { font-size: 18px; max-width: 520px; margin: 6px auto 8px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.review { text-align: start; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; margin-top: 14px; }
.review summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.review ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.review li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; background: #fff; border-radius: 12px; padding: 8px 12px; border: 1px solid var(--line); }
.rv-q .en { font-size: 18px; }
.rv-a { color: var(--mint-700); font-weight: 700; }

/* ------------------------------------------------------------------ words page */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg-btn { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 700; min-height: 42px; color: var(--muted); }
.seg-btn.active { background: var(--blue); color: #fff; }
.word-group h2 { font-size: 19px; margin-bottom: 8px; }
.done-pill { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--mint); color: #fff; font-size: 13px; vertical-align: middle; }
.vocab { width: 100%; border-collapse: collapse; }
.vocab th { text-align: start; font-size: 13px; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.vocab td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.vocab tr:last-child td { border-bottom: 0; }
.v-img { width: 56px; }
.v-img svg { width: 48px; height: 48px; display: block; }
.v-en { font-size: 20px; }
.v-pron { color: var(--blue); }
.vocab .audio-row { flex-wrap: nowrap; }
.vocab .audio-btn { min-height: 40px; }
.empty { text-align: center; }
@media (max-width: 560px) {
  .vocab .v-pron { font-size: 14px; }
  .vocab .audio-btn.slow { display: none; }
  .v-en { font-size: 18px; }
  .toolbar .btn, .seg { width: 100%; }
  .seg-btn { flex: 1; }
}

/* ------------------------------------------------------------------ print (words list) */
@media print {
  body { background: #fff; font-size: 12pt; }
  .sidebar, .topbar, .scrim, .no-print, .skip-link, .toast, .audio-row, .hero-art { display: none !important; }
  .main { margin: 0; padding: 0; }
  .hero { background: none !important; color: var(--ink); box-shadow: none; padding: 0 0 10px; border-radius: 0; }
  .hero::before, .hero::after { display: none; }
  .hero .kicker, .hero .lead { color: var(--ink); }
  .block, .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .word-group { break-inside: auto; }
  .vocab tr { break-inside: avoid; }
}
