/* Ultratype's studio layer. Existing theme palettes and typing mechanics live in styles.css.
   Everything here takes its cue from the keycap mascot: soft rounded forms, a chunky
   "skirt" under anything you can press, and springy motion that settles instead of snapping. */
:root {
  --font-display: "Fredoka", "Nunito", ui-rounded, system-ui, sans-serif;
  --font-sans: "Nunito", ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
}

body {
  --panel: color-mix(in srgb, var(--surface) 92%, var(--bg));
  --panel-edge: color-mix(in srgb, var(--text) 11%, transparent);
  --hairline: color-mix(in srgb, var(--text) 9%, transparent);
  --soft-accent: color-mix(in srgb, var(--accent) 13%, transparent);
  --deep-shadow: 0 28px 70px rgb(0 0 0 / .17), 0 3px 12px rgb(0 0 0 / .08);
  /* The keycap skirt: a solid ledge under pressable things. */
  --skirt: color-mix(in srgb, var(--text) 13%, var(--bg));
  --accent-skirt: color-mix(in srgb, var(--accent) 68%, #000);
  --on-accent: var(--bg);
  min-height: 100svh;
  background-image:
    radial-gradient(ellipse 50% 32% at 78% 6%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 75%),
    radial-gradient(ellipse 40% 30% at 8% 96%, color-mix(in srgb, #ffc24b 6%, transparent), transparent 75%);
  background-attachment: fixed;
  font-family: var(--font-sans);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body[data-theme="light"] {
  --bg: #f6f6f2;
  --surface: #ffffff;
  --surface-2: #eff1f5;
  --text: #1d2736;
  --sub: #667489;
  --faint: #dce2e9;
  --accent: #4866e8;
  --error: #cd4e57;
  --error-extra: #a85058;
  --caret: #4866e8;
  --chart-wpm: #4866e8;
  --chart-raw: #9aa9bf;
  --panel: #fff;
  --panel-edge: #e3e7ee;
  --hairline: #e8ecf1;
  --soft-accent: #eaeeff;
  --skirt: #dfe3ea;
  --on-accent: #fff;
  --deep-shadow: 0 28px 76px rgb(42 55 81 / .075), 0 3px 12px rgb(42 55 81 / .035);
}
body[data-theme="dark"] {
  --bg: #121721;
  --surface: #1d2632;
  --surface-2: #283443;
  --text: #eef2f8;
  --sub: #a0aec0;
  --faint: #455263;
  --accent: #9eb0ff;
  --caret: #9eb0ff;
  --chart-wpm: #9eb0ff;
  --chart-raw: #7b8b9f;
}

button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, .typing-area:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}

/* ---------- keycaps: the shared pressable shape ---------- */
.action-btn, .restart-btn, .nav-btn.active-view, .cfg-btn.active, kbd {
  box-shadow: 0 3px 0 var(--skirt);
}
.action-btn, .restart-btn, .nav-btn, .cfg-btn, .ghost-btn, .appearance-option {
  transition: color .2s, background .2s, box-shadow .18s var(--ease-out), transform .28s var(--spring);
}
.action-btn:active, .restart-btn:active, .nav-btn:active, .cfg-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--skirt);
  transition-duration: .06s;
}

/* ---------- top bar ---------- */
.topbar {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 28px clamp(24px, 5.5vw, 88px);
  z-index: 30;
}
.logo { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-display); font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.brand-period { color: var(--accent); }
.brand-mark { position: relative; width: 62px; height: 62px; margin: -12px -2px -12px -8px; display: block; flex: none; cursor: pointer; }
.mascot-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mascot-fx { position: absolute; left: 50%; top: 50%; width: 320px; height: 320px; margin: -160px 0 0 -160px; overflow: visible; pointer-events: none; z-index: 40; }

/* Keycap mascot: cel bands derived from the theme so every palette gets its own cap. */
body {
  --m-ink: color-mix(in srgb, var(--bg) 62%, #000);
  --m-cap: color-mix(in srgb, var(--text) 80%, #fff);
  --m-cool: color-mix(in srgb, var(--accent) 42%, var(--m-ink));
}
body[data-theme="light"] { --m-ink: #18202d; --m-cap: #fff; }
.m-outline { fill: var(--m-ink); stroke: var(--m-ink); stroke-width: 4.2; stroke-linejoin: round; }
.m-top { fill: var(--m-cap); }
.m-lit { fill: color-mix(in srgb, var(--m-cap) 86%, var(--m-cool)); }
.m-mid { fill: color-mix(in srgb, var(--m-cap) 66%, var(--m-cool)); }
.m-shade { fill: color-mix(in srgb, var(--m-cap) 44%, var(--m-cool)); }
.m-top, .m-lit, .m-mid, .m-shade { stroke: none; }
.m-edge { fill: none; stroke: var(--m-ink); stroke-width: .9; stroke-linejoin: round; opacity: .32; }
.m-ground { fill: var(--m-ink); opacity: 1; fill-opacity: .14; }
.m-ink { fill: var(--m-ink); }
.m-glint { fill: #fff; }
.m-happy { fill: none; stroke: var(--m-ink); stroke-width: .12; stroke-linecap: round; }
.m-mouth { fill: var(--m-ink); stroke: var(--m-ink); stroke-width: .1; stroke-linecap: round; stroke-linejoin: round; }
.m-blush { fill: var(--accent); }
.m-dish { fill: color-mix(in srgb, var(--m-cap) 88%, var(--m-cool)); }
.m-gloss { fill: none; stroke: #fff; stroke-width: .05; stroke-linecap: round; opacity: .9; }
body[data-theme="light"] .m-gloss { display: none; }
.m-stem-ring { fill: none; stroke: var(--m-ink); stroke-width: .07; opacity: .35; }
.m-stem-cross { fill: var(--m-ink); opacity: .55; }
.m-c0 { fill: var(--accent); }
.m-c1 { fill: #ffc24b; }
.m-c2 { fill: #ff6f91; }
.m-c3 { fill: var(--m-cap); stroke: var(--m-ink); stroke-width: .6; }
.m-spark { fill: #ffd45e; }
.m-z { fill: var(--sub); font: 700 11px var(--font-sans); }

.topbar-actions { gap: 4px; padding: 5px; border-radius: 999px; background: var(--surface-2); }
.nav-btn { color: var(--sub); font-size: .92rem; font-weight: 800; padding: 9px 17px; border-radius: 999px; }
.nav-btn:hover { color: var(--text); transform: translateY(-1px); }
.nav-btn.active-view { color: var(--accent); background: var(--panel); }
.appearance-wrap { margin-left: 2px; padding-left: 0; border-left: 0; }
.ghost-btn { color: var(--sub); width: 38px; height: 38px; padding: 9px; border-radius: 999px; font-size: 1.2rem; }
.ghost-btn svg { fill: none; }
.ghost-btn:hover { color: var(--text); background: var(--panel); transform: rotate(-20deg); }
.ghost-btn.active-view { color: var(--accent); background: var(--soft-accent); }
.appearance-menu { width: 270px; border: 2px solid var(--panel-edge); border-radius: var(--r-md); background: var(--panel); box-shadow: 0 5px 0 var(--skirt), var(--deep-shadow); padding: 10px; transform-origin: top right; animation: menuPop .38s var(--spring) both; }
.appearance-menu-header { color: var(--text); font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; letter-spacing: 0; text-transform: none; padding: 6px 11px 10px; }
.appearance-option { font-family: var(--font-sans); font-weight: 700; border-radius: var(--r-sm); }
.appearance-option:hover { transform: translateX(3px); }
.appearance-option.active { background: var(--soft-accent); box-shadow: none; }
.appearance-option.active .appearance-name { color: var(--accent); font-weight: 800; }
.appearance-name { font-family: var(--font-sans); }

/* ---------- page + views ---------- */
.page { width: min(1080px, calc(100% - 64px)); margin: 0 auto; padding: 52px 0 64px; justify-content: flex-start; }
body[data-view="test"] .page { justify-content: center; padding-top: 25px; padding-bottom: 25px; }
.view { width: 100%; animation: viewIn .6s var(--spring) both; }

.view-intro { margin: 0 0 30px; }
.view-intro h1 {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(3rem, 7vw, 5.4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  margin: 0;
  transform-origin: 0 90%;
  animation: titlePop .75s var(--spring) both;
}
.view-intro h1::after { content: "."; color: var(--accent); }

/* ---------- practice ---------- */
.overlord { flex: none; display: flex; flex-direction: column; align-items: center; text-align: center; margin: 0 auto 36px; }
.overlord-stage { position: relative; width: 248px; height: 190px; isolation: isolate; }
.overlord-stage::before { content: ""; position: absolute; inset: 6px -32px -14px; z-index: -1; background: radial-gradient(ellipse, color-mix(in srgb, var(--accent) 18%, transparent), transparent 69%); }
.overlord-orbit { position: absolute; width: 206px; height: 144px; left: 21px; top: 30px; border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent); border-radius: 50%; transform: rotate(-18deg); }
.overlord-orbit::after { content: ""; position: absolute; inset: 13px -9px; border: 1px dashed color-mix(in srgb, var(--accent) 15%, transparent); border-radius: inherit; transform: rotate(36deg); }
.overlord-mascot { width: 186px; height: 186px; margin: 0 auto; top: 12px; cursor: pointer; }
.overlord-crown { position: absolute; width: 49px; height: 34px; left: calc(50% - 24.5px); top: 0; z-index: 2; overflow: visible; fill: #ffd45e; stroke: var(--m-ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; transform: rotate(-8deg); filter: drop-shadow(0 3px 0 rgb(0 0 0 / .08)); animation: crownFloat 4s ease-in-out infinite; pointer-events: none; }
.overlord-spark { position: absolute; color: var(--accent); font-size: 25px; pointer-events: none; }
.spark-left { left: 9px; top: 66px; transform: rotate(-12deg); }
.spark-right { right: 5px; top: 108px; color: #c69a32; font-size: 32px; }
.overlord-title { font-family: var(--font-display); font-size: 1.65rem; font-weight: 600; letter-spacing: -.02em; }
.overlord-caption { color: var(--sub); font-size: .8rem; margin: 6px 0 0; letter-spacing: .025em; }
@keyframes crownFloat { 50% { transform: translateY(-5px) rotate(5deg); } }
@media (max-width: 600px) {
  .overlord { margin-bottom: 26px; }
  .overlord-stage { width: 210px; height: 156px; }
  .overlord-mascot { width: 154px; height: 154px; top: 8px; }
  .overlord-orbit { width: 178px; height: 116px; left: 16px; top: 26px; }
  .overlord-crown { width: 42px; height: 29px; left: calc(50% - 21px); }
  .spark-left { top: 55px; }
  .spark-right { top: 85px; }
  .overlord-title { font-size: 1.4rem; }
}
.practice-panel { position: relative; width: 100%; padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
.practice-panel > * { position: relative; }
.panel-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; color: var(--sub); }
.session-total { font-size: .88rem; font-weight: 700; }
.session-total strong { font-family: var(--font-display); color: var(--text); font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-right: 2px; }
.panel-status { display: inline-flex; align-items: center; gap: 9px; color: var(--sub); font-size: .82rem; font-weight: 800; padding: 7px 14px 7px 12px; border-radius: 999px; background: var(--surface-2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--soft-accent); }
.practice-panel.is-running .panel-status { color: var(--accent); background: var(--soft-accent); }
.practice-panel.is-running .status-dot { animation: statusPulse 1.7s ease-in-out infinite; }
@keyframes statusPulse { 50% { box-shadow: 0 0 0 7px var(--soft-accent); transform: scale(1.15); } }

.test-header { margin: 26px 0 30px; min-height: 52px; }
.config-bar { gap: 12px; font-family: var(--font-sans); font-size: .9rem; font-weight: 800; }
.config-group { gap: 3px; padding: 5px; border-radius: 999px; background: var(--surface-2); }
.cfg-btn { min-width: 44px; padding: 8px 15px; border-radius: 999px; color: var(--sub); }
.cfg-btn:hover { color: var(--text); transform: translateY(-1px); }
.cfg-btn.active { background: var(--panel); color: var(--accent); }
.config-divider { display: none; }
.config-bar.hidden-during-test { transform: translateY(-8px) scale(.97); }

.live-stats { gap: clamp(14px, 2.6vw, 34px); font-family: var(--font-sans); min-height: 52px; }
.live-stat-label { font-size: .74rem; font-weight: 800; letter-spacing: .01em; text-transform: none; margin-bottom: 4px; }
.live-stat-value { font-family: var(--font-display); font-size: 2.2rem; font-weight: 600; letter-spacing: -.01em; }
.live-stat-value.secondary { font-size: 1.25rem; font-weight: 600; color: var(--text); }
.live-stat-value.bump { animation: statBump .36s var(--spring); }

.test-progress { height: 8px; border-radius: 999px; background: var(--surface-2); margin: 0 0 36px; overflow: hidden; }
.test-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .5s var(--spring); }

.typing-area { min-height: 180px; }
.words-viewport { height: calc(3 * 3.8rem + .4rem); font-family: var(--font-sans); }
.words { font-size: clamp(1.5rem, 2.8vw, 2.1rem); line-height: 3.8rem; letter-spacing: .005em; font-weight: 700; }
.word { margin-right: .5em; border-bottom-width: 3px; border-radius: 2px; }
.letter { color: color-mix(in srgb, var(--text) 38%, var(--bg)); }
.letter.correct { color: var(--text); }
.word.active-word .letter.current-letter { box-shadow: none; }
.word.active-word.error-word { border-color: transparent; }
.word.error-word { border-color: color-mix(in srgb, var(--error) 70%, transparent); }
.caret { width: 3px; border-radius: 99px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--caret) 15%, transparent); }
.focus-overlay { background: color-mix(in srgb, var(--bg) 80%, transparent); font-family: var(--font-sans); border-radius: var(--r-lg); }
.focus-overlay.visible .focus-title { animation: nudge 2.4s var(--spring) infinite; }
.focus-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; padding: 12px 24px; border-radius: 999px; background: var(--panel); border: 2px solid var(--panel-edge); box-shadow: 0 4px 0 var(--skirt); margin: 0; }

.bottom-bar { justify-content: space-between; align-items: center; margin-top: 32px; padding-top: 0; border-top: 0; }
.bottom-hint { color: var(--sub); font-size: .84rem; font-weight: 700; }
kbd { font-family: var(--font-sans); font-weight: 800; border: 2px solid var(--panel-edge); border-bottom-width: 2px; background: var(--panel); color: var(--text); font-size: .74rem; padding: 3px 8px; border-radius: 8px; margin-right: 5px; display: inline-block; }
.hint-divider { padding: 0 10px; color: var(--faint); }
.restart-btn { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 800; color: var(--text); padding: 10px 18px; border-radius: 999px; background: var(--panel); border: 2px solid var(--panel-edge); }
.restart-btn svg { font-size: 1.1rem; transition: transform .5s var(--spring); }
.restart-btn:hover { color: var(--accent); transform: translateY(-2px); background: var(--panel); box-shadow: 0 5px 0 var(--skirt); }
.restart-btn:hover svg { transform: rotate(-200deg); }

/* ---------- shared tiles ---------- */
.result-card, .history-card, .profile-card { background: transparent; border: 0; box-shadow: none; border-radius: 0; padding: 0; width: 100%; max-width: none; }
.stat-cell, .habit-card, .profile-hero-card, .profile-chart-wrap, .pb-table-wrap, .activity-item, .table-tile {
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  border-radius: var(--r-md);
  box-shadow: 0 4px 0 var(--skirt);
}
.stat-cell, .habit-card, .profile-hero-card, .activity-item { animation: tileIn .55s var(--spring) both; transition: transform .3s var(--spring), box-shadow .3s var(--ease-out); }
.stat-cell:hover, .habit-card:hover, .profile-hero-card:hover, .activity-item:hover { transform: translateY(-3px); box-shadow: 0 7px 0 var(--skirt); border-color: var(--panel-edge); }

.result-label, .stat-key, .habit-card-title, .profile-hero-label {
  font-family: var(--font-sans); color: var(--sub); font-size: .8rem; font-weight: 800; letter-spacing: .01em; text-transform: none;
}
.result-big, .stat-val, .habit-card-value, .profile-hero-value { font-family: var(--font-display); letter-spacing: -.01em; font-weight: 600; }

/* ---------- results ---------- */
.result-top { gap: clamp(20px, 4vw, 56px); padding: clamp(20px, 3vw, 32px); background: var(--panel); border: 2px solid var(--panel-edge); border-radius: var(--r-lg); box-shadow: 0 5px 0 var(--skirt); }
.result-main { gap: 18px; justify-content: center; }
.result-wpm-group { animation: tileIn .6s var(--spring) both; }
.result-big { font-size: clamp(3.4rem, 7vw, 6rem); }
.result-chart-wrap { min-height: 235px; }
.stat-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 22px; padding-top: 0; border-top: 0; }
.stat-cell { padding: 16px 18px; }
.stat-val { font-size: 1.55rem; margin-top: 4px; }
.stat-val small { font-family: var(--font-sans); font-weight: 700; }
.habit-insights { margin-top: 22px; padding-top: 0; border-top: 0; }
.habit-insights-grid { gap: 14px; }
.habit-card { padding: 18px 20px; }
.habit-card-title { margin-bottom: 10px; }
.habit-card-value { font-size: 1.5rem; }
.habit-card-sub, .habit-insight-row, .personal-bests, .habit-empty { font-family: var(--font-sans); font-weight: 700; }
.habit-key { font-family: var(--font-sans); font-weight: 800; border-width: 2px; border-radius: 9px; box-shadow: 0 2px 0 var(--skirt); background: var(--panel); }
.habit-bar { height: 8px; background: var(--surface-2); }
.habit-bar-fill { transition: width .8s var(--spring); }
.personal-bests { margin-top: 20px; text-align: center; }
.personal-bests .pb-new { display: inline-block; font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; padding: 9px 20px; border-radius: 999px; background: var(--soft-accent); animation: pbWiggle 2.6s var(--spring) infinite; }

.result-actions, .history-actions, .profile-actions { gap: 12px; }
.result-actions { margin-top: 34px; }
.action-btn { font-family: var(--font-sans); font-size: .95rem; font-weight: 800; border-radius: 999px; padding: 12px 24px; background: var(--panel); border: 2px solid var(--panel-edge); color: var(--text); }
.action-btn:hover { color: var(--text); transform: translateY(-2px); box-shadow: 0 5px 0 var(--skirt); }
.action-btn.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); box-shadow: 0 3px 0 var(--accent-skirt); }
.action-btn.primary:hover { box-shadow: 0 5px 0 var(--accent-skirt), 0 12px 24px color-mix(in srgb, var(--accent) 22%, transparent); }
.action-btn.primary:active { box-shadow: 0 0 0 var(--accent-skirt); }
.action-btn.danger:hover { color: var(--error); }

/* ---------- history ---------- */
.history-summary { font-family: var(--font-sans); font-weight: 700; font-size: .95rem; margin-bottom: 20px; }
.history-summary strong { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; }
.history-table { font-family: var(--font-sans); font-weight: 700; font-size: .95rem; border-collapse: separate; border-spacing: 0 4px; }
.history-table th { color: var(--sub); border: 0; font-size: .8rem; font-weight: 800; letter-spacing: .01em; text-transform: none; padding: 6px 14px; }
.history-table td { border: 0; padding: 12px 14px; }
.history-table tbody tr { animation: tileIn .45s var(--spring) both; }
.history-table tbody tr:hover { background: transparent; }
.history-table tbody tr:hover td { background: var(--surface-2); }
.history-table td:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.history-table td:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.history-table .wpm-col, .profile-table td:first-child { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--accent); }
.history-empty { font-family: var(--font-sans); font-weight: 700; }
.history-actions { margin-top: 26px; }

/* ---------- profile ---------- */
.profile-view { flex-direction: column; align-items: stretch; padding-top: 0; }
.profile-empty { font-family: var(--font-sans); padding: 30px 0 10px; }
.profile-empty-icon { font-size: 2.8rem; margin-bottom: 10px; animation: float 3.2s ease-in-out infinite; }
.profile-empty-title { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; margin-bottom: 22px; }
.profile-hero { gap: 14px; margin-bottom: 0; }
.profile-hero-card { padding: 22px 16px; }
.profile-hero-value { font-size: 2.4rem; }
.profile-hero-label { margin-top: 8px; }
.profile-section { margin-top: 38px; }
.profile-section-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; letter-spacing: -.01em; text-transform: none; color: var(--text); border-bottom: 0; padding-bottom: 0; margin-bottom: 14px; }
.profile-grid { gap: 14px; }
.profile-chart-wrap { padding: 16px 16px 10px; height: 210px; }
.profile-chart-legend { font-family: var(--font-sans); font-weight: 700; font-size: .8rem; }
.legend-dot { width: 10px; height: 10px; }
.profile-two-col { gap: 28px; }
.pb-table-wrap { padding: 6px; }
.pb-table { font-family: var(--font-sans); font-weight: 700; font-size: .92rem; }
.pb-table th { font-size: .78rem; font-weight: 800; letter-spacing: .01em; text-transform: none; border-color: var(--hairline); }
.pb-table td { border-color: var(--hairline); }
.pb-table td:nth-child(2) { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.activity-list { gap: 10px; }
.activity-item { font-family: var(--font-sans); padding: 12px 16px; }
.activity-wpm { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; }
.activity-mode { text-transform: none; letter-spacing: .01em; font-weight: 800; font-size: .74rem; }
.activity-acc { font-weight: 800; }
.activity-date { font-weight: 700; }
.activity-empty, .pb-table .pb-empty { font-family: var(--font-sans); font-weight: 700; border-radius: var(--r-md); }
.profile-table-scroll { width: 100%; overflow-x: auto; }
.profile-actions { border-top: 0; padding-top: 0; margin-top: 34px; }

/* ---------- footer ---------- */
.footer { width: min(100%, 1440px); display: flex; justify-content: space-between; gap: 20px; margin: auto auto 0; padding: 30px clamp(24px, 5.5vw, 88px); text-align: left; border-top: 0; font-family: var(--font-sans); font-size: .8rem; font-weight: 700; color: var(--sub); }
.footer > span:first-child { font-family: var(--font-display); font-weight: 600; font-size: .95rem; color: var(--text); }
.footer-shortcuts { color: var(--sub); opacity: .85; }

/* ---------- motion ---------- */
@keyframes viewIn { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes titlePop {
  0% { opacity: 0; transform: translateY(24px) scale(.85) rotate(-3deg); }
  60% { opacity: 1; }
  to { opacity: 1; transform: none; }
}
@keyframes tileIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes menuPop { from { opacity: 0; transform: translateY(-6px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes statBump { 35% { transform: scale(1.14) translateY(-2px); } }
@keyframes nudge { 0%, 70%, 100% { transform: none; } 80% { transform: translateY(-4px) rotate(-1.5deg); } 90% { transform: translateY(0) rotate(1deg); } }
@keyframes pbWiggle { 0%, 80%, 100% { transform: none; } 86% { transform: rotate(-3deg) scale(1.04); } 93% { transform: rotate(2deg) scale(1.02); } }
@keyframes float { 50% { transform: translateY(-6px) rotate(-4deg); } }

/* ---------- responsive ---------- */
@media (min-width: 900px) and (max-height: 850px) {
  .topbar { padding-top: 20px; padding-bottom: 20px; }
  .test-header { margin-top: 20px; margin-bottom: 20px; }
  .test-progress { margin-bottom: 28px; }
  .bottom-bar { margin-top: 24px; }
}
@media (max-width: 760px) {
  .topbar { padding: 22px 24px; }
  .page { width: min(100% - 40px, 700px); }
  body[data-view="test"] .page { padding-top: 30px; padding-bottom: 30px; }
  .words { font-size: 1.55rem; line-height: 3rem; }
  .words-viewport { height: calc(3 * 3rem + .4rem); }
  .result-top { grid-template-columns: 1fr; }
  .result-chart-wrap { min-height: 180px; order: initial; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; gap: 18px; padding: 20px 15px; }
  .logo { font-size: 1.45rem; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .nav-btn { font-size: .86rem; padding: 8px 12px; }
  .appearance-wrap { margin-left: auto; }
  .page { width: min(100% - 30px, 500px); padding-top: 26px; padding-bottom: 40px; }
  body[data-view="test"] .page { padding-top: 20px; padding-bottom: 24px; }
  .panel-heading { gap: 12px; }
  .panel-status { font-size: .74rem; padding: 6px 12px 6px 10px; }
  .test-header { min-height: 90px; margin: 22px 0 16px; }
  .config-bar { flex-wrap: wrap; gap: 8px; }
  .cfg-btn { padding: 7px 12px; min-width: 38px; }
  .live-stats { flex-wrap: wrap; gap: 10px 18px; }
  .live-stat.secondary:not(:nth-child(-n+5)) { display: none; }
  .live-stat-value { font-size: 1.8rem; }
  .test-progress { margin-bottom: 22px; }
  .words { font-size: clamp(1.25rem, 5vw, 1.5rem); line-height: 2.7rem; }
  .words-viewport { height: calc(3 * 2.7rem + .4rem); }
  .typing-area { min-height: 135px; }
  .bottom-bar { margin-top: 18px; }
  .bottom-hint { font-size: .74rem; }
  .hint-divider { padding: 0 4px; }
  .restart-btn { font-size: .8rem; padding: 8px 14px; }
  .view-intro { margin-bottom: 22px; }
  .view-intro h1 { font-size: 3rem; }
  .result-top { border-radius: var(--r-md); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .result-actions, .history-actions, .profile-actions { flex-wrap: wrap; }
  .history-card { overflow-x: auto; }
  .history-table { min-width: 550px; }
  .profile-table { min-width: 460px; }
  .profile-hero { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .profile-hero-value { font-size: 2rem; }
  .footer { padding: 22px 20px; }
  .footer-shortcuts { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
