:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #15181d;
  --ink-2: #444c57;
  --muted: #737d89;
  --line: #e2e5ea;
  --line-strong: #cbd1d9;
  --accent: #2463eb;
  --accent-ink: #ffffff;
  --accent-soft: #e5edfd;
  --ok: #17864a;
  --ok-soft: #e2f4e9;
  --err: #c93636;
  --err-soft: #fbe8e8;
  --warn: #9a6200;
  --warn-soft: #fdf1d8;
  --key: #ffffff;
  --key-edge: #c6ccd4;
  --key-ink: #252a31;
  --f-LP: #f7cbd5;
  --f-LR: #f8ddb1;
  --f-LM: #d9edb4;
  --f-LI: #c0e1f6;
  --f-RI: #d9cff7;
  --f-RM: #d9edb4;
  --f-RR: #f8ddb1;
  --f-RP: #f7cbd5;
  --f-TH: #e6e8ec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 6px rgba(16, 24, 40, .05);
  --radius: 14px;
  --font: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e24;
    --surface-2: #20252c;
    --ink: #eceef1;
    --ink-2: #c3c9d1;
    --muted: #8d96a2;
    --line: #2c323a;
    --line-strong: #3b434d;
    --accent: #5b8cff;
    --accent-ink: #0b1220;
    --accent-soft: #1d2a47;
    --ok: #4cc47f;
    --ok-soft: #173325;
    --err: #ff6b6b;
    --err-soft: #3a1c1f;
    --warn: #f0b44c;
    --warn-soft: #3a2d14;
    --key: #262c34;
    --key-edge: #3d4550;
    --key-ink: #e6e9ed;
    --f-LP: #4a2a33;
    --f-LR: #4a3a1f;
    --f-LM: #33452a;
    --f-LI: #1f3b50;
    --f-RI: #342c55;
    --f-RM: #33452a;
    --f-RR: #4a3a1f;
    --f-RP: #4a2a33;
    --f-TH: #2a3038;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.nosel { user-select: none; -webkit-user-select: none; }

kbd {
  display: inline-block;
  min-width: 1.9em;
  padding: 3px 7px 4px;
  font: 600 12.5px/1.2 var(--mono);
  text-align: center;
  color: var(--key-ink);
  background: var(--key);
  border: 1px solid var(--key-edge);
  border-bottom-width: 3px;
  border-radius: 6px;
  white-space: nowrap;
}
.combo { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.combo .plus { color: var(--muted); font-size: 12px; }
.combos { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.combos .or { color: var(--muted); font-size: 13px; }

/* ——— Шапка ——— */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 24px 8px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent);
  position: relative; flex: none;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
}
.logo::before, .logo::after {
  content: ''; position: absolute; left: 8px; right: 8px; height: 4px; border-radius: 2px; background: var(--accent-ink);
}
.logo::before { top: 12px; box-shadow: 0 7px 0 var(--accent-ink); }
.logo::after { top: 26px; left: 13px; right: 13px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-weight: 700; font-size: 17px; }
.brand-text small { color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tabs a {
  padding: 8px 14px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 15px;
}
.tabs a:hover { background: var(--surface-2); color: var(--ink); }
.tabs a.on { background: var(--accent); color: var(--accent-ink); }
.tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main { max-width: 1240px; margin: 0 auto; padding: 12px 24px 48px; }
.notice {
  max-width: 1192px; margin: 8px auto 0; padding: 10px 14px; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn); font-size: 14px;
}

/* ——— Общие элементы ——— */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 22px;
  min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; min-height: 30px; margin-bottom: 6px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 500 15px/1.2 var(--font); cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary kbd { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .35); color: inherit; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 6px 10px; font-size: 14px; }

.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat {
  display: flex; flex-direction: column; min-width: 120px; padding: 12px 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
}
.stat-v { font: 600 24px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.stat-l { font-size: 13px; color: var(--muted); }
.stat.sm { min-width: 0; flex: 1 1 110px; padding: 8px 12px; }
.stat.sm .stat-v { font-size: 20px; }

/* ——— Горячие клавиши ——— */
.sc-bar { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; margin: 8px 0 10px; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.seg-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 7px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2);
  font: inherit; cursor: pointer; text-align: left;
}
.seg-btn:hover { background: var(--surface-2); }
.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg-name { font-weight: 600; font-size: 14px; }
.seg-sub { font-size: 12.5px; color: var(--muted); }
.seg-btn.passed .seg-name::after { content: ' ✓'; color: var(--ok); }
.seg-btn.on { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }

.sc-progress { display: flex; flex-direction: column; gap: 6px; flex: 1 1 180px; min-width: 160px; }
.sc-count { font-size: 14px; color: var(--ink-2); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .35s ease; }
.sc-timer { font: 600 18px var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 56px; text-align: right; }
.sc-rule { font-size: 14px; color: var(--muted); margin: 0 2px 14px; }

.sc-split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.sc-title { font-size: 22px; margin-bottom: 6px; }
.sc-desc { color: var(--ink-2); margin-bottom: 14px; max-width: 60ch; }
.sc-body { display: flex; flex-direction: column; gap: 14px; }

.steps { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 4px; counter-reset: s; }
.step {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px;
  border: 1px solid transparent; font-size: 15px;
}
.step .tick {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--line-strong); position: relative;
}
.step .step-text { flex: 1; min-width: 0; }
.step .combos { margin-left: auto; }
.step.cur { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.step.cur .tick { border-color: var(--accent); }
.step.done .tick { background: var(--ok); border-color: var(--ok); }
.step.done .tick::after {
  content: ''; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.step.done .step-text { color: var(--muted); }

.fld-wrap { display: flex; flex-direction: column; gap: 6px; }
.fld-label { font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.fld {
  width: 100%; padding: 12px 14px;
  font: 500 17px/1.45 var(--font); color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 10px;
  resize: none;
}
.fld:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.is-src .fld { background: var(--surface-2); }
.is-src .fld::selection, .people ::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

.card {
  display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0;
  padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--line-strong);
}
.card dt { color: var(--muted); font-size: 14px; }
.card dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.people {
  max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
}
.person { display: flex; justify-content: space-between; gap: 12px; padding: 7px 14px; border-bottom: 1px solid var(--line); font-size: 15px; }
.person:last-child { border-bottom: 0; }
.person .tel { font-family: var(--mono); font-size: 14px; user-select: all; -webkit-user-select: all; cursor: pointer; white-space: nowrap; }

.sc-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.sc-feedback { margin-top: 14px; padding: 11px 14px; border-radius: 10px; font-size: 15px; }
.sc-feedback[data-kind="ok"] { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.sc-feedback[data-kind="err"] { background: var(--err-soft); color: var(--err); }

.sc-summary {
  max-width: 720px; margin: 8px auto 0; padding: 32px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.sc-summary h2 { font-size: 26px; margin-bottom: 20px; }
.sc-summary .stats { justify-content: center; margin-bottom: 16px; }
.sc-summary p { margin-top: 8px; }
.sc-summary .sc-actions { justify-content: center; margin-top: 24px; }

/* ——— Слепая печать ——— */
.tt { display: grid; grid-template-columns: 250px 1fr; gap: 18px; align-items: start; }
.tt-lessons { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 8px; }
.lesson-list { display: flex; flex-direction: column; gap: 2px; }
.lesson {
  display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto auto; column-gap: 8px;
  padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2);
  font: inherit; text-align: left; cursor: pointer;
}
.lesson:hover { background: var(--surface); }
.lesson:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.lesson-n {
  grid-row: 1 / 3; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font: 600 13px var(--mono); background: var(--surface); border: 1px solid var(--line-strong);
}
.lesson-t { font-size: 14.5px; font-weight: 500; }
.lesson-s { font-size: 12px; color: var(--muted); }
.lesson-s:empty { display: none; }
.lesson.on { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--accent); }
.lesson.passed .lesson-n { background: var(--ok); border-color: var(--ok); color: #fff; }

.tt-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.tt-title { font-size: 22px; margin-bottom: 4px; }
.tt-note { color: var(--ink-2); max-width: 70ch; }
.tt-tools { display: flex; gap: 4px; flex: none; }

.tt-text {
  padding: 22px 26px; min-height: 130px;
  font: 500 25px/1.75 var(--mono); letter-spacing: .01em;
  white-space: pre-wrap; overflow-wrap: break-word;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  user-select: none; -webkit-user-select: none;
}
.ch { border-radius: 3px; }
.ch.ok { color: var(--muted); }
.ch.fixed { color: var(--err); opacity: .75; }
.ch.cur { background: var(--accent-soft); box-shadow: inset 0 -3px 0 var(--accent); }
.ch.cur.err { background: var(--err-soft); box-shadow: inset 0 -3px 0 var(--err); }
.ch.sp.cur { padding: 0 .1em; }

.tt-hint { min-height: 24px; font-size: 15px; color: var(--ink-2); }
.tt-hint[data-kind="warn"] { color: var(--warn); font-weight: 500; }
.tt-hint[data-kind="err"] { color: var(--err); }

.tt-result {
  padding: 18px 22px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.tt-result h3 { font-size: 20px; margin-bottom: 4px; }
.tt-result .sc-actions { margin-top: 14px; }

.kb {
  display: flex; flex-direction: column; gap: 5px; padding: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px;
}
.kb-row { display: grid; grid-template-columns: repeat(60, 1fr); gap: 5px; }
.key {
  position: relative; height: 46px; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  font: 600 15px var(--mono); color: var(--key-ink);
  background: var(--fc, var(--key)); border: 1px solid var(--key-edge); border-bottom-width: 3px; border-radius: 8px;
  transition: transform .06s ease;
}
.key small { position: absolute; top: 3px; left: 6px; font-size: 10.5px; font-weight: 500; opacity: .7; }
.key.wide { font-size: 12px; font-weight: 500; }
.key.home::after { content: ''; position: absolute; bottom: 7px; width: 12px; height: 2.5px; border-radius: 2px; background: currentColor; opacity: .55; }
.key.next { outline: 3px solid var(--accent); outline-offset: 1px; z-index: 1; }
.key.down { transform: translateY(2px); border-bottom-width: 1px; }
.key.wrong { background: var(--err-soft); border-color: var(--err); }
.f-LP { --fc: var(--f-LP); } .f-LR { --fc: var(--f-LR); } .f-LM { --fc: var(--f-LM); } .f-LI { --fc: var(--f-LI); }
.f-RI { --fc: var(--f-RI); } .f-RM { --fc: var(--f-RM); } .f-RR { --fc: var(--f-RR); } .f-RP { --fc: var(--f-RP); }
.f-TH { --fc: var(--f-TH); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); padding: 0 4px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg i { width: 14px; height: 14px; border-radius: 4px; background: var(--fc); border: 1px solid var(--key-edge); }

/* ——— Шпаргалка ——— */
.cheats-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 8px 0 16px; flex-wrap: wrap; }
.cheats-head h2 { font-size: 24px; margin-bottom: 4px; }
.cheats { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.cheat h3 { font-size: 17px; margin-bottom: 10px; }
.cheat dl { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; margin: 0; }
.cheat dt, .cheat dd { padding: 8px 0; border-top: 1px solid var(--line); margin: 0; }
.cheat dt:first-of-type, .cheat dd:first-of-type { border-top: 0; }
.cheat dt small { display: block; color: var(--warn); font-size: 12.5px; }
.cheat dd { text-align: right; }

/* ——— Сообщения ——— */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="warn"] { background: var(--warn); color: #fff; }

/* ——— Узкие экраны ——— */
@media (max-width: 900px) {
  .sc-split, .tt { grid-template-columns: 1fr; }
  .tt-lessons { position: static; }
  .lesson-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .lesson { flex: none; grid-template-columns: 26px auto; }
  .tt-text { font-size: 20px; padding: 16px; }
  .key { height: 38px; font-size: 13px; }
  .key small { display: none; }
}
@media (max-width: 560px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  .tabs { width: 100%; }
  .tabs a { flex: 1; text-align: center; padding: 8px 6px; font-size: 14px; }
  .seg { width: 100%; }
  .seg-btn { flex: 1; padding: 6px 8px; }
  .seg-sub { display: none; }
  .panel { padding: 16px; }
  .tt-head { flex-direction: column; }
  .kb { padding: 8px; gap: 3px; }
  .kb-row { gap: 3px; }
  .key { height: 30px; font-size: 11px; border-radius: 5px; }
  .key.wide { font-size: 9px; }
  .cheats { grid-template-columns: 1fr; }
}

/* ——— Печать шпаргалки ——— */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; }
  .top, .notice, .toast, .cheats-head .btn, #view-shortcuts, #view-typing { display: none !important; }
  #view-cheats { display: block !important; }
  main { padding: 0; max-width: none; }
  .cheats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .panel { box-shadow: none; border-color: #bbb; padding: 10px 14px; break-inside: avoid; }
  .cheat dt, .cheat dd { padding: 4px 0; font-size: 12px; }
  kbd { font-size: 10.5px; padding: 1px 5px 2px; }
}
