/* Voice it up (V2) - calm, minimalist card flow. */
:root {
  --bg: #f5f5f7;
  --bg-2: #ecebf5;
  --card: rgba(255, 255, 255, 0.86);
  --card-solid: #ffffff;
  --tile: #ffffff;
  --tile-hover: #f7f7fb;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #a1a1a6;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #5e5ce6;
  --accent-soft: rgba(94, 92, 230, 0.12);
  --accent-2: #ff8a65;
  --good: #34c759;
  --good-soft: rgba(52, 199, 89, 0.14);
  --bad: #ff453a;
  --bad-soft: rgba(255, 69, 58, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 40px rgba(60, 60, 120, 0.10);
  --shadow-tile: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(60, 60, 120, 0.06);
  --radius: 28px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: light;
}
/* Dark mode: follows the device unless the student picks light or dark with the ☾/☀ button (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f14;
    --bg-2: #17162a;
    --card: rgba(30, 30, 38, 0.82);
    --card-solid: #1e1e26;
    --tile: #26262f;
    --tile-hover: #2e2e39;
    --text: #f5f5f7;
    --muted: #a1a1aa;
    --faint: #6e6e78;
    --line: rgba(255, 255, 255, 0.09);
    --accent: #7d7aff;
    --accent-soft: rgba(125, 122, 255, 0.18);
    --good-soft: rgba(52, 199, 89, 0.2);
    --bad-soft: rgba(255, 69, 58, 0.2);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 48px rgba(0, 0, 0, 0.45);
    --shadow-tile: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f14;
  --bg-2: #17162a;
  --card: rgba(30, 30, 38, 0.82);
  --card-solid: #1e1e26;
  --tile: #26262f;
  --tile-hover: #2e2e39;
  --text: #f5f5f7;
  --muted: #a1a1aa;
  --faint: #6e6e78;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #7d7aff;
  --accent-soft: rgba(125, 122, 255, 0.18);
  --good-soft: rgba(52, 199, 89, 0.2);
  --bad-soft: rgba(255, 69, 58, 0.2);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-tile: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%) fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

/* soft colour glows in the background */
.glow { position: fixed; width: 520px; height: 520px; border-radius: 50%; filter: blur(90px); opacity: 0.35; pointer-events: none; z-index: 0; }
.glow-a { background: #a5a3ff; top: -180px; left: -160px; }
.glow-b { background: #ffc6b3; bottom: -220px; right: -180px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .glow { opacity: 0.16; } }
:root[data-theme="dark"] .glow { opacity: 0.16; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 14px 16px; max-width: 720px; margin: 0 auto; }
.brand { font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; user-select: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.bar-right { margin-left: auto; display: flex; gap: 4px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); transition: background .2s, color .2s; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

.progress { position: relative; z-index: 1; display: flex; justify-content: center; gap: 6px; height: 6px; margin: 2px auto 0; }
.progress i { width: 6px; height: 6px; border-radius: 3px; background: var(--line); transition: all .35s ease; }
.progress i.done { background: var(--accent); opacity: .45; }
.progress i.on { width: 22px; background: var(--accent); }

/* stage and cards */
.stage { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; padding: 22px 16px 80px; }
.card {
  background: var(--card);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 28px 28px;
  border: 1px solid var(--line);
}
.card.enter { animation: cardIn .55s cubic-bezier(.2, .8, .2, 1) both; }
.card.enter.back { animation-name: cardInBack; }
.card.leave { animation: cardOut .22s ease both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(26px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes cardInBack { from { opacity: 0; transform: translateY(-18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes cardOut { to { opacity: 0; transform: translateY(-10px) scale(.985); } }

.eyebrow { font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: .02em; text-transform: uppercase; margin: 0 0 8px; }
.q { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 6px; }
.hint { color: var(--muted); margin: 0 0 22px; font-size: 15px; }

/* option tiles */
.tiles { display: grid; gap: 10px; grid-template-columns: 1fr; }
/* At most 2 (or 3) columns; columns drop away when a tile would get too narrow (phones, folded foldables). */
.tiles.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, max(165px, calc((100% - 10px) / 2))), 1fr)); }
.tiles.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, max(120px, calc((100% - 20px) / 3))), 1fr)); }
@media (max-width: 480px) { .q { font-size: 24px; } .card { padding: 28px 20px 22px; } }
.tile {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--tile); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow-tile);
  border: 1.5px solid transparent;
  transition: transform .18s ease, background .2s, border-color .2s, box-shadow .2s;
  animation: tileIn .5s cubic-bezier(.2, .8, .2, 1) both;
}
.tile { min-width: 0; }
.tile > div { min-width: 0; overflow-wrap: anywhere; }
.tile:hover { background: var(--tile-hover); transform: translateY(-1px); }
.tile:active { transform: scale(.98); }
.tile.sel { border-color: var(--accent); background: var(--accent-soft); }
.tile .emo { font-size: 26px; line-height: 1; width: 34px; text-align: center; flex: none; }
.tile .lbl { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.tile .sub { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.tile.compact { flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 14px 16px; }
.tile.compact .emo { width: auto; font-size: 24px; }
.tile.center { justify-content: center; text-align: center; flex-direction: column; gap: 2px; }
.tile.center .lbl { font-size: 19px; }
@keyframes tileIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* inputs and buttons */
.field { width: 100%; border-radius: 16px; border: 1.5px solid var(--line); background: var(--tile); padding: 14px 16px; outline: none; transition: border-color .2s, box-shadow .2s; resize: vertical; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.spread { justify-content: space-between; }
.mt { margin-top: 18px; }
.mt-s { margin-top: 10px; }
.btn { border-radius: 999px; padding: 12px 22px; font-weight: 600; font-size: 15px; background: var(--tile); box-shadow: var(--shadow-tile); transition: transform .15s, background .2s, opacity .2s; }
.btn:hover { background: var(--tile-hover); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 8px 24px rgba(94, 92, 230, .35); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { padding: 16px 28px; font-size: 17px; width: 100%; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { color: var(--accent); background: var(--accent-soft); }
.btn.small { padding: 8px 14px; font-size: 13.5px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; background: var(--tile); box-shadow: var(--shadow-tile); font-size: 14px; border: 1.5px solid transparent; transition: background .2s, border-color .2s; }
.chip:hover { background: var(--tile-hover); }
.chip.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip.static { box-shadow: none; background: var(--accent-soft); color: var(--accent); font-weight: 500; font-size: 13px; padding: 5px 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .03em; }
.seg { display: inline-flex; background: var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted); transition: background .2s, color .2s; }
.seg button.on { background: var(--card-solid); color: var(--text); box-shadow: var(--shadow-tile); }

/* voice picker */
.voices { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: thin; }
.voice { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-radius: 999px; background: var(--tile); box-shadow: var(--shadow-tile); border: 1.5px solid transparent; font-size: 14px; }
.voice.sel { border-color: var(--accent); background: var(--accent-soft); }
.voice small { color: var(--muted); }
.play-mini { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11px; }
.speaker-box { padding: 14px 0 4px; border-top: 1px solid var(--line); }
.speaker-box:first-of-type { border-top: 0; }

/* summary */
.summary { display: grid; gap: 8px; margin: 6px 0 22px; }
.summary div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--tile); border-radius: 14px; font-size: 15px; }
.summary span:first-child { color: var(--muted); }
.summary span:last-child { font-weight: 600; text-align: right; }

/* the listening animation */
.working { text-align: center; padding-top: 18px; }
.listener { width: 220px; height: 220px; margin: 0 auto 10px; display: block; overflow: visible; }
.listener .head-group { transform-origin: 110px 150px; animation: bob 1.1s ease-in-out infinite; }
.listener .eye { transform-box: fill-box; transform-origin: center; animation: blink 4s infinite; }
.listener .smile { animation: grin 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.listener .note { opacity: 0; animation: float 3s ease-in infinite; transform-box: fill-box; }
.listener .note.n2 { animation-delay: .8s; }
.listener .note.n3 { animation-delay: 1.6s; }
.listener .note.n4 { animation-delay: 2.3s; }
.listener .wave { transform-box: fill-box; transform-origin: center; animation: pulse 1.1s ease-in-out infinite; }
.listener .wave.w2 { animation-delay: .25s; }
@keyframes bob { 0%, 100% { transform: rotate(-4deg) translateY(0); } 50% { transform: rotate(4deg) translateY(-3px); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes grin { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(1.12); } }
@keyframes float { 0% { opacity: 0; transform: translate(0, 0) rotate(0) scale(.7); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx, 20px), -90px) rotate(var(--rot, 18deg)) scale(1.1); } }
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.9); } 50% { opacity: .9; transform: scale(1.08); } }
.stages { list-style: none; padding: 0; margin: 14px auto 0; max-width: 320px; text-align: left; display: grid; gap: 10px; }
.stages li { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 15px; transition: color .3s; }
.stages li.on { color: var(--text); font-weight: 500; }
.stages li.ok { color: var(--muted); }
.stages li.err { color: var(--bad); }
.dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 11px; }
.stages li.on .dot { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.stages li.ok .dot { border-color: var(--good); background: var(--good); color: #fff; }
.stages li.err .dot { border-color: var(--bad); background: var(--bad); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.tip { margin-top: 22px; color: var(--muted); font-size: 14px; min-height: 22px; transition: opacity .4s; }

/* result */
.result-head { text-align: center; margin-bottom: 18px; }
.result-head .q { font-size: 26px; }
.result-head .chips { justify-content: center; margin-top: 10px; }
.player { background: var(--tile); border-radius: 22px; padding: 18px 18px 14px; box-shadow: var(--shadow-tile); }
.player-main { display: flex; align-items: center; gap: 14px; }
.play { width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; box-shadow: 0 8px 22px rgba(94, 92, 230, .35); transition: transform .15s; }
.play:active { transform: scale(.94); }
.skip { width: 40px; height: 40px; border-radius: 50%; color: var(--muted); display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.skip:hover { background: var(--accent-soft); color: var(--accent); }
.track { flex: 1; }
.bar-bg { height: 6px; border-radius: 3px; background: var(--line); position: relative; cursor: pointer; }
.bar-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.speeds { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.speeds button { font-size: 13px; padding: 5px 11px; border-radius: 999px; color: var(--muted); }
.speeds button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.tabs { display: flex; justify-content: center; margin: 24px 0 16px; }
.panel { animation: tileIn .4s ease both; }

.ex { background: var(--tile); border-radius: 20px; padding: 20px; margin-bottom: 14px; box-shadow: var(--shadow-tile); }
.ex h3 { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.01em; }
.ex .instr { color: var(--muted); margin: 0 0 14px; font-size: 14.5px; }
.item { padding: 14px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; padding-top: 4px; }
.item .prompt { margin-bottom: 10px; }
.item .num { color: var(--faint); font-weight: 600; margin-right: 6px; font-variant-numeric: tabular-nums; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts.col { flex-direction: column; align-items: stretch; }
.opt { text-align: left; padding: 10px 14px; border-radius: 14px; background: var(--bg); border: 1.5px solid transparent; font-size: 15px; transition: background .2s, border-color .2s; }
.opt:hover { border-color: var(--line); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.gap-input { display: inline-block; width: 150px; padding: 4px 10px; border: 0; border-bottom: 2px solid var(--accent); background: var(--accent-soft); border-radius: 8px 8px 0 0; outline: none; margin: 0 2px; }
.gap-input.right { border-color: var(--good); background: var(--good-soft); }
.gap-input.wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { margin-top: 10px; font-size: 14px; color: var(--muted); padding: 10px 12px; border-radius: 12px; background: var(--bg); animation: tileIn .35s ease both; }
.feedback b { color: var(--text); }
.feedback .quote { display: block; margin-top: 4px; font-style: italic; }
.scorebox { display: flex; align-items: center; gap: 16px; background: var(--tile); border-radius: 20px; padding: 16px 20px; margin-bottom: 14px; box-shadow: var(--shadow-tile); animation: tileIn .4s ease both; }
.ring { width: 64px; height: 64px; flex: none; }
.score-txt { font-size: 18px; font-weight: 600; }
.score-sub { color: var(--muted); font-size: 14px; }

.word { background: var(--tile); border-radius: 18px; padding: 16px 18px; margin-bottom: 10px; box-shadow: var(--shadow-tile); }
.word .w { font-weight: 600; font-size: 17px; }
.word .py { color: var(--accent); margin-left: 6px; }
.word .pos { color: var(--faint); font-size: 13px; margin-left: 6px; }
.word .tr { margin-top: 4px; font-weight: 500; }
.word .def { color: var(--muted); margin-top: 4px; font-size: 14.5px; }
.word .exm { margin-top: 8px; font-size: 14px; font-style: italic; color: var(--muted); border-left: 3px solid var(--accent-soft); padding-left: 10px; }

.transcript { background: var(--tile); border-radius: 20px; padding: 18px 20px; box-shadow: var(--shadow-tile); }
.tline { padding: 7px 0; }
.tline b { color: var(--accent); font-weight: 600; margin-right: 6px; }
.tline.s2 b { color: var(--accent-2); }
.veil { text-align: center; padding: 30px 10px; color: var(--muted); }
.veil .big-emo { font-size: 40px; display: block; margin-bottom: 8px; }

.downloads { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 22px; }
.dl { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px; background: var(--tile); box-shadow: var(--shadow-tile); font-size: 14px; font-weight: 500; text-align: left; }
.dl:hover { background: var(--tile-hover); }
.dl span { font-size: 18px; }
.foot { text-align: center; color: var(--faint); font-size: 12.5px; margin-top: 18px; }
.error-box { background: var(--bad-soft); color: var(--text); border-radius: 16px; padding: 14px 16px; margin-top: 14px; font-size: 14.5px; }
.loading-line { color: var(--muted); text-align: center; padding: 24px; }

/* admin / language sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .25); z-index: 20; animation: fade .25s ease both; }
.sheet { position: fixed; z-index: 21; left: 50%; bottom: 0; transform: translateX(-50%); width: min(560px, 100%); background: var(--card-solid); border-radius: 26px 26px 0 0; padding: 26px 22px 30px; box-shadow: var(--shadow); animation: sheetUp .35s cubic-bezier(.2, .8, .2, 1) both; max-height: 85vh; overflow-y: auto; }
.sheet h2 { margin: 0 0 14px; font-size: 22px; letter-spacing: -0.02em; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.set-row small { display: block; color: var(--muted); font-size: 13px; }
.switch { width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(20px); }
.ok-dot { color: var(--good); font-weight: 600; }
.no-dot { color: var(--bad); font-weight: 600; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translate(-50%, 100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.badge { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.tile.sel .badge { box-shadow: 0 0 0 3px var(--accent-soft); }
@media (max-width: 480px) {
  .player-main { flex-wrap: wrap; justify-content: center; gap: 10px 18px; }
  .player-main .track { order: 5; flex-basis: 100%; }
  .stage { padding: 14px 12px 60px; }
  .result-head .q { font-size: 23px; }
  .downloads { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .player-main > :nth-child(2) { order: 1; }
  .player-main > .play { order: 2; }
  .player-main > :nth-child(4) { order: 3; }
}
.multi { color: var(--muted); font-size: 15px; line-height: 1.55; margin: 4px 0 10px; }
.hint + .tiles, .multi + .hint { margin-top: 0; }
.dl-all { margin-bottom: 10px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.dl em { font-style: normal; }

/* accounts */
.auth-form { display: grid; gap: 10px; }
.auth-form .btn.big { margin-top: 6px; }
.field.bad { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.form-error { background: var(--bad-soft); border-radius: 12px; padding: 10px 14px; font-size: 14.5px; }
.small-hint { margin: -4px 2px 0; color: var(--muted); font-size: 13.5px; }
.tile.rec { position: relative; padding-right: 54px; }
.trash { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; opacity: .45; transition: opacity .2s, background .2s; cursor: pointer; }
.trash:hover { opacity: 1; background: var(--bad-soft); }
.danger { color: var(--bad) !important; }
.danger-bg { background: var(--bad) !important; box-shadow: none !important; }
.small-field { width: 140px; padding: 8px 12px; border-radius: 12px; }
.user-row { flex-wrap: wrap; }
.user-row small { margin-top: 2px; }
.set-row > div:first-child { flex: 1; min-width: 0; }
.set-row .row { flex-wrap: nowrap; }
.seg button { white-space: nowrap; }

/* pinyin (Chinese) */
.py-sub { color: var(--muted); opacity: .85; font-size: .88em; font-style: normal; margin-top: 2px; letter-spacing: .01em; }
.tline .py-sub { margin-left: 0; }
.py-line { display: none; color: var(--muted); opacity: .85; font-size: .86em; margin-top: 3px; font-weight: 400; }
.pinyin-on .py-line { display: block; animation: tileIn .3s ease both; }
.opt .py-line { margin-top: 2px; }
.prompt .py-line { margin-left: 22px; }
.py-toggle::before { content: "拼 "; font-weight: 700; color: var(--accent); }

/* dictionary */
.word { position: relative; }
.word > .mark + div { padding-right: 34px; }
.mark { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--faint); transition: color .2s, background .2s, transform .15s; }
.mark:hover { background: var(--accent-soft); color: var(--accent); }
.mark:active { transform: scale(.9); }
.mark.on { color: var(--accent); }
.word-foot { margin-top: 10px; display: flex; }
.list-chip { font-size: 13px; padding: 4px 11px; box-shadow: none; background: var(--accent-soft); color: var(--accent); }
.list-chip.empty { background: transparent; color: var(--faint); border: 1.5px dashed var(--line); }
.list-chip.empty:hover { color: var(--accent); border-color: var(--accent); }
.group-head { width: 100%; display: flex; align-items: center; gap: 8px; padding: 14px 4px 10px; font-size: 15px; font-weight: 600; color: var(--text); text-align: left; }
.group-head::before { content: "›"; display: inline-block; width: 14px; color: var(--muted); transition: transform .2s; }
.group-head.open::before { transform: rotate(90deg); }
.group-head .count { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 13px; background: var(--line); border-radius: 999px; padding: 1px 9px; }
.veil .big-emo svg { color: var(--faint); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 14px; background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: 14.5px; box-shadow: var(--shadow); animation: toastIn .3s cubic-bezier(.2, .8, .2, 1) both; max-width: calc(100% - 32px); }
.toast button { color: var(--accent); font-weight: 600; filter: brightness(1.3); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }

/* Chinese transcript: characters and pinyin linked word by word */
.tline .zh { font-size: 1.06em; }
.tw { border-radius: 5px; padding: 0 1px; margin: 0 -1px; cursor: default; transition: background .15s, color .15s; }
.tw.hl { background: var(--accent-soft); color: var(--accent); opacity: 1; }
.py-words .tw.hl { font-weight: 500; }

/* Answer marks: green tick, red cross */
.feedback .tick.ok { color: var(--good); }
.feedback .tick.bad { color: var(--bad); }

/* Floating mini player (shown when the main player is scrolled out of view) */
.mini { position: fixed; right: 20px; bottom: 20px; z-index: 25; display: flex; align-items: center; gap: 4px; padding: 6px; background: var(--tile); border-radius: 999px; box-shadow: var(--shadow); animation: miniIn .25s cubic-bezier(.2, .8, .2, 1) both; }
.mini[hidden] { display: none; }
.mini-play { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.mini-play svg { width: 22px; height: 22px; }
.mini-skip { width: 42px; height: 42px; border-radius: 50%; color: var(--muted); font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.mini-skip:hover { background: var(--accent-soft); color: var(--accent); }
@keyframes miniIn { from { opacity: 0; transform: translateY(12px) scale(.95); } }
@media (max-width: 480px) { .mini { right: 16px; bottom: 16px; } }

/* Very narrow screens (folded foldables, small phones) */
@media (max-width: 380px) {
  .card { padding: 24px 16px 18px; }
  .q { font-size: 22px; }
  .tile { padding: 14px 14px; gap: 12px; }
  .bar-right { gap: 0; }
  .icon-btn { width: 34px; height: 34px; }
}

/* Transcript follows the audio: the line being spoken is highlighted; click a line to hear it */
.transcript .tline { border-radius: 12px; margin: 0 -10px; padding: 7px 10px; transition: background .25s; }
.transcript.seekable .tline { cursor: pointer; }
.transcript.seekable .tline:hover { background: var(--tile-hover); }
.transcript .tline.now { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }

/* Our own icons (icons.js). Lines follow the text colour; the one accent detail uses --accent. */
.ico { display: inline-flex; vertical-align: -0.2em; line-height: 1; }
.ico svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.ico .a { fill: var(--accent); stroke: none; }
.ico .as { stroke: var(--accent); }
.ico .f { fill: currentColor; stroke: none; }
.ico .t { stroke-width: 1.3; }
.tile .emo .ico svg { width: 1.15em; height: 1.15em; }
.btn.primary .ico .a, .btn.primary .ico .f { fill: currentColor; }
.btn.primary .ico .as { stroke: currentColor; }
.veil .big-emo .ico { color: var(--faint); }
.veil .big-emo .ico svg { width: 1.1em; height: 1.1em; }
.trash .ico svg { width: 18px; height: 18px; }

/* Breathing space between a question and its choices (when there is no hint line in between) */
.q + .tiles, .q + .field, .q + textarea, .q + .chips { margin-top: 20px; }

/* Welcome screen: centred, short, one clear title */
.welcome { text-align: center; }
.welcome .welcome-mark { width: 60px; height: 60px; margin: 2px auto 16px; border-radius: 20px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 30px; }
.welcome .welcome-mark .ico { vertical-align: 0; }
.welcome .multi { margin: 2px 0 24px; font-size: 14px; }
.welcome .tile { text-align: left; }
.nowrap { white-space: nowrap; }

/* Exercise headers: a small "Exercise 1" tag, the title, and a line that separates them from the questions */
.ex-head { padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.ex-head .ex-tag { display: inline-block; margin: 0 0 8px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.ex-head .instr { margin: 4px 0 0; }
.ex .ex-head + .item { border-top: 0; padding-top: 14px; }

/* Multiple choice: the letter sits in its own small circle, apart from the answer text */
.opt.lettered { display: flex; align-items: center; gap: 12px; }
.opt-letter { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 600; line-height: 1; transition: all .2s; }
.opt-txt { min-width: 0; }
.opt.lettered:hover .opt-letter { border-color: var(--accent); color: var(--accent); }
.opt.sel .opt-letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt.right .opt-letter { background: var(--good); border-color: var(--good); color: #fff; }
.opt.wrong .opt-letter { background: var(--bad); border-color: var(--bad); color: #fff; }

/* Summary lines are buttons: tap one to change that setting */
.summary .sum-row { display: grid; grid-template-columns: auto 1fr 14px; align-items: center; gap: 12px; width: 100%; padding: 12px 14px 12px 16px;
  background: var(--tile); border-radius: 14px; font-size: 15px; text-align: left; border: 1.5px solid transparent; transition: border-color .2s, background .2s; }
.summary .sum-row span:nth-child(2) { font-weight: 600; text-align: right; }
.summary .sum-row span:first-child { color: var(--muted); }
.summary .sum-go { color: var(--faint); display: grid; place-items: center; transform: scaleX(-1); transition: color .2s, transform .2s; }
.summary .sum-row:hover { border-color: var(--accent); }
.summary .sum-row:hover .sum-go { color: var(--accent); transform: scaleX(-1) translateX(-2px); }

/* Back button inside the card (BACK_IN_CARD in app.js) */
.card-back { display: inline-flex; align-items: center; gap: 2px; margin: -6px 0 12px -8px; padding: 5px 10px 5px 4px; border-radius: 999px;
  color: var(--muted); font-size: 14px; font-weight: 500; transition: background .2s, color .2s; }
.card-back:hover { color: var(--text); background: var(--tile); }
.card-back svg { display: block; }

/* Dots logo (LOGO_STYLE in icons.js) */
.logo-mark { display: inline-grid; place-items: center; }
.brand .logo-mark.small { margin-right: 2px; }
.welcome .welcome-mark.dots { width: 120px; height: 120px; margin: -6px auto 6px; background: none; border-radius: 0; }

/* The logo + name in the top bar is a home button: same soft highlight as the round icon buttons, as a pill */
.brand { padding: 6px 12px 6px 8px; margin-left: -8px; border-radius: 999px; transition: background .2s, color .2s; }
.brand:hover, .brand:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }

/* Frosted top bar: see-through at the top of the page; once content scrolls under it, a blurred
   page-coloured background and a hairline (class "scrolled", set in app.js). Spans the full screen width. */
.bar::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 100vw; transform: translateX(-50%); z-index: -1;
  background: color-mix(in srgb, var(--bg) 72%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6);
  border-bottom: 1px solid var(--line); opacity: 0; transition: opacity .25s ease; pointer-events: none; }
.bar.scrolled::before { opacity: 1; }

/* Tokens: price and balance on the summary, the balance in My account */
.price-line { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; margin: 18px 0 12px; color: var(--muted); font-size: 14.5px; }
.price-line span { display: inline-flex; align-items: center; gap: 8px; }
.price-line b, .token-count { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
.price-line b.low { color: var(--bad); }
.btn.primary.big.no-tokens { background: var(--tile); color: var(--muted); box-shadow: none; opacity: 1; font-size: 15px; }
/* Admin on a phone: one more icon in the top bar (the gear), and student rows with three buttons */
.brand { white-space: nowrap; }
@media (max-width: 400px) { .bar { gap: 4px; } .icon-btn { width: 30px; height: 30px; } }
@media (max-width: 520px) { .user-row > div:first-child { flex-basis: 100%; } .user-row > .row { margin-left: auto; } }
