/* English at the Register — app styles
   Arabic-first (RTL) interface; English target language is set LTR inline. */

/* Palette: Ocean Ember, copper-forward variation. Deep Current bar and headings on a cool ground,
   Oceanic Teal for interactive states and progress, Burnished Copper for primary buttons and the
   current-step highlight, Golden Drift only on dark surfaces.
   In both themes, text pairs meet WCAG AA (4.5:1); brand fills, focus rings and step outlines 3:1. */
:root {
  --bg: #eef4f4;         /* cool ground */
  --surface: #ffffff;
  --surface-2: #e3eced;
  --ink: #0a2f3a;        /* Deep Current: body text and headings */
  --ink-2: #2d4c55;
  --ink-3: #4a666e;
  --line: rgba(10, 47, 58, .13);
  --brand: #1d6b78;      /* Oceanic Teal: interactive states and progress */
  --brand-strong: #155560;
  --brand-ink: #ffffff;
  --brand-soft: #e0edef;
  --brand-text: #1d6b78; /* brand-coloured text and icons on light surfaces */
  --cta: #a35e33;        /* Burnished Copper: primary buttons, always with --cta-ink text */
  --cta-strong: #8a4c27;
  --cta-ink: #ffffff;
  --cta-line: #a35e33;   /* current-step highlight: 3:1 against the page */
  --tag: #d8975a;        /* Golden Drift: dark surfaces only, always with --tag-ink text */
  --tag-strong: #e3ac77;
  --tag-ink: #0a2f3a;
  --bar: #0a2f3a;        /* app bar */
  --hero: #0a2f3a;       /* hero cards stay dark in both themes */
  --amber: #864716;
  --amber-soft: #f8ecd9;
  --good: #1f7440;
  --good-soft: #e2f1e5;
  --bad: #b3261e;
  --bad-soft: #fbe7e3;
  --blue: #2b5794;       /* the customer's voice */
  --blue-soft: #e6edf7;
  --track: #d5e2e3;    /* progress bar tracks */
  --seg-todo: #6f8a90; /* outline of steps not done yet: 3:1 against the page */
  --shadow: 0 1px 2px rgba(10, 47, 58, .06), 0 6px 18px rgba(10, 47, 58, .07);
  --radius: 14px;
  --radius-lg: 20px;
  --f-ar: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --f-ar-h: "Alexandria", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif; /* Arabic headings */
  --f-en: "Archivo", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace; /* prices and receipts only */
  --nav-h: 64px;
  --bar-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #071e25;
    --surface: #0c2932;
    --surface-2: #12343e;
    --ink: #e7f0f1;
    --ink-2: #bacbce;
    --ink-3: #8fa8ad;
    --line: #1f4550;
    --brand: #6db7c2;
    --brand-strong: #96ced6;
    --brand-ink: #04181e;
    --brand-soft: #133e47;
    --brand-text: #8dc8d0;
    --cta-line: #d8975a;
    --bar: #051920;
    --hero: #0e3d4a;
    --amber: #d8975a;
    --amber-soft: #33261a;
    --good: #79c48e;
    --good-soft: #17301f;
    --bad: #f2918a;
    --bad-soft: #3b1c1a;
    --blue: #9fbdee;
    --blue-soft: #1d2840;
    --track: #1f4550;
    --seg-todo: #6a8790;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #071e25;
  --surface: #0c2932;
  --surface-2: #12343e;
  --ink: #e7f0f1;
  --ink-2: #bacbce;
  --ink-3: #8fa8ad;
  --line: #1f4550;
  --brand: #6db7c2;
  --brand-strong: #96ced6;
  --brand-ink: #04181e;
  --brand-soft: #133e47;
  --brand-text: #8dc8d0;
  --cta-line: #d8975a;
  --bar: #051920;
  --hero: #0e3d4a;
  --amber: #d8975a;
  --amber-soft: #33261a;
  --good: #79c48e;
  --good-soft: #17301f;
  --bad: #f2918a;
  --bad-soft: #3b1c1a;
  --blue: #9fbdee;
  --blue-soft: #1d2840;
  --track: #1f4550;
  --seg-todo: #6a8790;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  /* Keep focused and scrolled-to elements clear of the sticky app bar and the fixed tab bar. */
  scroll-padding-top: calc(var(--bar-h) + env(safe-area-inset-top, 0px) + 8px);
  scroll-padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-ar);
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
[hidden] { display: none !important; }

h1, h2, h3 { font-family: var(--f-ar-h); }
.en, [lang="en"] { font-family: var(--f-en); }
.num { font-family: var(--f-en); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.center { text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ---------- App shell ---------- */
.app-bar {
  position: sticky; top: 0; z-index: 20;
  min-height: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 12px 6px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bar);
  border-bottom: 3px solid var(--tag); /* the shelf-edge strip */
  color: #fff;
}
.app-bar .titles { flex: 1; min-width: 0; }
.app-bar .t1, .app-bar .t2 {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.app-bar .t1 { margin: 0; font-weight: 700; font-size: 1.02rem; line-height: 1.25; }
.app-bar .t2 { font-size: .82rem; line-height: 1.3; color: rgba(255, 255, 255, .88); }
.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 12px;
  background: rgba(255, 255, 255, .12); color: #fff;
}
@media (hover: hover) { .icon-btn:hover { background: rgba(255, 255, 255, .2); } }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.sos { background: #c2412d; }
a.icon-btn { text-decoration: none; }
@media (hover: hover) { .icon-btn.sos:hover { background: #d4513b; } }

main#view {
  max-width: 600px; margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px));
}
/* The app moves focus to the main region after each navigation for screen readers;
   it is not a control, so it needs no focus ring. */
main#view:focus { outline: none; }

.tab-bar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab-bar .tabs { display: flex; width: 100%; max-width: 600px; }
.tab-bar a, .tab-bar button {
  flex: 1; min-width: 0; height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--ink-3);
  font-size: .8125rem; font-weight: 600; line-height: 1.2; text-align: center;
  border: 0; background: none; padding: 0 2px;
}
.tab-bar a svg, .tab-bar button svg {
  width: 56px; height: 30px; padding: 3px 16px; flex: none;
  border-radius: 999px; transition: background .2s ease;
}
.tab-bar .help-tab svg { color: #c2412d; }
.tab-bar .help-tab { flex: 1.3; } /* its two-word label stays on one line at 13 px */
.tab-bar a[aria-current="page"] { color: var(--brand-text); font-weight: 700; }
.tab-bar a[aria-current="page"] svg { background: var(--brand-soft); }

/* ---------- Generic blocks ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card.tight { padding: 12px 14px; }
a.card, button.card { display: block; width: 100%; text-align: start; text-decoration: none; color: inherit; font: inherit; }
a.card.unit-card, button.card.unit-card, a.card.row, button.card.row { display: flex; }
@media (hover: hover) { a.card:hover, button.card:hover { border-color: var(--brand); } }
fieldset { margin: 0; min-width: 0; }
a.sr-only:focus {
  position: fixed; top: 8px; inset-inline-start: 8px; z-index: 100;
  width: auto; height: auto; margin: 0; padding: 8px 12px; clip: auto;
  background: var(--surface); color: var(--ink); border-radius: 8px;
}

.hero {
  border-radius: var(--radius-lg);
  padding: 20px;
  color: #fff;
  background: var(--hero);
  box-shadow: var(--shadow);
}
.hero h2 { margin: 0 0 4px; font-size: 1.35rem; line-height: 1.3; }
.hero p { margin: 0; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.hero .pill { background: rgba(255, 255, 255, .16); color: #fff; }

h2.section {
  font-size: 1.05rem; margin: 8px 0 0;
  display: flex; align-items: baseline; gap: 8px;
}
h2.section .en { font-size: .8rem; font-weight: 500; color: var(--ink-3); }
h3, h2.h-card { margin: 0; font-size: 1rem; line-height: 1.4; } /* card titles: h2 under the screen's h1 */
p { margin: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .82rem; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap;
}
.pill.brand { background: var(--brand-soft); color: var(--brand-text); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.tag { background: var(--cta); color: var(--cta-ink); }
a.pill { text-decoration: none; }
.stack > .pill { align-self: flex-start; } /* a pill hugs its text */
.stack.center > .pill { align-self: center; }
button.pill { border: 0; cursor: pointer; font: inherit; }
.pill svg { width: 16px; height: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px;
  border-radius: 12px; border: 1.5px solid transparent;
  font-weight: 700; font-size: .98rem; text-decoration: none;
  background: var(--cta); color: var(--cta-ink);
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
@media (hover: hover) { .btn:hover { background: var(--cta-strong); } }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
@media (hover: hover) { .btn.ghost:hover { border-color: var(--brand); background: var(--surface); } }
.btn.soft { background: var(--brand-soft); color: var(--brand-text); }
@media (hover: hover) { .btn.soft:hover { background: var(--brand-soft); border-color: var(--brand); } }
.btn.danger { background: var(--bad); color: var(--surface); } /* light text in light mode, dark text on the lighter red of dark mode */
.btn.small { min-height: 44px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.audio-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 14px;
  border-radius: 999px; border: 1.5px solid var(--brand);
  background: var(--surface); color: var(--brand-text);
  font-weight: 600; font-size: .85rem;
}
.audio-btn svg { width: 18px; height: 18px; }
.audio-btn.playing { background: var(--brand); color: var(--brand-ink); }

.progress {
  height: 8px; border-radius: 999px; background: var(--track); overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; transition: width .4s ease; }
.hero .progress { background: rgba(255, 255, 255, .2); }
.hero .progress > span { background: var(--tag); }

/* ---------- Language blocks ---------- */
.say {
  direction: ltr; text-align: left;
  font-family: var(--f-en); font-weight: 600; font-size: 1.08rem; line-height: 1.45;
}
.say.big { font-size: 1.35rem; }
.gloss { color: var(--ink-2); font-size: .92rem; }
.speaker {
  display: inline-block; align-self: flex-start; font-size: .82rem; font-weight: 700;
  padding: 2px 10px; border-radius: 999px; margin-bottom: 4px;
}
.speaker.c { background: var(--blue-soft); color: var(--blue); }
.speaker.k { background: var(--brand-soft); color: var(--brand-text); }

.no-ar .gloss, .no-ar .ar-gloss { display: none !important; }
.prompt-ar { color: var(--ink); }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }
.hero .ltr { color: #fff; }
mark { background: var(--amber-soft); color: var(--amber); border-radius: 4px; padding: 0 2px; font-weight: 700; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.note {
  border-radius: 12px; padding: 12px 14px;
  background: var(--amber-soft); color: var(--ink);
  border-inline-start: 4px solid var(--amber);
  font-size: .93rem;
}
.note.brand { background: var(--brand-soft); border-color: var(--brand); }
.note strong { color: var(--amber); }
.note.brand strong { color: var(--brand-strong); }

/* ---------- Unit list ---------- */
.unit-card { display: flex; gap: 12px; align-items: flex-start; }
.unit-badge {
  width: 46px; height: 46px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-text);
  font-weight: 700;
}
.unit-badge.t-blue { background: var(--blue-soft); color: var(--blue); }
.unit-badge.t-amber { background: var(--amber-soft); color: var(--amber); }
.unit-badge.t-good { background: var(--good-soft); color: var(--good); }
.unit-badge.t-red { background: var(--bad-soft); color: var(--bad); }
.unit-badge.done { background: var(--good); color: var(--surface); }
.unit-badge svg { width: 24px; height: 24px; }
.unit-card .chev { color: var(--ink-3); align-self: center; }
.unit-card .chev svg { width: 20px; height: 20px; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

.outcomes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.outcomes li { display: flex; gap: 10px; align-items: flex-start; }
.outcomes li svg { width: 20px; height: 20px; flex: none; color: var(--brand); margin-top: 3px; }
.outcomes .en { display: block; direction: ltr; text-align: left; color: var(--ink-3); font-size: .82rem; }

/* ---------- Lesson steps ---------- */
.step {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
@media (hover: hover) { .step:hover { border-color: var(--brand); } }
.step .ico {
  width: 40px; height: 40px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2);
}
.step .ico svg { width: 22px; height: 22px; }
.step.done .ico { background: var(--good-soft); color: var(--good); }
.step .strand { font-size: .82rem; color: var(--ink-3); }
.step .title { font-weight: 700; }
.step .chev { color: var(--ink-3); }
.step .chev svg { width: 20px; height: 20px; }

/* ---------- Activity / quiz ---------- */
.activity-head { display: flex; align-items: center; gap: 10px; }
.activity-head .progress { flex: 1; }
.counter { font-size: .85rem; color: var(--ink-3); white-space: nowrap; direction: ltr; unicode-bidi: isolate; }

.prompt-card { text-align: center; padding: 16px; }
.prompt-card .say { text-align: center; }
.prompt-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; }
.big-play {
  width: 72px; height: 72px; margin: 2px auto 4px;
  border-radius: 50%; border: 0;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(29, 107, 120, .3);
}
.big-play svg { width: 34px; height: 34px; }
.big-play.playing { animation: pulse 1s ease-in-out infinite; }
.big-play[disabled] { opacity: .4; cursor: default; }
.shake { animation: shake .35s ease; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pulse { 50% { transform: scale(1.06); } }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  width: 100%; text-align: start;
  padding: 12px 16px; min-height: 50px;
  border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface);
  display: flex; align-items: center; gap: 10px;
}
@media (hover: hover) { .option:hover { border-color: var(--brand); } }
.option .say { font-size: 1rem; flex: 1; }
.option.center { justify-content: center; }
.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option[disabled] { cursor: default; }
.option .mark { width: 22px; height: 22px; flex: none; }
.option.correct .mark { color: var(--good); }
.option.wrong .mark { color: var(--bad); }

.feedback {
  border-radius: 12px; padding: 12px 14px; font-weight: 600;
  display: flex; gap: 10px; align-items: flex-start;
}
.feedback svg { width: 22px; height: 22px; flex: none; margin-top: 2px; }
.feedback.good { background: var(--good-soft); color: var(--good); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback .detail { color: var(--ink); font-weight: 400; display: block; margin-top: 4px; }

.num-input {
  width: 100%; direction: ltr; text-align: center;
  font-family: var(--f-num); font-size: 2rem; letter-spacing: .04em;
  padding: 10px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--surface);
}
.num-input:focus { outline: none; border-color: var(--brand); }

.price-tag {
  direction: ltr; font-family: var(--f-num); font-weight: 600;
  font-size: 3rem; line-height: 1.1; color: var(--ink);
}
.price-tag small { font-size: 1rem; color: var(--ink-3); margin-inline-start: 6px; }

.receipt {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 14px 16px;
  font-family: var(--f-num); font-size: .92rem;
  direction: ltr; text-align: left;
}
.receipt .r-row { display: flex; justify-content: space-between; gap: 12px; }
.receipt .r-total { border-top: 1px dashed var(--ink-3); margin-top: 6px; padding-top: 6px; font-weight: 700; }

/* ---------- Dialogue ---------- */
.dialogue { display: flex; flex-direction: column; gap: 10px; }
.bubble {
  display: block; max-width: 88%; padding: 10px 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line);
  font: inherit; color: inherit; text-align: start; cursor: pointer;
}
@media (hover: hover) { .bubble:hover { border-color: var(--brand); } }
.stage-chip {
  align-self: center; margin-top: 4px;
  font-size: .82rem; font-weight: 600; color: var(--ink-2);
  background: var(--surface-2); padding: 2px 12px; border-radius: 999px;
}
.stage-chip .en { color: var(--ink-3); font-weight: 500; }
.bubble.c { align-self: flex-start; border-start-start-radius: 4px; }
.bubble.k { align-self: flex-end; background: var(--brand-soft); border-color: transparent; border-start-end-radius: 4px; }
.bubble .say { font-size: 1rem; }
.bubble.hidden-line .say { filter: blur(6px); user-select: none; }
.bubble.active { outline: 2px solid var(--brand); }

/* ---------- Mic ---------- */
.mic-btn {
  width: 72px; height: 72px; border-radius: 50%; border: 0;
  background: var(--blue); color: var(--surface);
  display: grid; place-items: center; margin: 0 auto;
}
.mic-btn svg { width: 32px; height: 32px; }
.mic-btn.listening { animation: pulse 1s ease-in-out infinite; background: var(--bad); }
.heard { direction: ltr; text-align: center; font-family: var(--f-en); color: var(--ink-2); min-height: 1.6em; }

/* ---------- Flashcard ---------- */
.flash { min-height: 220px; display: flex; flex-direction: column; justify-content: center; gap: 12px; text-align: center; }
.flash .say { text-align: center; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; text-align: center; }
.stat .v { font-family: var(--f-en); font-variant-numeric: tabular-nums; font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.stat .l { font-size: .82rem; color: var(--ink-3); }
.hero .stat { background: rgba(255, 255, 255, .14); border-color: transparent; }
.hero .stat .l { color: rgba(255, 255, 255, .85); }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 7.5rem 1fr 3rem; align-items: center; gap: 10px; font-size: .88rem; }
.bar-row .progress { height: 10px; }
.bar-row .v { font-family: var(--f-en); font-variant-numeric: tabular-nums; font-weight: 600; text-align: end; }

.compare { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; text-align: center; }
.compare .box { background: var(--surface-2); border-radius: 12px; padding: 12px 6px; }
.compare .v { font-family: var(--f-en); font-variant-numeric: tabular-nums; font-size: 1.6rem; font-weight: 700; }
.compare .arrow svg { width: 24px; height: 24px; color: var(--ink-3); }

/* ---------- Forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 400;
}
.input:focus { outline: none; border-color: var(--brand); }
textarea.input { min-height: 96px; resize: vertical; }

.scale { display: flex; gap: 6px; }
.scale label { flex: 1; position: relative; }
.scale input { position: absolute; opacity: 0; pointer-events: none; }
.scale span {
  display: flex; align-items: center; justify-content: center; min-height: 44px;
  text-align: center; padding: 6px 4px; border-radius: 10px; line-height: 1.25;
  border: 1.5px solid var(--line); background: var(--surface);
  font-size: .85rem; font-weight: 600; cursor: pointer;
}
.scale input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.scale input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 44px; border: 0; background: transparent; padding: 8px; border-radius: 9px; font-weight: 600; font-size: .88rem; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; cursor: pointer; }
.switch { position: relative; display: block; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch input:checked + span { background: var(--brand); }
[dir="rtl"] .switch input:checked + span::after { transform: translateX(-20px); }
[dir="ltr"] .switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- Sheet (quick phrases) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4, 24, 30, .5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 600px; max-height: 86vh; overflow: auto;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: rise .2s ease;
}
.sheet .grabber { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 12px; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }

.phrase-btn {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  text-align: start;
}
@media (hover: hover) { .phrase-btn:hover { border-color: var(--brand); } }
.phrase-btn .play {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--brand); color: var(--brand-ink);
}
.phrase-btn .play svg { width: 18px; height: 18px; }
.phrase-btn.playing .play { background: var(--blue); }

details.acc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
details.acc > summary {
  list-style: none; cursor: pointer; padding: 14px 16px;
  display: flex; align-items: center; gap: 10px; font-weight: 700;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary .chev { margin-inline-start: auto; transition: transform .2s; color: var(--ink-3); }
details.acc > summary .chev svg { width: 18px; height: 18px; }
details.acc[open] > summary .chev { transform: rotate(180deg); }
details.acc .acc-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }

table.plain { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.plain th, table.plain td { text-align: start; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plain th { font-size: .82rem; color: var(--ink-3); font-weight: 600; }
.table-scroll { overflow-x: auto; }
table.matrix th, table.matrix td { text-align: center; }
table.matrix tbody th { text-align: start; }
.dot { color: var(--ink-3); font-size: 1rem; }
.dot.full { color: var(--brand); }
table.rubric td, table.rubric th { min-width: 7rem; }

.toast {
  position: fixed; inset-inline: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  max-width: 420px; margin: 0 auto;
  background: var(--ink); color: var(--bg);
  padding: 12px 16px; border-radius: 12px; text-align: center; font-weight: 600;
  box-shadow: var(--shadow);
  animation: rise .2s ease;
}

.empty { text-align: center; padding: 28px 12px; color: var(--ink-3); }
.empty svg { width: 40px; height: 40px; margin: 0 auto 8px; }

/* ---------- Certificate (print) ---------- */
.certificate {
  background: #ffffff; color: #0a2f3a;
  border: 6px double #a35e33; border-radius: 6px;
  padding: 28px 20px; text-align: center;
}
.certificate h2 { font-size: 1.4rem; margin: 6px 0; }
.certificate .who { font-size: 1.5rem; font-weight: 700; margin: 10px 0; }
.certificate .en { direction: ltr; }

@media print {
  .app-bar, .tab-bar, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  main#view { padding: 0; max-width: none; }
  .card { box-shadow: none; }
}

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

/* ---------- Learner flow additions ---------- */
.inline-ico { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; }
.hero .btn.hero-btn { background: var(--tag); color: var(--tag-ink); align-self: stretch; } /* the hero stays dark in both themes */
@media (hover: hover) { .hero .btn.hero-btn:hover { background: var(--tag-strong); } }
.step.current { border-color: var(--brand); border-width: 2px; }
/* Step strip: done = filled, not yet = outlined, current = taller. */
.step-progress { display: flex; align-items: center; gap: 5px; min-height: 12px; }
.step-progress span { flex: 1; height: 8px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--seg-todo); }
.step-progress span.done { background: var(--brand); box-shadow: none; }
.step-progress span.now { height: 12px; box-shadow: inset 0 0 0 2.5px var(--cta-line); }
.step-progress span.now.done { background: var(--cta-line); box-shadow: none; }
.order-list { margin: 0; padding-inline-start: 1.4em; display: flex; flex-direction: column; gap: 8px; }
.order-list:empty { display: none; }
.order-list li { padding: 8px 12px; border-radius: 12px; background: var(--good-soft); }
.order-list li .say { font-size: 1rem; }
.order-list li .gloss { display: block; }
#orderChoices .option { flex-direction: column; align-items: stretch; gap: 4px; }
#orderChoices .speaker { align-self: flex-start; }
.word-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; width: 100%; }
.word-pair:has(> .word-btn:only-child) { grid-template-columns: 1fr; }
.word-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; padding: 8px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface-2); color: var(--ink); font: inherit; text-align: center; cursor: pointer;
}
.word-btn svg { width: 18px; height: 18px; color: var(--ink-3); }
.word-btn .w { font-family: var(--f-en); font-weight: 600; font-size: 1.02rem; }
.word-btn .m { font-size: .85rem; color: var(--ink-2); }
.word-btn.amber { background: var(--amber-soft); border-color: transparent; }
.word-btn.amber .w { color: var(--amber); }
.word-btn.playing { outline: 2px solid var(--brand); }
.neq { align-self: center; color: var(--ink-3); font-weight: 700; }
.row-ico { width: 20px; height: 20px; flex: none; color: var(--brand); margin-top: 4px; }
.watch-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.watch-list li { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.watch-list .m { font-size: .88rem; color: var(--ink-2); padding-inline-start: 4px; }
.say-line {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  min-height: 44px; padding: 6px 12px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; text-align: start;
}
.say-line span { font-family: var(--f-en); font-weight: 600; }
.say-line svg { width: 18px; height: 18px; flex: none; color: var(--brand); }
.say-line.playing { outline: 2px solid var(--brand); }
.unit-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-2); }
.unit-facts b { color: var(--ink); font-weight: 600; }
.voice-warn { display: flex; flex-direction: column; gap: 10px; }
.voice-warn p { margin: 0; }
.voice-warn ol { margin: 4px 0 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 4px; }

/* An activity's main buttons stay in reach just above the tab bar while the page scrolls. */
.action-bar {
  position: sticky; z-index: 5;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  margin-inline: -16px; padding: 12px 16px 10px;
  background: linear-gradient(to bottom, transparent, var(--bg) 12px);
}
.action-bar:empty { display: none; }
.action-bar > * + * { margin-top: 10px; }
.steps-list { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 6px; }
.steps-list .btn { vertical-align: middle; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 12px;
  color: var(--ink-3); font-size: .85rem; text-decoration: underline; text-underline-offset: 3px;
}

/* Lessons (unit steps): no tab bar, so the activity gets the whole screen. */
html.lesson { scroll-padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); }
html.lesson .tab-bar { display: none; }
html.lesson main#view { padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
html.lesson .action-bar { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
html.lesson .toast { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }

/* Home: the learner's name, asked once in the welcome card. */
.hero-name { display: flex; gap: 8px; align-items: stretch; }
.hero-name .input { flex: 1; min-width: 0; background: #ffffff; color: #0a2f3a; border-color: transparent; }
.hero-name .input::placeholder { color: #4a666e; }
.btn.on-hero { flex: none; background: transparent; color: #fff; border-color: rgba(255, 255, 255, .75); }
@media (hover: hover) { .btn.on-hero:hover { background: rgba(255, 255, 255, .12); } }
.hero .hero-sub { margin-top: -4px; color: rgba(255, 255, 255, .88); }
.hero .stat.met .v { color: var(--tag); }

/* Quick phrases: each phrase can be shown to a customer in large type. */
.phrase-row { display: flex; gap: 8px; align-items: stretch; }
.phrase-row .phrase-btn { flex: 1; min-width: 0; }
.show-btn {
  flex: none; width: 52px; min-height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--brand-text);
}
.show-btn svg { width: 22px; height: 22px; }
.big-phrase {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 32px;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 20px calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); color: var(--ink);
  animation: rise .2s ease;
}
.big-phrase .say { margin: 0; max-width: 20ch; text-align: center; font-size: clamp(2rem, 9vw, 3.5rem); line-height: 1.25; }

/* Icon-only play buttons still get a 44 px target. */
.audio-btn.icon-only { min-width: 44px; justify-content: center; padding: 8px; }
.prompt-lines li > .row { justify-content: space-between; }

/* The workshop guide's unit switcher: pills with a full touch target. */
.pill.nav-pill { min-width: 44px; min-height: 44px; justify-content: center; }

/* ---------- UI pass (2.5.0) ---------- */
/* Cards that are links answer a tap on touch screens too. */
a.card, button.card, a.step { transition: background .12s ease; }
@media (hover: none) { a.card:active, button.card:active, a.step:active, .tl a.step:active { background: var(--surface-2); } }

/* Units list: this week's unit. */
.unit-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
a.card.unit-card.current { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand), var(--shadow); }
.unit-card.current .unit-badge:not(.done) { background: var(--brand); color: var(--brand-ink); }

/* Unit page: the steps as one connected path. Done steps are green, the next step is tinted. */
.tl {
  list-style: none; margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.tl li { position: relative; }
.tl li:not(:last-child)::after {
  content: ""; position: absolute; z-index: 1;
  inset-inline-start: 33px; top: 50%; height: 100%; width: 2px;
  background: var(--line);
}
.tl li.done:not(:last-child)::after { background: var(--good); }
.tl .step, .tl .step.current { border: 0; border-radius: 10px; background: transparent; padding: 10px 14px; }
.tl .step .ico { position: relative; z-index: 2; border-radius: 50%; }
.tl .step.done .ico { background: var(--good); color: var(--surface); }
.tl .step.current { background: var(--brand-soft); }
.tl .step.current .ico { background: var(--brand); color: var(--brand-ink); }
.tl .step.current .title { color: var(--brand-text); }
.tl .step:focus-visible { outline-offset: -3px; }
@media (hover: hover) { .tl .step:hover { background: var(--surface-2); } .tl .step.current:hover { background: var(--brand-soft); } }

/* Dialogue bubbles: who speaks, and an icon for what a tap does. */
.bubble .b-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.bubble .b-head .speaker { margin: 0; }
.bubble .b-ico { width: 18px; height: 18px; flex: none; color: var(--ink-3); }
.bubble.playing { outline: 2px solid var(--brand); }
.bubble.playing .b-ico, .bubble.active .b-ico { color: var(--brand); }

/* Results: a ring that fills to the score. */
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }
.ring {
  --c: var(--brand);
  position: relative; width: 136px; height: 136px; margin: 4px auto;
  display: grid; place-items: center; border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--track) 0);
  animation: ring-fill .9s ease-out both;
}
.ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface); }
.ring .v {
  position: relative; font-family: var(--f-en); font-variant-numeric: tabular-nums;
  font-size: 2.1rem; font-weight: 700; line-height: 1;
}
.ring.good { --c: var(--good); }
.ring.amber { --c: var(--amber); }
@keyframes ring-fill { from { --p: 0; } }
.big-num { font-family: var(--f-en); font-variant-numeric: tabular-nums; font-size: 3rem; font-weight: 700; line-height: 1.1; }
