/* ============================================================================
   Ayah Polyglot
   Warm layered minimalism. Editorial serif display, system sans for UI,
   one muted accent per language, frosted glass only where something floats.
   Calm is the feature: nothing here streaks, scores, or celebrates.
   Every colour pair below is verified >= 4.5:1 in both themes.
   ========================================================================= */

:root {
  /* --- ground and ink (light) ------------------------------------------- */
  --bg:          #FBF7F1;
  --bg-lift:     #FFFCF6;
  --bg-sink:     #F3EADC;
  --surface:     #FFFDFA;
  --surface-2:   #F7F1E8;
  --ink:         #211F1C;
  --ink-2:       #55504A;
  --ink-3:       #6E6862;
  --hairline:    #E7DFD3;
  --hairline-2:  #F0E9DE;

  /* --- language accents (AA on both ground and surface) ----------------- */
  --en: #2E6B94;
  --es: #A24A2B;
  --ar: #6B5E14;
  --zh: #AB3722;
  --ja: #77396E;
  --on-accent: #FFFFFF;
  --accent: var(--en);              /* powder blue is the house colour */
  --accent-wash: rgba(46, 107, 148, .10);

  --danger: #8E3B22;

  /* --- glass ------------------------------------------------------------- */
  --glass: rgba(251, 247, 241, .72);
  --glass-solid: #FBF7F1;
  --glass-line: rgba(33, 31, 28, .08);

  /* --- shadow: ambient + key -------------------------------------------- */
  --shadow-card: 0 1px 2px rgba(60, 46, 28, .04), 0 8px 20px -12px rgba(60, 46, 28, .16);
  --shadow-lift: 0 2px 4px rgba(60, 46, 28, .05), 0 18px 40px -20px rgba(60, 46, 28, .28);

  /* --- type -------------------------------------------------------------- */
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, "Palatino Linotype", Palatino, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* --- shape ------------------------------------------------------------- */
  --r-xl: 1.75rem;
  --r-lg: 1.5rem;
  --r-md: 1rem;
  --r-sm: .75rem;
  --tap: 3.25rem;

  /* --- motion (emil: strong curves, short durations, never ease-in) ------ */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  /* One deliberate overshoot, used only for the card entrance the brief asks
     for. Kept to a 1.12 crest: a settle, not a bounce. */
  --ease-spring: cubic-bezier(.34, 1.12, .64, 1);
  --t-press: 140ms;
  --t-ui: 200ms;
  --t-card: 300ms;

  /* --- insets ------------------------------------------------------------ */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --gutter: 1.25rem;
  --tabh: calc(4rem + var(--safe-b));

  /* --- z scale ----------------------------------------------------------- */
  --z-tabbar: 10;
  --z-player: 20;
  --z-toast: 40;

  color-scheme: light;
}

/* --- dark palette -------------------------------------------------------
   Warm charcoal, not black: this is read in a nursery with a baby going to
   sleep. Values are parked here once, then applied by two selectors — the
   system preference, and an explicit choice in Settings. */
:root {
  --d-bg:         #191613;
  --d-bg-lift:    #221E19;
  --d-bg-sink:    #100E0C;
  --d-surface:    #221E19;
  --d-surface-2:  #2A251F;
  --d-ink:        #F2ECE3;
  --d-ink-2:      #BFB6AA;
  --d-ink-3:      #9C9286;
  --d-hairline:   #332C25;
  --d-hairline-2: #2A241E;
  --d-en: #96C3E8;
  --d-es: #E7A183;
  --d-ar: #CFB864;
  --d-zh: #EE9077;
  --d-ja: #C79CC0;
  --d-on-accent: #191613;
  --d-accent-wash: rgba(150, 195, 232, .12);
  --d-danger: #E79C86;
  --d-glass: rgba(25, 22, 19, .72);
  --d-glass-solid: #191613;
  --d-glass-line: rgba(242, 236, 227, .10);
  --d-shadow-card: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 20px -12px rgba(0, 0, 0, .6);
  --d-shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 18px 40px -20px rgba(0, 0, 0, .8);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--d-bg);
    --bg-lift: var(--d-bg-lift);
    --bg-sink: var(--d-bg-sink);
    --surface: var(--d-surface);
    --surface-2: var(--d-surface-2);
    --ink: var(--d-ink);
    --ink-2: var(--d-ink-2);
    --ink-3: var(--d-ink-3);
    --hairline: var(--d-hairline);
    --hairline-2: var(--d-hairline-2);
    --en: var(--d-en);
    --es: var(--d-es);
    --ar: var(--d-ar);
    --zh: var(--d-zh);
    --ja: var(--d-ja);
    --on-accent: var(--d-on-accent);
    --accent-wash: var(--d-accent-wash);
    --danger: var(--d-danger);
    --glass: var(--d-glass);
    --glass-solid: var(--d-glass-solid);
    --glass-line: var(--d-glass-line);
    --shadow-card: var(--d-shadow-card);
    --shadow-lift: var(--d-shadow-lift);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: var(--d-bg);
  --bg-lift: var(--d-bg-lift);
  --bg-sink: var(--d-bg-sink);
  --surface: var(--d-surface);
  --surface-2: var(--d-surface-2);
  --ink: var(--d-ink);
  --ink-2: var(--d-ink-2);
  --ink-3: var(--d-ink-3);
  --hairline: var(--d-hairline);
  --hairline-2: var(--d-hairline-2);
  --en: var(--d-en);
  --es: var(--d-es);
  --ar: var(--d-ar);
  --zh: var(--d-zh);
  --ja: var(--d-ja);
  --on-accent: var(--d-on-accent);
  --accent-wash: var(--d-accent-wash);
  --danger: var(--d-danger);
  --glass: var(--d-glass);
  --glass-solid: var(--d-glass-solid);
  --glass-line: var(--d-glass-line);
  --shadow-card: var(--d-shadow-card);
  --shadow-lift: var(--d-shadow-lift);
  color-scheme: dark;
}

/* per-language accent scoping: any .lang-xx retints its own subtree */
.lang-en { --accent: var(--en); }
.lang-es { --accent: var(--es); }
.lang-ar { --accent: var(--ar); }
.lang-zh { --accent: var(--zh); }
.lang-ja { --accent: var(--ja); }

/* ============================================================== base ==== */

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Author display rules (.btn is display:block) outrank the UA stylesheet's
   [hidden] { display: none }, so hiding a styled element silently fails
   without this. */
[hidden] { display: none !important; }

html {
  /* no font-size override: iOS Dynamic Type and browser zoom must both work */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  /* layered warmth, not flat cream */
  background-image:
    radial-gradient(125% 70% at 50% -12%, var(--bg-lift) 0%, transparent 62%),
    radial-gradient(100% 55% at 105% 102%, var(--bg-sink) 0%, transparent 58%);
}

#app { height: 100%; position: relative; overflow: hidden; }

::selection { background: var(--accent-wash); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: .375rem;
}

/* ============================================================= views ==== */

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
}
.view[hidden] { display: none; }

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    .25rem
    calc(var(--gutter) + var(--safe-r))
    calc(1.25rem + var(--tabh))
    calc(var(--gutter) + var(--safe-l));
}

.topbar {
  flex: none;
  padding:
    calc(1.25rem + var(--safe-t))
    calc(var(--gutter) + var(--safe-r))
    .75rem
    calc(var(--gutter) + var(--safe-l));
}

/* ========================================================= typography === */

.wordmark {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: -.02em;
  margin: 0;
  text-wrap: balance;
}

.date {
  margin: .25rem 0 0;
  font-size: .8125rem;
  color: var(--ink-3);
  letter-spacing: .01em;
}

.lede {
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 1rem 0 1.25rem;
  max-width: 34ch;
  text-wrap: pretty;
}
.lede em { font-style: italic; color: var(--ink); }

.section-h {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.3125rem;
  letter-spacing: -.01em;
  margin: 2.25rem 0 .75rem;
  color: var(--ink);
}
.section-h:first-child { margin-top: 1rem; }

.fineprint {
  font-size: .875rem;
  line-height: 1.55;
  color: var(--ink-3);
  margin: .75rem 0 0;
  max-width: 46ch;
  text-wrap: pretty;
}
.fineprint.nudge { margin-top: 0; margin-bottom: .875rem; }
.fineprint.centred { text-align: center; margin-inline: auto; }
.fineprint.version { margin-top: 2rem; font-size: .75rem; }

.privacy {
  display: flex;
  gap: .625rem;
  align-items: flex-start;
  background: var(--accent-wash);
  border-radius: var(--r-md);
  padding: .875rem 1rem;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0 0 1.25rem;
}

.notice {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--ink-2);
  border-radius: var(--r-md);
  padding: .875rem 1rem;
  font-size: .875rem;
  margin: 0 0 1rem;
}
.notice[hidden] { display: none; }

/* The weekly routine's one line about what changed. Quiet, never a badge. */
.whatsnew {
  display: flex;
  gap: .5rem;
  align-items: baseline;
  background: var(--accent-wash);
  border-radius: var(--r-md);
  padding: .75rem .9375rem;
  margin: 0 0 1rem;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--ink-2);
  text-wrap: pretty;
}
.whatsnew::before {
  content: "New";
  flex: none;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
}

/* text field */
.field { display: block; margin-bottom: .625rem; }
.field-label {
  display: block;
  font-size: .8125rem;
  color: var(--ink-3);
  margin-bottom: .375rem;
}
.field input {
  width: 100%;
  min-height: var(--tap);
  padding: .875rem 1rem;
  border-radius: var(--r-lg);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  transition: border-color var(--t-ui) ease;
}
.field input::placeholder { color: var(--ink-3); }
.field input:focus { border-color: var(--accent); outline: none; }
.field input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.due {
  font-size: .875rem;
  color: var(--ink-3);
  margin: 0 0 1rem;
  min-height: 1.25rem;
}

/* ======================================================== today list === */

.wordlist { list-style: none; margin: 0 0 1rem; padding: 0; }

/* No entrance animation here on purpose: today's words are the whole point of
   the screen, and content must never be gated behind a transition that may
   not fire. They are simply present. */
.wordlist li {
  display: flex;
  align-items: center;
  gap: .875rem;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-lg);
  padding: .75rem 1rem;
  margin-bottom: .5rem;
  box-shadow: var(--shadow-card);
}

.wl-emoji {
  font-size: 2.0625rem;
  line-height: 1;
  flex: none;
  width: 2.75rem;
  text-align: center;
}
.wl-body { min-width: 0; flex: 1; }
.wl-en {
  font-family: var(--serif);
  font-size: 1.3125rem;
  line-height: 1.2;
  display: block;
  letter-spacing: -.01em;
}
.wl-sub {
  font-size: .8125rem;
  color: var(--ink-3);
  display: block;
  margin-top: .125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.langline {
  font-size: .8125rem;
  color: var(--ink-3);
  margin: 0 0 .875rem;
}

/* ============================================================ buttons === */

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  font-family: var(--sans);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -.01em;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out),
              background-color var(--t-ui) ease,
              border-color var(--t-ui) ease,
              opacity var(--t-ui) ease;
}
.btn:active { transform: scale(.97); }

.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-card);
}
.btn.soft {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--hairline);
}
.btn.ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--hairline);
}
.btn.ghost.danger { color: var(--danger); }
.btn.big { font-size: 1.125rem; padding: 1.1875rem 1.25rem; }
.btn.small {
  min-height: 2.75rem;
  width: auto;
  margin: 0 auto;
  padding: .625rem 1.125rem;
  font-size: .9375rem;
  font-weight: 500;
}

/* A quiet third-tier action. Still a 44px target, but it never competes
   with the one thing the screen is asking you to do. */
.btn.quiet {
  min-height: 2.75rem;
  width: 100%;
  background: none;
  border: none;
  box-shadow: none;
  color: var(--ink-3);
  font-size: .9375rem;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--hairline);
  text-underline-offset: .25rem;
  padding: .75rem 0 0;
  margin-top: .25rem;
}
.btn.quiet:active { transform: none; color: var(--ink); }
.btn + .btn { margin-top: .625rem; }
.btn[disabled] {
  background: var(--surface-2);
  color: var(--ink-3);
  border-color: var(--hairline);
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .btn.ghost:hover, .btn.soft:hover { border-color: var(--ink-3); }
  .btn.primary:hover { filter: brightness(1.06); }
}

.iconbtn {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 1.0625rem;
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-ui) ease;
}
.iconbtn:active { transform: scale(.92); background: var(--surface-2); }

/* ============================================================== chips === */

.langpicker {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 0 0 1.25rem;
}

.chip {
  min-height: 2.75rem;
  padding: .625rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out),
              background-color var(--t-ui) ease,
              color var(--t-ui) ease,
              border-color var(--t-ui) ease;
}
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* ============================================================ toggles === */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--tap);
  padding: .9375rem 1.125rem;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-lg);
  margin-bottom: .625rem;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform var(--t-press) var(--ease-out);
}
.toggle-row:active { transform: scale(.99); }
.toggle-row > span:first-child { flex: 1; min-width: 0; }
.toggle-row strong {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.1875rem;
  display: block;
  letter-spacing: -.01em;
}
.toggle-row small {
  display: block;
  color: var(--ink-3);
  font-size: .8125rem;
  line-height: 1.45;
  margin-top: .125rem;
}
.toggle-row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.switch {
  flex: none;
  width: 3.25rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--hairline);
  position: relative;
  transition: background-color var(--t-ui) var(--ease-out);
}
.switch::after {
  content: "";
  position: absolute;
  top: .1875rem;
  left: .1875rem;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .22);
  transition: transform var(--t-ui) var(--ease-out);
}
.toggle-row input:checked ~ .switch { background: var(--accent); }
.toggle-row input:checked ~ .switch::after { transform: translateX(1.25rem); }
.toggle-row input:focus-visible ~ .switch { outline: 3px solid var(--accent); outline-offset: 2px; }

/* =============================================== stats: a book page ===== */

.tally { margin: 0; padding: 0; }

.tally-row {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding: .8125rem 0;
  border-bottom: 1px solid var(--hairline-2);
}
.tally-row dt {
  font-family: var(--serif);
  font-size: 1.1875rem;
  color: var(--ink);
  letter-spacing: -.01em;
}
.tally-rule {
  flex: 1;
  height: 0;
  border-bottom: 1px dotted var(--hairline);
  transform: translateY(-.25rem);
}
.tally-row dd {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.1875rem;
  color: var(--ink-2);
  font-variant-numeric: oldstyle-nums tabular-nums;
  white-space: nowrap;
}
.tally-row dd b { font-weight: 600; color: var(--accent); font-size: 1.375rem; }
.tally-row.none dd { color: var(--ink-3); }

.tally-note {
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 1.125rem 0 0;
  max-width: 40ch;
  text-wrap: pretty;
}

/* ========================================================= voices tab === */

.voicelist { display: flex; flex-direction: column; gap: .625rem; }

.vrow {
  display: flex;
  align-items: center;
  gap: .875rem;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-lg);
  padding: .75rem .875rem .75rem 1rem;
  box-shadow: var(--shadow-card);
}
.vrow.has { border-color: color-mix(in srgb, var(--accent) 40%, var(--hairline-2)); }

.v-emoji { font-size: 1.875rem; line-height: 1; flex: none; width: 2.25rem; text-align: center; }
.v-body { flex: 1; min-width: 0; }
.v-word {
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  /* keep the RTL word on the same left edge as its transliteration below;
     dir="rtl" still governs shaping and bidi order */
  text-align: left;
}
.v-word[dir="rtl"] { font-size: 1.3125rem; line-height: 1.6; }
.v-sub {
  font-size: .8125rem;
  color: var(--ink-3);
  margin-top: .0625rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v-sub.has { color: var(--accent); font-weight: 600; }

/* five dots: which languages this word already has in a parent's voice */
.vdots { display: flex; gap: .3125rem; margin-top: .375rem; }
.vdot {
  width: .4375rem;
  height: .4375rem;
  border-radius: 50%;
  background: var(--hairline);
  transition: background-color var(--t-ui) ease;
}
.vdot.on { background: var(--accent); }

.v-actions { display: flex; gap: .375rem; flex: none; }

.minibtn {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: var(--bg);
  font-size: 1rem;
  cursor: pointer;
  color: var(--ink-2);
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-ui) ease;
}
.minibtn:active { transform: scale(.94); }
.minibtn.rec { color: var(--danger); font-size: .8125rem; }
.minibtn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #FFF;
  animation: breathe 1.4s ease-in-out infinite;
}

/* ======================================================= device voices == */

.vcheck {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .6875rem 0;
  border-bottom: 1px solid var(--hairline-2);
  font-size: .9375rem;
}
.vc-lang { color: var(--ink); }
.vc-state {
  color: var(--ink-3);
  font-size: .8125rem;
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  align-self: center;
}
.vc-state.ok { color: var(--ink-2); }

/* ========================================================= card player == */

.player { z-index: var(--z-player); }

.player-top {
  flex: none;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding:
    calc(.75rem + var(--safe-t))
    calc(.75rem + var(--safe-r))
    .375rem
    calc(.75rem + var(--safe-l));
}

.player-lang {
  flex: none;
  min-width: 3.75rem;
  text-align: right;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--accent);
}

.dots {
  flex: 1;
  display: flex;
  gap: .3125rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.dot {
  width: .375rem;
  height: .375rem;
  border-radius: 50%;
  background: var(--hairline);
  flex: none;
  transition: background-color var(--t-ui) ease, transform var(--t-ui) var(--ease-out);
}
.dot.done { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.dot.now { background: var(--accent); transform: scale(1.5); }

.player-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .25rem;
  padding: .5rem calc(1.375rem + var(--safe-r)) .5rem calc(1.375rem + var(--safe-l));
}

/* the emoji sits on a soft tinted halo */
.emoji {
  position: relative;
  font-size: clamp(7rem, 30vw, 9rem);   /* floor = 112px, per the brief */
  line-height: 1.08;
  margin-bottom: .375rem;
  user-select: none;
}
.emoji::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 52%;
  width: 1.55em;
  height: 1.55em;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle,
    color-mix(in srgb, var(--accent) 26%, transparent) 0%,
    color-mix(in srgb, var(--accent) 10%, transparent) 45%,
    transparent 68%);
  z-index: -1;
}

.native {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 12.5vw, 4.5rem);
  line-height: 1.15;
  letter-spacing: -.03em;
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.native[dir="rtl"] {
  font-size: clamp(2.6rem, 13vw, 4.75rem);
  line-height: 1.7;
  letter-spacing: 0;
}
.native.emphasise { color: var(--accent); }

.translit {
  margin: .25rem 0 0;
  font-size: 1.1875rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .02em;
}
.translit[hidden] { display: none; }

.gloss {
  margin: .375rem 0 0;
  font-size: .8125rem;
  color: var(--ink-3);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.gloss[hidden] { display: none; }

.reveal {
  font-family: var(--serif);
  font-size: clamp(2rem, 9vw, 3rem);
  line-height: 1.3;
  margin: .5rem 0 0;
  overflow-wrap: anywhere;
  animation: rise var(--t-ui) var(--ease-out);
}
.reveal[hidden] { display: none; }
.reveal .r-tr {
  display: block;
  font-family: var(--sans);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .02em;
  margin-top: .25rem;
}

.playbtn {
  margin-top: 1.5rem;
  min-height: 3.75rem;
  padding: 0 1.75rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .6875rem;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform var(--t-press) var(--ease-out),
              background-color var(--t-ui) ease,
              color var(--t-ui) ease;
}
.playbtn:active { transform: scale(.97); }
.playbtn .playglyph { color: var(--accent); font-size: 1.125rem; transition: color var(--t-ui) ease; }
.playbtn.playing {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  animation: breathe 1.5s ease-in-out infinite;
}
.playbtn.playing .playglyph { color: var(--on-accent); }

.novoice {
  margin: 1rem 0 0;
  font-size: .8125rem;
  line-height: 1.5;
  color: var(--ink-3);
  max-width: 30ch;
}
.novoice[hidden] { display: none; }

/* the footer floats over the card: frosted, not a slab */
.player-foot {
  flex: none;
  padding:
    .875rem
    calc(var(--gutter) + var(--safe-r))
    calc(1.125rem + var(--safe-b))
    calc(var(--gutter) + var(--safe-l));
  border-top: 1px solid var(--glass-line);
  background: var(--glass-solid);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .player-foot {
    background: var(--glass);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
  }
}
.player-foot.two { display: flex; gap: .625rem; }
.player-foot.two .btn { margin-top: 0; }
.player-foot.two .btn.soft { flex: 1; }
.player-foot.two .btn.primary { flex: 1.35; }

.coach {
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.45;
  color: var(--ink-2);
  margin: 0 0 .875rem;
  text-align: center;
  text-wrap: pretty;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================ end card == */

.end .scroll { padding-bottom: calc(2rem + var(--safe-b)); }

.end-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  letter-spacing: -.02em;
  margin: .375rem 0 .5rem;
  text-wrap: balance;
}
.end-sub {
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.45;
  color: var(--accent);
  margin: 0 0 1.5rem;
  max-width: 30ch;
  text-wrap: pretty;
}

/* The fridge card: read across a kitchen, photographed, or pasted into a
   message. Typeset properly rather than dumped as monospace -- Arabic
   harakat are the whole point for one of these languages, and a mono font
   crushes them. The plain-text version is what the share button sends. */
.fridge {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.125rem 1rem;
  color: var(--ink);
  margin: 0 0 1.25rem;
  box-shadow: var(--shadow-lift);
}

.fridge-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: .625rem;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: .875rem;
}
.fridge-date { font-family: var(--serif); font-size: 1.125rem; }
.fridge-mark {
  font-size: .6875rem;
  letter-spacing: .1em;
  color: var(--ink-3);
  text-transform: uppercase;
  white-space: nowrap;
}

/* One grid per word so the language code, the word, and the transliteration
   line up as three true columns. `display: contents` on the rows lets each
   row keep its own accent while its cells join the parent grid. */
.fword {
  display: grid;
  grid-template-columns: 1.5rem auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: .625rem;
  row-gap: .125rem;
  margin-bottom: .875rem;
}
.fword:last-of-type { margin-bottom: .5rem; }

.fword-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .25rem;
}
.fw-emoji { font-size: 1.25rem; line-height: 1; }
.fw-en { font-family: var(--serif); font-size: 1.1875rem; letter-spacing: -.01em; }

.frow { display: contents; }
.frow-lang {
  font-size: .625rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--accent);
  justify-self: end;
}
.frow-word {
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  justify-self: start;       /* RTL words start where the LTR ones do */
}
/* Arabic needs the room: harakat sit above and below the baseline */
.frow-word[dir="rtl"] { font-size: 1.25rem; line-height: 1.85; }
.frow-tr { font-size: .8125rem; color: var(--ink-3); justify-self: start; }

.fridge-foot {
  margin: 0;
  padding-top: .75rem;
  border-top: 1px solid var(--hairline-2);
  font-size: .8125rem;
  line-height: 1.5;
  color: var(--ink-3);
  text-wrap: pretty;
}
.fridge[hidden] { display: none; }
.fridge::before {
  content: "";
  position: absolute;
  inset: .375rem;
  border: 1px solid var(--hairline-2);
  border-radius: calc(var(--r-lg) - .375rem);
  pointer-events: none;
}

.end-actions { margin-bottom: .5rem; }

/* =============================================================== tabs === */

.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--tabh);
  padding-bottom: var(--safe-b);
  display: flex;
  z-index: var(--z-tabbar);
  border-top: 1px solid var(--glass-line);
  background: var(--glass-solid);
}
.tabbar[hidden] { display: none; }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tabbar {
    background: var(--glass);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
  }
}

.tab {
  flex: 1;
  min-height: 3.25rem;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1875rem;
  font-family: var(--sans);
  font-size: .6875rem;
  letter-spacing: .01em;
  color: var(--ink-3);
  cursor: pointer;
  transition: color var(--t-ui) ease;
}
.tab[hidden] { display: none; }
.tab .tabglyph {
  font-size: 1.1875rem;
  line-height: 1;
  filter: grayscale(1);
  opacity: .5;
  transition: opacity var(--t-ui) ease, filter var(--t-ui) ease, transform var(--t-press) var(--ease-out);
}
.tab:active .tabglyph { transform: scale(.9); }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tab[aria-selected="true"] .tabglyph { filter: none; opacity: 1; }

/* ============================================================== toast === */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tabh) + 1rem);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: .75rem 1.125rem;
  border-radius: 999px;
  font-size: .875rem;
  line-height: 1.4;
  max-width: calc(100% - 2.5rem);
  text-align: center;
  z-index: var(--z-toast);
  box-shadow: var(--shadow-lift);
  animation: toast-in var(--t-ui) var(--ease-out);
}
.toast[hidden] { display: none; }

/* ============================================================= motion === */

@keyframes rise {
  from { opacity: 0; transform: translateY(.5rem); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, .5rem); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* the card arrives with a little overshoot, then settles */
@keyframes card-in {
  from { opacity: 0; transform: translateY(1rem) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: .84; }
}

.spring { animation: card-in var(--t-card) var(--ease-spring); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  /* comprehension still needs the state change, just not the movement */
  .spring, .reveal, .wordlist li { animation: fade-in 160ms ease both; }
  .playbtn.playing { animation: none; opacity: 1; }
  .minibtn.recording { animation: none; }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
}

/* ========================================================= responsive === */

/* 320px: nothing may overflow sideways */
@media (max-width: 359px) {
  :root { --gutter: 1rem; }
  .wl-emoji { font-size: 2rem; width: 2.25rem; }
  .wl-en { font-size: 1.25rem; }
  .chip { padding: .625rem .8125rem; font-size: .875rem; }
  .player-foot.two { gap: .5rem; }
  .btn { font-size: 1rem; padding: 1rem; }
  .fridge { font-size: .75rem; padding: 1.125rem 1rem; }
}

/* short phones: keep the card composition from clipping */
@media (max-height: 700px) {
  .emoji { font-size: clamp(7rem, 22vh, 7.5rem); }
  .playbtn { margin-top: 1rem; }
  .coach { min-height: 2.5rem; }
}

@media (min-width: 720px) {
  .scroll, .topbar, .player-top, .player-body, .player-foot {
    max-width: 40rem;
    margin-inline: auto;
    width: 100%;
  }
  .tabbar { justify-content: center; }
  .tab { max-width: 8rem; }
}
