/* Кубометр. Светлая тема по умолчанию, тёмная — по системе или data-theme. */
:root {
  --bg: #eceee8;
  --surface: #fbfbf8;
  --surface-2: #f2f3ee;
  --ink: #16181b;
  --ink-2: #4b5158;
  --muted: #767c83;
  --line: #d8dbd2;
  --line-strong: #bfc3b8;
  --accent: #2f4bd1;
  --accent-soft: rgba(47, 75, 209, 0.1);
  --on-ink: #fbfbf8;
  --ready: #0f8f4f;
  --hold: #cf3a31;
  --good: #11743a;
  --good-soft: rgba(17, 116, 58, 0.1);
  --warn: #9a6400;
  --warn-soft: rgba(237, 161, 0, 0.16);
  --bad: #b8322a;
  --bad-soft: rgba(207, 58, 49, 0.1);
  --plastic: #1b1d20;
  --shadow: 0 10px 30px rgba(22, 24, 27, 0.12);
  /* цвета этапов — по порядку, проверенная категориальная палитра */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #4a3aa7;

  --f-display: "Unbounded", "Onest", system-ui, sans-serif;
  --f-body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "Azeret Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1012;
    --surface: #16191c;
    --surface-2: #1d2124;
    --ink: #eceef0;
    --ink-2: #b3bac1;
    --muted: #7f8790;
    --line: #2a2f34;
    --line-strong: #3a4047;
    --accent: #8499ff;
    --accent-soft: rgba(132, 153, 255, 0.14);
    --on-ink: #0e1012;
    --ready: #37c97b;
    --hold: #ff665d;
    --good: #3fcf7f;
    --good-soft: rgba(63, 207, 127, 0.12);
    --warn: #f0b43c;
    --warn-soft: rgba(240, 180, 60, 0.14);
    --bad: #ff7a70;
    --bad-soft: rgba(255, 102, 93, 0.13);
    --plastic: #050607;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
    --c5: #d55181; --c6: #008300; --c7: #9085e9;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1012;
  --surface: #16191c;
  --surface-2: #1d2124;
  --ink: #eceef0;
  --ink-2: #b3bac1;
  --muted: #7f8790;
  --line: #2a2f34;
  --line-strong: #3a4047;
  --accent: #8499ff;
  --accent-soft: rgba(132, 153, 255, 0.14);
  --on-ink: #0e1012;
  --ready: #37c97b;
  --hold: #ff665d;
  --good: #3fcf7f;
  --good-soft: rgba(63, 207, 127, 0.12);
  --warn: #f0b43c;
  --warn-soft: rgba(240, 180, 60, 0.14);
  --bad: #ff7a70;
  --bad-soft: rgba(255, 102, 93, 0.13);
  --plastic: #050607;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --c5: #d55181; --c6: #008300; --c7: #9085e9;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.app {
  max-width: 1220px;
  margin: 0 auto;
  padding-inline: 20px;
  padding-block: 0 48px;
}
.label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
kbd {
  font: 500 11px var(--f-mono);
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--ink-2);
}

/* ---------- Верхняя панель ---------- */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding-block: 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  transition: opacity 0.2s;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 7px);
  gap: 1.5px;
  padding: 2.5px;
  background: var(--plastic);
  border-radius: 4px;
}
.brand-mark i { width: 7px; height: 7px; border-radius: 1.5px; background: #f5c518; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(6) { background: #16a34a; }
.brand-mark i:nth-child(4) { background: #d7262b; }
.brand-mark i:nth-child(8) { background: #1f5fd6; }
.brand-mark i:nth-child(9) { background: #f07a12; }
.brand-name { font: 600 17px var(--f-display); letter-spacing: -0.01em; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0;
  background: none;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.on { background: var(--ink); color: var(--on-ink); }
.sync {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sync { border: 0; background: none; padding: 4px 6px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 12.5px; }
.sync:hover { background: var(--surface-2); color: var(--ink); }
.theme-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: none;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.theme-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.theme-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn .fill { fill: currentColor; stroke: none; }
.theme-btn .ti { display: none; }
.theme-btn[data-mode="system"] .ti-system, .theme-btn[data-mode="light"] .ti-light, .theme-btn[data-mode="dark"] .ti-dark { display: block; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.sync[data-state="cloud"]::before { background: var(--good); }
.sync[data-state="connecting"]::before { background: var(--warn); }
.sync[data-state="error"]::before { background: var(--bad); }

body.solving .topbar, body.solving .timer-side, body.solving .method-row, body.solving .scramble-card {
  opacity: 0.28;
  pointer-events: none;
}

/* ---------- Общие элементы ---------- */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  flex-wrap: wrap;
}
.seg button {
  border: 0;
  background: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 14px;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--line); }

.btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--on-ink);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { opacity: 0.88; }
.btn.on { background: var(--hold); border-color: var(--hold); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); opacity: 1; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--bad); border-color: var(--line-strong); }
.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chip-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 999px;
  font: 500 13px var(--f-mono);
  cursor: pointer;
}
.chip-btn:hover { background: var(--surface-2); }
.chip-btn.on { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.chip-btn.danger { font-family: var(--f-body); color: var(--bad); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--ink-2); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.check.row { display: flex; padding-block: 6px; color: var(--ink); }
.check.small { font-size: 12.5px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-sub { font-size: 12.5px; color: var(--muted); }
.panel-note { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.5; max-width: 65ch; }
.empty { color: var(--muted); font-size: 14px; margin: 0; padding: 8px 0; }
.moves { font: 400 17px/1.6 var(--f-mono); letter-spacing: 0.01em; margin: 0; word-spacing: 0.15em; }
.moves.small { font-size: 13px; color: var(--ink-2); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2.5px; flex: none; vertical-align: -1px; margin-right: 8px; }

/* ---------- Таймер ---------- */
.view-timer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
  align-items: start;
}
.timer-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.timer-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; transition: opacity 0.2s; }
.method-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; transition: opacity 0.2s; }
.method-note { font-size: 13px; color: var(--muted); max-width: 52ch; }

.scramble-card { transition: opacity 0.2s; }
.scramble-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.scramble-actions { display: flex; gap: 6px; }
.scramble-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.scramble-hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); max-width: 70ch; }
.scramble-hint:empty { display: none; }
.orient { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.orient-pic { width: 110px; flex: none; background: var(--surface-2); border-radius: 10px; padding: 10px; }
.orient-pic svg { width: 100%; height: auto; display: block; }
.orient-body { flex: 1; min-width: 220px; }
.orient-body .panel-note { margin-top: 10px; }
.target-row select {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 7px; padding: 6px 8px; font-size: 14px;
}
.scramble { font: 400 clamp(17px, 2.2vw, 22px)/1.55 var(--f-mono); margin: 0; word-spacing: 0.22em; text-wrap: balance; }
.net-wrap { margin-top: 12px; display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.cube-net { width: 216px; max-width: 100%; height: auto; }
.net-caption { font-size: 12px; color: var(--muted); }

.pad {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 20px 22px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pad-state { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); min-height: 20px; }
.clock {
  font: 300 clamp(68px, 13vw, 150px)/1 var(--f-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  margin: 10px 0 12px;
  color: var(--ink);
  transition: color 0.1s;
}
.clock.small { font-size: clamp(44px, 7vw, 64px); margin: 6px 0 0; }
.pad-hint { font-size: 13px; color: var(--muted); min-height: 20px; }
.pad.is-hold .clock, .pad.is-hold .pad-state { color: var(--hold); }
.pad.is-ready { border-color: var(--ready); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ready) 22%, transparent); }
.pad.is-ready .clock, .pad.is-ready .pad-state { color: var(--ready); }
.pad.is-running { border-color: var(--line-strong); }
.pad.is-running .pad-state { color: var(--ink); }
.pad.is-inspect .clock { color: var(--warn); }

.stages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
}
.stage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stage-name { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; }
.stage-name::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--sc); margin-right: 7px; flex: none; }
.stage-time { font: 400 17px var(--f-mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.stage.done .stage-time { color: var(--ink); }
.stage.current { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.stage.current .stage-time { color: var(--ink); }

.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.result-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.result-title { margin: 0; font: 600 15px var(--f-display); }
.result-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.result-rows { display: flex; flex-direction: column; }
.rrow {
  display: grid;
  grid-template-columns: 18px minmax(110px, 1.1fr) 76px minmax(60px, 1.4fr) minmax(120px, auto);
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.rrow .sw { margin: 0; }
.rrow .rtime { font: 400 15px var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; }
.rbar { height: 8px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.rbar i { display: block; height: 100%; border-radius: 0 3px 3px 0; }
.rbar.note { background: none; height: auto; font-size: 12.5px; color: var(--muted); }
.rdelta { font: 400 13px var(--f-mono); text-align: right; color: var(--muted); }
.rdelta.worse { color: var(--bad); }
.rdelta.better { color: var(--good); }
.rrow.total { border-bottom: 0; font-weight: 600; }
.rrow.total .rtime { font-weight: 500; }
.rrow.missing { color: var(--muted); }
.note-field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.note-field input, .target-row input {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 14px;
  color: var(--ink);
}

.avgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.avgs div { display: flex; flex-direction: column; }
.avgs b { font: 500 19px var(--f-mono); font-variant-numeric: tabular-nums; }
.solve-list { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow-y: auto; border-top: 1px solid var(--line); }
.solve-list li { border-bottom: 1px solid var(--line); }
.solve-list li.empty { border: 0; padding: 10px 0; }
.solve-item {
  width: 100%;
  display: grid;
  grid-template-columns: 30px 74px 1fr 52px;
  gap: 8px;
  align-items: center;
  border: 0;
  background: none;
  padding: 7px 4px;
  cursor: pointer;
  text-align: left;
}
.solve-item:hover { background: var(--surface-2); }
.solve-item .n { font: 400 12px var(--f-mono); color: var(--muted); }
.solve-item .t { font: 400 14.5px var(--f-mono); font-variant-numeric: tabular-nums; }
.solve-item .t.pen { color: var(--warn); }
.solve-item .t small { font-size: 10px; margin-left: 3px; }
.solve-item .meta { font-size: 11.5px; color: var(--muted); text-align: right; white-space: nowrap; }
.mini { display: flex; gap: 1px; height: 7px; border-radius: 2px; overflow: hidden; }
.mini i { display: block; height: 100%; }

.metro-bpm { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bpm-value { display: flex; flex-direction: column; align-items: center; }
.bpm-value b { font: 400 34px/1.1 var(--f-mono); font-variant-numeric: tabular-nums; }
.bpm-value span { font-size: 12px; color: var(--muted); }
#bpm-range { width: 100%; margin: 12px 0 10px; accent-color: var(--ink); }
.metro-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.beat { width: 12px; height: 12px; border-radius: 50%; background: var(--line-strong); }
.beat.pulse { animation: beat 0.22s ease-out; }
.beat.pulse.accent { animation-name: beat-accent; }
@keyframes beat { from { background: var(--ink); transform: scale(1.35); } to { background: var(--line-strong); transform: scale(1); } }
@keyframes beat-accent { from { background: var(--hold); transform: scale(1.5); } to { background: var(--line-strong); transform: scale(1); } }

/* ---------- Разбор ---------- */
.view-stats { display: flex; flex-direction: column; gap: 16px; }
.stats-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.demo-banner {
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  font-size: 14px;
  color: var(--ink-2);
}
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile b { font: 400 30px/1.15 var(--f-mono); letter-spacing: -0.02em; }
.tile-sub { font-size: 12.5px; color: var(--muted); }

.insight {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 24px;
  padding: 20px 22px;
  background: var(--ink);
  color: var(--on-ink);
  border-radius: 14px;
}
.insight:empty { display: none; }
.insight .label { color: color-mix(in srgb, var(--on-ink) 60%, transparent); }
.insight h3 { margin: 4px 0 6px; font: 600 clamp(20px, 2.6vw, 26px)/1.2 var(--f-display); display: flex; align-items: center; text-wrap: balance; }
.insight h3 .sw { width: 14px; height: 14px; border-radius: 3px; margin-right: 12px; }
.insight p { margin: 0; font-size: 14.5px; line-height: 1.55; }
.insight-advice { color: color-mix(in srgb, var(--on-ink) 82%, transparent); align-self: center; max-width: 62ch; }

.table-wrap { overflow-x: auto; }
.stage-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.stage-table th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0 10px 8px; border-bottom: 1px solid var(--line); }
.stage-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.stage-table tr:last-child td { border-bottom: 0; }
.stage-table .num { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.share { display: inline-block; width: 70px; height: 7px; background: var(--surface-2); border-radius: 3px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.share i { display: block; height: 100%; }
.share-val { font: 400 12.5px var(--f-mono); color: var(--ink-2); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font: 500 12.5px var(--f-mono); }
.pill.ok { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.spark { display: block; }
.spark path { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark-empty { color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2.5px; }
.chart { width: 100%; overflow: hidden; }
.chart svg { display: block; max-width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font: 400 11px var(--f-mono); }
.chart .target { stroke: var(--ink-2); stroke-width: 1.2; stroke-dasharray: 4 4; }
.chart .target-label { fill: var(--ink-2); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit.on { fill: var(--ink); fill-opacity: 0.06; }
.chart .hit-area { fill: transparent; cursor: crosshair; }
.chart .dot { fill: var(--muted); fill-opacity: 0.55; }
.chart .avg-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .avg-end { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--accent); font-weight: 500; }
.chart .cross { stroke: var(--line-strong); stroke-width: 1; }

.cmp { display: flex; flex-direction: column; gap: 14px; }
.cmp-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.cmp-name { font-weight: 500; font-size: 14px; }
.cmp-bars { display: flex; flex-direction: column; gap: 4px; }
.cmp-bar { display: grid; grid-template-columns: 88px minmax(0, 1fr) 48px; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); }
.cmp-bar i { display: block; height: 10px; border-radius: 0 3px 3px 0; }
.cmp-bar i.b { background: var(--muted); }
.cmp-bar i.c { background: var(--c1); }
.cmp-bar b { font: 400 13px var(--f-mono); color: var(--ink); }

.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 12.5px;
  min-width: 160px;
}
.tooltip b { font-weight: 600; }
.tip-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; margin-top: 3px; color: var(--ink-2); }
.tip-row i { width: 8px; height: 8px; border-radius: 2px; }
.tip-row b { font: 400 12.5px var(--f-mono); color: var(--ink); }

/* ---------- Кейсы ---------- */
.view-drills { display: flex; flex-direction: column; gap: 16px; }
.runner {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  scroll-margin-top: 90px;
}
.runner-visual { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.runner-pic { display: flex; align-items: center; justify-content: center; background: var(--surface-2); border-radius: 12px; padding: 18px; aspect-ratio: 1; max-width: 100%; }
.seg.small { align-self: flex-start; }
.seg.small button { padding: 4px 10px; font-size: 13px; }
.player { display: flex; flex-direction: column; gap: 10px; }
.player-stage { background: var(--surface-2); border-radius: 12px; aspect-ratio: 1; max-width: 100%; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.player-stage canvas { display: block; cursor: grab; }
.player-stage canvas:active { cursor: grabbing; }
.player-stage svg { width: 80%; height: auto; }
.player-moves { display: flex; flex-wrap: wrap; gap: 4px; font: 400 14px var(--f-mono); }
.player-moves span { padding: 2px 6px; border-radius: 5px; background: var(--surface-2); color: var(--ink); transition: background 0.15s, color 0.15s; }
.player-moves span.done { color: var(--muted); background: transparent; }
.player-moves span.on { background: var(--ink); color: var(--on-ink); }
.player-say { margin: 0; font-size: 14px; color: var(--ink); min-height: 42px; line-height: 1.45; }
.player-buttons { display: flex; gap: 6px; align-items: center; }
.pl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; min-width: 38px; padding: 0 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 8px; cursor: pointer; font-weight: 500;
}
.pl-btn:hover:not(:disabled) { background: var(--surface-2); }
.pl-btn:disabled { opacity: 0.4; cursor: default; }
.pl-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pl-btn.primary { flex: 1; background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.pl-btn.primary:hover { background: var(--ink); opacity: 0.88; }
.pl-btn.primary svg { fill: currentColor; stroke: none; }
.pl-btn.primary .i-pause { display: none; fill: none; stroke: currentColor; stroke-width: 2.4; }
.pl-btn.primary.playing .i-pause { display: block; }
.pl-btn.primary.playing .i-play { display: none; }
.player-tip { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.runner-note { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--ink); font-size: 13.5px; line-height: 1.5; max-width: 65ch; }
.runner-pic svg { width: 100%; max-width: 250px; height: auto; }
.runner-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.runner-title h2 { margin: 2px 0 0; font: 600 24px/1.2 var(--f-display); }
.setup .moves { font-size: clamp(18px, 2.4vw, 23px); margin-top: 4px; }
.alg-reveal { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.moves.alg { padding: 8px 12px; background: var(--accent-soft); border-radius: 8px; color: var(--ink); }
.runner-pad {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.runner-pad.is-hold .clock, .runner-pad.is-hold .pad-state { color: var(--hold); }
.runner-pad.is-ready { border-color: var(--ready); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ready) 22%, transparent); }
.runner-pad.is-ready .clock, .runner-pad.is-ready .pad-state { color: var(--ready); }
.runner-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.runner-last { font-size: 13.5px; color: var(--ink-2); }
.drill-note { margin: 0; font-size: 13.5px; color: var(--muted); max-width: 70ch; }

.case-group h3 { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); margin: 10px 0 10px; }
.case-group h3 span { color: var(--muted); font-weight: 500; margin-left: 4px; }
.cases { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; }
.case { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.case.cur { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.case.off { opacity: 0.45; }
.case-pic { border: 0; background: var(--surface-2); padding: 12px; cursor: pointer; display: flex; justify-content: center; }
.case-pic:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--line)); }
.case-pic svg { width: 100%; max-width: 104px; height: auto; }
.case-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.case-body b { font-size: 14px; }
.case-body code { font: 400 12px/1.45 var(--f-mono); color: var(--ink-2); }
.case-stat { font-size: 12px; color: var(--muted); }
.case-stat.slow { color: var(--bad); font-weight: 500; }
.case-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.case-play {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 3px 10px 3px 7px; font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.case-play:hover { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.case-play svg { width: 13px; height: 13px; fill: currentColor; }

.cube-body { fill: var(--plastic); }
.cube-iso polygon:not(.cube-body) { stroke: none; }

/* ---------- Настройки ---------- */
.view-settings { display: flex; flex-direction: column; gap: 16px; max-width: 820px; }
.targets { margin-top: 12px; }
.target-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.target-row label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.target-row input { width: 80px; font-family: var(--f-mono); }
.keys { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 8px 20px; margin: 0; font-size: 14px; }
.keys dt { color: var(--ink-2); }
.keys dd { margin: 0; }
.data-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.code-form { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.code-row { display: flex; gap: 8px; flex-wrap: wrap; }
.code-row input {
  font: 500 17px var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase;
  width: 14em; max-width: 100%; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--ink);
}
.code-show { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.code-show .label { flex-basis: 100%; }
.code { font: 500 26px var(--f-mono); letter-spacing: 0.08em; user-select: all; }
.confirm { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 12px 14px; border: 1px solid var(--bad); border-radius: 8px; background: var(--bad-soft); font-size: 14px; }

/* ---------- Диалог ---------- */
.solve-dialog {
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
.solve-dialog::backdrop { background: rgba(10, 12, 14, 0.45); }
.dialog-body { padding: 18px 20px 6px; display: flex; flex-direction: column; gap: 12px; }
.dlg-head { display: flex; flex-direction: column; }
.dlg-time { font: 400 40px/1.1 var(--f-mono); }
.dlg-stages { display: flex; flex-direction: column; }
.dlg-stages div { display: flex; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.dlg-stages span:nth-child(2) { flex: 1; }
.dlg-stages b { font: 400 14px var(--f-mono); }
.dialog-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; margin: 0; }

/* ---------- Адаптив ---------- */
@media (max-width: 980px) {
  .view-timer { grid-template-columns: minmax(0, 1fr); }
  .timer-side { position: static; }
  .insight { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 720px) {
  .app { padding-inline: 16px; }
  .topbar { flex-wrap: wrap; gap: 10px 14px; padding-block: 10px; margin-bottom: 16px; }
  .tabs { order: 3; flex-basis: 100%; }
  .sync { margin-left: auto; }
  .theme-btn { width: 32px; height: 32px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile b { font-size: 24px; }
  .runner { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px; }
  .runner-pic svg { max-width: 180px; }
  .runner-pic { aspect-ratio: auto; }
  .player-stage { width: min(100%, 340px); align-self: center; }
  .rrow { grid-template-columns: 14px minmax(0, 1fr) 64px 92px; }
  .rrow .rbar { display: none; }
  .rrow.total .rbar { display: none; }
  .cmp-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .cmp-row .pill { justify-self: start; }
  .keys { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .keys dd { margin-bottom: 8px; color: var(--muted); }
  .cases { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .stages { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
