:root {
  --bg: #f6f4ef;
  --paper: #fffdf9;
  --ink: #14131a;
  --ink-2: #4a4853;
  --ink-3: #8b8893;
  --line: #e6e2d9;
  --accent: #d63a2f;
  --accent-soft: #fbe3df;
  --ok: #1f8a5b;
  --bad: #d63a2f;
  --radius: 22px;
  --shadow: 0 1px 0 rgba(20,19,26,.04), 0 12px 40px -18px rgba(20,19,26,.18);
  --f-lp: #f4b8b0; --f-lr: #f6d49a; --f-lm: #c9e3a6; --f-li: #a8d8e8;
  --f-ri: #c3b6f2; --f-rm: #f3b6dd; --f-rr: #b5e3cf; --f-rp: #f2c6a6; --f-th: #e5e1d8;
  --display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(circle at 1px 1px, rgba(20,19,26,.06) 1px, transparent 0);
  background-size: 28px 28px;
}
a { color: inherit; }
kbd {
  font: 500 .78em var(--mono); padding: .12em .5em; border-radius: 6px;
  background: var(--paper); border: 1px solid var(--line); border-bottom-width: 2px; white-space: nowrap;
}
b { font-weight: 600; }
.muted { color: var(--ink-3); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 28px;
  padding: 14px clamp(20px, 4vw, 56px);
  background: rgba(246,244,239,.78); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid rgba(230,226,217,.7);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-key {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font: 700 18px var(--display);
  box-shadow: inset 0 -3px 0 rgba(255,255,255,.12);
}
.brand-key.small { width: 26px; height: 26px; font-size: 13px; border-radius: 8px; }
.brand-name { font: 600 18px var(--display); letter-spacing: -.02em; }
.nav-links { display: flex; gap: 22px; }
.nav-links a { text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 15px; }
.nav-links a:hover { color: var(--ink); }
.toggle { margin-left: auto; display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--ink-2); user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 40px; height: 24px; border-radius: 99px; background: #dcd8ce; position: relative; transition: background .2s; flex: none; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .25s cubic-bezier(.3,1.5,.6,1); }
.toggle input:checked + .toggle-track { background: var(--ink); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 22px; border-radius: 14px; font: 600 15px var(--sans); text-decoration: none;
  border: 1px solid transparent; cursor: pointer; transition: transform .15s, background .2s, box-shadow .2s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--bg); box-shadow: inset 0 -3px 0 rgba(255,255,255,.1), 0 8px 24px -10px rgba(20,19,26,.5); }
.btn-primary:hover { background: #2a2933; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper); }
.btn-small { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center;
  max-width: 1240px; margin: 0 auto; padding: clamp(56px, 10vh, 120px) clamp(20px, 4vw, 56px) 80px;
}
.eyebrow { margin: 0 0 18px; font: 500 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.hero h1 { font: 800 clamp(40px, 6.4vw, 84px)/1.02 var(--display); letter-spacing: -.045em; }
.hero-accent { color: var(--accent); }
.lede { max-width: 520px; margin: 26px 0 34px; font-size: 19px; color: var(--ink-2); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-art { position: relative; height: 440px; }
.float-key {
  position: absolute; display: grid; place-items: center; width: 92px; height: 92px; border-radius: 22px;
  background: var(--paper); border: 1px solid var(--line); font: 600 40px var(--display);
  box-shadow: 0 2px 0 var(--line), 0 6px 0 #ddd8cc, 0 26px 40px -20px rgba(20,19,26,.35);
  animation: bob 7s ease-in-out infinite;
}
.k1 { top: 6%; left: 10%; background: var(--ink); color: var(--bg); border-color: var(--ink); box-shadow: 0 6px 0 #000, 0 26px 40px -16px rgba(20,19,26,.5); width: 120px; height: 120px; font-size: 56px; }
.k2 { top: 0; left: 58%; animation-delay: -1.2s; }
.k3 { top: 36%; left: 72%; animation-delay: -2.4s; background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 6px 0 #a92a21, 0 26px 40px -16px rgba(214,58,47,.5); }
.k4 { top: 44%; left: 2%; animation-delay: -3.1s; width: 76px; height: 76px; font-size: 32px; }
.k5 { top: 30%; left: 38%; animation-delay: -4.4s; width: 70px; height: 70px; font-size: 30px; }
.k6 { top: 4%; left: 86%; animation-delay: -5.2s; width: 64px; height: 64px; font-size: 28px; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-14px) rotate(2deg); } }
.hero-type {
  position: absolute; left: 4%; right: 4%; bottom: 8%; padding: 22px 26px; border-radius: 18px;
  background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow);
  font: 500 clamp(20px, 2.4vw, 28px) var(--mono); min-height: 80px; display: flex; align-items: center;
}
.caret { display: inline-block; width: 3px; height: 1.1em; background: var(--accent); margin-left: 3px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- sections ---------- */
.section { max-width: 1240px; margin: 0 auto; padding: 72px clamp(20px, 4vw, 56px); }
.section-head { margin-bottom: 36px; }
.section-head h2 { font: 700 clamp(28px, 3.6vw, 44px)/1.1 var(--display); letter-spacing: -.035em; max-width: 720px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- learn ---------- */
.learn-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 18px; }
.step { padding: 28px; position: relative; grid-column: span 2; }
.step:nth-child(4), .step:nth-child(5) { grid-column: span 3; }
.step h3 { font: 600 20px/1.25 var(--display); letter-spacing: -.02em; margin: 18px 0 10px; }
.step p { margin: 0 0 12px; color: var(--ink-2); font-size: 15px; }
.step .note { font-size: 13.5px; color: var(--ink-3); margin: 14px 0 0; }
.step-n { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); font: 500 13px var(--mono); }
.os-tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--bg); border-radius: 12px; margin: 6px 0 12px; }
.os-tab, .mode-tab {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; font: 500 13px var(--sans);
  color: var(--ink-3); cursor: pointer; transition: all .2s;
}
.os-tab.active, .mode-tab.active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.home-row { display: flex; gap: 5px; margin: 16px 0 6px; }
.home-row span {
  flex: 1; aspect-ratio: 1; max-width: 40px; display: grid; place-items: center; border-radius: 9px;
  background: var(--bg); border: 1px solid var(--line); font: 600 15px var(--display); position: relative;
}
.home-row .gap { background: none; border: 0; max-width: 10px; }
.home-row .bump { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.home-row .bump::after { content: ""; position: absolute; bottom: 5px; width: 10px; height: 2px; border-radius: 2px; background: currentColor; opacity: .6; }
.lookalikes { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lookalikes li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-2); }
.lookalikes b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font: 600 17px var(--display); flex: none; }
.finger-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 14px; font-size: 12.5px; color: var(--ink-2); }
.finger-legend span { display: flex; align-items: center; gap: 6px; }
.finger-legend i { width: 12px; height: 12px; border-radius: 4px; background: var(--fc); }
[data-f="lp"] { --fc: var(--f-lp); } [data-f="lr"] { --fc: var(--f-lr); } [data-f="lm"] { --fc: var(--f-lm); }
[data-f="li"] { --fc: var(--f-li); } [data-f="ri"] { --fc: var(--f-ri); } [data-f="rm"] { --fc: var(--f-rm); }
[data-f="rr"] { --fc: var(--f-rr); } [data-f="rp"] { --fc: var(--f-rp); } [data-f="th"] { --fc: var(--f-th); }

.explorer { margin-top: 18px; padding: 32px; }
.explorer-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 26px; flex-wrap: wrap; }
.explorer-head h3 { font: 600 22px var(--display); letter-spacing: -.02em; margin-bottom: 6px; }
.explorer-head p { margin: 0; font-size: 15px; }
.explorer-info { display: flex; align-items: center; gap: 16px; padding: 12px 20px 12px 12px; border-radius: 18px; background: var(--bg); min-width: 300px; }
.ex-letter { display: grid; place-items: center; min-width: 64px; height: 64px; padding: 0 10px; border-radius: 14px; background: var(--ink); color: var(--bg); font: 600 26px var(--display); }
.explorer-info b { display: block; font: 600 18px var(--display); }
.ex-hint { font-size: 13.5px; color: var(--ink-3); }

/* ---------- keyboard ---------- */
.keyboard { --u: clamp(22px, 4.4vw, 54px); --g: clamp(3px, .5vw, 6px); display: flex; flex-direction: column; gap: var(--g); align-items: center; user-select: none; }
.kb-row { display: flex; gap: var(--g); }
.key {
  position: relative; width: calc(var(--u) * var(--w) + var(--g) * (var(--w) - 1)); height: var(--u);
  border-radius: calc(var(--u) * .2); background: var(--paper); border: 1px solid var(--line);
  box-shadow: 0 2px 0 #e0dbd0; display: grid; place-items: center;
  transition: transform .08s, box-shadow .08s, background .15s;
}
.key::before { content: ""; position: absolute; left: 18%; right: 18%; bottom: 4px; height: 3px; border-radius: 2px; background: var(--fc); opacity: .95; }
.key.fn::before { display: none; }
.k-ru { font: 600 calc(var(--u) * .36) var(--display); }
.k-lat { position: absolute; right: 12%; bottom: 14%; font: 500 calc(var(--u) * .18) var(--mono); color: var(--ink-3); opacity: .7; }
.k-sh { position: absolute; left: 14%; top: 8%; font: 500 calc(var(--u) * .2) var(--mono); color: var(--ink-3); }
.k-fn { font: 500 calc(var(--u) * .2) var(--sans); color: var(--ink-3); }
.key.home .k-ru::after { content: ""; position: absolute; left: 50%; top: 68%; transform: translateX(-50%); width: 22%; height: 2px; border-radius: 2px; background: var(--ink-3); opacity: .5; }

.keyboard-learn .key:not(.fn) { background: color-mix(in srgb, var(--fc) 34%, var(--paper)); border-color: color-mix(in srgb, var(--fc) 70%, var(--line)); cursor: pointer; }
.keyboard-learn .key:not(.fn):hover, .keyboard-learn .key.active { transform: translateY(-3px); box-shadow: 0 6px 14px -6px rgba(20,19,26,.35); background: var(--fc); }
.keyboard-learn .key.active { outline: 2px solid var(--ink); outline-offset: 1px; }
.keyboard-learn .key::before { display: none; }

.keyboard-practice { --u: clamp(20px, 3.7vw, 46px); margin-top: 26px; }
.keyboard-practice .key.next { background: var(--fc); border-color: color-mix(in srgb, var(--fc) 60%, var(--ink)); transform: translateY(-2px); box-shadow: 0 4px 0 color-mix(in srgb, var(--fc) 60%, #000), 0 10px 20px -8px rgba(20,19,26,.3); }
.keyboard-practice .key.next.fn { background: var(--fc); }
.keyboard-practice .key.next::before { opacity: 0; }
.key.pressed { transform: translateY(2px) !important; box-shadow: 0 0 0 #e0dbd0 !important; }
.key.wrong { background: var(--bad) !important; color: #fff; border-color: var(--bad) !important; transform: translateY(2px); }
.key.wrong .k-lat, .key.wrong .k-sh { color: #fff; }

/* ---------- practice ---------- */
.practice-layout { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.lessons { padding: 14px; position: sticky; top: 84px; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--bg); border-radius: 13px; margin-bottom: 10px; }
.lesson-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; max-height: 560px; overflow: auto; }
.lesson {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 12px;
  background: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; transition: background .15s;
}
.lesson:hover { background: var(--bg); }
.lesson.current { background: var(--ink); color: var(--bg); }
.lesson.current .l-keys, .lesson.current .l-n { color: rgba(246,244,239,.6); }
.l-n { font: 500 12px var(--mono); color: var(--ink-3); }
.l-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.l-body b { font-size: 14px; font-weight: 600; }
.l-keys { font: 500 11.5px var(--mono); color: var(--ink-3); letter-spacing: .05em; }
.l-stars, .stars { display: flex; gap: 3px; }
.l-stars i, .stars i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.lesson.current .l-stars i { background: rgba(255,255,255,.18); }
.l-stars i.on, .stars i.on { background: #f0b429 !important; }
.mode-desc { padding: 10px 10px 4px; }
.mode-desc h4 { font: 600 16px var(--display); margin-bottom: 6px; }
.mode-desc p { margin: 0 0 10px; font-size: 14px; color: var(--ink-2); }
.weak-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.weak-chips span { display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 5px; border-radius: 10px; background: var(--accent-soft); font-size: 12px; color: var(--accent); }
.weak-chips b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--paper); font: 600 13px var(--display); }
.reset-link { display: block; margin: 10px auto 2px; background: none; border: 0; font: 12px var(--sans); color: var(--ink-3); cursor: pointer; }
.reset-link:hover { color: var(--accent); }

.trainer { padding: 28px 32px 22px; position: relative; overflow: hidden; }
.trainer-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.trainer-title span { font: 500 12px var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.trainer-title h3 { font: 600 24px var(--display); letter-spacing: -.02em; margin-top: 4px; }
.stats { display: flex; gap: 6px; }
.stat { min-width: 78px; padding: 8px 12px; border-radius: 14px; background: var(--bg); text-align: center; }
.stat span { display: block; font: 600 22px var(--display); font-variant-numeric: tabular-nums; }
.stat small { font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.progress { height: 3px; background: var(--line); border-radius: 3px; margin: 22px 0 6px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--ink); border-radius: 3px; transition: width .2s; }

.typing-wrap { position: relative; height: calc(3 * 52px + 34px); padding-top: 14px; overflow: hidden; outline: none; cursor: text; }
.typing { font: 400 clamp(22px, 2.6vw, 30px)/52px var(--mono); letter-spacing: .01em; transition: transform .25s cubic-bezier(.3,.8,.3,1); color: var(--ink-3); height: calc(3 * 52px); }
.word { white-space: nowrap; }
.ch { position: relative; border-radius: 4px; transition: color .1s; }
.ch.ok { color: var(--ink); }
.ch.bad { color: var(--bad); }
.ch.cur { color: var(--ink); background: var(--accent-soft); }
.ch.cur::after { content: ""; position: absolute; left: 0; right: 0; bottom: 4px; height: 3px; border-radius: 2px; background: var(--accent); animation: blink 1s steps(2) infinite; }
.typing-wrap:not(.focused) .ch.cur::after { animation: none; opacity: .4; }
.ch.space.bad { background: rgba(214,58,47,.15); }
.ch.shake { animation: shake .25s; }
.ch.shake.cur { background: rgba(214,58,47,.2); }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.gloss { position: absolute; left: 0; bottom: 0; height: 26px; font: 500 13px var(--sans); color: var(--ink-3); font-style: italic; }
.gloss:not(:empty)::before { content: "→ "; font-style: normal; }
.focus-veil {
  position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,253,249,.72);
  backdrop-filter: blur(3px); transition: opacity .2s; font-weight: 500; color: var(--ink-2);
}
.focus-veil span { padding: 10px 18px; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.typing-wrap.focused .focus-veil { opacity: 0; pointer-events: none; }
.hidden-input { position: absolute; opacity: 0; width: 1px; height: 1px; left: 0; top: 0; border: 0; padding: 0; }
.layout-warn { margin-top: 10px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: #8d241c; font-size: 14px; }

.trainer-foot { display: flex; align-items: center; gap: 16px; margin-top: 22px; }
.trainer-foot .hint { margin-left: auto; font-size: 12.5px; }
.next-hint { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.next-hint:not(:empty)::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--fc); }
.next-hint b { font: 600 14px var(--mono); padding: 1px 7px; border-radius: 6px; background: var(--bg); }

.result { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,253,249,.9); backdrop-filter: blur(8px); animation: fade .3s; }
@keyframes fade { from { opacity: 0; } }
.result-inner { text-align: center; padding: 30px; animation: rise .4s cubic-bezier(.3,1.3,.5,1); }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.result h3 { font: 800 clamp(34px, 4vw, 52px) var(--display); letter-spacing: -.04em; }
.result-stats { display: flex; justify-content: center; gap: 36px; margin: 26px 0 18px; }
.result-stats span { display: block; font: 600 36px var(--display); }
.result-stats small { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.result .stars { justify-content: center; gap: 8px; margin-bottom: 12px; }
.result .stars i { width: 18px; height: 18px; clip-path: polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%); border-radius: 0; }
.result-weak { margin: 4px 0 4px; font-size: 14px; min-height: 22px; }
.result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }

/* ---------- footer ---------- */
.footer { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 40px 20px 56px; color: var(--ink-3); font-size: 13.5px; text-align: center; }
.footer p { margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { height: 320px; }
  .learn-grid { grid-template-columns: 1fr 1fr; }
  .step, .step:nth-child(4), .step:nth-child(5) { grid-column: span 1; }
  .step:nth-child(5) { grid-column: span 2; }
  .practice-layout { grid-template-columns: 1fr; }
  .lessons { position: static; }
  .lesson-list { flex-direction: row; overflow-x: auto; max-height: none; padding-bottom: 4px; }
  .lesson-list li { flex: none; }
  .lesson { width: auto; }
  .mode-tabs { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) {
  .nav { gap: 14px; flex-wrap: wrap; }
  .nav-links { display: none; }
  .toggle-label { font-size: 12.5px; }
  .learn-grid { grid-template-columns: 1fr; }
  .step, .step:nth-child(5) { grid-column: span 1; }
  .explorer, .trainer { padding: 20px 16px; }
  .explorer-info { min-width: 0; width: 100%; }
  .stat { min-width: 62px; }
  .trainer-foot .hint { display: none; }
  .result-stats { gap: 18px; }
  .k-lat, .k-sh { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.practice-layout > *, .learn-grid > * { min-width: 0; }
@media (max-width: 640px) {
  .keyboard, .keyboard-practice { --g: 2px; --u: calc((100vw - 76px) / 15.3); }
  .typing { font-size: 20px; }
  .lessons { padding: 10px; }
}
