:root {
  --bg: #F6F3EC;
  --surface: #FFFFFF;
  --surface-2: #EFEADF;
  --text: #1D1C19;
  --muted: #6A665C;
  --line: #E4DED0;
  --accent: #0B7FA3;
  --accent-2: #D9F0F6;
  --on-accent: #FFFFFF;
  --gold: #C99400;
  --gold-2: #FFF1C7;
  --ok: #1E8A4C;
  --ok-2: #DDF3E5;
  --warn: #B86A00;
  --warn-2: #FDEBD2;
  --bad: #C63D33;
  --bad-2: #FBE1DE;
  --shadow: 0 1px 2px rgba(40, 32, 12, .06), 0 4px 16px rgba(40, 32, 12, .06);
  --r: 16px;
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101416; --surface: #181D20; --surface-2: #20272B; --text: #ECEAE4; --muted: #9A978E; --line: #2A3237;
    --accent: #3CC0E0; --accent-2: #103642; --on-accent: #06222B; --gold: #F0C34A; --gold-2: #3A300F;
    --ok: #4CC37C; --ok-2: #10301E; --warn: #F0A43C; --warn-2: #3A2A10; --bad: #F07268; --bad-2: #3A1816;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101416; --surface: #181D20; --surface-2: #20272B; --text: #ECEAE4; --muted: #9A978E; --line: #2A3237;
  --accent: #3CC0E0; --accent-2: #103642; --on-accent: #06222B; --gold: #F0C34A; --gold-2: #3A300F;
  --ok: #4CC37C; --ok-2: #10301E; --warn: #F0A43C; --warn-2: #3A2A10; --bad: #F07268; --bad-2: #3A1816;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; letter-spacing: -.01em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.kk { font-size: 20px; font-weight: 600; letter-spacing: -.005em; }
.kk.big { font-size: 26px; }
.ru { color: var(--muted); }

#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; }
#top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 18px; }
#topright { display: flex; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.fire { color: var(--warn); }
.chip.gold { background: var(--gold-2); border-color: transparent; color: var(--text); }

#view { padding: 4px 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px); outline: none; }
.boot { padding: 40px 0; text-align: center; color: var(--muted); }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-top: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
#tabs a { flex: 1; max-width: 128px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--muted); font-size: 11px; font-weight: 600; }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.on { color: var(--accent); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.sec { margin: 22px 2px 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card.tight { padding: 12px 14px; }
.card.hero { background: linear-gradient(135deg, #0B7FA3 0%, #0A5670 100%); color: #fff; border: none; }
.card.hero .muted, .card.hero .ru { color: rgba(255,255,255,.82); }
.card.gold { background: var(--gold-2); border-color: transparent; }
.card.link { display: block; color: inherit; }
.card.link:active { transform: scale(.99); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.card.hero .btn.primary { background: #fff; color: #0B7FA3; border-color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding-left: 8px; padding-right: 8px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btn svg, .icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--surface); cursor: pointer; flex: none; }
.iconbtn.accent { background: var(--accent-2); border-color: transparent; color: var(--accent); }
.iconbtn.playing { background: var(--accent); color: var(--on-accent); }

.mic {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 12px 22px; border-radius: 999px;
  border: none; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 17px; cursor: pointer; box-shadow: var(--shadow);
}
.mic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mic.on { background: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
.mic.busy { opacity: .7; }
.mic.block { width: 100%; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); } 50% { box-shadow: 0 0 0 10px transparent; } }

.tile { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--text); min-height: 86px; }
.tile b { font-size: 15px; }
.tile span { font-size: 12px; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 520px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--text); min-height: 52px; }
.li:first-child { border-top: none; }
.li .t { font-weight: 600; }
.li .s { font-size: 13px; color: var(--muted); }
.check { color: var(--ok); font-weight: 800; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--ok-2); color: var(--ok); }
.pill.warn { background: var(--warn-2); color: var(--warn); }
.pill.bad { background: var(--bad-2); color: var(--bad); }
.pill.acc { background: var(--accent-2); color: var(--accent); }

.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .4s; }
.card.hero .bar { background: rgba(255,255,255,.25); }
.card.hero .bar > i { background: #fff; }

.ring { width: 64px; height: 64px; flex: none; }
.ring circle { fill: none; stroke-width: 7; }
.ring .bg { stroke: rgba(255,255,255,.25); }
.ring .fg { stroke: #fff; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .5s; }

/* урок */
.steps { display: flex; gap: 6px; margin: 4px 0 14px; }
.steps i { flex: 1; height: 5px; border-radius: 9px; background: var(--surface-2); }
.steps i.done { background: var(--accent); }
.steps i.cur { background: var(--gold); }
.bubbles { display: flex; flex-direction: column; gap: 10px; }
.bub { max-width: 88%; padding: 10px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.bub.me { align-self: flex-end; background: var(--accent-2); border-color: transparent; }
.bub .who { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.bub .kk { font-size: 18px; }
.bub.now { outline: 2px solid var(--gold); }
.bub .hidden { letter-spacing: .3em; color: var(--muted); }
.g { border-bottom: 1.5px dotted color-mix(in srgb, var(--accent) 60%, transparent); cursor: help; }
.pop { position: fixed; z-index: 30; max-width: 260px; padding: 8px 12px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); pointer-events: none; }

.result { border-radius: 14px; padding: 12px 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.words { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 18px; font-weight: 600; }
.w-ok { color: var(--ok); }
.w-close { color: var(--warn); }
.w-wrong, .w-missed { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 4px; }
.score { font-size: 28px; font-weight: 800; }
.score.ok { color: var(--ok); } .score.warn { color: var(--warn); } .score.bad { color: var(--bad); }

.fix { border-left: 3px solid var(--warn); padding: 6px 10px; background: var(--warn-2); border-radius: 0 10px 10px 0; font-size: 14px; }
.fix b { display: block; }

.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.chatbar { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 8px); display: flex; gap: 8px; align-items: center; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.hints { display: flex; flex-direction: column; gap: 6px; }

input[type=text], input[type=url], input[type=time], textarea, select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 72px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 38px; border: none; background: transparent; border-radius: 9px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); }
.switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; }
.heat i { width: 13px; height: 13px; border-radius: 3px; background: var(--surface-2); }
.heat i.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); }
.heat i.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
.heat i.l3 { background: color-mix(in srgb, var(--accent) 80%, var(--surface-2)); }
.heat i.l4 { background: var(--accent); }
.heat i.fz { background: var(--gold); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat b { display: block; font-size: 24px; font-weight: 800; }
.stat span { font-size: 13px; color: var(--muted); }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#snack { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 40; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; transition: .25s; pointer-events: none; max-width: calc(100vw - 32px); }
#snack.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.xp { position: fixed; z-index: 41; font-weight: 800; color: var(--gold); pointer-events: none; animation: xp 1.1s ease-out forwards; }
@keyframes xp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-50px); } }

.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; margin: 4px 0 10px; min-height: 36px; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
details summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }
hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
