:root {
  /* AraBiC brand: direction B «Quest» (brand/DECISIONS.md, brand/tokens.css). WCAG-checked. */
  --bg: #F6EEDF;              /* Sand */
  --bg-2: #F6EEDF;
  --ink: #0E4D64;             /* Deep sea: text, titles */
  --muted: #5B6B70;
  --brand: #07303F;           /* primary-button shadow */
  --brand-2: #0E4D64;         /* primary button: Deep sea, white text */
  --c: var(--brand-2);        /* per-section colour (content/tracks.json) */
  --card: #ffffff;
  --line: #E6DCC8;
  --tile: #ffffff;
  --tile-shadow: #D9CDB5;
  --green: #2E9E5B;           /* Reef: correct */
  --green-dark: #1C7543;
  --green-soft: #E7F5EC;
  --red: #E4572E;             /* Signal red: wrong */
  --red-soft: #FCEAE4;
  --gold: #FFB627;            /* Sun: stars, rewards (never text on light) */
  --mark: #FFE7B0;
  --link: #0A7579;            /* Deep lagoon: links, focus, selection */
  --accent: #1FA2A6;          /* Lagoon: progress, highlights (never text on light) */
  --pale: #E3F4F4;            /* selected / soft lagoon */
  --soft: #FBF7EF;            /* soft panels */
  --sun-pale: #FFF4DA;
  --sun-line: #FFD98A;
  --done-line: #A9D9BA;
  --track: #E3D7C0;
  --focus: rgba(10, 117, 121, 0.3);
  --night: #0A2E3B;
  --radius: 18px;
  --font: 'Baloo Bhaijaan 2', 'Fredoka', system-ui, sans-serif;   /* screens */
  --font-ar: 'Scheherazade New', 'Noto Naskh Arabic', 'Geeza Pro', serif;   /* learning text: chosen for clarity of تشكيل */
  --font-en: 'Fredoka', system-ui, sans-serif;                     /* English help, Latin */
  --font-display: 'Lalezar', 'Baloo Bhaijaan 2', sans-serif;      /* titles */
}

/* Dark mode: follows the device (index.html sets data-theme). */
:root[data-theme="dark"] {
  --bg: #0A2E3B; --bg-2: #0A2E3B;
  --ink: #F6EEDF; --muted: #A9BFC4;
  --brand: #C98A0E; --brand-2: #FFB627;            /* primary button: Sun with Night text */
  --card: #0E4D64; --line: #1E5A6E;
  --tile: #134E62; --tile-shadow: #072631;
  --green: #5FD38D; --green-dark: #2E9E5B; --green-soft: #143F35;
  --red: #FF8A66; --red-soft: #4A2A28;
  --mark: #5C4A12;
  --link: #45C9CC; --accent: #45C9CC; --pale: #134E62; --soft: #0C3F52; --sun-pale: #3A3416; --sun-line: #6B5A1C;
  --done-line: #2E7A55; --track: #1E5A6E; --focus: rgba(69, 201, 204, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.ar { font-family: var(--font-ar); }
.muted { color: var(--muted); }
.center { text-align: center; }
mark { background: var(--mark); border-radius: 6px; padding: 0 4px; color: inherit; }

/* English help: hidden unless the EN toggle is on */
.i-en { display: none; font-family: var(--font-en); font-size: 0.78em; font-weight: 600; color: var(--muted); line-height: 1.35; }
.show-en .i-en { display: block; }
.i-ar { display: inline; }

.screen { max-width: 620px; margin: 0 auto; padding: 14px 16px 56px; }
.page-title { font-size: 1.6rem; font-weight: 800; margin: 12px 0 16px; color: var(--ink); }
.page-title .i-en { font-size: 0.6em; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.brand { flex: 1; font-family: var(--font-en); font-size: 1.45rem; font-weight: 800; color: var(--brand); text-decoration: none; letter-spacing: -0.02em; }
.back, .me, .en-toggle {
  display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px;
  border-radius: 12px; border: none; background: var(--card); color: var(--brand);
  text-decoration: none; box-shadow: 0 2px 0 var(--tile-shadow); cursor: pointer;
}
.me { font-size: 1.4rem; }
.en-toggle { font-family: var(--font-en); font-weight: 800; font-size: 0.85rem; color: var(--muted); }
.show-en .en-toggle { background: var(--brand-2); color: #fff; box-shadow: 0 2px 0 var(--brand); }
.level-tag, .star-total {
  font-weight: 700; font-size: 0.9rem; color: var(--muted); background: var(--card);
  padding: 6px 12px; border-radius: 999px; box-shadow: 0 2px 0 var(--tile-shadow);
  max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.star-total { color: var(--gold); font-family: var(--font-en); font-weight: 800; }

/* ---------- Buttons ---------- */
.btn {
  display: block; width: 100%; border: none; border-radius: 18px; padding: 14px 18px;
  font-size: 1.2rem; font-weight: 800; text-decoration: none; cursor: pointer; text-align: center;
}
.btn.primary { background: var(--brand-2); color: #fff; box-shadow: 0 5px 0 var(--brand); }
.btn.primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--brand); }
.btn.primary:disabled { background: #b8bfee; box-shadow: 0 5px 0 #9ea6e0; cursor: default; }
.btn.ghost { background: var(--card); color: var(--brand); border: 2px solid var(--line); }
.btn.small { display: inline-block; width: auto; padding: 8px 22px; font-size: 1rem; border-radius: 14px; }
.btn .i-en { color: inherit; opacity: 0.85; }
.link { background: none; border: none; color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; padding: 4px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 4px 12px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
}
.chip:hover { background: #e3e6ff; }
.badge { font-size: 0.75rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #fff1d6; color: #9a5b00; }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }

/* ---------- Cards ---------- */
.card {
  background: rgba(255, 255, 255, 0.85); border: 1px solid var(--line); border-radius: 24px;
  padding: 16px; box-shadow: 0 10px 30px rgba(59, 79, 216, 0.08); margin-bottom: 14px;
}
.card-hint { text-align: center; color: var(--muted); font-weight: 600; font-size: 0.95rem; margin: 0 0 12px; }

/* ---------- Who / profiles ---------- */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.profile-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 8px;
  border: 1px solid var(--line); border-radius: 22px; background: var(--card);
  box-shadow: 0 4px 0 var(--tile-shadow); cursor: pointer;
}
.profile-card .avatar { font-size: 3rem; line-height: 1.1; }
.profile-name { font-weight: 800; font-size: 1.15rem; }
.profile-stars { color: var(--gold); font-family: var(--font-en); font-weight: 800; }
.profile-card.add { border-style: dashed; color: var(--muted); box-shadow: none; }
.new-profile { display: grid; gap: 12px; }
.new-profile label { display: grid; gap: 4px; font-weight: 700; }
.new-profile input, .new-profile select, .pin-form input {
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-size: 1.1rem;
}
.avatar-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-pick input { position: absolute; opacity: 0; }
.avatar-pick span { display: grid; place-items: center; width: 46px; height: 46px; font-size: 1.6rem; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; }
.avatar-pick input:checked + span { border-color: var(--brand-2); background: #eef0ff; }
.avatar-pick input:focus-visible + span { outline: 3px solid var(--brand-2); }

/* ---------- Home ---------- */
.hero { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 24px; padding: 10px 16px; box-shadow: 0 10px 30px rgba(59, 79, 216, 0.08); margin-bottom: 14px; }
.hero .bubble { display: none; }
.hero-mascot .mascot-body { width: 84px; height: 88px; }
.hero-hi { font-size: 1.6rem; font-weight: 700; margin: 0; color: var(--brand); line-height: 1.4; }
.hero-sub { margin: 0; color: var(--muted); font-weight: 600; }
.continue { display: flex; align-items: center; gap: 12px; text-decoration: none; border: 2px solid var(--brand-2); }
.continue-icon { font-size: 2rem; }
.continue strong { display: block; font-size: 1.05rem; }
.continue .muted { font-size: 0.95rem; }
.track-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
.track-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px; min-height: 130px;
  border-radius: 22px; text-decoration: none; color: #fff;
  background: var(--c); box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 70%, #000);
}
.track-card:active { transform: translateY(3px); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 70%, #000); }
.track-icon { font-size: 2.2rem; line-height: 1.2; }
.track-name { font-weight: 800; font-size: 1.2rem; line-height: 1.3; }
.track-name .i-en { color: rgba(255, 255, 255, 0.85); }
.track-meta { margin-top: auto; font-size: 0.85rem; opacity: 0.9; font-weight: 600; }
.show-en .track-meta .i-en { display: inline; color: inherit; font-size: inherit; margin-inline-start: 6px; }
.track-card.soon { opacity: 0.5; box-shadow: none; }
.mine-link { display: block; text-decoration: none; font-weight: 700; text-align: center; }

/* ---------- Track (unit list) ---------- */
.unit-list { display: grid; gap: 10px; }
.unit-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 3px 0 var(--tile-shadow); text-decoration: none;
}
.unit-card.done { border-color: #b8dcae; background: var(--green-soft); }
.unit-card.soon { opacity: 0.55; box-shadow: none; }
.unit-icon { font-size: 1.8rem; width: 44px; text-align: center; }
.unit-text { flex: 1; display: grid; }
.unit-name { font-weight: 800; font-size: 1.1rem; line-height: 1.35; }
.unit-meta { font-size: 0.85rem; color: var(--muted); }
.unit-check { color: var(--green); font-size: 1.4rem; font-weight: 800; }

/* ---------- Unit (step path) ---------- */
.path { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; position: relative; }
.step {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none;
  background: var(--card); border: 2px solid var(--line); border-radius: 18px; box-shadow: 0 3px 0 var(--tile-shadow);
}
.step.done { border-color: #b8dcae; }
.step.locked { opacity: 0.5; box-shadow: none; }
.step-num {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 800; font-family: var(--font-en);
}
.step.done .step-num { background: var(--green); }
.step.locked .step-num { background: #dfe2f5; color: var(--muted); }
.step-text { flex: 1; display: grid; }
.step-name { font-weight: 800; font-size: 1.1rem; }
.step-kind { font-size: 0.85rem; color: var(--muted); }
.show-en .step-kind .i-en { display: inline; margin-inline-start: 6px; }
.lock { font-size: 1.1rem; }

/* ---------- Activity shell ---------- */
.progress { display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 10px; background: #dfe2f7; border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--c); border-radius: inherit; transition: width 0.4s ease; }
.count { font-size: 0.85rem; color: var(--muted); font-weight: 700; font-family: var(--font-en); min-width: 2.5em; text-align: end; }
.instruction { text-align: center; color: var(--c); font-size: 1.35rem; font-weight: 800; margin: 14px 0 0; }
.instruction-sub { text-align: center; color: var(--muted); font-size: 0.95rem; margin: 0 0 6px; }

/* ---------- Mascot ---------- */
.mascot-wrap { display: flex; justify-content: center; margin-bottom: 10px; }
.mascot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mascot-body { width: 90px; height: 94px; }
.mascot-body svg { width: 100%; height: 100%; overflow: visible; }
.mascot .m-eyes-happy, .mascot .m-eyes-sad { display: none; }
.mascot[data-mood='happy'] .m-eyes-open, .mascot[data-mood='sad'] .m-eyes-open { display: none; }
.mascot[data-mood='happy'] .m-eyes-happy { display: inline; }
.mascot[data-mood='sad'] .m-eyes-sad { display: inline; }
.mascot[data-mood='happy'] .mascot-body { animation: hop 0.5s ease; }
.mascot[data-mood='sad'] .mascot-body { animation: wobble 0.45s ease; }
.mascot[data-mood='thinking'] .mascot-body { animation: think 1.2s ease-in-out infinite; }
.mascot[data-mood='thinking'] .m-bulb { animation: glow 0.5s ease-in-out infinite; }
.m-eye { transform-box: fill-box; transform-origin: center; animation: blink 4s infinite; }
.m-bulb { animation: glow 2s ease-in-out infinite; }
.bubble {
  order: -1; max-width: 320px; min-height: 1.6em; padding: 6px 14px; border-radius: 14px;
  background: var(--card); box-shadow: 0 2px 0 var(--tile-shadow); font-weight: 700; font-size: 1rem;
  text-align: center; opacity: 0; position: relative;
}
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px;
  background: var(--card); transform: translateX(-50%) rotate(45deg); border-radius: 2px;
}
.bubble.show { opacity: 1; }
.bubble.pop { animation: pop 0.3s ease; }

/* ---------- Lesson ---------- */
.lesson-text { font-size: 1.45rem; line-height: 2; margin: 4px 0 8px; }
.lesson-en { font-size: 0.95rem; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0; }
.example { font-size: 1.5rem; padding: 4px 14px; background: #f1f3ff; border-radius: 12px; border: 1px solid var(--line); }
.lesson-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.lesson-count { color: var(--muted); font-family: var(--font-en); font-weight: 700; }

/* ---------- Sort ---------- */
.sort-current { display: grid; place-items: center; min-height: 110px; margin-bottom: 4px; }
.sort-word {
  font-size: 2.6rem; font-weight: 700; padding: 6px 28px 14px; border-radius: 18px;
  background: var(--tile); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--tile-shadow);
}
.sort-word.pop { animation: pop 0.3s ease; }
.sort-current.done .sort-word { background: var(--green); color: #fff; border-color: var(--green-dark); }
.sort-note { min-height: 1.6em; text-align: center; font-weight: 700; margin: 4px 0 10px; font-family: var(--font-ar); }
.sort-note.good { color: var(--green-dark); }
.sort-note.bad { color: var(--red); }
.bins { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 10px; }
.bin {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-height: 150px; padding: 10px 8px;
  border: 2px dashed color-mix(in srgb, var(--c) 45%, #fff); border-radius: 18px; background: #fbfbff; cursor: pointer;
}
.bin:hover { background: #f1f3ff; }
.bin-title { font-weight: 800; font-size: 1.05rem; color: var(--c); }
.bin-items { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.bin-chip { background: var(--green-soft); border: 1px solid #b8dcae; border-radius: 10px; padding: 0 8px; font-size: 1.05rem; animation: pop 0.3s ease; }
.bin.wrong { animation: shake 0.4s ease; border-color: var(--red); }

/* ---------- Word tiles (order + fix) ---------- */
.sentence { border: 2px solid transparent; border-radius: var(--radius); padding: 8px; margin-bottom: 10px; transition: border-color 0.2s, background 0.2s, box-shadow 0.2s; }
.sentence.active { border-color: var(--c); background: var(--card); box-shadow: 0 6px 20px rgba(91, 108, 255, 0.18); }
.sentence.solved { border-color: #b8dcae; background: var(--green-soft); }
.row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.tile {
  flex: 1 0 auto; min-width: 60px; padding: 6px 14px 10px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--tile); box-shadow: 0 3px 0 var(--tile-shadow); font-size: 1.45rem; font-weight: 600; line-height: 1.5;
  cursor: default; user-select: none; -webkit-user-select: none; transition: background 0.2s, color 0.2s, box-shadow 0.2s, opacity 0.15s;
}
.sentence.active .tile { cursor: grab; touch-action: none; }
.sentence:not(.active):not(.solved) .tile { opacity: 0.8; }
.tile.selected { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(91, 108, 255, 0.35), 0 3px 0 var(--tile-shadow); transform: translateY(-2px); }
.tile.placeholder { opacity: 0.25; border-style: dashed; box-shadow: none; }
.tile.hinted { animation: flash 0.7s ease; }
.tile.ghost { position: fixed; z-index: 1000; margin: 0; pointer-events: none; transform: scale(1.08) rotate(-2deg); box-shadow: 0 12px 24px rgba(31, 35, 82, 0.25); border-color: var(--brand-2); }
.sentence.solved .tile, .tile.fixed { background: var(--green); border-color: var(--green-dark); box-shadow: 0 3px 0 var(--green-dark); color: #fff; }
.sentence-meta { display: none; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 8px; padding: 0 2px; }
.sentence.active .sentence-meta, .sentence.solved .sentence-meta { display: flex; }
.sentence.solved .row-actions { display: none; }
.meaning { color: var(--muted); font-weight: 700; font-size: 1rem; }
.row-actions { display: flex; gap: 6px; }
.fix-row { justify-content: flex-start; }
.fix-row .tile { cursor: pointer; flex: 0 1 auto; }
.tile.found { background: var(--red-soft); border-color: var(--red); color: var(--red); text-decoration: line-through; }
.tile.shake { animation: shake 0.4s ease; }
.fix-options { margin-top: 14px; }

/* ---------- Match ---------- */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-label { text-align: center; font-weight: 800; color: var(--c); }
.match-item {
  border: 1px solid var(--line); border-radius: 14px; background: var(--tile); box-shadow: 0 3px 0 var(--tile-shadow);
  min-height: 58px; padding: 6px 10px 10px; font-size: 1.3rem; line-height: 1.4; cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.match-item.long { font-size: 1.05rem; }
.match-item.selected { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(91, 108, 255, 0.35), 0 3px 0 var(--tile-shadow); }
.match-item.matched { background: var(--green); border-color: var(--green-dark); box-shadow: 0 3px 0 var(--green-dark); color: #fff; cursor: default; }
.match-item.wrong { animation: shake 0.4s ease; border-color: var(--red); }

/* ---------- Choice ---------- */
.prompt { text-align: center; margin-bottom: 14px; }
.lead { display: block; color: var(--muted); font-weight: 700; }
.prompt-sentence { font-size: 1.7rem; line-height: 2.1; margin: 6px 0 4px; }
.blank { display: inline-block; min-width: 70px; margin: 0 4px; border-bottom: 3px dashed var(--c); padding: 0 6px; color: var(--green-dark); font-weight: 700; }
.blank.filled { border-bottom-style: solid; border-color: var(--green); }
.options { display: grid; grid-template-columns: 1fr; gap: 10px; }
.options.compact { grid-template-columns: repeat(3, 1fr); }
.option {
  border: 1px solid var(--line); border-radius: 14px; background: var(--tile); box-shadow: 0 3px 0 var(--tile-shadow);
  min-height: 58px; padding: 6px 12px 10px; font-size: 1.35rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.1s;
}
.options.compact .option { font-size: 1.8rem; }
.option:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--tile-shadow); }
.option:disabled { cursor: default; }
.option.correct { background: var(--green); border-color: var(--green-dark); box-shadow: 0 3px 0 var(--green-dark); color: #fff; }
.option.wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); animation: shake 0.4s ease; opacity: 0.8; }
.tip { margin-top: 14px; padding: 12px; border-radius: 14px; background: #fff8e1; border: 1px solid #ffe08a; text-align: center; }
.tip p { margin: 0 0 10px; font-weight: 600; font-size: 1.1rem; line-height: 1.8; }

/* ---------- Read ---------- */
.read-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.read-emoji { font-size: 2rem; }
.read-title { flex: 1; margin: 0; font-size: 1.6rem; color: var(--c); }
.story { font-size: 1.45rem; line-height: 2.2; }
.story p { margin: 0 0 14px; }
.gloss { font: inherit; background: var(--mark); border: none; border-bottom: 2px solid #e8b400; border-radius: 6px; padding: 0 3px; cursor: pointer; }
.gloss.on { background: #ffd65c; }
.gloss-pop {
  position: sticky; bottom: 12px; display: grid; gap: 2px; padding: 10px 14px; margin-bottom: 12px;
  background: #1f2352; color: #fff; border-radius: 14px; font-size: 1.15rem; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.gloss-pop strong { font-size: 1.3rem; color: #ffd65c; }
.gloss-pop .i-en { color: #c9cdf5; }
.read-questions { margin-top: 4px; }

/* ---------- Write ---------- */
.write-prompt { text-align: center; }
.write-emoji { font-size: 2.6rem; }
.write-task { font-size: 1.35rem; line-height: 1.9; margin: 4px 0; font-weight: 600; }
.reqs { list-style: none; padding: 10px 14px; margin: 12px 0; background: #f4f6ff; border-radius: 14px; display: grid; gap: 4px; }
.reqs li { font-size: 1.05rem; }
.reqs li::before { content: '◻︎ '; color: var(--c); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips.starters .chip { background: #fff8e1; border-color: #ffe08a; }
.chips .chip { font-size: 1.05rem; }
.dice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; align-items: stretch; }
.die { display: grid; gap: 2px; text-align: center; padding: 8px 4px; border-radius: 14px; background: #fff; border: 2px solid var(--line); }
.die-label { font-size: 0.8rem; color: var(--muted); font-weight: 700; }
.die-value { font-size: 1.1rem; font-weight: 700; color: var(--c); }
.dice .btn { grid-column: 1 / -1; justify-self: center; }
.boxes { display: grid; gap: 10px; margin-top: 8px; }
.box { display: grid; gap: 4px; }
.box-label { font-weight: 800; color: var(--c); }
.box textarea {
  width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 14px; background: #fff;
  font-size: 1.3rem; line-height: 1.9; resize: vertical;
}
.box textarea:focus { outline: none; border-color: var(--c); }
.write-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.word-count { color: var(--muted); font-weight: 700; }
.write-foot .btn { flex: 1; min-width: 200px; }
.write-error { color: var(--red); font-weight: 700; text-align: center; }

.fb-card h3, .fb-card h4 { margin: 6px 0; color: var(--c); }
.fb-title { font-size: 1.2rem; }
.fb-praise { font-size: 1.2rem; line-height: 1.9; background: var(--green-soft); border-radius: 14px; padding: 10px 14px; margin: 8px 0; }
.fb-fixes, .fb-reqs { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
.fb-fix { display: grid; gap: 2px; padding: 10px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.fb-type { font-size: 0.75rem; font-weight: 800; color: #9a5b00; background: #fff1d6; border-radius: 999px; padding: 0 8px; justify-self: start; }
.fb-change { font-size: 1.3rem; }
.fb-change del { color: var(--red); }
.fb-change ins { color: var(--green-dark); text-decoration: none; font-weight: 700; }
.fb-why { color: var(--muted); font-size: 1.05rem; }
.fb-reqs li { font-size: 1.05rem; }
.fb-reqs small { display: block; color: var(--muted); padding-inline-start: 1.6em; }
.fb-corrected { background: #f4f6ff; border-radius: 14px; padding: 8px 12px; margin: 8px 0; }
.fb-corrected summary { cursor: pointer; font-weight: 700; }
.fb-corrected p { font-size: 1.2rem; line-height: 2; }
.fb-next { font-size: 1.15rem; font-weight: 600; background: #fff8e1; border-radius: 14px; padding: 10px 14px; }

/* ---------- Speak ---------- */
.recorder { display: grid; justify-items: center; gap: 8px; margin: 14px 0; }
.rec-btn {
  width: 96px; height: 96px; border-radius: 50%; border: none; font-size: 2.6rem; cursor: pointer;
  background: var(--c); color: #fff; box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 70%, #000);
}
.rec-btn.on { background: var(--red); box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.5); animation: pulse 1.2s infinite; }
.rec-btn:disabled { opacity: 0.4; cursor: default; }
.rec-label { font-weight: 700; color: var(--muted); }
.rec-audio, .sub-card audio { width: 100%; max-width: 420px; }
.sub-card audio { margin: 6px 0; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.5); } 70% { box-shadow: 0 0 0 18px rgba(229, 72, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); } }

/* ---------- Finish ---------- */
.finish { text-align: center; margin-top: 18px; animation: pop 0.35s ease; }
.finish-msg { color: var(--muted); font-weight: 800; margin: 8px 0; }
.finish-links { display: flex; justify-content: center; gap: 18px; margin-top: 12px; }
.stars { color: #d3d6ea; letter-spacing: 2px; font-size: 1rem; white-space: nowrap; }
.stars .on { color: var(--gold); }
.stars.big { font-size: 2.6rem; margin: 4px 0 14px; }
.stars.big span { display: inline-block; animation: pop 0.4s ease backwards; }
.stars.big span:nth-child(2) { animation-delay: 0.12s; }
.stars.big span:nth-child(3) { animation-delay: 0.24s; }

/* ---------- Challenge board (Jeopardy-style) ---------- */
.board-link {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 14px; text-decoration: none;
  border-radius: 22px; color: #fff; background: linear-gradient(135deg, #1d2b8f, #3b4fd8);
  box-shadow: 0 5px 0 #141f6b;
}
.board-link-icon { font-size: 2.2rem; }
.board-link strong { display: block; font-size: 1.2rem; }
.board-link-sub { font-size: 0.85rem; opacity: 0.85; }
.board-link .i-en { color: rgba(255, 255, 255, 0.8); }
.pick.on { border-color: var(--brand-2); background: #eef0ff; box-shadow: 0 0 0 3px rgba(91, 108, 255, 0.35); }
.players { display: flex; gap: 10px; margin-bottom: 12px; }
.player {
  flex: 1; display: grid; justify-items: center; gap: 2px; padding: 10px; border-radius: 18px;
  background: var(--card); border: 3px solid var(--line); position: relative;
}
.player.turn { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(255, 184, 0, 0.25); }
.player .avatar { font-size: 1.8rem; }
.player-name { font-weight: 800; }
.player-score { font-family: var(--font-en); font-weight: 900; font-size: 1.6rem; color: var(--brand); }
.turn-tag { position: absolute; top: -12px; background: var(--gold); color: #3a2800; font-size: 0.75rem; font-weight: 800; padding: 1px 10px; border-radius: 999px; }
.board-grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 6px; }
.board-head {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 70px;
  padding: 6px 2px; border-radius: 12px; background: #1d2b8f; color: #fff; text-align: center;
  font-size: 0.78rem; font-weight: 800; line-height: 1.25;
}
.board-head span:first-child { font-size: 1.3rem; }
.board-cell {
  display: grid; place-items: center; min-height: 58px; border-radius: 12px; text-decoration: none;
  background: linear-gradient(180deg, #3b4fd8, #2a3aa8); color: #ffd23f; box-shadow: 0 3px 0 #1d2b8f;
  font-family: var(--font-en); font-weight: 900; font-size: 1.15rem;
}
.board-cell:active { transform: translateY(2px); box-shadow: 0 1px 0 #1d2b8f; }
.board-cell.used { background: #e6e8f5; color: var(--muted); box-shadow: none; font-size: 1.2rem; line-height: 1.1; }
.board-cell.used small { font-size: 0.7rem; font-weight: 700; }
.board-foot { color: var(--muted); margin-top: 12px; }
.winner { text-align: center; }
.winner-emoji { font-size: 3.5rem; }
.winner-text { font-size: 1.5rem; font-weight: 700; margin: 4px 0 12px; }
.tile-banner {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; margin: 6px 0 4px;
  border-radius: 16px; background: #1d2b8f; color: #fff; font-weight: 800;
}
.tile-value { font-family: var(--font-en); color: #ffd23f; font-size: 1.4rem; font-weight: 900; }
.points-won { font-family: var(--font-en); font-size: 3rem; font-weight: 900; color: var(--green); animation: pop 0.4s ease; }
@media (max-width: 420px) {
  .board-grid { gap: 4px; }
  .board-head { font-size: 0.66rem; min-height: 62px; }
  .board-cell { min-height: 50px; font-size: 0.95rem; }
}

/* ---------- My writing / parent ---------- */
.sub-card header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.sub-card header strong { flex: 1; }
.sub-card time { color: var(--muted); font-size: 0.85rem; }
.sub-card .stars { color: var(--gold); }
.sub-text { font-size: 1.2rem; line-height: 2; background: #fbfbff; border-radius: 12px; padding: 8px 12px; }
.parent-comment { background: #eef0ff; border-radius: 12px; padding: 8px 12px; font-weight: 600; }
.parent-flag { background: var(--red-soft); color: #9b1c20; border: 1px solid #f3b4b6; border-radius: 12px; padding: 8px 12px; font-family: var(--font-en); font-weight: 700; }
.comment-box { display: grid; gap: 4px; margin: 10px 0 6px; font-weight: 700; }
.comment-box textarea { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 8px; font-family: var(--font-ar); font-size: 1.1rem; }
.kid-tabs { display: grid; gap: 8px; margin-bottom: 14px; }
.kid-tab { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 16px; border: 2px solid var(--line); background: #fff; cursor: pointer; text-align: start; }
.kid-tab.on { border-color: var(--brand-2); background: #eef0ff; }
.kid-tab .avatar { font-size: 1.6rem; }
.kid-stats { flex-basis: 100%; color: var(--muted); font-size: 0.9rem; }
.pin-form { display: grid; gap: 12px; }
.pin-form label { display: grid; gap: 6px; font-weight: 700; }
pre { background: #1f2352; color: #fff; padding: 10px; border-radius: 10px; }

/* ---------- Welcome, accounts, family ---------- */
.welcome-hero { text-align: center; margin: 18px 0 10px; }
.welcome-title { margin: 0; line-height: 0; }
.welcome-title img { width: min(240px, 62vw); height: auto; }
.endorse { margin: 14px 0 4px; }
.endorse img { height: 40px; width: auto; opacity: .9; }
.card h2 { margin: 0 0 8px; font-size: 1.25rem; }
.card h3 { margin: 0 0 8px; font-size: 1.1rem; }
.pin-form input, .pin-form select, .inline-form input, .admin-form input, .admin-form select, .admin-search {
  width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; font-size: 1.05rem;
}
.code-form input[name=code] { font-family: var(--font-en); letter-spacing: 0.12em; text-align: center; font-size: 1.3rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.btn-row .btn { width: auto; flex: 1 1 auto; text-align: center; text-decoration: none; }
.btn-row .btn.small { flex: 0 1 auto; }
.check { display: flex !important; align-items: flex-start; gap: 10px; font-weight: 600 !important; }
.check input { width: 22px; height: 22px; flex: none; margin-top: 4px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 8px 0; }
.inline-form label { flex: 1 1 200px; display: grid; gap: 4px; font-weight: 700; }
.inline-form input { flex: 1 1 200px; }
.family-code { font-family: var(--font-en); font-size: clamp(1.25rem, 6.4vw, 1.9rem); white-space: nowrap; font-weight: 900; letter-spacing: 0.1em; text-align: center; color: var(--brand); background: #eef0ff; border-radius: 14px; padding: 10px; margin: 6px 0; user-select: all; }
.kids-line { font-size: 1.15rem; }
.plan-line { font-weight: 700; font-size: 1.1rem; }
.offers { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0 6px; }
.offer { display: grid; gap: 2px; text-align: center; text-decoration: none; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 12px 8px; }
.offer .price { font-family: var(--font-en); font-weight: 900; font-size: 1.2rem; color: var(--brand); }
.offer small { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.offer.best { border-color: var(--gold); background: #fffaf0; }
.ledger { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 0.92rem; }
.ledger time { color: var(--muted); margin-inline-end: 6px; }
details.danger { margin-top: 14px; border-top: 2px dashed var(--line); padding-top: 10px; }
details.danger summary { color: var(--red); font-weight: 700; cursor: pointer; }
.btn.danger-btn { background: var(--red); color: #fff; border: none; box-shadow: 0 4px 0 #b3363a; }
.legal-links { margin-top: 18px; }
.how h2 { margin-bottom: 4px; }
.how-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.how-list li { display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; }
.how-list li > span:first-child { font-size: 1.3rem; line-height: 1.3; }
.how-prices { border-top: 2px dashed var(--line); padding-top: 8px; }
.how-prices p { margin: 6px 0; }
button.offer { font: inherit; color: inherit; cursor: pointer; }
button.offer:disabled { opacity: .6; cursor: wait; }
.signout-link { color: var(--muted); font-size: 0.95rem; }
.company { color: var(--muted); font-family: var(--font-en); font-size: 0.8rem; }
.legal-text { line-height: 1.9; }
.legal-text section[dir=ltr] { font-family: var(--font-en); line-height: 1.6; }
.legal-text hr { border: none; border-top: 2px dashed var(--line); margin: 20px 0; }

/* ---------- Rating the AI tutor ---------- */
.rate { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 2px dashed var(--line); }
.rate-q { font-weight: 700; flex: 1 1 200px; }
.rate-btn { font-size: 1.4rem; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 4px 12px; cursor: pointer; }
.rate-btn.on { border-color: var(--brand-2); background: #eef0ff; }
.rate-more { flex-basis: 100%; display: grid; gap: 6px; }
.rate-more textarea { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 8px; }

/* ---------- Admin ---------- */
.admin { font-family: var(--font-en); }
.screen.admin { max-width: 1100px; }
.admin .back svg { transform: scaleX(-1); }
.admin .page-title { text-align: left; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; display: grid; }
.stat span { color: var(--muted); font-size: 0.85rem; }
.stat strong { font-size: 1.4rem; }
.admin-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.admin-tab { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 6px 14px; cursor: pointer; font-weight: 700; }
.admin-tab.on, .admin .btn.on { border-color: var(--brand-2); background: #eef0ff; }
.admin-search { margin-bottom: 10px; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 14px; border: 2px solid var(--line); }
.admin-table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.admin-table th, .admin-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin-table tbody tr { cursor: pointer; }
.admin-table tbody tr:hover { background: #f5f6ff; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; background: #eef0ff; font-size: 0.8rem; font-weight: 700; }
.tag-owner { background: #fff0b3; } .tag-nonprofit { background: var(--green-soft); } .tag-demo { background: #e6f3ff; }
.tag-partner { background: #f3e8ff; } .tag-complimentary { background: #ffe8f1; } .tag-free { background: var(--green); color: #fff; }
.admin-form { display: grid; gap: 10px; }
.admin-form label { display: grid; gap: 4px; font-weight: 700; }
.rating-card header { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.rating-big { font-size: 1.5rem; }
.rating-comment { background: #fffaf0; border-radius: 10px; padding: 6px 10px; }

/* ==========================================================================
   AraBiC «Quest» brand (merged from the approved restyle preview, 2026-10-09)
   ========================================================================== */
.brand { display: inline-flex; align-items: center; }
.brand img { height: 30px; width: auto; display: block; }
:root[data-theme="dark"] .mascot-body [fill="#fff"] { fill: #F6EEDF; }
/* type: Lalezar for titles, Fredoka for Latin, Baloo for screens (unchanged), Naskh for learning text (unchanged) */
:root .page-title, :root .hero-hi, :root .instruction,
:root .finish-msg, :root .track-name .i-ar { font-family: var(--font-display); font-weight: 400; letter-spacing: 0; }
:root .page-title { font-size: 1.85rem; }
:root .hero-hi { font-size: 1.75rem; color: var(--ink); }
:root .track-name { font-size: 1.3rem; }

/* links, focus, selection */
:root .link { color: var(--link); }
:root :focus-visible { outline-color: var(--link); }
:root.show-en .en-toggle { background: var(--ink); box-shadow: 0 2px 0 var(--brand); }
:root .btn.primary:disabled { background: #9DB4BC; box-shadow: 0 5px 0 #7F98A1; }
:root .card { background: #FFFFFF; box-shadow: 0 10px 30px rgba(14, 77, 100, 0.07); }
:root .hero { box-shadow: 0 10px 30px rgba(14, 77, 100, 0.07); }
:root .chip:hover, :root .bin:hover { background: var(--pale); }
:root .badge, :root .fb-type { background: #FFF0D1; color: #7A4E00; }
:root .avatar-pick input:checked + span, :root .pick.on, :root .kid-tab.on,
:root .rate-btn.on, :root .admin-tab.on, :root .tag, :root .parent-comment,
:root .family-code { background: var(--pale); }
:root .avatar-pick input:checked + span, :root .kid-tab.on, :root .rate-btn.on,
:root .pick.on, :root .tile.selected, :root .match-item.selected { border-color: var(--link); }
:root .tile.selected, :root .match-item.selected, :root .pick.on { box-shadow: 0 0 0 3px var(--focus), 0 3px 0 var(--tile-shadow); }
:root .sentence.active { box-shadow: 0 6px 20px rgba(14, 77, 100, 0.14); }
:root .family-code { color: var(--ink); }

/* progress and done states */
:root .bar, :root .step.locked .step-num { background: var(--track); }
:root .bar span { background: var(--accent); }
:root .unit-card.done, :root .step.done, :root .sentence.solved, :root .bin-chip { border-color: var(--done-line); }
:root .stars { color: #D9CDB5; }
:root .stars .on, :root .stars.big .on { color: var(--gold); }

/* soft panels */
:root .example, :root .reqs, :root .fb-corrected { background: var(--soft); }
:root .bin, :root .sub-text { background: var(--soft); }
:root .tip, :root .chips.starters .chip, :root .fb-next { background: var(--sun-pale); border-color: var(--sun-line); }
:root .offer.best, :root .rating-comment { background: var(--sun-pale); }
:root .gloss { border-bottom-color: #E09A00; }
:root .gloss.on { background: #FFD27A; }
:root .gloss-pop, :root pre { background: var(--night); }
:root .gloss-pop strong { color: var(--gold); }

/* the challenge board: night sea with sun-gold values */
:root .board-link { background: linear-gradient(135deg, #0A2E3B, #0E4D64); box-shadow: 0 5px 0 #07202A; }
:root .board-head, :root .tile-card, :root .board-tile { background: var(--night); }
:root .board-cell { background: linear-gradient(180deg, #0E4D64, #0A3E52); color: var(--gold); box-shadow: 0 3px 0 #07202A; }
:root .board-cell:active { box-shadow: 0 1px 0 #07202A; }
:root .board-cell.used { background: #EFE6D3; color: var(--muted); box-shadow: none; }
:root .tile-value { color: var(--gold); }

/* ---------- dark mode ---------- */
:root[data-theme="dark"] .card, :root[data-theme="dark"] .hero { background: var(--card); box-shadow: none; }
:root[data-theme="dark"] .btn.primary { color: #0A2E3B; }
:where(:root[data-theme="dark"]) .btn.ghost, :where(:root[data-theme="dark"]) .profile-card, :where(:root[data-theme="dark"]) .unit-card,
:where(:root[data-theme="dark"]) .step, :where(:root[data-theme="dark"]) .option, :where(:root[data-theme="dark"]) .tile,
:where(:root[data-theme="dark"]) .match-item, :where(:root[data-theme="dark"]) .sentence, :where(:root[data-theme="dark"]) .die,
:where(:root[data-theme="dark"]) .fb-fix, :where(:root[data-theme="dark"]) .offer, :where(:root[data-theme="dark"]) .rate-btn,
:where(:root[data-theme="dark"]) .kid-tab, :where(:root[data-theme="dark"]) .stat, :where(:root[data-theme="dark"]) .admin-tab,
:where(:root[data-theme="dark"]) .table-wrap, :where(:root[data-theme="dark"]) input, :where(:root[data-theme="dark"]) select,
:where(:root[data-theme="dark"]) textarea, :where(:root[data-theme="dark"]) .topbar a:not(.brand), :where(:root[data-theme="dark"]) .topbar button,
:where(:root[data-theme="dark"]) .level-tag, :where(:root[data-theme="dark"]) .star-total, :where(:root[data-theme="dark"]) .bubble {
  background: var(--tile); color: var(--ink); border-color: var(--line);
}
:root[data-theme="dark"] .btn.ghost, :root[data-theme="dark"] .link { color: var(--link); }
:root[data-theme="dark"] .bubble::after { border-top-color: var(--tile); }
:root[data-theme="dark"] .badge, :root[data-theme="dark"] .fb-type { background: #3A3416; color: #FFD27A; }
:root[data-theme="dark"] .stars { color: #1E5A6E; }
:root[data-theme="dark"] .board-cell.used { background: #134E62; }
/* (the base rule above uses :where() so answer states — correct, wrong, done, selected — always win) */
:root[data-theme="dark"] .option.correct, :root[data-theme="dark"] .tile.fixed, :root[data-theme="dark"] .sentence.solved .tile,
:root[data-theme="dark"] .match-item.matched, :root[data-theme="dark"] .sort-current.done .sort-word, :root[data-theme="dark"] .tag-free { color: #0A2E3B; }
/* section-coloured text, lightened so it reads on Night */
:root[data-theme="dark"] .instruction, :root[data-theme="dark"] .bin-title, :root[data-theme="dark"] .match-label,
:root[data-theme="dark"] .read-title, :root[data-theme="dark"] .die-value, :root[data-theme="dark"] .box-label,
:root[data-theme="dark"] .fb-card h3, :root[data-theme="dark"] .fb-card h4, :root[data-theme="dark"] .reqs li::before { color: color-mix(in srgb, var(--c) 45%, #F6EEDF); }

/* ---------- Animations ---------- */
@keyframes pop { 0% { transform: scale(0.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-12px); } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-6deg); } 70% { transform: rotate(6deg); } }
@keyframes think { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(0.1); } }
@keyframes glow { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes flash { 0%, 100% { background: var(--tile); } 40% { background: #fff1b8; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 380px) {
  .tile { font-size: 1.25rem; min-width: 50px; padding: 4px 10px 8px; }
  .bin-title { font-size: 0.95rem; }
  .track-name { font-size: 1.05rem; }
}
