:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --text: #171a2b;
  --muted: #697089;
  --line: #dfe3ef;
  --primary: #272bdb;
  --primary-2: #4d51ee;
  --primary-soft: #ececff;
  --success: #0d9f6e;
  --success-soft: #e8f8f2;
  --warning: #d78000;
  --warning-soft: #fff3dd;
  --danger: #d84343;
  --danger-soft: #ffeaea;
  --shadow: 0 18px 50px rgba(31, 37, 83, .10);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --sidebar: 232px;
  --topbar: 74px;
  --typing-font-size: 31px;
}

[data-theme="dark"] {
  --bg: #11131c;
  --surface: #1a1d29;
  --surface-2: #232735;
  --text: #f4f5fb;
  --muted: #a4aac0;
  --line: #323748;
  --primary: #7d80ff;
  --primary-2: #9c9eff;
  --primary-soft: #2a2d54;
  --success-soft: #173b31;
  --warning-soft: #4a3517;
  --danger-soft: #4a2428;
  --shadow: 0 18px 50px rgba(0, 0, 0, .26);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: var(--topbar) minmax(0, 1fr);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar);
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark, .onboarding-logo {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary-2), var(--primary)); color: white; font-weight: 800;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 28%, transparent);
}
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-button {
  width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface);
  display: grid; place-items: center; cursor: pointer; transition: .2s ease;
}
.icon-button:hover { transform: translateY(-1px); border-color: var(--primary); }
.profile-chip {
  display: inline-flex; align-items: center; gap: 9px; padding: 5px 12px 5px 5px; border: 1px solid var(--line);
  background: var(--surface); border-radius: 999px; cursor: pointer;
}
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 800; }

.sidebar {
  position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); padding: 22px 14px 18px;
  display: flex; flex-direction: column; gap: 7px; background: var(--surface); border-right: 1px solid var(--line); z-index: 20;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-radius: 13px;
  background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; text-align: left; transition: .18s ease;
}
.nav-item span { width: 22px; text-align: center; font-size: 18px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-spacer { flex: 1; }
.daily-mini { padding: 14px; border-radius: 16px; background: var(--surface-2); }
.daily-mini-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-bottom: 8px; color: var(--muted); }
.daily-mini-row strong { color: var(--text); }
.progress-track, .course-progress-line, .trainer-progress { height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-fill, .course-progress-line > div, .trainer-progress > div { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width .35s ease; }
.back-site { margin-top: 7px; padding: 11px 13px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 700; }
.back-site:hover { color: var(--primary); }

.main { min-width: 0; padding: 32px; }
.view { display: none; animation: viewIn .28s ease; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(30px, 3.2vw, 48px); line-height: 1.06; letter-spacing: -.035em; }
h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
p { color: var(--muted); line-height: 1.65; }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 20px; }
.hero-card, .goal-card, .panel, .stat-card, .mode-card, .test-card {
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.hero-card {
  min-height: 340px; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(220px, .65fr); align-items: center;
  padding: 42px; border-radius: var(--radius-xl); overflow: hidden; position: relative;
}
.hero-card p:not(.eyebrow) { max-width: 690px; font-size: 17px; margin: 18px 0 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.primary-button, .secondary-button, .danger-button, .text-button {
  border: 0; border-radius: 13px; font-weight: 800; cursor: pointer; transition: .18s ease;
}
.primary-button { padding: 13px 19px; background: linear-gradient(145deg, var(--primary-2), var(--primary)); color: white; box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 24%, transparent); }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.04); }
.primary-button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.secondary-button { padding: 12px 18px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.secondary-button:hover { border-color: var(--primary); color: var(--primary); }
.secondary-button.small { padding: 9px 13px; font-size: 13px; }
.danger-button { padding: 12px 18px; background: var(--danger-soft); color: var(--danger); }
.text-button { padding: 8px; background: transparent; color: var(--primary); }
.text-button.danger { color: var(--danger); }
.full { width: 100%; }
.hero-illustration { position: relative; height: 230px; min-width: 230px; }
.hands-symbol { position: absolute; inset: 55px 0 auto; font-size: 42px; text-align: center; filter: drop-shadow(0 12px 22px rgba(0,0,0,.12)); }
.floating-key { position: absolute; width: 68px; height: 68px; border-radius: 18px; display: grid; place-items: center; font-size: 26px; font-weight: 900; background: var(--surface-2); border: 1px solid var(--line); box-shadow: var(--shadow); animation: float 4s ease-in-out infinite; }
.key-a { top: 8px; left: 22px; transform: rotate(-8deg); }
.key-j { right: 12px; top: 32px; transform: rotate(8deg); animation-delay: .7s; }
.key-shift { bottom: 5px; left: 88px; width: 88px; animation-delay: 1.3s; }
@keyframes float { 0%,100% { translate: 0 0; } 50% { translate: 0 -9px; } }
.goal-card { min-height: 340px; padding: 30px; border-radius: var(--radius-xl); display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.goal-ring { --p: 0; width: 148px; height: 148px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 22px; background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-2) 0); position: relative; }
.goal-ring::after { content: ""; position: absolute; inset: 13px; border-radius: inherit; background: var(--surface); }
.goal-ring span { position: relative; z-index: 1; font-size: 29px; font-weight: 900; }
.goal-card h2 { font-size: 26px; }
.goal-card p { margin-bottom: 0; font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 20px 0; }
.stat-card { padding: 21px; border-radius: var(--radius-lg); box-shadow: none; }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card span { font-size: 13px; font-weight: 700; }
.stat-card strong { display: block; margin: 8px 0 5px; font-size: 28px; letter-spacing: -.03em; }
.stat-card small { font-size: 12px; }
.dashboard-grid, .statistics-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.panel { padding: 25px; border-radius: var(--radius-xl); box-shadow: none; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.recommended-lesson { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 17px; border-radius: var(--radius-lg); background: var(--surface-2); }
.lesson-badge { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 900; font-size: 20px; }
.recommended-lesson strong, .recommended-lesson small { display: block; }
.recommended-lesson small { color: var(--muted); margin-top: 4px; }
canvas { display: block; width: 100%; max-width: 100%; height: auto; }
.problem-panel { margin-top: 20px; }
.problem-keys { display: flex; flex-wrap: wrap; gap: 10px; }
.problem-key { min-width: 70px; padding: 12px; border-radius: 14px; background: var(--surface-2); text-align: center; }
.problem-key strong { display: block; font-size: 22px; }
.problem-key small { color: var(--muted); }
.empty-state { color: var(--muted); padding: 14px 0; }

.page-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 25px; }
.page-heading p:not(.eyebrow) { margin-bottom: 0; max-width: 760px; }
.course-progress-box { min-width: 110px; text-align: right; }
.course-progress-box strong { display: block; font-size: 32px; }
.course-progress-box span { color: var(--muted); font-size: 13px; }
.course-progress-line { margin-bottom: 26px; }
.course-modules { display: grid; gap: 20px; }
.course-module { border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); overflow: hidden; }
.module-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.module-head p { margin: 5px 0 0; font-size: 13px; }
.module-status { font-size: 12px; font-weight: 800; color: var(--primary); background: var(--primary-soft); padding: 7px 10px; border-radius: 999px; white-space: nowrap; }
.lesson-list { display: grid; }
.lesson-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 16px; align-items: center; padding: 17px 24px; border-bottom: 1px solid var(--line); }
.lesson-row:last-child { border-bottom: 0; }
.lesson-index { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); font-weight: 900; }
.lesson-row.completed .lesson-index { background: var(--success-soft); color: var(--success); }
.lesson-row.locked { opacity: .55; }
.lesson-row strong, .lesson-row small { display: block; }
.lesson-row small { margin-top: 4px; color: var(--muted); }
.lesson-result { text-align: right; min-width: 90px; }
.lesson-result strong { font-size: 14px; }
.lesson-result small { font-size: 11px; }
.lesson-row button { min-width: 90px; }

.mode-grid, .test-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.mode-card, .test-card { padding: 25px; border-radius: var(--radius-xl); box-shadow: none; display: flex; flex-direction: column; }
.mode-icon, .test-icon { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 23px; margin-bottom: 22px; }
.mode-card h2, .test-card h2 { font-size: 20px; }
.mode-card p, .test-card p { flex: 1; font-size: 14px; }
.mode-card .secondary-button, .test-card .secondary-button { width: 100%; }
.custom-text-panel, .rules-panel { margin-top: 20px; }
textarea, input, select { color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
textarea { width: 100%; padding: 16px; resize: vertical; line-height: 1.55; }
input, select { width: 100%; padding: 12px 13px; }
.inline-options { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; margin-top: 14px; }
.inline-options label { color: var(--muted); font-size: 13px; }
.inline-options input { width: auto; }
.inline-options .primary-button { margin-left: auto; }
.rule-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 20px; }
.rule-grid > div { display: flex; align-items: center; gap: 12px; padding: 15px; background: var(--surface-2); border-radius: 15px; }
.rule-grid strong { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); }
.rule-grid span { color: var(--muted); font-size: 13px; }

.stat-grid.detailed { margin-top: 0; }
.chart-panel { min-width: 0; }
.panel select { width: auto; min-width: 110px; padding: 8px 10px; }
.key-heatmap { display: grid; grid-template-columns: repeat(auto-fit, minmax(48px, 1fr)); gap: 8px; }
.heat-key { aspect-ratio: 1; min-height: 48px; border-radius: 11px; display: grid; place-items: center; text-align: center; border: 1px solid var(--line); background: var(--surface-2); }
.heat-key strong { display: block; font-size: 16px; }
.heat-key small { display: block; font-size: 9px; color: var(--muted); }
.heat-good { background: var(--success-soft); }
.heat-mid { background: var(--warning-soft); }
.heat-bad { background: var(--danger-soft); }
.history-panel { margin-top: 20px; }
.history-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 690px; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
td strong { color: var(--text); }
.result-pass { color: var(--success); font-weight: 800; }
.result-fail { color: var(--danger); font-weight: 800; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.settings-card h2 { margin-bottom: 20px; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 700; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row strong, .switch-row small { display: block; }
.switch-row small { color: var(--muted); margin-top: 4px; }
.switch-row input { appearance: none; width: 46px; height: 26px; flex: 0 0 auto; padding: 0; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; }
.switch-row input::after { content: ""; width: 20px; height: 20px; border-radius: 50%; background: white; position: absolute; top: 2px; left: 2px; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: .18s ease; }
.switch-row input:checked { background: var(--primary); }
.switch-row input:checked::after { left: 22px; }
.button-stack { display: flex; flex-wrap: wrap; gap: 10px; }
.file-button { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.file-button input { display: none; }

.trainer-screen { position: fixed; inset: 0; z-index: 100; display: none; background: var(--bg); overflow: auto; }
.trainer-screen.active { display: flex; flex-direction: column; }
.trainer-topbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 15px 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.trainer-title strong, .trainer-title small { display: block; }
.trainer-title small { color: var(--muted); margin-top: 2px; }
.trainer-live-stats { display: flex; gap: 26px; }
.trainer-live-stats div { min-width: 78px; text-align: right; }
.trainer-live-stats span, .trainer-live-stats strong { display: block; }
.trainer-live-stats span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.trainer-live-stats strong { margin-top: 3px; font-size: 16px; }
.trainer-progress { border-radius: 0; height: 5px; }
.trainer-content { width: min(1380px, 100%); margin: 0 auto; flex: 1; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 30px; padding: 35px 30px 18px; align-items: center; }
.finger-guide { align-self: center; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); text-align: center; }
.finger-guide h3 { margin: 0 0 15px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.finger-guide p { font-size: 13px; margin-bottom: 0; }
.finger-hands { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; align-items: end; height: 92px; }
.finger { height: var(--h); border-radius: 999px 999px 10px 10px; background: var(--surface-2); border: 1px solid var(--line); transition: .18s ease; }
.finger.active { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 6px var(--primary-soft); transform: translateY(-4px); }
.typing-stage { min-width: 0; max-width: 980px; width: 100%; margin: 0 auto; text-align: center; }
.lesson-instruction { min-height: 24px; margin-bottom: 15px; color: var(--muted); font-size: 13px; }
.typing-text { padding: 26px 28px; min-height: 170px; max-height: 310px; overflow-y: auto; border-radius: var(--radius-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); text-align: left; font-size: var(--typing-font-size); line-height: 1.7; letter-spacing: .018em; white-space: pre-wrap; word-break: break-word; font-family: "Segoe UI", ui-monospace, monospace; }
.typing-text.small { --typing-font-size: 25px; }
.typing-text.medium { --typing-font-size: 31px; }
.typing-text.large { --typing-font-size: 37px; }
.typing-text.xlarge { --typing-font-size: 45px; }
.char { color: var(--muted); border-radius: 3px; }
.char.correct { color: var(--text); background: color-mix(in srgb, var(--success) 13%, transparent); }
.char.incorrect { color: var(--danger); background: var(--danger-soft); text-decoration: underline; text-decoration-thickness: 2px; }
.char.current { color: var(--text); background: var(--primary-soft); box-shadow: inset 0 -3px 0 var(--primary); animation: caretPulse 1s ease-in-out infinite; }
@keyframes caretPulse { 50% { box-shadow: inset 0 -3px 0 transparent; } }
.typing-input { position: absolute; opacity: .01; pointer-events: none; width: 1px; height: 1px; }
.typing-hint { margin-top: 13px; color: var(--muted); font-size: 12px; }
.virtual-keyboard { width: min(1100px, calc(100% - 40px)); margin: 0 auto 25px; display: grid; gap: 6px; }
.keyboard-row { display: flex; gap: 6px; justify-content: center; }
.key { min-width: 42px; height: 42px; padding: 0 9px; border-radius: 9px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 3px 0 color-mix(in srgb, var(--line) 80%, black 5%); font-size: 12px; font-weight: 800; color: var(--muted); transition: .12s ease; }
.key.wide { min-width: 68px; }
.key.space { min-width: min(360px, 42vw); }
.key.target { color: white; background: var(--primary); border-color: var(--primary); transform: translateY(2px); box-shadow: 0 1px 0 var(--primary); }
.key.pressed { color: white; background: var(--success); transform: translateY(2px); box-shadow: none; }
.key.error { background: var(--danger); color: white; }

.modal-backdrop { position: fixed; inset: 0; z-index: 200; padding: 20px; display: grid; place-items: center; background: rgba(10, 12, 24, .62); backdrop-filter: blur(8px); }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 34px; border-radius: 28px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,.28); text-align: center; position: relative; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border: 0; border-radius: 11px; background: var(--surface-2); cursor: pointer; }
.result-icon { width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); color: var(--success); font-size: 34px; font-weight: 900; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 24px 0; }
.result-grid > div { padding: 13px 8px; background: var(--surface-2); border-radius: 14px; }
.result-grid span, .result-grid strong { display: block; }
.result-grid span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.result-grid strong { margin-top: 5px; }
.result-new-record { margin: -5px 0 18px; padding: 9px 12px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); font-weight: 900; font-size: 13px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions > * { flex: 1; }
.onboarding-modal { width: min(630px, 100%); padding: 40px; }
.onboarding-logo { margin: 0 auto 23px; width: 62px; height: 62px; border-radius: 18px; font-size: 24px; }
.onboarding-modal .field { text-align: left; margin: 26px 0 16px; }
.level-choice { display: grid; gap: 10px; margin: 25px 0 18px; text-align: left; }
.level-choice button { padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-2); cursor: pointer; text-align: left; }
.level-choice button:hover, .level-choice button.selected { border-color: var(--primary); background: var(--primary-soft); }
.level-choice strong, .level-choice span { display: block; }
.level-choice span { margin-top: 5px; color: var(--muted); font-size: 13px; }
.toast { position: fixed; z-index: 400; left: 50%; bottom: 26px; transform: translate(-50%, 20px); padding: 12px 18px; border-radius: 13px; background: var(--text); color: var(--surface); font-weight: 800; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  :root { --sidebar: 82px; }
  .sidebar { padding-inline: 10px; }
  .nav-item { justify-content: center; padding: 12px 8px; font-size: 0; }
  .nav-item span { font-size: 20px; }
  .daily-mini, .back-site { display: none; }
  .hero-grid { grid-template-columns: 1fr; }
  .goal-card { min-height: auto; flex-direction: row; gap: 24px; text-align: left; }
  .goal-ring { flex: 0 0 auto; margin: 0; }
  .mode-grid, .test-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  :root { --topbar: 64px; }
  .app-shell { display: block; padding-bottom: 74px; }
  .topbar { height: var(--topbar); padding: 0 14px; }
  .brand small, .profile-chip span:last-child, #soundToggle { display: none; }
  .sidebar { position: fixed; inset: auto 0 0; height: 70px; display: grid; grid-template-columns: repeat(6, 1fr); padding: 7px 8px max(7px, env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--line); }
  .nav-item { display: grid; justify-items: center; gap: 3px; padding: 4px 2px; font-size: 9px; border-radius: 10px; }
  .nav-item span { font-size: 17px; }
  .sidebar-spacer, .daily-mini, .back-site { display: none; }
  .main { padding: 22px 14px; }
  .hero-card { min-height: auto; grid-template-columns: 1fr; padding: 28px 24px; }
  .hero-illustration { display: none; }
  .goal-card { align-items: center; }
  .goal-ring { width: 108px; height: 108px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .statistics-grid, .settings-grid { grid-template-columns: 1fr; }
  .mode-grid, .test-grid { grid-template-columns: 1fr; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .course-progress-box { text-align: left; }
  .lesson-row { grid-template-columns: auto minmax(0, 1fr) auto; padding: 15px; }
  .lesson-result { display: none; }
  .trainer-topbar { grid-template-columns: auto minmax(0,1fr); padding: 12px; }
  .trainer-live-stats { grid-column: 1 / -1; justify-content: space-around; border-top: 1px solid var(--line); padding-top: 9px; }
  .trainer-live-stats div { text-align: center; }
  .trainer-content { display: block; padding: 20px 14px 12px; }
  .finger-guide { display: none; }
  .typing-text { padding: 20px; min-height: 210px; font-size: 26px; }
  .virtual-keyboard { width: calc(100% - 16px); overflow-x: auto; padding-bottom: 5px; }
  .keyboard-row { min-width: 740px; justify-content: flex-start; }
  .key { min-width: 38px; height: 38px; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  h1 { font-size: 31px; }
  .hero-card p:not(.eyebrow) { font-size: 15px; }
  .hero-actions { display: grid; }
  .goal-card { display: block; text-align: center; }
  .goal-ring { margin: 0 auto 18px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-card strong { font-size: 22px; }
  .panel { padding: 20px; }
  .recommended-lesson { grid-template-columns: auto 1fr; }
  .recommended-lesson button { grid-column: 1 / -1; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .inline-options { display: grid; }
  .inline-options .primary-button { margin-left: 0; }
  .rule-grid { grid-template-columns: 1fr; }
  .lesson-row { gap: 10px; }
  .lesson-row button { min-width: 72px; padding-inline: 10px; }
  .module-head { padding: 18px; }
  .modal, .onboarding-modal { padding: 30px 20px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
