/* Phrazo — frontend typing styles, «бумажный» redesign.
   Source of truth: doc/design/Phrazo Redesign Spec.md + phrazo-redesign.css.
   Theme/font-size toggle via data-* attributes on <html>;
   data-theme ∈ {light, dark} — dark is the same paper under a night lamp
   (token inversion, identical structure). */

:root, html[data-theme="light"] {
  color-scheme: light;

  /* paper tokens */
  --paper:   #f4efe4;
  --paper-2: #ebe4d3;
  --ink:     #1d1b16;
  --pencil:  #4a463c;
  --muted:   #8a8576;
  --accent:  #2f7a4f;
  --warn:    #b04638;
  --hint:    #b88a2c;
  --shadow:  rgba(0,0,0,0.08);
  --dot:     rgba(0,0,0,0.04);
  --dot2:    rgba(0,0,0,0.03);
  --accent-soft: rgba(47,122,79,0.14);
  --warn-soft:   rgba(176,70,56,0.12);
  --hint-soft:   rgba(184,138,44,0.18);

  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --hand: 'Caveat', cursive;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;

  /* legacy aliases: sections not yet restructured keep their selectors but
     pick up the paper palette through these. Remove as sections migrate. */
  --bg:        var(--paper);
  --surface:   var(--paper);
  --surface-2: var(--paper-2);
  --ink-soft:  var(--pencil);
  --line:      var(--ink);
  --line-soft: var(--paper-2);

  --pending:   var(--pencil);
  --current:   var(--ink);
  --correct:   var(--accent);
  --correct-bg:transparent;
  --wrong:     var(--warn);
  --wrong-bg:  var(--warn-soft);
  --fixed:     var(--hint);
  --fixed-bg:  transparent;

  --accent-ink: var(--accent);

  --shadow-card: 3px 3px 0 0 var(--shadow);
  --shadow-pop:  4px 4px 0 0 var(--shadow);

  --radius-card: 0;
  --radius-inner: 0;
  --radius-pill: 999px;

  --heat-0: var(--paper);
  --heat-1: var(--accent-soft);
  --heat-2: color-mix(in oklab, var(--accent) 40%, var(--paper));
  --heat-3: color-mix(in oklab, var(--accent) 66%, var(--paper));
  --heat-4: var(--accent);
  --gold:   var(--hint);

  --phrase-size: clamp(26px, 3.4vw, 38px);
  --phrase-line: 1.5;
}

html[data-fontsize="large"]  { --phrase-size: clamp(30px, 4vw, 44px); }
html[data-fontsize="huge"]   { --phrase-size: clamp(34px, 4.8vw, 52px); }

html[data-theme="dark"] {
  color-scheme: dark;
  --paper:   #221f19;
  --paper-2: #2b2720;
  --ink:     #ece5d2;
  --pencil:  #b5ad9b;
  --muted:   #7d7666;
  --accent:  #63b083;
  --warn:    #d4715f;
  --hint:    #d3a94a;
  --shadow:  rgba(0,0,0,0.45);
  --dot:     rgba(255,255,255,0.05);
  --dot2:    rgba(255,255,255,0.03);
  --accent-soft: rgba(99,176,131,0.16);
  --warn-soft:   rgba(212,113,95,0.16);
  --hint-soft:   rgba(211,169,74,0.2);
}

* { box-sizing: border-box; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  background: var(--paper);
  background-image:
    radial-gradient(var(--dot) 1px, transparent 1px),
    radial-gradient(var(--dot2) 1px, transparent 1px);
  background-size: 22px 22px, 11px 11px;
  background-position: 0 0, 5px 5px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.25s, color 0.25s;
}

/* micro-label: repeating «этикетка» pattern (section captions, card heads) */
.microlabel {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  border-bottom: 1px dashed var(--pencil);
  background: transparent;
  position: relative;
  z-index: 30;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
a.brand { text-decoration: none; }
a.brand:hover .brand-mark { color: var(--accent); }

.brand-mark {
  font-family: var(--hand);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.brand-sub {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* состояние набора фраз на урок — живёт в шапке, видно всегда */
.today-plan {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  flex: 1;
  max-width: 420px;
  font-size: 13px;
}

.today-plan[hidden] { display: none; }

.today-plan-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.today-plan-count {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  color: var(--ink);
}

.today-plan-bar {
  flex: 1;
  height: 5px;
  border: 1px solid var(--ink);
  background: var(--paper);
  overflow: hidden;
}

.today-plan-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ink);
  transition: width 200ms ease;
}

.today-plan-eta {
  font-family: var(--hand);
  font-size: 17px;
  color: var(--pencil);
  flex-shrink: 0;
}

.today-plan-eta[hidden] { display: none; }

.scenario-tabs {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* The class display would beat the UA [hidden] rule — keep the retired
   scenario tabs really hidden (registry stays for a future return). */
.scenario-tabs[hidden] { display: none !important; }

.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  letter-spacing: 0.02em;
}

.tab:hover:not(.tab-disabled) {
  color: var(--ink);
  background: var(--surface-2);
}

.tab.tab-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent-soft);
}

.tab.tab-disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  margin-left: auto;
}

/* topbar pills: compact ink-bordered buttons (spec .pill-btn) */
.topbar-actions .ghost-btn {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 13px;
  line-height: 1.3;
  border-color: var(--ink);
  color: var(--ink);
}

.topbar-actions .ghost-btn:hover { background: var(--paper-2); }

.ghost-btn,
.primary-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14px;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 0;
  cursor: pointer;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.ghost-btn {
  border-color: var(--pencil);
  color: var(--pencil);
}

.ghost-btn:hover {
  background: var(--paper-2);
  border-color: var(--ink);
  color: var(--ink);
}

.primary-btn {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.primary-btn:hover {
  opacity: 0.9;
}

/* class display would beat the UA [hidden] rule */
.ghost-btn[hidden],
.primary-btn[hidden] { display: none !important; }

.ghost-btn[disabled],
.primary-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* hotkey badge inside a button: mono key cap */
.ghost-btn kbd,
.primary-btn kbd {
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid currentColor;
  border-bottom-width: 2px;
  border-radius: 2px;
  padding: 1px 5px;
  opacity: 0.75;
}

/* ---------- auth pill + popover ---------- */

.auth-slot {
  position: relative;
}

.auth-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  min-height: 32px;
  padding: 4px 6px 4px 10px;
  border-radius: 0;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  max-width: 260px;
}

.auth-pill:hover {
  background: var(--paper-2);
}

.auth-pill-av {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--hand);
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.auth-pill-email {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-pill-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.auth-pill-badge[data-plan="guest"] {
  background: var(--line-soft);
  color: var(--muted);
}

.auth-pill-badge[data-plan="trial"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.auth-pill-badge[data-plan="expired_trial"] {
  background: var(--warn-soft);
  color: var(--warn);
}

.auth-pill-badge[data-plan="paid"] {
  background: var(--accent-soft);
  color: var(--accent);
}

/* F1: cold-load shimmer. While viewerStore.isLoaded() === false the pill
   carries data-state="loading" so the rendered email/badge spans are
   replaced with a single non-breaking space — see auth-ui.js renderPill.
   The pill itself is sized to its max-width during loading so a cookied
   refresh (the case F1 protects against) resolves to a real authenticated
   pill of the same width — zero layout shift. The inner spans get a
   subtle animated gradient sourced from the theme palette so the user
   never sees a misleading "Гость" label flash. */
.auth-pill[data-state="loading"] {
  min-width: 260px;
  justify-content: space-between;
}

.auth-pill[data-state="loading"] .auth-pill-email,
.auth-pill[data-state="loading"] .auth-pill-badge {
  min-width: 6ch;
  display: inline-block;
  color: transparent;
  background-image: linear-gradient(
    90deg,
    var(--line-soft) 0%,
    var(--surface-2) 50%,
    var(--line-soft) 100%
  );
  background-size: 200% 100%;
  background-position: 0 0;
  animation: auth-pill-shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
}

.auth-pill[data-state="loading"] .auth-pill-email {
  flex: 1 1 auto;
  max-width: 160px;
}

@keyframes auth-pill-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-pill[data-state="loading"] .auth-pill-email,
  .auth-pill[data-state="loading"] .auth-pill-badge {
    animation: none;
  }
}

.auth-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  /* Widened 25% (260 -> 325) so the auth forms — incl. the new confirm-
     password field + eye toggles — have more breathing room. */
  min-width: 325px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  box-shadow: var(--shadow-pop);
  padding: 16px;
  display: grid;
  gap: 12px;
  z-index: 40;
}

.auth-popover[hidden] { display: none; }

.auth-login,
.auth-account {
  display: grid;
  gap: 10px;
}

/* заголовок формы — микро-ярлык с пунктирным подчёркиванием (как h4
   поповеров в эталоне) */
.auth-login-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--pencil);
}

.auth-login-hint,
.auth-account-plan {
  font-size: 13px;
  color: var(--muted);
}

/* Billing plan picker (billing-ui.js). Buttons reuse primary-btn/ghost-btn;
   this lays the picker out and tones down the offer-acceptance line. */
.auth-billing {
  display: grid;
  gap: 10px;
}
.auth-billing-title {
  font-weight: 600;
}
.auth-billing-plan {
  width: 100%;
}
.auth-billing-offer {
  font-size: 12px;
  color: var(--muted);
}
.auth-billing-offer a {
  color: inherit;
  text-decoration: underline;
}

.auth-login-error {
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px dashed var(--warn);
  border-radius: 0;
  padding: 6px 10px;
}

.auth-input {
  appearance: none;
  font-family: var(--mono);
  font-size: 13px;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 8px 12px;
  background: var(--paper);
  color: var(--ink);
}

.auth-input:focus {
  outline: none;
  background: var(--paper-2);
}

/* Password field with a show/hide "eye" toggle. The input is wrapped in a
   relative container so the eye button sits inside the field's right edge;
   the input gets extra right padding so typed text never slides under it. */
.auth-pwd-field {
  position: relative;
  display: block;
  width: 100%;
}

.auth-pwd-field .auth-input {
  width: 100%;
  box-sizing: border-box;
  padding-right: 40px;
}

.auth-pwd-eye {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
}

.auth-pwd-eye:hover { color: var(--ink); }

.auth-pwd-eye:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* When the password is revealed, tint the eye and overlay a diagonal slash
   so it reads as "hide" (the standard eye / eye-off metaphor). */
.auth-pwd-eye.is-visible { color: var(--accent-ink); }

.auth-pwd-eye.is-visible::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 2px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(-45deg);
  border-radius: 2px;
}

.auth-dev-btn,
.auth-back {
  font-size: 12px;
  min-height: 32px;
}

.auth-upgrade {
  opacity: 0.6;
}

/* шапка аккаунта: аватар-круг + имя + mono-email (spec §5.5) */
.auth-account-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-account-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--hand);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
}

.auth-account-who { min-width: 0; }

.auth-account-who strong {
  display: block;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-account-email {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* строка плана в пунктирной рамке */
.auth-plan-line {
  border: 1px dashed var(--pencil);
  padding: 8px 10px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--pencil);
}

/* ---------- practice slot + popover ---------- */

.practice-slot {
  position: relative;
}

#practiceBtn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.practice-summary {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  border-left: 1px dashed var(--pencil);
  padding-left: 8px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.practice-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 280px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  box-shadow: var(--shadow-pop);
  padding: 14px;
  display: grid;
  gap: 10px;
  z-index: 40;
}

.practice-panel[hidden] { display: none; }

.practice-panel select {
  appearance: auto;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 5px 8px;
  min-width: 140px;
}

/* ---------- phrase meta row ---------- */

.phrase-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.phrase-meta[hidden] { display: none; }

/* пунктирные «карандашные» капсулы; цветом выделяем только смысл */
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--pencil);
  border: 1px dashed var(--pencil);
}

.meta-chip[data-kind="audio-live"] {
  color: var(--accent);
  border-color: var(--accent);
}

.meta-chip[data-kind="audio-tts"] {
  color: var(--muted);
  border-color: var(--muted);
}

.phrase-source {
  font-size: 12px;
  color: var(--muted);
}

.phrase-source[hidden] { display: none; }

.phrase-source a {
  color: var(--accent-ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-ink);
}

.phrase-source a:hover { border-bottom-style: solid; }

/* ---------- settings popover ---------- */

.settings-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 260px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  box-shadow: var(--shadow-pop);
  padding: 16px 18px;
  display: grid;
  gap: 10px;
  z-index: 40;
}

.settings-panel[hidden] { display: none; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink);
}

.settings-row select {
  appearance: auto;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 5px 8px;
  min-width: 130px;
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--ink);
  user-select: none;
  cursor: pointer;
  padding: 2px 0;
}

.settings-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.settings-row[hidden] { display: none; }

/* ссылка «расширенные ▸» — карандашный пунктир, как help-link */
.settings-advanced-toggle {
  align-self: start;
  justify-self: start;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 1px dashed var(--pencil);
  cursor: pointer;
  padding: 0 0 1px;
  letter-spacing: 0.5px;
  width: fit-content;
}

.settings-advanced-toggle:hover,
.settings-advanced-toggle.is-open {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ---------- shell ---------- */

/* Одна бумага на всю страницу: рабочая зона слева, aside «Сегодня» справа,
   между ними карандашный пунктир. Никаких внутренних карточек-коробок. */
.shell {
  flex: 1;
  width: min(1280px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 304px;
  align-items: stretch;
}

html[data-motivation="off"] .shell {
  grid-template-columns: minmax(0, 1fr);
}

html[data-motivation="off"] .motivation { display: none; }

/* ---------- stage ---------- */

.stage {
  background: transparent;
  border: 0;
  border-right: 1px dashed var(--pencil);
  border-radius: 0;
  box-shadow: none;
  padding: 30px 36px 34px;
  display: grid;
  gap: 20px;
  min-width: 0;
  align-content: start;
  position: relative;
}

html[data-motivation="off"] .stage { border-right: 0; }

/* ---------- phrase ---------- */

.phrase-frame {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 12px 2px 4px;
  min-height: 130px;
  display: flex;
  align-items: center;
  position: relative;
}

.phrase {
  font-family: var(--mono);
  font-size: var(--phrase-size);
  line-height: var(--phrase-line);
  font-weight: 400;
  letter-spacing: 1px;
  word-spacing: 4px;
  color: var(--pencil);
  text-align: left;
  word-break: normal;
  overflow-wrap: break-word;
  width: 100%;
}

.char {
  color: var(--pencil);
  border-radius: 0;
  padding: 0 1px;
  transition: color 0.06s, background 0.06s, box-shadow 0.06s;
}

/* Палитра состояний (spec §5.1 п.2): зелёный = верно, красный на мягкой
   подложке = ошибка, мигающее чернильное подчёркивание = каретка. */
.char.correct {
  color: var(--accent);
  background: transparent;
}

/* fixed = «было неверно, теперь верно»: зелёный с охряным пунктиром снизу —
   честная пометка исправления, не крик. */
.char.fixed {
  color: var(--accent);
  background: transparent;
  box-shadow: inset 0 -2px 0 var(--hint);
}

.char.wrong {
  color: var(--warn);
  background: var(--warn-soft);
}

.char.skipped {
  color: var(--muted);
  text-decoration: line-through;
}

.char.current {
  color: var(--ink);
  background: transparent;
  box-shadow: inset 0 -3px 0 var(--ink);
  animation: caret-blink 1s steps(1) infinite;
}

.char.current.space {
  box-shadow: inset 0 -3px 0 var(--ink);
  min-width: 0.5ch;
}

@keyframes caret-blink {
  50% { box-shadow: inset 0 -3px 0 transparent; }
}

/* охра = подсказка: вспышка на символе после «Подсказка · буква» */
.char.hint-flash {
  color: var(--hint);
  background: var(--hint-soft);
}

/* ---------- перевод: открыт на шаге 1, чип RU ▸ на шагах 2–3 ---------- */

.ru-row { min-height: 24px; }

.ru-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  border: 1px dashed var(--pencil);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--pencil);
  padding: 5px 12px;
  cursor: pointer;
}

.ru-toggle:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.ru-toggle .tri {
  font-size: 10px;
  display: inline-block;
}

.ru-toggle[hidden] { display: none; }

.ru-text {
  font-family: var(--sans);
  font-size: 16px;
  color: var(--pencil);
  line-height: 1.5;
  margin: 0;
}

.ru-toggle:not([hidden]) + .ru-text { margin-top: 10px; }

.ru-row[data-open="false"] .ru-text { display: none; }
.ru-row[data-open="true"] .tri { transform: rotate(90deg); }

/* ---------- progress ---------- */

.progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--ink);
  border-radius: 0;
  transition: width 0.08s linear;
}

/* рукописная подпись «11 / 44 символа» */
.status-hint {
  font-family: var(--hand);
  font-size: 18px;
  color: var(--pencil);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- actions: ровно две кнопки помощи + Пропустить/Далее ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* «Прослушать» — основная кнопка помощи: чернильная рамка, не pencil */
.btn-ink {
  border-color: var(--ink);
  color: var(--ink);
}

.assist-cost {
  font-family: var(--hand);
  font-size: 17px;
  color: var(--muted);
  line-height: 1.2;
  flex: 1;
  min-width: 0;
}

.actions .skip-btn { margin-left: auto; }

/* ---------- итог фразы: карточка с «тогда → сейчас» (spec §5.2) ---------- */

.result-card {
  max-width: 640px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 0 var(--shadow);
  padding: 18px 22px;
}

.result-card[hidden] { display: none; }

.r-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.r-title {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
}

.r-title[data-rating="clean"] { color: var(--accent); }
.r-title[data-rating="good"],
.r-title[data-rating="easy"]  { color: var(--accent); }
.r-title[data-rating="again"] { color: var(--warn); }

.r-xp {
  font-family: var(--hand);
  font-size: 22px;
  color: var(--ink);
}

.r-xp[hidden] { display: none; }

.r-label {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.then-now {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  border: 1px dashed var(--pencil);
  margin-bottom: 12px;
}

/* истории ещё нет — остаётся только колонка «сейчас» */
.then-now[data-has-then="false"] { grid-template-columns: 1fr; }
.then-now[data-has-then="false"] .tcol.then,
.then-now[data-has-then="false"] .tarrow { display: none; }

.then-now .tcol { padding: 12px 16px; }

.then-now .tcol.then {
  background: var(--paper-2);
  border-right: 1px dashed var(--pencil);
}

.then-now .tarrow {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 14px;
  border-right: 1px dashed var(--pencil);
  font-family: var(--hand);
  font-size: 17px;
  color: var(--accent);
  text-align: center;
}

.then-now .twhen {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 19px;
  margin-bottom: 8px;
  display: block;
  color: var(--ink);
}

.then-now .tm {
  display: flex;
  gap: 18px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.then-now .tm b {
  display: block;
  font-size: 20px;
  color: var(--ink);
  font-weight: 600;
  margin-top: 3px;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.then-now .tcol.then .tm b {
  color: var(--pencil);
  font-weight: 500;
}

.r-foot {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--pencil);
  line-height: 1.5;
  margin: 0 0 4px;
}

.r-foot[hidden] { display: none; }

.r-enter {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--pencil);
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--muted);
}

.result-save {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.result-save[data-state="saved"]   { color: var(--accent); }
.result-save[data-state="expired"] { color: var(--warn); }
.result-save[hidden] { display: none; }

/* ---------- микро-фидбек за прошлую фразу ---------- */

.micro-toast {
  position: absolute;
  right: 22px;
  bottom: 18px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 0 var(--shadow);
  padding: 10px 14px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--sans);
  font-size: 13px;
  animation: toast-enter 150ms ease-out;
}

.micro-toast[hidden] { display: none; }

.micro-toast .mt-ok { font-weight: 600; }
.micro-toast .mt-ok[data-kind="ok"]  { color: var(--accent); }
.micro-toast .mt-ok[data-kind="err"] { color: var(--warn); }

.micro-toast .mt-xp {
  font-family: var(--hand);
  font-size: 19px;
  color: var(--ink);
}

.micro-toast .mt-delta {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--pencil);
}

.micro-toast .mt-delta[hidden] { display: none; }

/* ---------- guest nudge ---------- */

.guest-nudge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--paper);
  border: 1.5px dashed var(--pencil);
  border-radius: 0;
  max-width: 640px;
}

.guest-nudge[hidden] { display: none; }

.guest-nudge-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 200px;
}

.guest-nudge-text strong {
  font-size: 14px;
  color: var(--ink);
}

.guest-nudge-text span {
  font-size: 13px;
  color: var(--muted);
}

.guest-nudge-actions {
  display: flex;
  gap: 8px;
}

/* ---------- aside «Сегодня» (spec §5.1) ---------- */

.motivation {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 22px;
  display: grid;
  gap: 14px;
  align-content: start;
  transition: opacity 0.3s;
}

/* во время печати панель гаснет; микро-тост скрывается */
.shell[data-typing="true"] .motivation {
  opacity: 0.35;
  filter: saturate(0.4);
}

.shell[data-typing="true"] .micro-toast { display: none; }

.aside-title {
  margin: 0 0 2px;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
}

.goal-card {
  border: 1.5px solid var(--ink);
  background: var(--paper);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.goal-ring {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  background: conic-gradient(var(--accent) 0 0%, var(--paper-2) 0% 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.goal-ring::after {
  content: '';
  position: absolute;
  inset: 6px;
  background: var(--paper);
  border-radius: 50%;
}

.goal-ring span {
  position: relative;
  z-index: 1;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
}

.goal-text strong {
  display: block;
  font-family: var(--hand);
  font-size: 26px;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--ink);
}

.goal-text span {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--pencil);
}

/* фазы сессии: Разминка → Ядро → Финал (тем же языком, что степпер) */
.session-phases {
  border: 1.5px solid var(--ink);
}

.session-phases[hidden] { display: none; }

.session-phases .ph {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px dashed var(--pencil);
}

.session-phases .ph:last-child { border-bottom: 0; }

.session-phases .ph .nm {
  font-size: 13px;
  font-weight: 500;
  color: var(--pencil);
}

.session-phases .ph .ct {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.session-phases .ph[data-status="done"] .nm::after {
  content: ' ✓';
  color: var(--accent);
}

.session-phases .ph[data-status="current"] { background: var(--paper-2); }

.session-phases .ph[data-status="current"] .nm {
  color: var(--ink);
  font-weight: 600;
}

.session-phases .ph[data-status="locked"] .nm {
  color: var(--muted);
  font-weight: 400;
}

.mot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border: 1.5px solid var(--ink);
  background: var(--paper);
}

.mot-cell {
  padding: 10px;
  border-right: 1px dashed var(--pencil);
  min-width: 0;
}

.mot-cell:last-child { border-right: 0; }

.mot-cell .lab {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.mot-cell .val {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  line-height: 1;
}

.heatmap-block { min-width: 0; }

.heatmap-head {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.reward-line {
  border-top: 1px dashed var(--pencil);
  padding-top: 10px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--pencil);
}

.reward-line b {
  font-family: var(--hand);
  font-size: 18px;
  color: var(--ink);
  font-weight: 700;
}

/* locked (гость / нет прав): цифры приглушены */
.motivation[data-locked="yes"] .mot-cell .val,
.motivation[data-locked="yes"] .goal-text strong,
.motivation[data-locked="yes"] .reward-line b {
  color: var(--muted);
  font-style: italic;
}

/* ---------- hotkeys footer ---------- */

.hotkeys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 22px;
  padding: 12px 28px 18px;
  border-top: 1px dashed var(--pencil);
  font-size: 12px;
  color: var(--pencil);
  letter-spacing: 0.02em;
}

html[data-hotkeys="off"] .hotkeys { display: none; }

.hotkeys kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--pencil);
  border-bottom-width: 2px;
  background: var(--paper);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink);
  margin-right: 5px;
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  :root { --phrase-size: 28px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .stage { border-right: 0; }
  .motivation { border-top: 1px dashed var(--pencil); }
  .dash-grid { grid-template-columns: 1fr; }
  .dashboard-card-wide { grid-column: auto; }
  .dashboard { width: calc(100vw - 32px); }
}

@media (max-width: 720px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
  .stage { padding: 18px; gap: 16px; border-right: 0; }
  .phrase-frame { padding: 12px 2px; min-height: 110px; }
  .progress-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .status-hint { white-space: normal; }
  .actions .skip-btn { margin-left: 0; }
  .assist-cost { display: none; }
  .hotkeys { gap: 10px; padding: 12px 16px 18px; }
}

@media (max-width: 430px) {
  :root { --phrase-size: clamp(22px, 7vw, 32px); }
  .brand-sub { display: none; }
  .topbar { gap: 10px; }
  .topbar-actions .ghost-btn { padding: 0 12px; min-height: 34px; font-size: 13px; }
  .practice-summary { display: none; }
  .stage { padding: 14px; }
  .result-panel { padding: 12px 14px; gap: 10px; }
  .settings-panel,
  .practice-panel { right: 0; left: auto; min-width: 220px; }
}

/* ---------- heatmap (shared by motivation aside and dashboard widget) ---------- */
/* Plan §3.3 referred to existing .heatmap / .heatmap-cell tokens; they were
   missing from this file. Added here so the motivation aside and the dashboard
   heatmap widget render correctly under the same selectors. */

.heatmap {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  margin-top: 6px;
}

.heatmap-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0;
  border: 1px solid var(--pencil);
  background: var(--heat-0);
  display: inline-block;
}

.heatmap-cell[data-level="4"] { border-color: var(--accent); }

.heatmap-cell[data-level="1"] { background: var(--heat-1); }
.heatmap-cell[data-level="2"] { background: var(--heat-2); }
.heatmap-cell[data-level="3"] { background: var(--heat-3); }
.heatmap-cell[data-level="4"] { background: var(--heat-4); }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted);
}

.heatmap-legend .heatmap-cell {
  width: 10px;
  height: 10px;
  aspect-ratio: auto;
}

/* ---------- page switching: trainer vs dashboard ---------- */

html[data-page="dashboard"] .shell { display: none; }
html[data-page="trainer"]   .dashboard { display: none; }

/* "Этапы обучения" is a third full-screen page, toggled the same way:
   when it is active the trainer and dashboard are hidden, and on every
   other page the help screen is hidden. */
html[data-page="help"]      .shell,
html[data-page="help"]      .dashboard { display: none; }
html[data-page="trainer"]   .help-screen,
html[data-page="dashboard"] .help-screen { display: none; }

/* [hidden] overrides for blocks that set their own display.
   CSS class rules win over the UA `[hidden]` selector by source order,
   so authored `display: grid/flex` would otherwise show these elements
   even with the `hidden` attribute present. */
.stage-route[hidden],
.dashboard[hidden],
.dashboard-card[hidden],
.help-screen[hidden] {
  display: none !important;
}

/* ---------- "Этапы обучения" help screen (spec §5.3) ---------- */

.help-screen {
  flex: 1;
  width: min(880px, calc(100vw - 32px));
  margin: 0 auto;
  display: block;
}

.help-inner {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 36px clamp(16px, 4vw, 40px) 48px;
}

.help-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}

.help-title {
  margin: 0;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 44px;
  line-height: 1;
  color: var(--ink);
}

.help-back {
  flex: none;
  white-space: nowrap;
}

.help-intro {
  margin: 10px 0 28px;
  color: var(--pencil);
  font-size: 15px;
  line-height: 1.55;
  max-width: 620px;
}

.help-stage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
  border-top: 2px solid var(--ink);
}

.help-stage {
  display: grid;
  grid-template-columns: 96px 1fr 150px;
  gap: 22px;
  padding: 22px 4px 24px;
  border-bottom: 1.5px solid var(--ink);
  background: transparent;
  border-radius: 0;
}

.help-stage .hnum {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 56px;
  line-height: 0.9;
  color: var(--ink);
}

.help-stage .hnum small {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 8px;
}

.help-stage-text {
  display: grid;
  gap: 0;
  min-width: 0;
  align-content: start;
}

.help-stage-name {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 18px;
  margin: 0 0 6px;
  color: var(--ink);
}

.help-stage-desc {
  color: var(--pencil);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0 0 12px;
}

.stage-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stage-chip {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px dashed var(--pencil);
  border-radius: var(--radius-pill);
  color: var(--pencil);
  padding: 3px 9px;
}

.help-stage .htime { text-align: right; }

.help-stage .htime .t {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 26px;
  color: var(--ink);
}

.help-stage .htime .d {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.help-foot {
  margin-top: 20px;
  padding: 14px 18px;
  border: 1.5px dashed var(--pencil);
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--pencil);
  line-height: 1.55;
}

.help-foot .hand {
  font-family: var(--hand);
  font-size: 19px;
  color: var(--accent);
}

@media (max-width: 560px) {
  .help-stage { grid-template-columns: 64px 1fr; }
  .help-stage .htime { grid-column: 2; text-align: left; }
}

/* ---------- dashboard (spec §5.4) ---------- */

.dashboard {
  flex: 1;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
  display: block;
}

.dash-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
}

.dash-title {
  margin: 0;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 38px;
  line-height: 1;
  color: var(--ink);
}

.dash-back { margin-left: auto; }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  align-items: stretch;
}

.dashboard-card {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  box-shadow: 3px 3px 0 0 var(--shadow);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dashboard-card-wide { grid-column: span 2; }

.dashboard-card-title {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--pencil);
}

.dashboard-card-stats {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.dashboard-card-stats > div {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  min-width: 56px;
}

.dashboard-card-stats span {
  font-size: 12px;
  font-weight: 400;
  color: var(--pencil);
}

.dashboard-card-stats strong {
  font-family: var(--hand);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}

.dashboard-card-foot {
  margin: auto 0 0;
  padding-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.dashboard-card-count {
  margin: 0 0 10px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.dashboard-card-count strong {
  font-family: var(--hand);
  font-size: 30px;
  font-weight: 700;
}

.dashboard-card-count span {
  font-size: 12.5px;
  color: var(--pencil);
}

.memory-curve {
  width: 100%;
  height: 110px;
  color: var(--accent);
  display: block;
}

.dashboard-cefr-mini {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.dashboard-cefr-mini li {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--paper);
  border: 1px dashed var(--pencil);
  border-radius: var(--radius-pill);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pencil);
  font-variant-numeric: tabular-nums;
}

.dashboard-cefr-mini .cefr-label { font-weight: 600; }

.dashboard-cefr-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.dashboard-cefr-list li {
  display: grid;
  grid-template-columns: 32px 1fr 36px;
  align-items: center;
  gap: 10px;
}

.dashboard-cefr-list .cefr-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
}

.cefr-bar {
  height: 9px;
  border: 1px solid var(--ink);
  background: var(--paper);
  border-radius: 0;
  overflow: hidden;
}

.cefr-fill {
  height: 100%;
  width: 0%;
  background: var(--ink);
  transition: width 0.15s ease-out;
}

.dashboard-cefr-list li strong {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 400;
  color: var(--pencil);
  text-align: right;
}

.dashboard-repair-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}

.dashboard-repair-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--pencil);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--pencil);
}

.dashboard-repair-list li .repair-key {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-repair-list li .repair-reason {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10px;
  color: var(--warn);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.dashboard-card [data-action="open-repair"] {
  align-self: flex-start;
  margin-top: auto;
}

/* ---------- степпер фразы: 3 видимых шага (spec §4 «Степпер») ---------- */

.stage-route {
  display: grid;
  gap: 8px;
}

.stage-route-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.stage-route-caption {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.stage-route-help-link {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 1px dashed var(--pencil);
  cursor: pointer;
  padding: 0 0 1px;
  letter-spacing: 0.5px;
}

.stage-route-help-link:hover,
.stage-route-help-link:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--ink);
  outline: none;
}

.stage-route-meet {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--pencil);
}

.stage-route-meet b {
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stage-route-meet[hidden] { display: none; }

.step-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
}

.step-item {
  position: relative;
  padding: 12px 14px 14px;
  border-right: 1px dashed var(--pencil);
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--paper);
}

.step-item:last-child { border-right: 0; }

.step-num {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.step-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--pencil);
  line-height: 1.2;
}

.step-sub {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--muted);
}

.step-item[data-status="done"] .step-num::after {
  content: ' ✓';
  color: var(--accent);
}

.step-item[data-status="current"] { background: var(--paper-2); }

.step-item[data-status="current"]::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 3px;
  background: var(--ink);
}

.step-item[data-status="current"] .step-name {
  color: var(--ink);
  font-weight: 600;
}

.step-item[data-status="current"] .step-num { color: var(--ink); }

.step-item[data-status="locked"] .step-name { color: var(--muted); }

.step-item[data-status="locked"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg,
    transparent, transparent 4px, var(--dot) 4px, var(--dot) 6px);
  pointer-events: none;
}

/* ---------- responsive overrides for new blocks ---------- */

@media (max-width: 720px) {
  .step-item .step-sub { display: none; }
  .stage-route-meet { display: none; }
  .dashboard { width: calc(100vw - 20px); gap: 12px; }
  .dashboard-card { padding: 14px; }
}

/* ---------- phrase training settings (mode block in settings popover) ----- */

.phrase-training-settings {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.phrase-training-settings[hidden] { display: none; }

.phrase-training-settings-title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.phrase-training-settings-subtitle {
  margin: 6px 0 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.phrase-training-settings input[type="number"] {
  appearance: none;
  font: inherit;
  font-size: 13px;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  min-width: 84px;
  text-align: right;
}

.phrase-training-settings input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

.phrase-training-settings input[disabled],
.phrase-training-settings select[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.phrase-training-settings .settings-check input[disabled] + span {
  opacity: 0.7;
  cursor: not-allowed;
}

.auth-register-sent {
  margin-top: 4px;
  color: var(--ink-soft);
}
.auth-register-password-hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

/* Full-screen overlay for /?verify=<token> landings. Z-index higher than
   any popover so it always wins, but a single <div hidden> root keeps the
   DOM cost zero when there is no deep-link. */
.auth-pages-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-pages-overlay[hidden] { display: none; }
.auth-pages-card {
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 0;
  box-shadow: 5px 5px 0 0 var(--shadow);
  padding: 28px 32px;
  min-width: 320px;
  max-width: 480px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-pages-title {
  margin: 0;
  font-family: var(--hand);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}
.auth-pages-message {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}
.auth-pages-close {
  align-self: flex-end;
  margin-top: 6px;
}

/* F8: toast/snackbar stack. The slot #toastStack already lives in
   index.html; the toast.js module appends .toast children as the 401
   interceptor (or future producers) need to surface non-modal messages.
   Positioned fixed bottom-right so it doesn't fight the topbar pill or
   the typing stage. Theme-neutral via existing CSS vars. column-reverse
   keeps newer toasts at the bottom while older ones drift upward. */
.toast-stack {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--paper);
  color: inherit;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 3px 3px 0 0 var(--shadow);
  font-size: 13px;
  max-width: 360px;
  animation: toast-enter 200ms ease-out;
}

.toast-message {
  flex: 1 1 auto;
}

.toast-action {
  appearance: none;
  background: var(--ink);
  color: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.toast-action:hover,
.toast-action:focus-visible {
  opacity: 0.9;
  outline: none;
}

.toast-leaving {
  animation: toast-leave 200ms ease-in forwards;
}

@keyframes toast-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-leave {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast-leaving {
    animation: none;
  }
}

/* Masked chars (partial_hints / cloze / blind stages): placeholder dots that
   reveal as the user types them. */
.char.masked { color: var(--muted); opacity: 0.55; }

/* ---------- итог сессии: «сессия заканчивается на победе» (§5.2) ---------- */

.sessiondone-card {
  max-width: 640px;
  justify-self: center;
  width: 100%;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 5px 5px 0 0 var(--shadow);
  padding: 30px 32px;
  text-align: center;
}

.sessiondone-card[hidden] { display: none; }

.sessiondone-card h2 {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 40px;
  margin: 0 0 6px;
  line-height: 1.05;
  color: var(--ink);
}

.sd-sub {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--pencil);
  margin: 0 0 20px;
}

.sd-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border: 1.5px solid var(--ink);
  margin-bottom: 20px;
}

.sd-stats .c {
  padding: 14px 10px;
  border-right: 1px dashed var(--pencil);
}

.sd-stats .c:last-child { border-right: 0; }

.sd-stats .c .lab {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sd-stats .c .val {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.1;
  color: var(--ink);
}

.sd-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
