/* Phrazez — Soft UI in Eagle Rank brand colours.
   Teal #46818F (primary, ~60%), Black/White (text & surfaces, ~25%), Coral #FF6F61 (accent, ~15%).
   Light/dark via [data-theme] on <html> (set before paint in base.html). */

/* Two typefaces, self-hosted (SIL OFL): Montserrat for headings, Inter for body text.
   Subsets cover Portuguese, English, French, Spanish, Italian, German and Russian;
   Chinese falls back to the system CJK font. */
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/montserrat-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/montserrat-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/montserrat-cyrillic.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/inter-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/inter-cyrillic.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

:root {
  --teal: #46818F;
  --teal-ink: #2F5F6A;        /* darker teal for small text: 6.5:1 on the light surface */
  --teal-soft: #DCEAED;
  --coral: #FF6F61;
  --coral-ink: #C8463A;       /* coral for small text: AA on light surface */
  --coral-soft: rgba(255, 111, 97, .22);
  --black: #000000;
  --white: #FFFFFF;

  --bg: #E7EEF0;
  --surface: #E7EEF0;
  --surface-hi: #F2F7F8;
  --text: #0B1416;
  --muted: #4E6166;
  --line: rgba(70, 129, 143, .16);
  --shadow-dark: rgba(70, 129, 143, .30);
  --shadow-light: rgba(255, 255, 255, .95);
  --raised: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light);
  --raised-sm: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
  --inset: inset 4px 4px 9px var(--shadow-dark), inset -4px -4px 9px var(--shadow-light);
  --on-teal: #FFFFFF;
  --good: #1F7A4D;
  --radius: 22px;
  --font-body: "Inter", "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, Arial, "Microsoft YaHei", "PingFang SC", "Segoe UI Arabic", Tahoma, sans-serif;
  --font-head: "Montserrat", "Segoe UI", ui-sans-serif, system-ui, -apple-system, Arial, "Microsoft YaHei", "PingFang SC", "Segoe UI Arabic", Tahoma, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --teal: #5FA3B3;
  --teal-ink: #8CC5D2;
  --teal-soft: #17323A;
  --coral: #FF7F72;
  --coral-ink: #FF9A90;
  --coral-soft: rgba(255, 127, 114, .25);
  --bg: #111C1F;
  --surface: #111C1F;
  --surface-hi: #16252A;
  --text: #EEF5F6;
  --muted: #9DB3B8;
  --line: rgba(95, 163, 179, .18);
  --shadow-dark: rgba(0, 0, 0, .55);
  --shadow-light: rgba(95, 163, 179, .10);
  --on-teal: #06161A;
  --good: #5BD49A;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  font-family: var(--font-body); color: var(--text); background: var(--bg);
  display: flex; flex-direction: column;
  transition: background-color .3s ease, color .3s ease;
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Headings and display text use the heading font; everything else the body font. */
h1, h2, h3, h4, .brand-word, .pill-name, .phrase-text, .counter, .lang-tag, .pill-label,
.practice-result .score, .explain-body h4, .brand-tag, .nav-btn, .action-btn, .speed-btn, .sheet-head h2, .lang-option .native, .chip {
  font-family: var(--font-head);
}

/* Soft UI primitives */
.soft-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--raised); }
.soft-inset { background: var(--surface); border-radius: 14px; box-shadow: var(--inset); }
.soft-btn {
  display: inline-grid; place-items: center; border: 0; background: var(--surface);
  border-radius: 14px; box-shadow: var(--raised-sm); color: var(--teal-ink);
  transition: box-shadow .15s ease, transform .15s ease;
}
.soft-btn.icon { width: 44px; height: 44px; }
.soft-btn:active, .soft-btn[aria-pressed="true"] { box-shadow: var(--inset); }
.soft-btn[aria-pressed="true"] { color: var(--coral-ink); }


/* Outlined panel (the mockups' framed cards), on top of the soft surface. */
:root { --frame: 1px solid color-mix(in srgb, var(--teal) 38%, transparent); --fill: #46818F; --on-fill: #FFFFFF; }
[data-theme="dark"] { --fill: #46818F; --on-fill: #FFFFFF; }
.panel { background: var(--surface-hi); border: var(--frame); border-radius: var(--radius); box-shadow: var(--raised-sm); }

/* Top bar: logo · language pair · tools (one row on desktop; pair below on tablet/phone). */
.topbar {
  position: relative; /* in the page flow, never floating over the card */
  width: 100%; max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 18px; padding-top: max(12px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--teal); }
.logo-mark { width: 40px; height: 40px; stroke: none; color: var(--teal); filter: drop-shadow(0 3px 8px color-mix(in srgb, var(--teal) 45%, transparent)); }
.brand-text { display: grid; line-height: 1.05; }
.brand-word { font-weight: 800; font-size: 1.5rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text); }
.brand-tag { font-family: var(--font-head); font-size: .62rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--teal-ink); }
.tools { display: flex; gap: 10px; }
.icon-btn {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px;
  border: var(--frame); background: var(--surface-hi); color: var(--teal-ink); box-shadow: var(--raised-sm);
}
.icon-btn.small { width: 36px; height: 36px; border-radius: 10px; box-shadow: none; }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--coral-ink); }
.icon-btn[aria-pressed="true"] { background: var(--fill); color: var(--on-fill); }
#theme-toggle .i-sun { display: none; }
[data-theme="dark"] #theme-toggle .i-sun { display: block; }
[data-theme="dark"] #theme-toggle .i-moon { display: none; }

.stage { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 12px 18px 28px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; }

/* Language pair (currency-converter style) */
.pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; }
.lang-pill {
  display: grid; gap: 4px; text-align: start; min-width: 0;
  padding: 10px 14px; border: var(--frame); border-radius: 16px; background: var(--surface-hi); box-shadow: var(--raised-sm);
}
.lang-pill:hover .chev { color: var(--coral); }
.pill-label { font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.pill-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pill-name { font-weight: 700; font-size: 1.05rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chev { width: 18px; height: 18px; color: var(--muted); transition: color .15s; }
.flag { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; box-shadow: 0 0 0 2px var(--surface), 0 2px 6px var(--shadow-dark); }
.swap-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--fill); color: var(--on-fill); box-shadow: var(--raised-sm);
  transition: transform .35s cubic-bezier(.3, 1.4, .5, 1), background-color .15s;
}
.swap-btn:hover { background: var(--coral); color: #fff; }
.swap-btn.spin { transform: rotate(180deg); }

/* Filters: category + category search */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field {
  display: flex; align-items: center; gap: 10px; padding: 0 8px 0 14px; height: 50px; min-width: 0;
  border: var(--frame); border-radius: 14px; background: var(--surface-hi); color: var(--muted);
}
.field select, .field input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--text); font: inherit; font-size: .95rem; outline: none; }
.field select option { background: var(--surface-hi); color: var(--text); }
.field:focus-within { border-color: var(--coral); }

/* Card: picture + the two phrases */
.card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; touch-action: pan-y; transition: transform .25s ease, opacity .25s ease; }
.card.slide-left { transform: translateX(-24px); opacity: 0; }
.card.slide-right { transform: translateX(24px); opacity: 0; }
/* The whole picture is always shown in its own proportions (never cropped);
   a blurred copy fills any space around it. */
.card-media {
  position: relative; overflow: hidden; isolation: isolate; aspect-ratio: 16 / 9; max-height: 46vh; width: 100%;
  border-radius: var(--radius); border: var(--frame); background: var(--surface-hi); box-shadow: var(--raised-sm);
}
.card-media-bg { position: absolute; inset: -24px; z-index: -1; background-size: cover; background-position: center; filter: blur(22px) saturate(1.15) brightness(.85); transform: scale(1.05); }
.card-media img { width: 100%; height: 100%; display: block; object-fit: contain; transition: opacity .25s ease; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .3)); }
.card-media img.is-loading { opacity: 0; }
.card-media img:not([src]) { visibility: hidden; }
.chip { position: absolute; inset-inline-start: 14px; bottom: 14px; padding: 6px 14px; border-radius: 999px; font-size: .82rem; font-weight: 700; background: rgba(0, 0, 0, .6); color: #fff; backdrop-filter: blur(6px); }

.blocks { display: grid; gap: 16px; align-content: start; }
.lang-block {
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 16px 18px; border-radius: var(--radius); border: var(--frame); background: var(--surface-hi); box-shadow: var(--raised-sm);
}
.lang-block.is-base { background: var(--teal-soft); }
.block-main { min-width: 0; }
.tag-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lang-tag { display: inline-flex; align-items: center; gap: 10px; font-size: .78rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--teal-ink); }
.lang-tag .flag { width: 24px; height: 24px; }
.phrase-text { margin: 10px 0 0; line-height: 1.35; overflow-wrap: anywhere; }
/* Read-along text is always the top layer: nothing (label, controls, shadows) can cover it. */
.phrase-text { position: relative; z-index: 2; }
.word.on { position: relative; z-index: 3; }
.is-target .phrase-text { font-size: clamp(1.6rem, 4.6vw, 2.4rem); font-weight: 800; letter-spacing: -.01em; }
.is-base .phrase-text { font-size: clamp(1.15rem, 3.4vw, 1.5rem); font-weight: 600; }
/* Romanization / pronunciation line: much smaller and muted. */
.roman { margin: 6px 0 0; color: var(--teal-ink); font-size: .95rem; font-style: italic; }
.phrase-text.concealed { filter: blur(7px); user-select: none; cursor: pointer; }
.word { border-radius: 6px; padding: 0 2px; transition: background-color .12s ease, box-shadow .12s ease; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.word.on { background: var(--coral-soft); box-shadow: inset 0 -3px 0 var(--coral); }

.play-btn {
  position: relative; display: grid; place-items: center; width: 92px; height: 64px; border-radius: 20px; border: 0;
  background: var(--fill); color: var(--on-fill); box-shadow: var(--raised-sm); flex: none;
}
.play-btn svg { width: 28px; height: 28px; }
.play-btn:hover { filter: brightness(1.08); }
.play-btn.playing { background: var(--coral); color: #fff; }
.play-btn.no-audio { opacity: .4; }
.play-btn .spinner { display: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.play-btn.loading .spinner { display: block; }
.play-btn.loading .i-play { display: none; }
.text-btn { border: 0; background: none; color: var(--teal-ink); font-size: .82rem; font-weight: 700; padding: 6px 8px; border-radius: 10px; }
.text-btn:hover { color: var(--coral-ink); }

/* Dock: speed · previous · counter · next (in the page flow) */
.dock {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border: var(--frame); border-radius: var(--radius); background: var(--surface-hi); box-shadow: var(--raised-sm);
}
.dock-sep { width: 1px; align-self: stretch; background: var(--line); }
.nav-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 54px; padding: 0 22px; min-width: 54px;
  border-radius: 999px; border: 0; background: var(--fill); color: var(--on-fill); font-family: var(--font-head); font-weight: 700; font-size: 1rem;
  box-shadow: var(--raised-sm); flex: 1; max-width: 240px;
}
.nav-btn:hover:not(:disabled) { background: var(--coral); color: #fff; }
.nav-btn:disabled { opacity: .35; cursor: default; }
.counter { flex: 1; text-align: center; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.3rem; white-space: nowrap; }

.speed-wrap { position: relative; }
.speed-btn {
  display: inline-flex; align-items: center; gap: 10px; height: 54px; padding: 0 18px; border-radius: 999px;
  border: 2px solid var(--teal); background: transparent; color: var(--text); font-family: var(--font-head); font-weight: 700; white-space: nowrap;
}
.speed-btn .chev { transition: transform .2s; }
.speed-btn[aria-expanded="false"] .chev { transform: rotate(180deg); }
.speed-btn[aria-expanded="true"] { background: var(--fill); color: var(--on-fill); border-color: var(--fill); }
.speed-btn[aria-expanded="true"] .chev { color: inherit; }
#speed-label { font-variant-numeric: tabular-nums; }
.speed-panel {
  position: absolute; z-index: 20; inset-inline-start: 0; bottom: calc(100% + 12px); width: 300px;
  display: grid; gap: 14px; padding: 16px; border-radius: 18px; border: var(--frame);
  background: var(--surface-hi); box-shadow: var(--raised); animation: fade-in .15s ease;
}
.speed-value { justify-self: center; font-family: var(--font-head); font-weight: 800; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.speed-row { display: flex; align-items: center; gap: 10px; }
.speed-step { width: 36px; height: 36px; border-radius: 50%; border: var(--frame); background: var(--surface); color: var(--text); font-size: 1.2rem; line-height: 1; flex: none; }
.speed-step:hover { color: var(--coral-ink); }
/* Slider with a filled track, like YouTube's */
#speed { flex: 1; min-width: 0; height: 28px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; --pct: 33%; }
#speed::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--teal) var(--pct), var(--line) var(--pct)); }
#speed::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--teal) var(--pct), var(--line) var(--pct)); }
#speed::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff; border: 3px solid var(--teal); box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
#speed::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--teal); }
[dir="rtl"] #speed::-webkit-slider-runnable-track { background: linear-gradient(to left, var(--teal) var(--pct), var(--line) var(--pct)); }
.speed-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.speed-presets button { height: 34px; border-radius: 10px; border: var(--frame); background: var(--surface); color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.speed-presets button[aria-pressed="true"] { background: var(--fill); color: var(--on-fill); border-color: var(--fill); }

/* Practice row: Explain · Speak · Record */
.actions { display: flex; gap: 16px; }
.action-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 72px; padding: 12px 18px;
  border-radius: var(--radius); border: 2px solid var(--fill); background: var(--fill); color: var(--on-fill);
  font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; box-shadow: var(--raised-sm);
}
.action-btn svg { width: 26px; height: 26px; }
.action-btn.ghost { background: var(--surface-hi); color: var(--text); border-color: color-mix(in srgb, var(--teal) 60%, transparent); }
.action-btn.ghost:hover { border-color: var(--coral); }
.action-btn[aria-expanded="true"] { border-color: var(--coral); }
.action-btn.live { background: var(--coral); border-color: var(--coral); color: #fff; animation: pulse 1.4s ease-in-out infinite; }
.rec-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--coral); flex: none; }
.action-btn.live .rec-dot { background: #fff; }

.explain-body { padding: 16px 18px; border-radius: var(--radius); border: var(--frame); background: var(--surface-hi); display: grid; gap: 12px; }
.exp-item h4 { margin: 0 0 2px; font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--teal-ink); }
.exp-item p { margin: 0; font-size: .95rem; line-height: 1.5; }
.exp-item.similar > p { font-family: var(--font-head); font-weight: 600; color: var(--coral-ink); }
.explain-body.loading { display: block; color: var(--muted); font-style: italic; }
.practice-result { padding: 12px 16px; border-radius: var(--radius); border: var(--frame); background: var(--surface-hi); line-height: 1.55; }
.practice-result .score { font-weight: 800; font-size: 1.05rem; margin-bottom: 4px; }
.practice-result .hit { color: var(--good); font-weight: 700; }
.practice-result .miss { color: var(--coral-ink); text-decoration: underline wavy; text-underline-offset: 3px; }
.practice-result .heard { color: var(--muted); font-size: .85rem; margin-top: 4px; }
#my-recording { width: 100%; height: 40px; }
.hint { margin: 0; color: var(--muted); font-size: .84rem; }
.status { text-align: center; color: var(--muted); margin: 0; }
.status.error { color: var(--coral-ink); }

/* Desktop: pair inside the top bar, picture beside the phrases. */
@media (min-width: 1024px) {
  .card { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: stretch; }
  .card-media { aspect-ratio: 4 / 3; max-height: none; }
  .blocks { grid-auto-rows: 1fr; }
}
/* Tablet + phone */
/* Phone */
@media (max-width: 719px) {
  .filters { grid-template-columns: 1fr; gap: 10px; }
  .field { height: 46px; }
  .stage { padding-inline: 14px; gap: 14px; }
  .topbar { padding-inline: 14px; }
  .pair { gap: 8px; }
  .lang-pill { padding: 9px 10px; }
  .pill-name { font-size: .9rem; overflow-wrap: anywhere; }
  .lang-pill .chev { display: none; }
  .pill-main { gap: 8px; }
  .swap-btn { width: 44px; height: 44px; }
  .lang-block { padding: 14px; gap: 12px; }
  .play-btn { width: 72px; height: 56px; border-radius: 18px; }
  .dock { gap: 8px; padding: 8px; }
  .dock-sep { display: none; }
  .speed-btn { height: 46px; padding: 0 12px; gap: 6px; font-size: .9rem; }
  .speed-btn .chev, .speed-word { display: none; }
  .nav-btn { height: 46px; padding: 0 12px; }
  .nav-label { display: none; }
  .counter { font-size: 1rem; }
  .speed-panel { width: min(300px, calc(100vw - 40px)); }
  .actions { gap: 10px; }
  .action-btn { flex-direction: column; gap: 6px; min-height: 84px; padding: 10px 8px; font-size: .95rem; text-align: center; }
}
@media (max-width: 380px) {
  .flag { width: 22px; height: 22px; }
  .brand-word { font-size: 1.25rem; }
}

/* Footer: at the very bottom of the page, in the flow (never floating). */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 10px;
  padding: 18px 18px max(18px, env(safe-area-inset-bottom)); margin-top: auto;
  color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line);
}
.site-footer a { color: var(--teal-ink); font-weight: 700; text-decoration: none; }
.site-footer a:hover { color: var(--coral-ink); }

/* In-app alert, positioned next to the element that triggered it. */
.toast {
  position: fixed; z-index: 50; max-width: min(340px, calc(100vw - 24px));
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px 10px 14px; border-radius: 14px;
  background: var(--surface-hi); color: var(--text); box-shadow: var(--raised); font-size: .9rem; line-height: 1.4;
  border-left: 4px solid var(--teal); animation: fade-in .15s ease;
}
.toast.error { border-left-color: var(--coral); }
.toast-close { border: 0; background: none; color: var(--muted); font-size: 1.2rem; line-height: 1; padding: 0 2px; }
.toast-close:hover { color: var(--coral-ink); }

/* Language sheet */
.sheet { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; width: 100%; height: 100%; color: var(--text); }
.sheet::backdrop { background: rgba(0, 0, 0, .35); backdrop-filter: blur(3px); }
.sheet-inner {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 82dvh; display: flex; flex-direction: column; gap: 14px;
  padding: 18px 18px max(18px, env(safe-area-inset-bottom)); background: var(--surface);
  border-radius: 26px 26px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); animation: sheet-up .25s ease;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 1.2rem; font-weight: 800; }
.sheet-search { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 48px; color: var(--muted); flex: none; }
.sheet-search input { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; outline: none; }
.lang-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; display: grid; gap: 12px; }
.lang-option {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; border: 0; border-radius: 16px;
  background: var(--surface); box-shadow: var(--raised-sm); text-align: start;
}
.lang-option .flag { width: 34px; height: 34px; }
.lang-option .names { display: grid; flex: 1; min-width: 0; }
.lang-option .native { font-weight: 800; font-size: 1.02rem; }
.lang-option .english { color: var(--muted); font-size: .84rem; }
.lang-option .check { width: 22px; height: 22px; color: var(--coral); visibility: hidden; }
.lang-option[aria-selected="true"] { box-shadow: var(--inset); }
.lang-option[aria-selected="true"] .check { visibility: visible; }
.lang-empty { color: var(--muted); text-align: center; padding: 18px; }

/* Language sheet: centred dialog on tablet/desktop (after the base rule). */
@media (min-width: 720px) {
  .sheet-inner { left: 50%; top: 50%; bottom: auto; width: min(460px, 92vw); transform: translate(-50%, -50%); border-radius: 26px; animation: fade-in .2s ease; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px var(--coral-soft); } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Navbar holds only the logo and the theme toggle; the language pair opens the content. */
.topbar { border-bottom: 1px solid var(--line); max-width: none; padding-inline: max(18px, calc((100% - 1180px) / 2 + 18px)); }
.topbar > * { max-width: 1180px; }
@media (min-width: 1024px) { .pair { width: min(100%, 900px); justify-self: center; } }

/* "Sounds like" aid: about 60% of the phrase size, muted, like the romanization line. */
.sounds-like { margin: 6px 0 0; font-size: clamp(.95rem, 2.7vw, 1.3rem); font-weight: 500; color: var(--muted); letter-spacing: .01em; overflow-wrap: anywhere; }
.sounds-like::before { content: "≈ "; color: var(--coral-ink); font-weight: 700; }
.sl-btn { display: inline-flex; align-items: center; gap: 4px; }
.sl-btn svg { width: 16px; height: 16px; }
.sl-btn[aria-pressed="true"] { color: var(--coral-ink); }
.sl-btn.locked { opacity: .7; }
.sl-btn.locked::after { content: "★"; font-size: .7rem; color: var(--coral-ink); }

/* Report a wrong "sounds like" */
.sl-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.sl-flag { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; color: var(--muted); padding: 2px 4px; }
.sl-flag svg { width: 14px; height: 14px; }
.sl-report { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.sl-report input { flex: 1; min-width: 180px; height: 38px; padding: 0 12px; border-radius: 10px; border: var(--frame); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; }

/* Favourites */
.fav-btn {
  position: absolute; top: 12px; inset-inline-end: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(6px);
}
.fav-btn:hover { color: var(--coral); }
.fav-btn[aria-pressed="true"] svg, .fav-cat[aria-pressed="true"] svg { fill: var(--coral); stroke: var(--coral); }
.fav-cat:disabled { opacity: .35; cursor: default; }

/* Report wrong pronunciation */
.audio-flag { display: inline-grid; place-items: center; padding: 4px; color: var(--muted); margin-inline-start: auto; }
.audio-flag svg { width: 15px; height: 15px; }
.audio-flag:hover { color: var(--coral-ink); }
.tag-row .lang-tag { margin-inline-end: auto; }
.tag-row .audio-flag { margin-inline-start: 0; }
.audio-report { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-radius: 16px; border: var(--frame); background: var(--surface-hi); }
.audio-report-title { flex-basis: 100%; margin: 0; font-family: var(--font-head); font-weight: 700; font-size: .85rem; color: var(--teal-ink); }
.audio-report input { flex: 1; min-width: 180px; height: 38px; padding: 0 12px; border-radius: 10px; border: var(--frame); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; }
/* The sounds-like line highlights along with the voice */
.sounds-like .word.on { color: var(--text); }

/* Learning path bar */
.journey {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px 18px; padding: 14px 18px;
  border: var(--frame); border-radius: var(--radius); background: var(--surface-hi); box-shadow: var(--raised-sm);
}
.j-main { min-width: 0; display: grid; gap: 4px; }
.j-path { margin: 0; font-family: var(--font-head); font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--teal-ink); }
.j-unit { margin: 0; font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.j-step { font-family: var(--font-body); font-weight: 500; font-size: .82rem; color: var(--muted); }
.j-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.j-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--coral)); transition: width .4s ease; }
.j-stats { display: flex; gap: 14px; font-variant-numeric: tabular-nums; }
.j-stat { display: inline-flex; align-items: center; gap: 4px; font-size: .95rem; }
.j-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-btn {
  height: 40px; padding: 0 16px; border-radius: 999px; border: var(--frame); background: var(--surface); color: var(--text);
  font-family: var(--font-head); font-weight: 700; font-size: .88rem; white-space: nowrap;
}
.pill-btn.primary, .pill-btn[aria-pressed="true"] { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
.pill-btn:hover:not(:disabled) { border-color: var(--coral); }
.pill-btn:disabled { opacity: .45; cursor: default; }
@media (max-width: 899px) {
  .journey { grid-template-columns: minmax(0, 1fr) auto; }
  .j-actions { grid-column: 1 / -1; }
  .j-actions .pill-btn { flex: 1; }
}
@media (max-width: 719px) { .journey { padding: 12px; gap: 10px; } .pill-btn { padding: 0 10px; font-size: .8rem; } }

/* Roadmap */
.roadmap-list { overflow-y: auto; display: grid; gap: 6px; padding: 2px; }
.roadmap-list h3 { margin: 10px 4px 2px; font-size: .78rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--teal-ink); }
.roadmap-list ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.unit {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: var(--frame);
  background: var(--surface); color: var(--text); text-align: start;
}
.unit-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-size: .8rem; background: var(--line); flex: none; }
.unit-name { flex: 1; min-width: 0; font-weight: 600; }
.unit-count { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.unit-done .unit-icon { background: var(--good); color: #fff; }
.unit-current { border-color: var(--coral); }
.unit-current .unit-icon { background: var(--coral); color: #fff; }
.unit-locked { opacity: .55; }
.unit-here { box-shadow: inset 0 0 0 2px var(--teal); }

/* Profile / onboarding */
.profile-form { overflow-y: auto; }
.profile-intro { margin: 0; color: var(--muted); line-height: 1.5; }
.profile-langs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile-langs label { display: grid; gap: 4px; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.profile-langs select { height: 42px; border-radius: 10px; border: var(--frame); background: var(--surface-hi); color: var(--text); font: inherit; font-size: .95rem; text-transform: none; letter-spacing: 0; padding: 0 8px; }
.choice-grid { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.choice-grid legend { margin-bottom: 6px; font-family: var(--font-head); font-weight: 800; font-size: .85rem; }
.choice-grid label { position: relative; }
.choice-grid input { position: absolute; opacity: 0; }
.choice-grid label > span {
  display: grid; gap: 2px; height: 100%; padding: 10px 12px; border-radius: 12px; border: var(--frame); background: var(--surface-hi); cursor: pointer;
}
.choice-grid b { font-size: 1.3rem; }
.choice-grid em { font-style: normal; font-weight: 700; }
.choice-grid small { color: var(--muted); font-size: .76rem; line-height: 1.3; }
.choice-grid input:checked + span { border-color: var(--coral); box-shadow: inset 0 0 0 1px var(--coral); }
.choice-grid input:focus-visible + span { outline: 3px solid var(--coral); outline-offset: 2px; }
.text-btn.danger { color: var(--coral-ink); justify-self: center; }

/* Pronunciation score */
.score-panel { display: grid; gap: 8px; padding: 16px 18px; border-radius: var(--radius); border: var(--frame); background: var(--surface-hi); }
.meter { position: relative; height: 26px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--coral); transition: width .25s ease, background-color .25s; }
[dir="rtl"] .meter-fill { inset: 0 0 0 auto; }
.score-panel[data-band="ok"] .meter-fill { background: var(--teal); }
.score-panel[data-band="great"] .meter-fill { background: var(--good); }
.meter-value { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-size: .85rem; color: var(--text); font-variant-numeric: tabular-nums; }
.score-label { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; }
.score-words { margin: 0; font-size: 1.15rem; line-height: 1.6; }
.score-words .hit { color: var(--good); font-weight: 700; }
.score-words .miss { color: var(--coral-ink); text-decoration: underline wavy; text-underline-offset: 3px; }
.score-words .pending { color: var(--muted); }
.score-heard { margin: 0; color: var(--muted); font-size: .85rem; }
.action-btn .rec-dot { display: none; }
.action-btn.live svg { display: none; }
.action-btn.live .rec-dot { display: block; background: #fff; }

/* Celebration (90-100%, unit done, daily goal) */
.celebrate { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
.celebrate i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: confetti linear forwards; }
@keyframes confetti { to { transform: translate(var(--drift), 105vh) rotate(var(--spin)); opacity: .9; } }
.celebrate-badge {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); padding: 16px 26px; border-radius: 999px;
  background: var(--fill); color: var(--on-fill); font-family: var(--font-head); font-weight: 800; font-size: 1.3rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35); animation: pop .5s cubic-bezier(.3, 1.6, .5, 1), fade-out .5s ease 2.4s forwards; white-space: nowrap;
}
@keyframes pop { from { transform: translate(-50%, -50%) scale(.4); opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* ===== Soft UI (no outlines): raised surfaces, pressed fields, brand colours ===== */
:root { --frame: 0 solid transparent; --raised-lg: 12px 12px 26px var(--shadow-dark), -12px -12px 26px var(--shadow-light); }
.lang-block, .dock, .journey, .card-media, .explain-body, .score-panel, .audio-report, .speed-panel {
  background: var(--surface); box-shadow: var(--raised);
}
.lang-block.is-base { background: var(--surface); box-shadow: var(--inset); }
.field, .sheet-search, .profile-langs select, .sl-report input, .audio-report input { background: var(--surface); box-shadow: var(--inset); }
.lang-pill { background: var(--surface); box-shadow: var(--raised-sm); }
.lang-pill:active { box-shadow: var(--inset); }
.icon-btn { background: var(--surface); box-shadow: var(--raised-sm); }
.icon-btn:active, .icon-btn[aria-pressed="true"] { box-shadow: var(--inset); }
.icon-btn.small { box-shadow: var(--raised-sm); }
.speed-btn { border: 0; background: var(--surface); box-shadow: var(--raised-sm); }
.speed-btn[aria-expanded="true"] { box-shadow: var(--inset); background: var(--surface); color: var(--teal-ink); }
.speed-step, .speed-presets button { background: var(--surface); box-shadow: var(--raised-sm); }
.speed-presets button[aria-pressed="true"] { box-shadow: var(--inset); background: var(--surface); color: var(--coral-ink); }
.action-btn { border: 0; box-shadow: var(--raised); }
.action-btn.ghost { background: var(--surface); }
.action-btn.ghost:hover, .action-btn[aria-expanded="true"] { box-shadow: var(--inset); }
.action-btn:active, .nav-btn:active:not(:disabled), .play-btn:active, .swap-btn:active { box-shadow: var(--inset); }
.pill-btn { border: 0; background: var(--surface); box-shadow: var(--raised-sm); }
.pill-btn:hover:not(:disabled) { color: var(--coral-ink); }
.pill-btn.primary, .pill-btn[aria-pressed="true"] { background: var(--fill); color: var(--on-fill); }
.unit { background: var(--surface); box-shadow: var(--raised-sm); }
.unit-current { box-shadow: var(--inset); color: var(--coral-ink); }
.choice-grid label > span { background: var(--surface); box-shadow: var(--raised-sm); }
.choice-grid input:checked + span { box-shadow: var(--inset); color: var(--coral-ink); }
.dock-sep { background: transparent; }
.meter { box-shadow: var(--inset); background: var(--surface); }

/* Footer: "Phrazez powered by Eagle Rank" */
.brand-footer { flex-direction: column; gap: 12px; padding-top: 26px; }
.bf-brand { display: flex; align-items: center; gap: 10px; }
.bf-logo { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--surface); box-shadow: var(--raised-sm); color: var(--teal); }
.bf-logo .logo-mark { width: 28px; height: 28px; filter: none; }
.bf-line { margin: 0; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; justify-content: center; }
.bf-app { font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text); }
.bf-powered { color: var(--muted); font-size: .85rem; }
.bf-line a { font-family: var(--font-head); font-weight: 800; color: var(--teal-ink); text-decoration: none; }
.bf-line a:hover { color: var(--coral-ink); }
.bf-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; }
.bf-links a { color: var(--text); font-weight: 600; text-decoration: none; }
.bf-links a:hover { color: var(--coral-ink); }
.bf-legal { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; color: var(--muted); font-size: .82rem; }
.bf-legal a { color: var(--teal-ink); font-weight: 700; text-decoration: none; }

.unit-name { display: grid; gap: 1px; }
.unit-name small { color: var(--muted); font-size: .76rem; font-weight: 500; }

.logout-form { display: contents; }
.profile-account { margin: 0; font-size: .88rem; color: var(--muted); }
.profile-account b { color: var(--text); }

/* ===== AI credits: balance pill, credits sheet, paid AI help panel ===== */
.credits-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 46px; padding: 0 14px; border-radius: 14px; border: 0;
  background: var(--surface); box-shadow: var(--raised-sm); color: var(--teal-ink);
  font-family: var(--font-head); font-weight: 800; font-size: 1rem; font-variant-numeric: tabular-nums;
}
.credits-pill svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.credits-pill:hover { color: var(--coral-ink); }
.credits-pill:active { box-shadow: var(--inset); }
.credits-pill.low { color: var(--coral-ink); }
.credits-sheet h3 { margin: 6px 0 0; font-family: var(--font-head); font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--teal-ink); }
.credits-big { margin: 0; font-size: 1rem; color: var(--muted); }
.credits-big b { font-family: var(--font-head); font-size: 2.2rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.credits-intro, .credits-policy, .credits-soon { margin: 0; font-size: .9rem; line-height: 1.5; }
.credits-policy { padding: 12px 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--inset); }
.credits-soon { color: var(--muted); font-size: .82rem; }
.credits-costs, .credits-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.credits-costs li { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; }
.credits-costs b { color: var(--teal-ink); white-space: nowrap; }
.credits-history { max-height: 240px; overflow-y: auto; }
.credits-history li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline; font-size: .86rem; padding: 4px 0; border-bottom: 1px solid var(--line); }
.tx-when { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.tx-amount { font-variant-numeric: tabular-nums; color: var(--coral-ink); }
.tx-amount.plus { color: var(--teal-ink); }
.tx-none { display: block !important; color: var(--muted); border: 0 !important; }

.assist-note, .assist-wait, .assist-policy { margin: 0; font-size: .9rem; line-height: 1.5; }
.assist-wait { color: var(--muted); font-style: italic; }
.assist-policy { color: var(--muted); font-size: .78rem; }
.credit-confirm { display: grid; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--inset); }
.credit-confirm p { margin: 0; font-size: .9rem; font-weight: 600; }
.confirm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.assist-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.assist-examples h4, .assist-followups h4 { margin: 0 0 6px; font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--teal-ink); }
.assist-examples ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.assist-examples li { display: grid; gap: 2px; }
.assist-examples li b { font-family: var(--font-head); font-weight: 600; color: var(--coral-ink); }
.assist-examples li span { font-size: .9rem; color: var(--muted); }
.assist-followups { display: grid; gap: 10px; }
.followup-item { display: grid; gap: 4px; justify-items: start; }
.followup-q { margin: 0; font-weight: 700; font-size: .9rem; }
.followup-a { margin: 0; font-size: .95rem; line-height: 1.5; }
.followup-form { display: flex; gap: 8px; flex-wrap: wrap; }
.followup-form input { flex: 1; min-width: 180px; height: 40px; padding: 0 12px; border-radius: 12px; border: 0; background: var(--surface); box-shadow: var(--inset); color: var(--text); font: inherit; font-size: .9rem; }
.followup-item .listen-btn { height: 34px; font-size: .82rem; }
/* Five controls in the top bar: keep them on one line on phones. */
@media (max-width: 719px) {
  .tools { gap: 6px; }
  .topbar .icon-btn { width: 40px; height: 40px; }
  .credits-pill { height: 40px; padding: 0 10px; gap: 4px; }
}
@media (max-width: 420px) {
  .brand { gap: 6px; }
  .topbar .logo-mark { width: 32px; height: 32px; }
  .brand-word { font-size: 1.1rem; letter-spacing: .05em; }
  .topbar .icon-btn { width: 38px; height: 38px; }
  .credits-pill svg { width: 18px; height: 18px; }
}

/* Similar phrases: each with listen + "sounds like" */
.sim-row { display: grid; gap: 2px; padding: 4px 0; }
.sim-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sim-text { margin: 0; font-family: var(--font-head); font-weight: 600; color: var(--coral-ink); font-size: .98rem; }
.sim-tools { display: inline-flex; gap: 6px; flex: none; }
.sim-btn { display: inline-flex; align-items: center; gap: 4px; height: 34px; min-width: 34px; padding: 0 9px; border: 0; border-radius: 10px;
  background: var(--surface); box-shadow: var(--raised-sm); color: var(--teal-ink); font-family: var(--font-head); font-weight: 700; font-size: .72rem; }
.sim-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sim-btn:hover { color: var(--coral-ink); }
.sim-btn[aria-pressed="true"] { box-shadow: var(--inset); color: var(--coral-ink); }
.sim-hint { margin: 0; font-size: .92rem; }

/* ===== Plans: dialog, cards, banner, self-check ===== */
.plans-sheet { overflow-y: auto; }
.plans-sheet > * { flex: none; }
@media (min-width: 720px) { .plans-sheet { width: min(940px, 94vw); } }
.plans-reason { margin: 0; padding: 12px 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--inset); font-weight: 600; color: var(--coral-ink); }
.interval-toggle { display: flex; align-items: center; gap: 12px; justify-content: center; flex-wrap: wrap; }
.it-label { font-family: var(--font-head); font-weight: 700; color: var(--muted); cursor: pointer; transition: color .2s; }
.it-label.on { color: var(--text); }
.save-chip { margin-left: 4px; padding: 3px 8px; border-radius: 999px; background: var(--coral-soft); color: var(--coral-ink); font-size: .72rem; font-weight: 800; }
.switch { position: relative; width: 56px; height: 30px; flex: none; border: 0; border-radius: 999px; padding: 0;
  background: var(--surface); box-shadow: var(--inset); cursor: pointer; }
.switch .knob { position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--fill); box-shadow: var(--raised-sm); transition: transform .2s ease; }
.switch[aria-checked="true"] .knob { transform: translateX(26px); }
.switch:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .switch .knob { transition: none; } }
.plans-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.plan-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 20px; background: var(--surface); box-shadow: var(--raised-sm); }
.plan-card.current { box-shadow: var(--inset); }
.plan-card.plan-gold { outline: 2px solid color-mix(in srgb, var(--coral) 55%, transparent); }
.plan-card header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-card h3 { margin: 0; font-size: 1.2rem; font-weight: 800; }
.plan-badge { font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--teal-ink); }
.plan-price { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.plan-price b { font-family: var(--font-head); font-size: 1.7rem; font-weight: 800; }
.plan-price span { color: var(--muted); }
.plan-price small { flex-basis: 100%; color: var(--muted); font-size: .82rem; font-weight: 600; }
.plan-card ul { margin: 0; padding: 0 0 0 18px; display: grid; gap: 4px; font-size: .9rem; }
.plan-card .action-btn { flex: none; min-height: 48px; margin-top: auto; } /* buttons line up at the bottom of every card */
.plan-card ul { flex: none; }
.plans-list { align-items: stretch; }
.plans-foot { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; color: var(--muted); font-size: .82rem; }
.plans-foot a { color: var(--teal-ink); font-weight: 700; }
.notice-sheet { max-width: 460px; }
.notice-sheet p { margin: 0; line-height: 1.5; }
.plan-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--inset); }
.plan-banner p { margin: 0; flex: 1; min-width: 220px; font-size: .92rem; }
.profile-plan { margin: 0; font-size: .88rem; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.self-check { margin-top: 6px; }
.score-panel.no-meter .meter { display: none; }

/* ===== Credits sheet: fixed header and footer, scrolling body ===== */
.credits-sheet { padding: 0; gap: 0; overflow: hidden; }
.credits-sheet .sheet-head { flex: none; padding: 16px 18px 10px; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 14px; padding: 4px 18px 18px; }
.sheet-foot { flex: none; display: grid; gap: 8px; padding: 12px 18px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.sheet-foot .action-btn { min-height: 48px; flex: none; }
.cr-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--surface); box-shadow: var(--raised-sm); color: var(--teal-ink); }
.cr-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cr-balance { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--surface); box-shadow: var(--inset); }
.cr-balance .cr-icon { width: 44px; height: 44px; color: var(--coral-ink); }
.cr-balance p { margin: 0; color: var(--muted); }
.cr-balance b { font-family: var(--font-head); font-size: 2rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.cr-groups { display: grid; gap: 12px; }
.cr-group h4 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-family: var(--font-head); font-size: .92rem; font-weight: 800; color: var(--text); }
.cr-group .credits-costs { padding-left: 44px; }
.credits-costs li { padding: 3px 0; line-height: 1.4; }
.credits-costs b.free { color: var(--teal-ink); }
.credits-policy p { margin: 0; }
.credits-policy details { margin-top: 6px; }
.credits-policy summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 700; color: var(--teal-ink); }
.credits-policy summary:hover { color: var(--coral-ink); }
.credits-policy details p { color: var(--muted); }
.cr-h { display: flex; align-items: center; gap: 10px; }
.credits-history { max-height: none; overflow: visible; }
.credits-history li { padding: 8px 0; }
.cr-history-actions { display: flex; gap: 8px; }
.cr-history-actions .text-btn, .credits-sheet .text-btn { min-height: 44px; }
@media (max-width: 719px) { /* phones: near full-screen bottom sheet */
  .credits-sheet { height: 94dvh; max-height: 94dvh; }
}
@media (min-width: 720px) {
  .credits-sheet { width: min(640px, 94vw); max-height: 88dvh; }
  .sheet-body { padding: 4px 26px 22px; gap: 16px; }
  .credits-sheet .sheet-head { padding: 22px 26px 12px; }
  .sheet-foot { padding: 14px 26px 20px; grid-template-columns: 1fr auto; align-items: center; }
  .sheet-foot .action-btn { padding: 0 28px; }
  .cr-groups { grid-template-columns: 1fr 1fr; }
  .cr-group:first-child { grid-column: 1 / -1; }
}

/* ===== Enterprise & Institutions (under the plan cards) ===== */
.ent { display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; align-items: center; padding: 18px; border-radius: 20px; background: var(--surface); box-shadow: var(--raised-sm); }
.ent-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--surface); box-shadow: var(--inset); color: var(--teal-ink); align-self: start; }
.ent-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ent-copy h3 { margin: 0 0 4px; font-size: 1.1rem; font-weight: 800; }
.ent-copy p { margin: 0; font-size: .9rem; line-height: 1.5; }
.ent-price { margin-top: 6px !important; font-family: var(--font-head); font-weight: 800; color: var(--coral-ink); }
.ent-btn { grid-column: 1 / -1; min-height: 48px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ent-setup { grid-column: 1 / -1; margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--coral-soft); font-size: .85rem; }
.ent-setup a { color: var(--teal-ink); font-weight: 700; }
@media (min-width: 720px) {
  .ent { grid-template-columns: auto 1fr auto; }
  .ent-btn { grid-column: auto; padding: 0 28px; }
}

/* Credit packs in the credits sheet */
.cr-buy { display: grid; gap: 10px; }
.cr-packs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.pack-btn { display: grid; gap: 2px; justify-items: center; min-height: 64px; padding: 10px 12px; border: 0; border-radius: 16px;
  background: var(--surface); box-shadow: var(--raised-sm); color: var(--text); font: inherit; cursor: pointer; }
.pack-btn:hover { color: var(--coral-ink); }
.pack-btn:active { box-shadow: var(--inset); }
.pack-btn:disabled { opacity: .5; cursor: progress; }
.cr-buy-note { margin: 0; color: var(--muted); font-size: .8rem; }

/* Brand: "PHRAZEZ" in the logo's teal, letters as tall as the headphones (cap height ≈ 0.7 × font size,
   the headphones ≈ 0.7 × the logo box), so the word's font size = the logo size. */
:root { --brand-size: 40px; }
.topbar .logo-mark { width: var(--brand-size); height: var(--brand-size); }
.topbar .brand-word { color: var(--teal); font-size: var(--brand-size); line-height: 1; letter-spacing: .04em; }
@media (max-width: 719px) { :root { --brand-size: 32px; } }
@media (max-width: 420px) {
  :root { --brand-size: 26px; }
  .topbar .brand-word { letter-spacing: .02em; }
  .topbar .icon-btn { width: 36px; height: 36px; }
  .credits-pill { height: 36px; padding: 0 8px; }
}
@media (max-width: 380px) {
  :root { --brand-size: 22px; }
  .tools { gap: 4px; }
  .topbar .icon-btn { width: 34px; height: 34px; }
  .credits-pill { height: 34px; padding: 0 6px; gap: 3px; }
}

/* Brand logo image (headphones + PHRAZEZ). Height follows --brand-size; width keeps the ratio. */
.brand-logo { display: block; height: var(--brand-size, 40px); width: auto; max-width: 100%;
  filter: drop-shadow(0 3px 6px color-mix(in srgb, var(--teal) 30%, transparent)); }

/* Credit pack cards: centred, clear size hierarchy */
.cr-packs { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.pack-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 2px; min-height: 132px; padding: 14px 10px; }
.pack-n { font-family: var(--font-head); font-size: 2rem; font-weight: 800; line-height: 1; color: var(--teal-ink);
  font-variant-numeric: tabular-nums; }
.pack-unit { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pack-price { margin-top: 6px; font-family: var(--font-head); font-size: 1.05rem; font-weight: 800; color: var(--text); }
.pack-cta { margin-top: 8px; padding: 6px 16px; border-radius: 999px; background: var(--fill); color: var(--on-fill);
  font-family: var(--font-head); font-size: .82rem; font-weight: 800; }
.pack-btn:hover .pack-cta { background: var(--coral); }
.pack-btn:hover .pack-n { color: var(--coral-ink); }

/* "See plans": coral, gentle glow pulse and a shine sweep every few seconds (sales call to action). */
.cta-plans { position: relative; overflow: hidden; isolation: isolate; background: #C8463A !important; color: #fff !important; /* 4.5:1 with white */
  animation: cta-pulse 2.6s ease-in-out infinite; }
.cta-plans::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .45) 50%, transparent 65%);
  transform: translateX(-120%); animation: cta-shine 4s ease-in-out infinite; }
.cta-plans:hover, .cta-plans:focus-visible { animation-play-state: paused; transform: translateY(-1px); }
@keyframes cta-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--coral) 55%, transparent), var(--raised-sm); }
  50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--coral) 0%, transparent), var(--raised-sm); }
}
@keyframes cta-shine { 0%, 55% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
@media (prefers-reduced-motion: reduce) { .cta-plans, .cta-plans::after { animation: none; } }

/* Profile: current plan card (first thing in the profile) */
.pp-card { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
  padding: 16px 18px; border-radius: 18px; background: var(--surface); box-shadow: var(--raised-sm);
  border-left: 6px solid var(--teal); }
.pp-card.plan-silver { border-left-color: #9AA6AD; }
.pp-card.plan-gold { border-left-color: #D4A017; }
.pp-info { display: grid; gap: 2px; min-width: 0; }
.pp-label { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pp-name { font-family: var(--font-head); font-size: 1.6rem; font-weight: 800; line-height: 1.15; color: var(--text); }
.pp-card.plan-gold .pp-name::after { content: " ★"; color: #D4A017; }
.pp-meta { font-size: .88rem; color: var(--muted); }
.pp-card .action-btn { flex: none; min-height: 46px; padding: 0 22px; }
@media (max-width: 480px) { .pp-card .action-btn { width: 100%; } }

/* What's new (blog) */
.news-btn { position: relative; display: inline-grid; place-items: center; color: var(--text); }
.news-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.news-dot { position: absolute; top: 6px; inset-inline-end: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 2px var(--surface); }
.news-card { display: flex; align-items: center; gap: 12px; max-width: 1100px; margin: 8px auto 0; padding: 10px 12px 10px 18px; border-radius: 18px; background: var(--surface); box-shadow: var(--raised-sm); }
.news-card[hidden] { display: none; }
.news-card-label { flex: none; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--coral-ink); }
.news-card-title { flex: 1; min-width: 0; color: var(--text); font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.news-card-title:hover { color: var(--teal-ink); text-decoration: underline; }
.news-optin { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; font-size: .92rem; cursor: pointer; }
.news-optin input { width: 18px; height: 18px; accent-color: var(--teal); }
.gift-links { margin: 0 0 10px; font-size: .92rem; }
.gift-links a { color: var(--teal-ink); font-weight: 600; }
