/* Azbuka — stylesheet */
:root {
  --bg: #f4f3ee;
  --surface: #ffffff;
  --surface-2: #ebe9e2;
  --text: #16181d;
  --muted: #676c78;
  --border: #e0ded6;
  --accent: #2f55d4;
  --accent-ink: #ffffff;
  --accent-soft: #e3e9fb;
  --ok: #1c8f5a;
  --ok-soft: #dcf3e6;
  --bad: #cf3d3d;
  --bad-soft: #fbe3e3;
  --warn: #c98a05;
  --warn-soft: #fbf0d2;
  --gold: #d4a017;
  --radius: 18px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 10px 30px -14px rgba(20, 20, 30, .18);
  --font: "Inter", "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-cyr: "Noto Sans", "Inter", system-ui, sans-serif;
  --font-cyr-italic: "Noto Serif", "PT Serif", Georgia, "Times New Roman", serif;
}
[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #171a21;
  --surface-2: #20242d;
  --text: #ecEEf3;
  --muted: #8d93a3;
  --border: #2a2f3a;
  --accent: #7d97ff;
  --accent-ink: #0b1230;
  --accent-soft: #222c50;
  --ok: #3fd08f;
  --ok-soft: #16342a;
  --bad: #ff6f6f;
  --bad-soft: #3d1f22;
  --warn: #f5b731;
  --warn-soft: #3a2f12;
  --gold: #f1c148;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 14px 36px -16px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
kbd { font: inherit; font-size: .75rem; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
button { font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-family: var(--font-cyr-italic); font-style: italic; font-size: 22px; line-height: 1;
}
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { position: relative; padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .72rem; font-weight: 700; vertical-align: middle; }
.top-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--surface); }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 999px; cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--text); color: var(--bg); }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 16px; }
.icon-btn:hover { background: var(--surface-2); }

/* Layout */
.container { width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 16px 60px; flex: 1; }
.foot { padding: 20px 16px 30px; text-align: center; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.section { margin-top: 32px; }
.back { display: inline-block; margin-bottom: 14px; color: var(--muted); font-weight: 500; }
@media (max-width: 680px) { .grid-2 { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; transition: transform .08s ease, background .15s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.lg { padding: 14px 24px; font-size: 1.05rem; border-radius: 14px; }
.btn.sm { padding: 6px 12px; font-size: .85rem; border-radius: 9px; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.speak { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 17px; flex: none; }
.speak:hover { background: var(--accent-soft); border-color: var(--accent); }
.speak.playing { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.speak.tts::after { content: ""; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-size: .82rem; font-weight: 600; color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.gold { background: var(--warn-soft); color: var(--warn); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* Alphabet picker */
.hero { text-align: center; padding: 30px 0 10px; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); }
.hero .lead { font-size: 1.15rem; color: var(--muted); max-width: 520px; margin: 0 auto 28px; }
.picker { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 640px; margin: 0 auto; }
.pick { text-align: left; cursor: pointer; transition: transform .12s ease, border-color .12s ease; }
.pick:hover { transform: translateY(-2px); border-color: var(--accent); }
.pick .flag { font-size: 2rem; }
.pick .big { font-family: var(--font-cyr); font-size: 2.6rem; font-weight: 700; letter-spacing: .04em; margin: 6px 0; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; max-width: 760px; margin: 36px auto 0; text-align: left; }
.feature { padding: 14px 16px; border-radius: var(--radius-s); background: var(--surface); border: 1px solid var(--border); }
.feature b { display: block; margin-bottom: 2px; }
@media (max-width: 560px) { .picker { grid-template-columns: 1fr; } }

/* Dashboard */
.dash-hero { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; }
.ring { width: 120px; height: 120px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring .label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring .label b { font-size: 1.5rem; }
.ring .label span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.next-letter { display: flex; align-items: center; gap: 18px; }
.next-letter .glyph { font-family: var(--font-cyr); font-size: 4rem; font-weight: 700; line-height: 1; width: 84px; height: 84px; display: grid; place-items: center; border-radius: 20px; background: var(--accent-soft); color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 16px; }
.stat { padding: 12px 14px; border-radius: var(--radius-s); background: var(--surface); border: 1px solid var(--border); }
.stat b { display: block; font-size: 1.4rem; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
@media (max-width: 600px) { .dash-hero { grid-template-columns: 1fr; } .ring { margin: 0 auto; } }

.group { margin-top: 22px; }
.group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.group-head h3 { margin: 0; }
.group-head .blurb { color: var(--muted); font-size: .9rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-family: var(--font-cyr); transition: transform .1s ease, border-color .1s ease;
  text-decoration: none; color: var(--text);
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.tile .g { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.tile .s { font-size: .72rem; color: var(--muted); font-family: var(--font); }
.tile.locked { opacity: .45; cursor: not-allowed; }
.tile.locked:hover { transform: none; border-color: var(--border); }
.tile.next { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tile.learning { background: var(--accent-soft); border-color: transparent; }
.tile.mastered { background: var(--ok-soft); border-color: transparent; }
.tile.mastered .s { color: var(--ok); }
.tile.due::after { content: ""; position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 5px; border: 1px solid var(--border); background: var(--surface); }
.legend i.learning { background: var(--accent-soft); border-color: transparent; }
.legend i.mastered { background: var(--ok-soft); border-color: transparent; }
.legend i.due { background: var(--warn); border-color: transparent; border-radius: 50%; }

/* Lesson */
.letter-card { text-align: center; }
.letter-forms { display: flex; justify-content: center; align-items: baseline; gap: 28px; margin: 6px 0 14px; }
.letter-forms .form { font-size: clamp(4.2rem, 14vw, 6.5rem); line-height: 1; font-weight: 700; font-family: var(--font-cyr); }
.letter-forms .form.italic { font-family: var(--font-cyr-italic); font-style: italic; font-weight: 400; color: var(--muted); }
.form-label { display: flex; justify-content: center; gap: 48px; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.letter-meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.sound-big { font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.sound-big small { font-size: 1rem; font-weight: 500; color: var(--muted); margin-left: 8px; }
.mnemonic { margin-top: 14px; padding: 14px 16px; border-radius: var(--radius-s); background: var(--warn-soft); border-left: 4px solid var(--warn); }
.mnemonic b { color: var(--warn); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; display: block; margin-bottom: 2px; }
.words { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.word-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-s); background: var(--surface); border: 1px solid var(--border); text-align: left; }
.word-card .w-cyr { font-family: var(--font-cyr); font-size: 1.4rem; font-weight: 700; }
.word-card .w-cyr mark { background: none; color: var(--accent); }
.word-card .w-tr { color: var(--muted); font-size: .9rem; }
.word-card .w-mean { font-size: .85rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

/* Quiz */
.quiz { max-width: 640px; margin: 0 auto; }
.quiz-head { display: flex; align-items: center; gap: 12px; font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s ease; }
.quiz-title { text-align: center; font-size: 1.1rem; color: var(--muted); font-weight: 500; }
.quiz-big { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0 20px; font-family: var(--font-cyr); font-size: clamp(3.4rem, 12vw, 5.5rem); font-weight: 700; line-height: 1.1; min-height: 1.2em; animation: pop .25s ease; }
.quiz-big.word { font-size: clamp(2.4rem, 9vw, 3.6rem); }
.quiz-big.sound { font-family: var(--font); letter-spacing: -.02em; }
.quiz-big .lower { color: var(--muted); font-weight: 400; }
.quiz-sub { text-align: center; color: var(--muted); margin: -10px 0 16px; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices.letters { grid-template-columns: repeat(4, 1fr); }
.choice { display: flex; align-items: center; gap: 10px; padding: 14px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-align: left; transition: border-color .1s ease, background .1s ease; }
.choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.choice .choice-main { font-weight: 700; font-size: 1.15rem; }
.choice .choice-sub { display: block; font-size: .8rem; color: var(--muted); font-weight: 400; }
.choice .choice-main.cyr { font-family: var(--font-cyr); font-size: 1.9rem; }
.choices.letters .choice { flex-direction: column; justify-content: center; text-align: center; padding: 14px 6px; }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake .3s ease; }
.choice.dim { opacity: .5; }
.choice:disabled { cursor: default; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.type-form { display: flex; gap: 10px; }
.type-form input { flex: 1; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); font-size: 1.3rem; font-weight: 600; outline: none; }
.type-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.type-form input.correct { border-color: var(--ok); background: var(--ok-soft); }
.type-form input.wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-s); display: flex; gap: 12px; align-items: flex-start; animation: pop .2s ease; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback .fb-body { color: var(--text); flex: 1; }
.feedback .fb-body b { color: inherit; }
.feedback .fb-title { font-weight: 800; }
.quiz-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
@media (max-width: 520px) { .choices { grid-template-columns: 1fr; } .choices.letters { grid-template-columns: repeat(2, 1fr); } }

/* Result */
.result { text-align: center; max-width: 520px; margin: 0 auto; }
.result .score { font-size: 3.2rem; font-weight: 800; line-height: 1; margin: 10px 0; }
.result .score small { font-size: 1.2rem; color: var(--muted); font-weight: 600; }
.result-list { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 16px 0 22px; }
.result-list span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; font-family: var(--font-cyr); font-weight: 700; font-size: 1.2rem; }
.result-list .ok { background: var(--ok-soft); color: var(--ok); }
.result-list .bad { background: var(--bad-soft); color: var(--bad); }

/* Chart */
.chart { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.chart-cell { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-s); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.chart-cell:hover { text-decoration: none; border-color: var(--accent); }
.chart-cell .g { font-family: var(--font-cyr); font-size: 1.8rem; font-weight: 700; line-height: 1; }
.chart-cell .g small { font-weight: 400; color: var(--muted); }
.chart-cell .s { font-weight: 700; }
.chart-cell .l { font-size: .75rem; color: var(--muted); display: block; line-height: 1.2; }
.chart-cell.mastered { background: var(--ok-soft); border-color: transparent; }
.chart-cell.learning { background: var(--accent-soft); border-color: transparent; }

/* Games */
.game-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .game-cards { grid-template-columns: 1fr; } }
.game-card h2 { display: flex; align-items: center; gap: 10px; }
.game-card .emoji { font-size: 1.6rem; }
.speed-word { text-align: center; font-family: var(--font-cyr); font-size: clamp(2.6rem, 10vw, 4rem); font-weight: 700; margin: 16px 0; min-height: 1.3em; animation: pop .2s ease; }
.speed-word.flash-ok { color: var(--ok); }
.speed-word.flash-bad { color: var(--bad); }
.hud { display: flex; justify-content: space-between; font-weight: 700; font-size: 1.05rem; }
.hud .t { color: var(--accent); }
.match-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.m-tile { aspect-ratio: 1; display: grid; place-items: center; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 700; font-size: 1.1rem; transition: transform .1s ease, background .15s ease; }
.m-tile.cyr { font-family: var(--font-cyr); font-size: 1.9rem; }
.m-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.m-tile.sel { background: var(--accent-soft); border-color: var(--accent); }
.m-tile.done { background: var(--ok-soft); border-color: transparent; color: var(--ok); opacity: .6; cursor: default; transform: none; }
.m-tile.wrong { background: var(--bad-soft); border-color: var(--bad); animation: shake .3s ease; }
@media (max-width: 420px) { .m-tile { font-size: .95rem; } }

/* Converter */
.convert textarea { width: 100%; min-height: 150px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); resize: vertical; font-size: 1.1rem; line-height: 1.5; outline: none; }
.convert textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.convert .out { white-space: pre-wrap; word-break: break-word; min-height: 150px; font-size: 1.1rem; font-family: var(--font-cyr); }
.convert .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }

/* Settings */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting p { margin: 0; }

.fade { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); z-index: 50; animation: fade .2s ease; }
.speak svg, .icon-btn svg { display: block; }
.speak.tts { border-style: dashed; color: var(--muted); }

/* Mobile: bottom tab bar */
@media (max-width: 640px) {
  .top { gap: 10px; backdrop-filter: none; background: var(--bg); } /* backdrop-filter would trap the fixed nav */
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--border); }
  .nav:empty { display: none; }
  .nav a { text-align: center; padding: 8px 4px; font-size: .8rem; border-radius: 10px; }
  .badge { position: absolute; top: 2px; right: 6px; margin: 0; min-width: 18px; height: 18px; font-size: .68rem; }
  .container { padding-bottom: 90px; }
  .foot { padding-bottom: 80px; }
}

/* Accounts */
.user-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: .85rem; color: var(--text); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip:hover { text-decoration: none; background: var(--surface-2); }
.user-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.user-chip i[data-state="saving"] { background: var(--warn); }
.user-chip i[data-state="error"] { background: var(--bad); }
.guest-hint { margin: 14px 0 0; }
.auth { max-width: 440px; margin: 20px auto; }
.auth-tabs { margin-bottom: 18px; }
.field { display: grid; gap: 6px; }
.field span { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field input, .setting input[type=password] { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); outline: none; font-size: 1rem; }
.field input:focus, .setting input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.setting input[type=password] { padding: 7px 10px; width: 130px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; }
.check input { margin-top: 3px; }
.form-error { padding: 10px 14px; border-radius: var(--radius-s); background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: .9rem; }
.lb { width: 100%; border-collapse: collapse; font-size: .95rem; }
.lb th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.lb td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.lb tr:last-child td { border-bottom: 0; }
.lb tr.me td { background: var(--accent-soft); }
@media (max-width: 640px) { .lb th:nth-child(n+5), .lb td:nth-child(n+5) { display: none; } .nav a { font-size: .74rem; padding: 8px 2px; } }

/* ---- v2: utilities (no inline styles, strict CSP) ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; padding: 8px 12px; background: var(--accent); color: var(--accent-ink); border-radius: 8px; }
.skip:focus { left: 8px; }
.center { justify-content: center; }
.tight { margin: 2px 0 8px; }
.fw5 { font-weight: 500; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt14 { margin-top: 14px; } .mt16 { margin-top: 16px; } .mb16 { margin-bottom: 16px; }
.grow { flex: 1; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--muted); }
.stat-of { font-size: .9rem; font-weight: 500; }
.g-lower { font-weight: 400; color: var(--muted); }
.hint { margin-top: 10px; text-align: center; }
.warn-text { color: var(--warn); }
.result-list .plain { background: var(--surface-2); }
.landing-foot { margin-top: 28px; }
.hero .btn.lg { margin-top: 4px; }
.group-head .btn { margin-left: auto; }
.quiz-big.listen { min-height: 0; }
.listen-btn { font-family: var(--font); font-size: 1rem; }
.know-quiz { width: 100%; }
.know-quiz .choices { margin-top: 10px; }
.know-quiz .feedback { align-items: center; }
.seo-nav { justify-content: flex-end; }
.seo-glyph { font-family: var(--font-cyr); font-weight: 700; font-size: 1.6rem; }
.seo-letter h1 .seo-glyph { font-size: 4rem; }
.seo-table td, .seo-table th { vertical-align: middle; }
.seo-letter audio { height: 32px; vertical-align: middle; }
.nav a.more-link { display: none; }

/* Trace canvas */
.trace canvas { display: block; width: 100%; max-width: 600px; aspect-ratio: 2; border-radius: var(--radius); border: 1px solid var(--border); touch-action: none; cursor: crosshair; background: var(--surface-2); }

/* Reading */
.texts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.text-card { display: block; color: var(--text); transition: transform .12s ease, border-color .12s ease; }
.text-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.text-card.locked { opacity: .7; }
.text-preview { font-family: var(--font-cyr); font-size: 1.05rem; margin-top: 8px; color: var(--muted); }
.text-preview.italic, .read-words.italic { font-family: var(--font-cyr-italic); font-style: italic; }
.read-card { padding: 10px 20px; }
.read-line { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.read-line:last-child { border-bottom: 0; }
.read-words { font-family: var(--font-cyr); font-size: clamp(1.4rem, 4vw, 1.9rem); line-height: 1.9; }
.rw { display: inline-flex; flex-direction: column; align-items: center; border: 0; background: none; padding: 0 2px; border-radius: 8px; font: inherit; cursor: pointer; vertical-align: top; }
.rw:hover, .rw.open { background: var(--accent-soft); }
.rw .tr { font-family: var(--font); font-size: .75rem; color: var(--accent); line-height: 1.1; margin-top: -8px; margin-bottom: 4px; }
.rw-plain { font: inherit; }
.read-en { grid-column: 1 / -1; color: var(--muted); font-size: .95rem; }
.read-done { margin-top: 16px; }

/* Stats heatmap */
.hm { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.hm i, .hm-l { display: block; width: 12px; height: 12px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); }
.hm i.l1, .hm-l.l1 { background: color-mix(in srgb, var(--accent) 25%, var(--surface)); border-color: transparent; }
.hm i.l2, .hm-l.l2 { background: color-mix(in srgb, var(--accent) 50%, var(--surface)); border-color: transparent; }
.hm i.l3, .hm-l.l3 { background: color-mix(in srgb, var(--accent) 75%, var(--surface)); border-color: transparent; }
.hm i.l4, .hm-l.l4 { background: var(--accent); border-color: transparent; }
.legend .hm-l { display: inline-block; vertical-align: middle; margin: 0 1px; }

/* About / More */
.prose { max-width: 680px; }
.prose h2 { margin-top: 24px; }
.more-list { display: grid; gap: 10px; }
.more-item { display: grid; gap: 2px; color: var(--text); padding: 14px 18px; }
.more-item:hover { text-decoration: none; border-color: var(--accent); }

/* Mobile: 5 primary tabs + More */
@media (max-width: 640px) {
  .nav a.secondary { display: none; }
  .nav a.more-link { display: block; }
  .nav a { font-size: .74rem; padding: 8px 2px; }
  .read-line { grid-template-columns: 1fr; }
  .group-head .btn { margin-left: 0; }
}

/* Stress mark drawn by CSS instead of a combining character */
.st { -webkit-text-emphasis: "\02CA"; text-emphasis: "\02CA"; -webkit-text-emphasis-position: over right; text-emphasis-position: over right; text-emphasis-color: currentColor; }
.w-cyr mark .st, mark .st { text-emphasis-color: var(--accent); }
