/*
 * style.css — оформление тренажёра (агент H).
 *
 * Принцип: это рабочий инструмент, а не витрина. Спокойный тёмный фон,
 * крупная клавиатура по центру, читаемые цифры аппликатуры, минимум движения
 * на экране во время игры.
 *
 * Темы задаются переменными на :root и переопределяются в [data-theme="light"].
 * Внешних ресурсов нет: только системные шрифты.
 */

/* ==================================================================== */
/*  Палитра                                                             */
/* ==================================================================== */

:root {
  --bg: #14161a;
  --bg-soft: #191c22;
  --panel: #1c1f26;
  --panel-2: #232833;
  --line: #2c313c;
  --line-soft: #242833;
  --text: #e8eaee;
  --text-dim: #b6bcc7;
  --muted: #8d95a3;
  --accent: #e0a458;
  --accent-soft: rgba(224, 164, 88, 0.16);
  --accent-text: #14161a;
  --ok: #4ade80;
  --err: #f87171;
  --warn: #fbbf24;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);

  /* Переменные экранной клавиатуры (их читает keyboard.js). */
  --key-white: #f2efe8;
  --key-white-active: #d6cdb9;
  --key-black: #1b1e24;
  --key-black-face: #343943;
  --key-black-active: #454b56;
  --key-black-face-active: #5c636f;
  /* Объём клавиш: блик сверху, затемнение к основанию, торец, тени и блики.
     Плоская заливка читалась как нарисованный прямоугольник. */
  --key-white-hi: #fdfcf8;
  --key-white-mid: #f2efe8;
  --key-white-lo: #d5cebd;
  --key-lip-hi: #ffffff;
  --key-lip-lo: #e6dfd0;
  --key-black-hi: #454b56;
  --key-black-lo: #0d0f13;
  --key-shadow: rgba(0, 0, 0, 0.38);
  --key-gloss: rgba(255, 255, 255, 0.15);
  --key-shade: rgba(0, 0, 0, 0.36);
  --oct-band: rgba(255, 255, 255, 0.035);
  --oct-band-alt: rgba(255, 255, 255, 0.085);
  --oct-label: #8f959f;
  --key-edge: rgba(0, 0, 0, 0.45);
  --key-felt: #7d2d3a;
  --key-label: #8a8f98;
  --key-label-c: #565c66;
  --key-label-solfege: #9aa0aa;
  /* Руки: левая красная, правая зелёная. Оттенки взяты темнее и глуше, чем
     --ok/--err, чтобы подсказка руки не читалась как «верно»/«ошибка»;
     смысл всё равно несут буквы Л/П, а не только цвет. */
  --finger-lh: #cf4038;
  --finger-rh: #0d7c49;
  --finger-text: #ffffff;
  --kb-target: var(--accent);
  --kb-correct: var(--ok);
  --kb-wrong: var(--err);
  /* Фон полосы над клавишами: кольцо вокруг цифры аппликатуры красится в него,
     чтобы кружок не сливался с клавишей. var(--panel) сам меняется по теме. */
  --kb-lane: var(--panel);
  /* Нотный стан. Даже в тёмной теме его держим светлым: ноты везде печатаются
     чёрным по белому, и глаз читает их так быстрее, чем выворотку. */
  --staff-bg: #f4f1ea;
  --staff-line: #3a3f47;
  --staff-ink: #16181d;
  --staff-clef: #16181d;
  --staff-label: #5d636c;
  --staff-current: #b4762c;
  --staff-correct: #0d7c49;
  --staff-wrong: #c0322c;
  --kb-font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --heat-0: #22262e;
  --heat-1: #4a3a22;
  --heat-2: #7a5a2a;
  --heat-3: #b07c32;
  --heat-4: #e0a458;

  color-scheme: dark;
}

[data-theme='light'] {
  --bg: #f2f0eb;
  --bg-soft: #eae7e0;
  --panel: #ffffff;
  --panel-2: #f6f4ef;
  --line: #dcd7cc;
  --line-soft: #e7e3da;
  --text: #22252b;
  --text-dim: #444a54;
  --muted: #6b7280;
  --accent: #b4762c;
  --accent-soft: rgba(180, 118, 44, 0.14);
  --accent-text: #ffffff;
  --ok: #15a34a;
  --err: #dc2626;
  --warn: #b45309;
  --shadow: 0 6px 18px rgba(30, 25, 15, 0.12);

  --key-white: #ffffff;
  --key-white-active: #e3ddcd;
  --key-black: #2a2e36;
  --key-black-face: #454b56;
  --key-black-active: #565d69;
  --key-black-face-active: #6b7280;
  --key-white-hi: #ffffff;
  --key-white-mid: #faf8f3;
  --key-white-lo: #e4dfd2;
  --key-lip-hi: #ffffff;
  --key-lip-lo: #efeade;
  --key-black-hi: #565d69;
  --key-black-lo: #1a1d23;
  --key-shadow: rgba(60, 50, 30, 0.3);
  --key-gloss: rgba(255, 255, 255, 0.2);
  --key-shade: rgba(70, 60, 40, 0.26);
  --oct-band: rgba(60, 50, 30, 0.045);
  --oct-band-alt: rgba(60, 50, 30, 0.1);
  --oct-label: #6f757f;
  --key-edge: rgba(0, 0, 0, 0.3);
  --key-felt: #9c3b48;
  --key-label: #767c86;
  --key-label-c: #3f444d;
  --key-label-solfege: #8b919b;
  --staff-bg: #ffffff;
  --staff-line: #454b56;
  --staff-ink: #16181d;
  --staff-clef: #16181d;
  --staff-label: #6f757f;
  --staff-current: #b4762c;
  --staff-correct: #0a7442;
  --staff-wrong: #c0322c;
  --finger-lh: #a3201b;
  --finger-rh: #0a7442;
  --finger-text: #ffffff;

  --heat-0: #e2ded4;
  --heat-1: #ecd3a8;
  --heat-2: #dcb066;
  --heat-3: #c68f3a;
  --heat-4: #a86c1c;

  color-scheme: light;
}

/* ==================================================================== */
/*  Основа                                                              */
/* ==================================================================== */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; font-weight: 650; line-height: 1.25; }
p { margin: 0; }
ul { margin: 0; padding-left: 1.2em; }

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

::selection { background: var(--accent-soft); }

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

/* ==================================================================== */
/*  Аварийный экран                                                     */
/* ==================================================================== */

#fatal {
  max-width: 760px;
  margin: 12vh auto;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--err);
  border-radius: 10px;
}
#fatal h1 { font-size: 22px; margin-bottom: 12px; color: var(--err); }
#fatal p { margin-bottom: 12px; color: var(--text-dim); }
#fatal pre {
  margin: 0 0 14px;
  padding: 12px;
  overflow: auto;
  max-height: 40vh;
  background: var(--bg-soft);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
}
#fatal .fatal-hint { font-size: 14px; color: var(--muted); }
#fatal code, #fatal b { color: var(--text); }

/* ==================================================================== */
/*  Каркас                                                              */
/* ==================================================================== */

#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar__spacer { flex: 1 1 auto; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: 0.2px; }

.brand__mark {
  width: 26px;
  height: 18px;
  border-radius: 3px;
  background:
    linear-gradient(90deg, transparent 0 3px, var(--bg) 3px 5px, transparent 5px 9px,
                    var(--bg) 9px 11px, transparent 11px 17px, var(--bg) 17px 19px, transparent 19px),
    var(--key-white);
  box-shadow: inset 0 0 0 1px var(--line);
}

.brand__name { font-size: 15px; }

/* Индикатор MIDI */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  max-width: 280px;
}
.chip:hover { border-color: var(--accent); }
.chip__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip .dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}
.chip.is-ok   .dot { background: var(--ok);   box-shadow: 0 0 8px var(--ok); }
.chip.is-warn .dot { background: var(--warn); }
.chip.is-err  .dot { background: var(--err); }
.chip.is-off  .dot { background: var(--muted); }
.chip.is-ok  { color: var(--text); }

/* Громкость */
.vol { display: flex; align-items: center; gap: 8px; }
.vol__icon {
  width: 14px; height: 14px;
  background: var(--muted);
  clip-path: polygon(0 35%, 32% 35%, 62% 5%, 62% 95%, 32% 65%, 0 65%);
}
.vol input[type='range'] { width: 96px; }

/* Полоса «Включить звук» */
.sound-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  background: linear-gradient(90deg, var(--accent-soft), transparent 70%), var(--panel);
  border-bottom: 1px solid var(--accent);
}
.sound-bar__text { flex: 1 1 auto; font-size: 14px; color: var(--text-dim); }
.sound-bar__text b { color: var(--text); }

/* Меню */
.nav {
  grid-row: 3;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.nav__item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14.5px;
  border-left: 3px solid transparent;
}
.nav__item:hover { background: var(--panel-2); color: var(--text); }
.nav__item.is-active {
  background: var(--accent-soft);
  color: var(--text);
  border-left-color: var(--accent);
  font-weight: 600;
}

.screen {
  grid-row: 3;
  grid-column: 2;
  min-width: 0;
  padding: 22px 26px 60px;
  overflow-y: auto;
}

.screen__title { font-size: 24px; margin-bottom: 6px; }
.screen__subtitle { color: var(--accent); font-size: 14px; margin-bottom: 4px; }
.screen__desc { color: var(--muted); font-size: 14px; max-width: 78ch; margin-bottom: 16px; }

/* ==================================================================== */
/*  Кнопки, поля                                                        */
/* ==================================================================== */

.btn {
  appearance: none;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 15px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: default; }

.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.btn--accent:hover { filter: brightness(1.08); }

.btn--ghost { background: transparent; }
.btn--danger { border-color: var(--err); color: var(--err); background: transparent; }
.btn--danger:hover { background: var(--err); color: var(--bg); }
.btn--big { padding: 10px 22px; font-size: 15px; }
.btn--tiny { padding: 4px 10px; font-size: 12.5px; }
.btn--icon { color: var(--text-dim); }

.control {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 120px;
}
.control:hover { border-color: var(--accent); }
.control--num { min-width: 84px; width: 84px; }
select.control { cursor: pointer; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
}
.field__label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.field--check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  padding-top: 14px;
}
.field--check .field__label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  color: var(--text-dim);
}
.field--check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

input[type='range'] { accent-color: var(--accent); cursor: pointer; }
input[type='number'], textarea {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
}

.muted { color: var(--muted); font-size: 13px; }
.notes li { color: var(--text-dim); font-size: 14px; margin-bottom: 4px; }

.row-buttons { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ==================================================================== */
/*  Панели и показатели                                                 */
/* ==================================================================== */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.panel__title {
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.stat__value {
  font-size: 24px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat__label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ==================================================================== */
/*  Экран тренажёра                                                     */
/* ==================================================================== */

.trainer { display: flex; flex-direction: column; gap: 16px; }

.trainer__head {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
}
.trainer__headtext { min-width: 260px; flex: 1 1 380px; }
.trainer__pickers { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.trainer__note { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* Лента предстоящих нот */
.roll {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 0;
  overflow: hidden;
}
.roll__track {
  display: flex;
  gap: 6px;
  padding: 0 12px;
  overflow-x: auto;
  scrollbar-width: none;
  /* Лента доезжает плавно: без этого при каждой ноте она прыгала рывком. */
  scroll-behavior: smooth;
}
.roll__track::-webkit-scrollbar { display: none; }

.roll__fade {
  position: absolute;
  top: 0; bottom: 0;
  width: 28px;
  pointer-events: none;
  z-index: 2;
}
.roll__fade--left { left: 0; background: linear-gradient(90deg, var(--panel), transparent); }
.roll__fade--right { right: 0; background: linear-gradient(270deg, var(--panel), transparent); }

.roll__item {
  flex: 0 0 62px;
  min-height: 76px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  opacity: 0.62;
  /* Текущая нота не вспыхивает, а перетекает: подсвечиваются рамка, фон,
     прозрачность и лёгкий подъём. */
  transition:
    opacity 200ms cubic-bezier(0.33, 1, 0.68, 1),
    background-color 200ms cubic-bezier(0.33, 1, 0.68, 1),
    border-color 200ms cubic-bezier(0.33, 1, 0.68, 1),
    box-shadow 200ms cubic-bezier(0.33, 1, 0.68, 1),
    transform 200ms cubic-bezier(0.33, 1, 0.68, 1);
  will-change: transform, opacity;
}
.roll__item.is-next { opacity: 0.85; }
.roll__item.is-current {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
  transform: translateY(-2px);
}
.roll__item.is-wrapped { border-style: dashed; }

.roll__label {
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
}
.roll__hand {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}
.roll__mark {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 3px;
  line-height: 1.35;
}
.roll__hand--rh .roll__mark { color: var(--finger-rh); border-color: var(--finger-rh); }
.roll__hand--lh .roll__mark { color: var(--finger-lh); border-color: var(--finger-lh); }
.roll__note { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.roll__finger {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--finger-rh);
  border-radius: 50%;
  min-width: 17px;
  height: 17px;
  line-height: 17px;
  text-align: center;
}
.roll__hand--lh .roll__finger { background: var(--finger-lh); }
.roll__finger:empty { display: none; }
.roll__empty { color: var(--muted); font-size: 13px; padding: 24px 12px; }

/* Строка «как считать вслух» — в разделах ритма и независимости рук это
   главная подсказка, поэтому она набрана заметнее обычного описания. */
.trainer__counting {
  margin: 8px 0 0;
  padding: 7px 12px;
  display: inline-block;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}
.trainer__counting[hidden] { display: none; }

/* Легенда аппликатуры под клавиатурой: расшифровка цифр в кружках. */
.flegend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
}
.flegend__hands { display: flex; align-items: center; gap: 6px; }
.flegend__sep {
  width: 1px;
  align-self: stretch;
  background: var(--line);
}
.flegend__item { display: flex; align-items: center; gap: 5px; }
.flegend__num,
.flegend__hand {
  font-style: normal;
  font-weight: 800;
  font-size: 11px;
  color: var(--accent-text);
  background: var(--muted);
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
}
.flegend__hand--rh { background: var(--finger-rh); border-radius: 5px; }
.flegend__hand--lh { background: var(--finger-lh); border-radius: 5px; }
.flegend__name { white-space: nowrap; }

@media (max-width: 560px) {
  .flegend { font-size: 11px; gap: 5px 10px; }
  .flegend__sep { display: none; }
}

/* Нотный стан в разделе чтения — стоит на месте ленты нот.
   Фон светлее панели даже в тёмной теме: ноты читаются привычнее тёмными по светлому. */
.staff-host {
  background: var(--staff-bg, var(--panel));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  min-height: 120px;
}

/* Клавиатура */
.kb-host {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px 10px;
}

/* Транспорт */
.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
}
.transport__buttons { display: flex; gap: 10px; margin-left: auto; padding-top: 14px; }

.field--bpm { min-width: 260px; }
.bpm { display: flex; align-items: center; gap: 10px; }
.bpm__range { width: 170px; }
.bpm__number { width: 74px; text-align: center; font-variant-numeric: tabular-nums; }
.bpm__unit { font-size: 12px; color: var(--muted); }

.beat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line);
  display: inline-block;
}
.beat-dot.is-on { background: var(--ok); }
.beat-dot.is-on.is-accent { background: var(--accent); box-shadow: 0 0 9px var(--accent); }

/* ==================================================================== */
/*  Экран «Сегодня»                                                     */
/* ==================================================================== */

.plan { display: flex; flex-direction: column; gap: 2px; }
.plan__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 9px;
  cursor: pointer;
  border: 1px solid transparent;
}
.plan__row:hover { background: var(--panel-2); border-color: var(--line); }
.plan__row.is-done .plan__text { color: var(--muted); text-decoration: line-through; }
.plan__check { width: 18px; height: 18px; accent-color: var(--ok); cursor: pointer; flex: 0 0 auto; }
.plan__body { flex: 1 1 auto; display: flex; flex-direction: column; }
.plan__text { font-size: 15px; }
.plan__hint { font-size: 12.5px; color: var(--muted); }
.plan__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.plan__progress { color: var(--muted); font-size: 13px; }

/* ==================================================================== */
/*  Экран «Аккорды»                                                     */
/* ==================================================================== */

.chords__controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 14px; }
.chords__controls .btn { margin-top: 14px; }

.chords__table { overflow-x: auto; }
.chords__row {
  display: grid;
  grid-template-columns: 84px repeat(4, minmax(120px, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}
.chords__row--head { position: sticky; top: 0; }
.chords__col, .chords__corner {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 6px;
}
.chords__rowhead {
  display: flex;
  align-items: center;
  font-weight: 650;
  font-size: 14px;
  color: var(--text-dim);
  padding-left: 4px;
}
.chords__cell {
  appearance: none;
  cursor: pointer;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chords__cell:hover { border-color: var(--accent); }
.chords__cell.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.chords__symbol { font-size: 16px; font-weight: 650; }
.chords__notes { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.chords__detailbox {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.chords__title { font-size: 17px; margin-bottom: 6px; }
.chords__detail { font-size: 14px; color: var(--text-dim); }
.chords__hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

.drill { display: flex; flex-wrap: wrap; gap: 22px; align-items: stretch; }
.drill__stage {
  flex: 1 1 260px;
  min-height: 168px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px;
}
.drill__symbol {
  font-size: 58px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
}
.drill__symbol.is-ok { color: var(--ok); }
.drill__symbol.is-err { color: var(--err); }
.drill__hint { font-size: 13.5px; color: var(--muted); text-align: center; }
.drill__timer { font-size: 15px; color: var(--accent); font-variant-numeric: tabular-nums; }

.drill__side { flex: 1 1 320px; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; }
.drill__filters { display: flex; flex-direction: column; gap: 8px; }
.drill__group { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.drill__grouplabel {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  min-width: 84px;
}
.drill__group .field--check { padding-top: 0; }
.drill__side .transport__buttons { margin-left: 0; padding-top: 0; }

/* ==================================================================== */
/*  Экран «Статистика»                                                  */
/* ==================================================================== */

.heat-host { overflow-x: auto; padding-bottom: 4px; }
.heat {
  display: grid;
  grid-template-columns: auto max-content;
  grid-template-rows: auto auto;
  gap: 4px 6px;
}
.heat__spacer { grid-row: 1; grid-column: 1; }
.heat__months {
  grid-row: 1;
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(54, 13px);
  font-size: 10px;
  color: var(--muted);
}
.heat__month { grid-row: 1; }
.heat__days {
  grid-row: 2;
  grid-column: 1;
  display: grid;
  grid-template-rows: repeat(7, 13px);
  font-size: 10px;
  color: var(--muted);
  text-align: right;
}
.heat__day { line-height: 11px; }
.heat__grid {
  grid-row: 2;
  grid-column: 2;
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 2px;
}
.heat__cell { width: 11px; height: 11px; border-radius: 2px; background: var(--heat-0); }
.heat__cell.is-empty { background: transparent; }
.heat__cell--l0 { background: var(--heat-0); }
.heat__cell--l1 { background: var(--heat-1); }
.heat__cell--l2 { background: var(--heat-2); }
.heat__cell--l3 { background: var(--heat-3); }
.heat__cell--l4 { background: var(--heat-4); }
.heat__legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}
.heat__legend i { display: inline-block; }

.table-host { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.table tr:last-child td { border-bottom: 0; }
.table td:first-child { color: var(--text); }

.file-input { display: none; }
.export-box {
  display: none;
  width: 100%;
  margin-top: 12px;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 12px;
  resize: vertical;
}
.export-box.is-visible { display: block; }

/* ==================================================================== */
/*  Экран «Настройки»                                                   */
/* ==================================================================== */

.settings__row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; margin-bottom: 10px; }
.settings__status {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--text-dim);
  border-left: 3px solid var(--line);
  padding-left: 10px;
}
.settings__status.is-connected { border-left-color: var(--ok); }
.settings__status.is-no-devices { border-left-color: var(--warn); }
.settings__status.is-denied { border-left-color: var(--err); }
.settings__status.is-unsupported { border-left-color: var(--muted); }

/* ==================================================================== */
/*  Всплывающие сообщения                                               */
/* ==================================================================== */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease-out;
}
.toast--ok { border-left-color: var(--ok); }
.toast--warn { border-left-color: var(--warn); }
.toast--err { border-left-color: var(--err); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all 300ms ease; }

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

/* ==================================================================== */
/*  Адаптив: до 900 px меню превращается в верхнюю полосу                */
/* ==================================================================== */

@media (max-width: 900px) {
  #app { grid-template-columns: minmax(0, 1fr); }

  .nav {
    grid-row: 3;
    grid-column: 1;
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav__item {
    border-left: 0;
    border-bottom: 3px solid transparent;
    border-radius: 8px 8px 0 0;
    white-space: nowrap;
  }
  .nav__item.is-active { border-left: 0; border-bottom-color: var(--accent); }

  .screen { grid-row: 4; grid-column: 1; padding: 16px 14px 48px; }

  .topbar { flex-wrap: wrap; gap: 10px; padding: 8px 12px; }
  .vol input[type='range'] { width: 72px; }
  .chip { max-width: 200px; }

  .sound-bar { flex-direction: column; align-items: flex-start; gap: 10px; }

  .transport__buttons { margin-left: 0; width: 100%; }
  .chords__row { grid-template-columns: 70px repeat(4, minmax(104px, 1fr)); }
  .drill__symbol { font-size: 46px; }
}

@media (max-width: 560px) {
  .roll__item { flex-basis: 54px; }
  .stat__value { font-size: 20px; }
  .screen__title { font-size: 20px; }
}

/* Уважение к системной настройке «меньше движения». */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
