/* Layout: terms + weeks of the textbook on the left (a strip on phones), the study column with one big flip card */
:root {
  --bg: #F3F5F9; --surface: #FFFFFF; --surface-2: #E8EDF5; --ink: #0D1B34; --muted: #56647D; --line: #D8DFEA;
  --brand: #02377D; --yellow: #FFC300; --red: #E63946;
  --primary: #02377D; --on-primary: #FFFFFF; --bar-on-primary: rgba(255,255,255,.28);
  --word: #02377D; --back: #02377D; --on-back: #FFFFFF; --back-accent: #FFC300;
  --good: #16865A; --on-good: #FFFFFF; --good-soft: #E2F3EA; --bad: #C92A38; --bad-soft: #FBE7E9;
  --stroke1: #02377D; --focus: #FFC300; --hero: #02377D; --on-hero: #FFFFFF;
  --logo-l: block; --logo-d: none;
  --shadow: 0 1px 2px rgba(2,35,80,.06), 0 10px 28px rgba(2,35,80,.09);
  --font-word: "M PLUS Rounded 1c", "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
  --font-text: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #081429; --surface: #0F1F3D; --surface-2: #172B51; --ink: #E9EFF9; --muted: #9BABC6; --line: #243C66;
    --primary: #FFC300; --on-primary: #071330; --bar-on-primary: rgba(7,19,48,.22);
    --word: #F4F7FD; --back: #1A4C9C; --on-back: #FFFFFF; --back-accent: #FFD34D;
    --good: #3DC58C; --on-good: #06281B; --good-soft: #123A33; --bad: #FF7480; --bad-soft: #3A1A28;
    --stroke1: #FFFFFF; --focus: #FFC300; --hero: #13336B; --on-hero: #FFFFFF;
    --logo-l: none; --logo-d: block;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #081429; --surface: #0F1F3D; --surface-2: #172B51; --ink: #E9EFF9; --muted: #9BABC6; --line: #243C66;
  --primary: #FFC300; --on-primary: #071330; --bar-on-primary: rgba(7,19,48,.22);
  --word: #F4F7FD; --back: #1A4C9C; --on-back: #FFFFFF; --back-accent: #FFD34D;
  --good: #3DC58C; --on-good: #06281B; --good-soft: #123A33; --bad: #FF7480; --bad-soft: #3A1A28;
  --stroke1: #FFFFFF; --focus: #FFC300; --hero: #13336B; --on-hero: #FFFFFF;
  --logo-l: none; --logo-d: block;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-text); font-size: 15px; line-height: 1.5; margin: 0; }
button { font-family: inherit; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.shell {
  max-width: 1160px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 18px 36px;
  display: grid; gap: 20px;
}

/* Header */
.top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 46px; height: 46px; flex: none; }
.logo-l { display: var(--logo-l); }
.logo-d { display: var(--logo-d); }
.top-text { min-width: 0; }
.top-title { font-family: var(--font-word); font-weight: 800; font-size: 24px; line-height: 1.05; color: var(--word); margin: 0; }
.top-title span { color: var(--muted); font-weight: 500; }
.top-sub { color: var(--muted); font-size: 13px; margin: 3px 0 0; }
.total {
  margin-left: auto; font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 520px) { .total { display: none; } .top-title { font-size: 21px; } }

/* Welcome */
.hello { background: var(--hero); color: var(--on-hero); border-radius: 22px; padding: 20px 20px 18px; display: grid; gap: 12px; position: relative; overflow: hidden; }
.hello::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: #FFFFFF; opacity: .07; pointer-events: none; }
.hello h2 { margin: 0; font-family: var(--font-word); font-weight: 800; font-size: 24px; line-height: 1.2; padding-right: 36px; text-wrap: balance; }
.hello p { margin: 0; max-width: 64ch; opacity: .92; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (max-width: 520px) { .steps li { font-size: 13px; padding: 8px 10px; } .hello h2 { font-size: 21px; } }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.steps li { display: flex; gap: 10px; align-items: flex-start; background: rgba(255,255,255,.08); border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.steps b { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--yellow); color: #02377D; display: grid; place-items: center; font-size: 13px; }
.hello-lv { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: relative; z-index: 1; }
.hello-lv[hidden] { display: none; }
.hello-lv span { font-weight: 700; font-size: 13px; opacity: .85; margin-right: 2px; }
.hello-lv button { min-height: 40px; padding: 8px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,.4); background: transparent; color: var(--on-hero); font: 700 14px var(--font-word, inherit); cursor: pointer; }
.hello-lv button[aria-pressed="true"] { background: var(--yellow); border-color: var(--yellow); color: #02377D; }
.hello-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hello .btn-yellow { background: var(--yellow); color: #02377D; }
.hello-x { position: absolute; top: 12px; right: 12px; z-index: 1; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: var(--on-hero); font-size: 18px; cursor: pointer; }

/* Two columns on wide screens */
.layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 920px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); align-items: start; gap: 28px; }
  .side { position: sticky; top: calc(16px + env(safe-area-inset-top, 0px)); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
}
.label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; font-weight: 700; }

/* Terms */
.terms { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.term {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px;
  padding: 7px 2px 6px; cursor: pointer; display: grid; gap: 1px; justify-items: center; min-width: 0;
}
.term-n { font-weight: 700; font-size: 13px; }
.term-name { font-size: 10px; letter-spacing: -.01em; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.term[aria-pressed="true"] .term-name { color: var(--on-primary); opacity: .85; }

/* Weeks */
.weeks {
  position: relative; display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px;
  scroll-snap-type: x proximity; scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.week {
  flex: 0 0 64px; scroll-snap-align: center; display: grid; gap: 5px; justify-items: stretch; align-content: start;
  padding: 9px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  color: var(--ink); text-align: center; cursor: pointer; transition: border-color .15s;
}
.week:hover { border-color: var(--primary); }
.week-num { font-family: var(--font-word); font-weight: 800; font-size: 21px; line-height: 1; }
.week-title { display: none; }
.week-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.week-bar { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.week-bar i { display: block; height: 100%; background: var(--good); border-radius: 2px; }
.week[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.week[aria-pressed="true"] .week-meta { color: var(--on-primary); opacity: .85; }
.week[aria-pressed="true"] .week-bar { background: var(--bar-on-primary); }
.week.is-review .week-num { font-size: 18px; }
@media (min-width: 920px) {
  .weeks { display: grid; gap: 6px; overflow-y: auto; overflow-x: hidden; padding: 0 4px 0 0; min-height: 0; flex: 1; }
  .week { grid-template-columns: 34px minmax(0, 1fr) 44px; align-items: center; text-align: left; gap: 2px 8px; padding: 9px 10px; }
  .week-num { font-size: 17px; grid-row: span 2; text-align: center; }
  .week-title { display: block; font-size: 13px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .week-meta { text-align: right; grid-row: span 2; }
  .week-bar { grid-column: 2; }
}
.side-note { font-size: 12px; color: var(--muted); margin: 12px 0 0; display: none; }
@media (min-width: 920px) { .side-note { display: block; } }

/* Study column */
.study { min-width: 0; display: grid; gap: 16px; }
.study-head { display: grid; gap: 12px; }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.kicker .strokes { transform: translateY(1px); }
.study-head h1 { font-family: var(--font-word); font-weight: 800; color: var(--word); font-size: clamp(26px, 4.2vw, 34px); line-height: 1.1; margin: 0; text-wrap: balance; }
.h1-ru { font-weight: 700; font-size: 17px; margin: 4px 0 0; }
.goal { color: var(--muted); font-size: 14px; margin: 4px 0 0; max-width: 62ch; }
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.study-meta { color: var(--muted); font-size: 13px; margin: 0; font-variant-numeric: tabular-nums; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 2px; }
.tab { border: 0; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(2,35,80,.12); }

/* Progress bar */
.round-bar { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); max-width: 640px; width: 100%; margin: 0 auto; font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 3px; transition: width .25s ease; }

/* Flip card */
.stage { overflow: hidden; padding: 10px 14px 22px; margin: -10px -14px -22px; }
.card-wrap { position: relative; perspective: 1400px; max-width: 640px; margin: 0 auto; touch-action: pan-y; }
.card {
  position: relative; height: clamp(272px, 48vw, 350px); transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.2,.7,.2,1); cursor: pointer; outline: none;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
.card.flipped { transform: rotateY(180deg); }
.card.no-anim { transition: none; }
.card:focus-visible .face { outline: 3px solid var(--focus); outline-offset: 3px; }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 22px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 6px;
  padding: 16px 18px 14px; box-shadow: var(--shadow);
}
.front { background: var(--surface); border: 1px solid var(--line); }
.back { background: var(--back); color: var(--on-back); transform: rotateY(180deg); }
.face-top { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); min-height: 40px; padding-right: 48px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.back .face-top { color: var(--on-back); opacity: .85; }
.strokes { display: inline-flex; gap: 3px; align-items: flex-end; flex: none; }
.strokes i { display: block; width: 4px; height: 14px; border-radius: 2px; transform: rotate(20deg); }
.strokes i:nth-child(1) { background: var(--stroke1); }
.strokes i:nth-child(2) { background: var(--red); }
.strokes i:nth-child(3) { background: var(--yellow); }
.back .strokes i:nth-child(1), .hello .strokes i:nth-child(1) { background: #FFFFFF; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--good-soft); color: var(--good); }
.kind { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.kind-bonus { background: var(--yellow); color: #02377D; }
.kind-plus { background: transparent; border: 1px solid var(--line); }
.word-box { display: grid; place-items: center; align-content: center; gap: 8px; min-height: 0; text-align: center; }
.word {
  font-family: var(--font-word); font-weight: 800; font-size: clamp(28px, 6.4vw, 46px); line-height: 1.15;
  color: var(--word); text-wrap: balance; overflow-wrap: anywhere; margin: 0; padding-inline: 6px;
}
.word[data-len="l"] { font-size: clamp(24px, 5vw, 36px); }
.word[data-len="xl"] { font-size: clamp(20px, 4vw, 28px); }
.word:lang(ru) { font-family: var(--font-text); font-weight: 700; }
.back .word { color: var(--on-back); }
.back .word[data-len] { font-size: clamp(22px, 4.6vw, 34px); }
.back .word[data-len="xl"] { font-size: clamp(19px, 3.6vw, 26px); }
.back-sub { font-family: var(--font-word); font-weight: 500; color: var(--back-accent); font-size: 15px; margin: 0; }
.back-sub:lang(ru) { font-family: var(--font-text); }
.example { margin: 4px 0 0; font-size: 14px; line-height: 1.4; max-width: 46ch; opacity: .92; font-style: italic; text-wrap: balance; }
.example b { font-style: normal; color: var(--back-accent); font-weight: 700; }
.face-foot { font-size: 12px; color: var(--muted); text-align: center; }
.back .face-foot { color: var(--on-back); opacity: .7; }
.speak {
  position: absolute; top: 14px; right: 14px; z-index: 2; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--word);
  display: grid; place-items: center; cursor: pointer;
}
.speak svg { width: 20px; height: 20px; }
.swipe-hint {
  position: absolute; top: 50%; z-index: 3; pointer-events: none; opacity: 0; transition: opacity .12s;
  font-weight: 700; font-size: 16px; padding: 6px 12px; border-radius: 10px; border: 2px solid currentColor; background: var(--surface);
  transform: translateY(-50%) rotate(-8deg);
}
.hint-good { left: 18px; color: var(--good); }
.hint-bad { right: 18px; color: var(--bad); transform: translateY(-50%) rotate(8deg); }
.card-wrap[data-hint="good"] .hint-good, .card-wrap[data-hint="bad"] .hint-bad { opacity: 1; }

/* Buttons */
.answer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 640px; width: 100%; margin: 0 auto; }
.btn {
  font-weight: 700; font-size: 16px; border-radius: 14px; padding: 12px 16px; min-height: 52px;
  border: 2px solid transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.98); }
.btn-bad { background: var(--bad-soft); color: var(--bad); }
.btn-good { background: var(--good); color: var(--on-good); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn:hover { filter: brightness(1.04); }
.kbd { font-size: 12px; font-weight: 600; opacity: .7; border: 1px solid currentColor; border-radius: 5px; padding: 0 5px; line-height: 18px; }
@media (hover: none) { .kbd, .keys { display: none !important; } }

.tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 640px; width: 100%; margin: 0 auto; }
.chip {
  font-weight: 600; font-size: 13px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; gap: 7px; align-items: center;
}
.chip[aria-pressed]::before { content: ""; width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--muted); flex: none; }
.chip[aria-pressed="true"] { border-color: var(--primary); }
.chip[aria-pressed="true"]::before { background: var(--primary); border-color: var(--primary); box-shadow: inset 0 0 0 2.5px var(--surface); }
.chip:disabled { opacity: .45; cursor: default; }
.keys { font-size: 12px; color: var(--muted); text-align: center; margin: 0; }

/* Finish */
.finish { max-width: 640px; width: 100%; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 26px 22px; box-shadow: var(--shadow); display: grid; gap: 6px; justify-items: center; text-align: center; }
.fin-label { margin: 8px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.fin-score { margin: 0; font-family: var(--font-word); font-weight: 800; font-size: 44px; line-height: 1.1; color: var(--word); font-variant-numeric: tabular-nums; }
.fin-text { margin: 0 0 10px; color: var(--muted); }
.fin-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.mistakes { list-style: none; margin: 6px 0 12px; padding: 0; width: 100%; text-align: left; display: grid; gap: 6px; }
.mistakes li { padding: 10px 12px; border-radius: 12px; background: var(--bad-soft); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.mistakes b { font-family: var(--font-word); font-weight: 800; color: var(--ink); }
.mistakes span { color: var(--ink); }

/* Test */
.q-card { max-width: 640px; width: 100%; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 16px 18px 22px; box-shadow: var(--shadow); display: grid; gap: 10px; min-height: 170px; }
.q-card .face-top { padding-right: 0; min-height: 0; }
.q-card .word-box { min-height: 90px; }
.opts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; max-width: 640px; width: 100%; margin: 0 auto; }
@media (min-width: 560px) { .opts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; min-height: 58px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px; cursor: pointer; min-width: 0;
}
.opt > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.opt:lang(en) > span:last-child { font-family: var(--font-word); font-weight: 800; }
.opt:hover:not(:disabled) { border-color: var(--primary); }
.opt-key { flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: 13px; color: var(--muted); }
.opt:disabled { cursor: default; }
.opt.is-right { border-color: var(--good); background: var(--good-soft); }
.opt.is-right .opt-key { background: var(--good); color: var(--on-good); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.is-wrong .opt-key { background: var(--bad); color: var(--surface); }
.opt.is-dim { opacity: .55; }
.test-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; max-width: 640px; width: 100%; margin: 0 auto; min-height: 52px; }

/* List */
.list-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.search {
  flex: 1 1 260px; min-width: 0; font: 500 15px var(--font-text); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
}
.search::placeholder { color: var(--muted); }
.list-note { font-size: 13px; color: var(--muted); }
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
.c-en { width: 40%; }
.c-en b { display: block; font-family: var(--font-word); font-weight: 800; color: var(--word); font-size: 15px; }
.c-en .kind { display: inline-block; margin-top: 4px; font-size: 10px; padding: 2px 7px; }
.c-ru small { display: block; color: var(--muted); font-size: 12.5px; font-style: italic; margin-top: 3px; }
.c-l { width: 48px; color: var(--muted); font-variant-numeric: tabular-nums; display: none; }
.show-week .c-l { display: table-cell; }
.c-k { width: 54px; text-align: center; vertical-align: middle; }
.kbtn { width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface); color: var(--on-good); cursor: pointer; font-weight: 800; font-size: 15px; line-height: 1; }
.kbtn[aria-pressed="true"] { background: var(--good); border-color: var(--good); }
.reset { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 13px; }

.foot { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; justify-content: center; padding-top: 8px; text-align: center; }
.foot b { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .card, .bar i, .week, .btn { transition: none !important; }
}

/* ---------- v2: code gate, today panel, three answers ---------- */
:root { --mid: #8A5A00; --mid-soft: #FFF1CC; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --mid: #FFD34D; --mid-soft: #3A3217; } }
:root[data-theme="dark"] { --mid: #FFD34D; --mid-soft: #3A3217; }
html { -webkit-text-size-adjust: 100%; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
img { max-width: 100%; }

.screen { min-height: 60vh; display: grid; place-items: center; }
.gate { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 26px 22px; display: grid; gap: 14px; }
.gate h1 { margin: 0; font-family: var(--font-word); font-weight: 800; font-size: 28px; line-height: 1.1; color: var(--word); }
.gate p { margin: 0; color: var(--muted); }
.gate form { display: grid; gap: 10px; }
.code-input { font: 700 22px var(--font-word); letter-spacing: .08em; text-transform: uppercase; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 14px; padding: 13px 14px; width: 100%; min-width: 0; }
.code-input:focus { border-color: var(--primary); outline: none; }
.gate-err { color: var(--bad); font-weight: 600; font-size: 14px; }
.cta { display: grid; gap: 8px; padding: 14px; border-radius: 16px; background: var(--surface-2); font-size: 14px; }
.cta a { justify-self: start; font-weight: 700; color: var(--ink); }
.gate .link-btn { justify-self: start; }
.loading { color: var(--muted); font-weight: 600; display: flex; gap: 10px; align-items: center; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.today { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 16px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; box-shadow: var(--shadow); }
.today-main { display: grid; gap: 2px; min-width: 0; flex: 1 1 260px; }
.today-title { font-weight: 700; font-size: 17px; }
.today-sub { color: var(--muted); font-size: 13px; }
.today-nums { display: flex; gap: 8px; flex-wrap: wrap; }
.num { display: grid; justify-items: center; min-width: 74px; padding: 8px 10px; border-radius: 14px; background: var(--surface-2); }
.num b { font-family: var(--font-word); font-weight: 800; font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.num span { font-size: 11px; color: var(--muted); font-weight: 600; }
.today .btn { min-height: 48px; }
.today.is-done .today-title { color: var(--good); }

.answer-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.answer-row .btn { flex-direction: column; gap: 2px; padding: 9px 8px; min-height: 60px; line-height: 1.15; }
.btn-mid { background: var(--mid-soft); color: var(--mid); }
.ivl { font-size: 12px; font-weight: 600; opacity: .8; }
.answer-row .kbd { display: none; }
@media (max-width: 420px) { .answer-row .btn { font-size: 15px; padding: 9px 4px; } }

.st { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; display: inline-block; }
.st-new { background: var(--surface-2); color: var(--muted); }
.st-learn { background: var(--mid-soft); color: var(--mid); }
.st-done { background: var(--good-soft); color: var(--good); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .st-done { color: #146C2E; } }
:root[data-theme="light"] .st-done { color: #146C2E; }
.c-st { width: 104px; vertical-align: middle; }
.c-st small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.sync { font-size: 12px; color: var(--muted); }

/* transcription */
.ipa { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Arial Unicode MS", sans-serif; font-size: 16px; color: var(--muted); letter-spacing: .01em; }
.ipa:empty { display: none; }
.back .ipa { color: var(--on-back); opacity: .8; font-size: 14px; }
.ipa-back { margin-top: -4px; }
.ipa-hint { margin: 0; text-align: center; font-size: 13px; }
.ipa-hint a { color: var(--muted); text-underline-offset: 3px; }
.c-en .ipa-l { display: block; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; font-size: 12.5px; color: var(--muted); margin-top: 2px; font-weight: 400; }

/* language switch */
.langs { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; flex: none; }
.langs button { border: 0; background: transparent; font: 700 12px var(--font-text); color: var(--muted); padding: 6px 8px; border-radius: 9px; cursor: pointer; min-width: 40px; min-height: 40px; }
.langs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(2,35,80,.12); }
.top .total { margin-left: auto; }
.top .langs { margin-left: auto; }
/* на телефоне: сверху «‹ Кабинет» и языки, под ними название — иначе всё сжимается в одну строку */
@media (max-width: 600px) { .top { flex-wrap: wrap; row-gap: 10px; } .top .top-text { order: 2; flex-basis: 100%; } .top .langs, .top .total + .langs { margin-left: auto; } }
.top .total:not([hidden]) + .langs { margin-left: 10px; }
