/* Klava — общие токены и компоненты.
   Layout: одна спокойная колонка; громкие только цвета пальцев. */
:root {
  --bg: #F1F2F8; --surface: #FFFFFF; --ink: #1D2140; --muted: #646B8F; --line: #DCDFEC;
  --accent: #E4465A; --ok: #1E9E6A; --bad: #D93A4A;
  --pinky: #8E6BDB; --ring: #3D82EA; --middle: #23A874; --index: #EE9A2C; --thumb: #8A90AB;
  --s-pl: #D2364E; --s-ru: #2F6BD8; --grid: #E6E8F2;
  --tint: 20%;
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13152A; --surface: #1C1F3B; --ink: #ECEEFB; --muted: #9CA2C6; --line: #2E3259;
    --accent: #FF6B7C; --ok: #46CC92; --bad: #FF6B7C;
    --pinky: #A98BF0; --ring: #67A2F7; --middle: #44C994; --index: #F7B455; --thumb: #9AA0BE;
    --s-pl: #F0566C; --s-ru: #5089F0; --grid: #282B4C;
    --tint: 26%; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #13152A; --surface: #1C1F3B; --ink: #ECEEFB; --muted: #9CA2C6; --line: #2E3259;
  --accent: #FF6B7C; --ok: #46CC92; --bad: #FF6B7C;
  --pinky: #A98BF0; --ring: #67A2F7; --middle: #44C994; --index: #F7B455; --thumb: #9AA0BE;
  --s-pl: #F0566C; --s-ru: #5089F0; --grid: #282B4C;
  --tint: 26%; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(20px, env(safe-area-inset-top, 0px)) 48px;
}
[hidden] { display: none !important; }
.wrap { max-width: 940px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; text-wrap: balance; margin: 0; line-height: 1.15; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
kbd { font-family: var(--mono); font-size: .8em; background: var(--surface); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* верх */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: inherit; }
.brand h1 { font-size: 30px; letter-spacing: .5px; }
.brand span { color: var(--muted); font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 4px 14px; font-weight: 800; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.ghost { background: transparent; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px; color: var(--muted); }
.ghost:hover { color: var(--ink); border-color: var(--muted); }
.go { background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 12px 26px; font-family: var(--display); font-size: 20px; font-weight: 600; }
.go:hover { filter: brightness(1.05); }
.gbtn { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: 14px; }
.gbtn svg { width: 16px; height: 16px; }
.who { font-weight: 800; font-size: 15px; }

.banner { border-radius: 14px; padding: 12px 16px; font-weight: 700; background: color-mix(in srgb, var(--index) var(--tint), var(--surface)); border: 1.5px solid var(--index); }
.banner small { display: block; font-weight: 600; color: var(--muted); }
.note { border-radius: 14px; padding: 10px 14px; background: var(--surface); border: 1.5px dashed var(--line); color: var(--muted); font-size: 14px; font-weight: 600; }

.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 22px; padding: 20px clamp(16px, 3vw, 28px); display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* сегодня */
.today { display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; align-items: center; }
@media (max-width: 640px) { .today { grid-template-columns: 1fr; } }
.today h2 { font-size: clamp(24px, 4.6vw, 34px); }
.meter { display: flex; flex-direction: column; gap: 6px; }
.meter .lbl { display: flex; justify-content: space-between; font-weight: 800; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter .lbl b { color: var(--ink); }
.track { height: 10px; border-radius: 10px; background: var(--bg); overflow: hidden; }
.track i { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 10px; transition: width .3s; }
.week { display: flex; gap: 8px; align-items: center; font-weight: 800; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.week .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; color: var(--surface); }
.week .dot.on { background: var(--ok); border-color: var(--ok); }

/* список уроков */
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.ls { text-align: left; background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: center; }
.ls .t { grid-column: 2; } .ls .st { grid-column: 2; }
/* счётчик-барабанчик: сколько раз урок пройден целиком */
.odo { grid-column: 3; grid-row: 1 / span 2; display: inline-flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--ink); align-self: center; }
.odo .dg { width: 15px; height: 22px; overflow: hidden; border-radius: 4px; background: linear-gradient(var(--surface) 0 49%, color-mix(in srgb, var(--surface) 88%, var(--ink)) 51% 100%); }
.odo .strip { display: flex; flex-direction: column; transform: translateY(calc(var(--to) * -22px)); font-family: var(--mono); font-weight: 700; font-size: 14px; line-height: 22px; text-align: center; color: var(--ink); }
.odo .strip[data-roll="1"] { transform: translateY(calc(var(--from) * -22px)); }
.odo .strip[data-roll="1"].roll { transform: translateY(calc(var(--to) * -22px)); transition: transform 1.1s cubic-bezier(.2, .9, .25, 1.15) .35s; }
.ls:hover { border-color: var(--muted); }
.ls.next { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.ls.done .num { background: color-mix(in srgb, var(--ok) 20%, var(--surface)); }
.ls .num { grid-row: span 2; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-family: var(--display); font-size: 19px; background: var(--bg); }
.ls .t { font-weight: 800; line-height: 1.25; }
.ls .st { font-size: 14px; letter-spacing: 1px; color: var(--line); }
.ls .st b { color: var(--index); font-weight: 400; }
.redo { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: 0; color: var(--ink); background: color-mix(in srgb, var(--index) 26%, var(--surface)); vertical-align: 1px; }
.sec-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sec-h h3 { font-size: 22px; }

/* урок: список упражнений */
.exlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.ex { text-align: left; background: var(--bg); border: 1.5px solid transparent; border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.ex:hover { border-color: var(--muted); }
.ex.next { border-color: var(--accent); }
.ex .t { font-weight: 800; }
.ex .st { color: var(--line); letter-spacing: 1px; }
.ex .st b { color: var(--index); font-weight: 400; }

/* упражнение */
.ex-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.ex-head h2 { font-size: 24px; }
.stats { display: flex; gap: 18px; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; font-size: 14px; }
.stats b { color: var(--ink); font-size: 18px; }
.bar { height: 6px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .15s; }
.text { font-family: var(--mono); font-weight: 500; font-size: clamp(24px, 5vw, 40px); line-height: 1.6; white-space: pre-wrap; word-break: normal; overflow-wrap: break-word; min-height: 2.2em; letter-spacing: .02em; }
.text span { border-radius: 6px; }
.text .done { color: color-mix(in srgb, var(--ink) 35%, transparent); }
.text .done.miss { color: var(--bad); text-decoration: underline wavy; text-decoration-thickness: 1.5px; text-underline-offset: 6px; }
.text .cur { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: inset 0 -4px 0 var(--accent); }
.text .sp { position: relative; }
.text .cur.sp::before { content: "␣"; color: var(--accent); position: absolute; font-weight: 700; opacity: .8; }
.text.shake { animation: shake .22s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.ready { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 700; }
.ready .big { font-family: var(--mono); border: 1.5px solid var(--line); border-bottom-width: 4px; border-radius: 8px; padding: 2px 30px; }
.finger-say { display: flex; align-items: center; gap: 10px; font-weight: 800; min-height: 28px; flex-wrap: wrap; }
.finger-say i { width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; background: var(--fc); }

/* клавиатура */
.kb-wrap { display: flex; flex-direction: column; gap: 14px; }
.kb { display: flex; flex-direction: column; gap: 5px; user-select: none; }
.kb.hide .key:not(.target) { color: transparent; }
.row { display: flex; gap: 5px; }
.key { flex: var(--w, 1) 1 0; min-width: 0; height: clamp(30px, 6.2vw, 48px); border-radius: 8px; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: clamp(10px, 2.2vw, 16px); background: color-mix(in srgb, var(--fc) var(--tint), var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--fc) 45%, var(--surface)); border-bottom-width: 3px; position: relative; text-transform: uppercase; overflow: hidden; white-space: nowrap; }
.key.mod { font-size: clamp(8px, 1.5vw, 12px); text-transform: none; font-family: var(--body); color: var(--muted); }
.key.bump::after { content: ""; position: absolute; bottom: 18%; width: 28%; height: 2px; border-radius: 2px; background: currentColor; opacity: .7; }
.key.target { background: var(--fc); color: #fff; border-color: var(--fc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fc) 35%, transparent); animation: pulse 1.1s ease-in-out infinite; }
.key.target.mod { color: #fff; }
.key.wrong { background: var(--bad); color: #fff; border-color: var(--bad); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--fc) 15%, transparent); } }
.f-lp, .f-rp { --fc: var(--pinky); } .f-lr, .f-rr { --fc: var(--ring); }
.f-lm, .f-rm { --fc: var(--middle); } .f-li, .f-ri { --fc: var(--index); } .f-th { --fc: var(--thumb); }
.hands { display: flex; justify-content: center; gap: clamp(30px, 10vw, 110px); }
.hand { display: flex; align-items: flex-end; gap: 5px; height: 84px; }
.fg { width: clamp(14px, 3vw, 20px); border-radius: 10px 10px 6px 6px; background: color-mix(in srgb, var(--fc) var(--tint), var(--surface)); border: 1.5px solid color-mix(in srgb, var(--fc) 50%, var(--surface)); transition: background .12s, transform .12s; }
.fg.on { background: var(--fc); border-color: var(--fc); transform: translateY(-6px); }
.fg.th { height: 30px; margin-bottom: -6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; color: var(--muted); font-size: 13px; font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; background: var(--fc); }
.under { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }

/* итог */
.res { text-align: center; align-items: center; padding-block: 28px; }
.res .big-stars { font-size: 52px; letter-spacing: 6px; color: var(--line); line-height: 1; }
.res .big-stars b { color: var(--index); font-weight: 400; }
.res h2 { font-size: clamp(26px, 5vw, 36px); }
.nums { display: flex; gap: 28px; justify-content: center; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.nums div { display: flex; flex-direction: column; }
.nums b { font-family: var(--display); font-size: 34px; font-weight: 600; }
.nums span { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.saved { font-size: 13px; font-weight: 700; color: var(--muted); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; width: 100%; height: 100%; }

/* кабинет семьи */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile .v { font-family: var(--display); font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .k { color: var(--muted); font-size: 13px; font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.pill.good { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ink); }
.pill.warn { background: color-mix(in srgb, var(--index) 22%, var(--surface)); color: var(--ink); }
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 15px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; }
td.n, th.n { text-align: right; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-family: var(--body); font-size: 12px; }
.chart .ax { stroke: var(--grid); stroke-width: 1; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 700; box-shadow: 0 6px 18px color-mix(in srgb, var(--ink) 14%, transparent); white-space: nowrap; }
.tip i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 6px; }
.lg { display: flex; gap: 16px; font-size: 13px; font-weight: 700; color: var(--muted); }
.lg span { display: inline-flex; align-items: center; gap: 6px; }
.lg i { width: 14px; height: 2px; border-radius: 2px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { border-radius: 12px; background: var(--bg); padding: 8px 6px; text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.day b { display: block; font-family: var(--display); font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }
.day.hit { background: color-mix(in srgb, var(--ok) 22%, var(--surface)); }
.day.today { outline: 2px solid var(--ink); outline-offset: -2px; }

@media (prefers-reduced-motion: reduce) { .odo .strip[data-roll="1"].roll { transition: none; } .key.target { animation: none; } .text.shake { animation: none; } .fg, .bar i, .track i { transition: none; } }
