/* Оформление «Пульт»: светлое, приборное. Токены — из варианта A макета docs/design/mockups.html.
   Шрифт: 4 размера (13/16/20/56) и 2 начертания (400/600). Отступы кратны 4 px. */
:root {
  color-scheme: light;
  --bg: #EEF1F5;
  --fg: #14213D;
  --muted: #56627A;
  --line: #CBD2DE;
  --control: #78849A;      /* границы полей и кнопок, уровень: 3,3:1 к фону */
  --card: #FFFFFF;
  --accent: #0B6E55;
  --on-accent: #FFFFFF;
  --warn: #A24A00;
  --track: #D8DEE8;
  --track-fg: #3D4960;
  --done: #B9D8CD;
  --done-fg: #0A4A39;
  --step-bg: #E2EFEA;      /* фон шага схемы в расшифровке */
  --radius: 10px;
  --radius-s: 6px;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-s: 13px;
  --fs-m: 16px;
  --fs-l: 20px;
  --fs-xl: 56px;
  --fw-regular: 400;
  --fw-bold: 600;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--fw-regular) var(--fs-m)/1.5 var(--font);
}

button, input, select, textarea { font: inherit; color: inherit; }

[hidden] { display: none !important; }

b, strong { font-weight: var(--fw-bold); }

.num { font-variant-numeric: tabular-nums; }

/* ---------- каркас экрана ---------- */
.screen {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: max(var(--gutter), env(safe-area-inset-top));
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.screen > .grow { flex: 1; }

/* Экран без панели действий: отступ под системную полосу телефона.
   С панелью отступ даёт сама панель (она в потоке, закреплена внизу через sticky). */
.screen:not(:has(> .actions)) { padding-bottom: max(var(--gutter), env(safe-area-inset-bottom)); }

/* Главные кнопки — внизу экрана, в нижней трети. */
.actions {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
  background: var(--bg);
}

.row { display: flex; gap: 8px; }
.row > * { flex: 1 1 0; min-width: 0; }   /* кнопки в ряду — равной ширины */

.eyebrow {
  font-size: var(--fs-s);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

h1.eyebrow { margin: 0; font-weight: var(--fw-bold); }
.title { font-size: var(--fs-l); line-height: 1.3; font-weight: var(--fw-bold); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-s); }
.warn { color: var(--warn); }
.text { margin: 0; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card.attention { border: 1.5px solid var(--warn); }

/* ---------- кнопки ---------- */
.btn {
  min-height: 48px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--control);
  white-space: nowrap;
  background: transparent;
  color: var(--fg);
  font-weight: var(--fw-bold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--card); }
.btn:active { background: var(--track); }
.btn.main { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.main:hover { background: #095D48; border-color: #095D48; }
.btn.main:active { background: #074A3A; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; flex: none; }

.link-btn {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: var(--fw-bold);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.link-btn svg { width: 16px; height: 16px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- поля ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: var(--fs-s); color: var(--muted); }

.select, .input {
  min-height: 48px;
  width: 100%;
  padding: 0 12px;
  border: 1.5px solid var(--control);
  border-radius: var(--radius);
  background: var(--card);
}
.input { padding: 12px; resize: vertical; line-height: 1.4; }

/* Переключатель из нескольких вариантов: радиокнопки, оформленные плитками. */
.seg { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.seg legend { padding: 0; margin-bottom: 4px; font-size: var(--fs-s); color: var(--muted); }
.seg .opts { display: flex; gap: 4px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.seg label span {
  min-height: 48px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  border-radius: var(--radius-s);
  background: var(--track);
  color: var(--track-fg);
  font-weight: var(--fw-bold);
  cursor: pointer;
}
.seg input:checked + span { background: var(--accent); color: var(--on-accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Неброская строка о внешней модели на главной (до «Понятно»). */
.notice { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.notice .link-btn { flex: none; }

/* ---------- тема и шпаргалка ---------- */
.topic { font-size: var(--fs-l); line-height: 1.3; font-weight: var(--fw-bold); margin: 0; overflow-wrap: anywhere; }

.cheat { background: var(--card); border-radius: var(--radius); }
.cheat summary {
  min-height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-weight: var(--fw-bold);
  list-style: none;
}
.cheat summary::-webkit-details-marker { display: none; }
.cheat summary svg { width: 16px; height: 16px; transition: transform .12s; }
.cheat[open] summary svg { transform: rotate(180deg); }
.cheat ol { margin: 0; padding: 0 16px 16px; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.plan-step { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; }
.plan-step b { font-weight: var(--fw-bold); }
.plan-step .sec { color: var(--muted); }
.plan-step .starter { grid-column: 1 / -1; color: var(--muted); }

/* ---------- запись ---------- */
.timer { font-size: var(--fs-xl); line-height: 1; font-weight: var(--fw-bold); letter-spacing: -.02em; }
.of { color: var(--muted); }

.steps { display: grid; gap: 4px; }
.steps div {
  min-width: 0;
  height: 36px;
  padding: 0 4px;
  border-radius: var(--radius-s);
  background: var(--track);
  color: var(--track-fg);
  font-size: var(--fs-s);
  font-weight: var(--fw-bold);
  line-height: 36px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.steps .done { background: var(--done); color: var(--done-fg); }
.steps .now { background: var(--accent); color: var(--on-accent); }

.cue { background: var(--card); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.cue b { font-weight: var(--fw-bold); }
.cue q { quotes: "«" "»"; }

.lvl { display: flex; gap: 4px; align-items: flex-end; height: 28px; }
.lvl i { flex: 1; min-height: 2px; background: var(--control); border-radius: 2px; }

.progress { height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.progress i { display: block; height: 100%; width: 40%; background: var(--accent); border-radius: 2px; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* ---------- навигация ---------- */
.nav {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: max(8px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
}
.nav a {
  flex: 1;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-s);
  color: var(--track-fg);
  font-size: var(--fs-s);
  font-weight: var(--fw-bold);
  text-decoration: none;
}
.nav a:hover { background: var(--card); }
.nav a[aria-current="page"] { background: var(--track); color: var(--fg); }
.nav + .screen { min-height: calc(100dvh - 52px); padding-top: 12px; }

/* ---------- общие для разбора, истории, тем ---------- */
.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.strong { font-weight: var(--fw-bold); }
.block { display: flex; flex-direction: column; gap: 8px; }
.block > h2 { margin: 0; font-weight: var(--fw-regular); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.note { background: var(--bg); border-radius: var(--radius-s); padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }

/* ---------- разбор ---------- */
.card.fix { border: 1.5px solid var(--accent); }
.fix-what { margin: 0; font-size: var(--fs-l); line-height: 1.3; font-weight: var(--fw-bold); }
.quote { color: var(--muted); quotes: "«" "»"; }
.quote-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.quote-btn svg { width: 16px; height: 16px; flex: none; margin-top: 4px; color: var(--accent); }
.quote-btn:hover .quote { color: var(--fg); }

.tl { position: relative; height: 28px; background: var(--track); border-radius: var(--radius-s); overflow: hidden; }
.tl span {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: var(--fs-s);
  font-weight: var(--fw-bold);
  color: var(--on-accent);
  background: var(--accent);
  border-left: 1px solid var(--card);
}
.tl .weak { background: var(--warn); }
.steps-list > li { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.step-head { display: flex; gap: 8px; align-items: center; }
.badge { font-size: var(--fs-s); font-weight: var(--fw-bold); padding: 0 8px; border-radius: var(--radius-s); background: var(--track); color: var(--track-fg); }
.badge.full { background: var(--done); color: var(--done-fg); }
.badge.weak { color: var(--warn); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi.wide { grid-column: 1 / -1; }
.kpi .v { font-size: var(--fs-l); line-height: 1.2; font-weight: var(--fw-bold); }
.kpi .d { font-size: var(--fs-s); font-weight: var(--fw-bold); }
.kpi .better { color: var(--accent); }
.kpi .worse { color: var(--warn); }
.kpi .same { color: var(--muted); }
.tally { gap: 0; }
.band { position: relative; height: 8px; margin: 4px 0; border-radius: 4px; background: var(--track); }
.band .zone { position: absolute; top: 0; bottom: 0; background: var(--done); border-radius: 4px; }
.band b { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; border-radius: 2px; background: var(--fg); }

.cmp { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; font-size: var(--fs-s); }
.cmp th, .cmp td { padding: 8px; text-align: right; border-bottom: 1px solid var(--line); }
.cmp th[scope="row"], .cmp thead th:first-child { text-align: left; font-weight: var(--fw-regular); color: var(--muted); }
.cmp thead th { font-weight: var(--fw-bold); }
.cmp tr:last-child > * { border-bottom: 0; }

.player { width: 100%; }
.transcript { margin: 0; line-height: 1.9; overflow-wrap: anywhere; }
.transcript .w { cursor: pointer; border-radius: 4px; }
.transcript .w:hover { background: var(--track); }
.m-filler { color: var(--warn); text-decoration: line-through; }
.m-hes { text-decoration: underline wavy var(--warn); text-underline-offset: 4px; }
.m-rep { text-decoration: underline dotted var(--fg); text-underline-offset: 4px; }
.m-filler.m-rep { text-decoration: line-through; }
.m-step { background: var(--step-bg); }
.legend span { padding: 0 4px; border-radius: 4px; }
.steptag {
  display: inline-block;
  margin-right: 4px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--fs-s);
  font-weight: var(--fw-bold);
  line-height: 1.5;
}

.danger { display: flex; flex-direction: column; gap: 8px; }
.link-btn.warn { color: var(--warn); align-self: flex-start; }
.danger-btn { border-color: var(--warn); color: var(--warn); }

/* ---------- история ---------- */
.hist { gap: 8px; }
.hrow {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  background: var(--card);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
}
.hrow:hover { outline: 1.5px solid var(--control); }
.hrow-topic { font-weight: var(--fw-bold); line-height: 1.3; overflow-wrap: anywhere; }
.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- мои темы ---------- */
.mine-row { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; background: var(--card); border-radius: var(--radius); padding: 12px 8px 12px 16px; }
.mine-row > div { min-width: 0; overflow-wrap: anywhere; }
.icon-btn { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: var(--radius-s); background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--track); color: var(--warn); }
.icon-btn svg { width: 16px; height: 16px; }

@media (prefers-reduced-motion: reduce) {
  .progress i { animation: none; width: 100%; opacity: .6; }
  .btn, .cheat summary svg { transition: none; }
}
