/* ==========================================================================
   Typing Speed Test — Premium Dashboard (Oct 2026)
   Fully rounded, soft shadows, subtle motion, cohesive editorial palette.
   Uses the bundled base tokens (--accent, --text-*, --bg-*) so light/dark
   themes work independently. No external framework required.
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
.typing-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  --tt-font-size: 2.38rem;
  --tt-width: 1120px;

  --r-pill: 999px;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;

  --tt-correct: #1a6b32;
  --tt-incorrect: #d11a2a;
  --tt-extra: #a06a00;
  --tt-missed: #7e796f;
  --tt-caret: #c9a600;
  --tt-raw: #5b7ba6;

  --card-shadow: 0 8px 32px rgba(18, 18, 17, .08), 0 1.5px 6px rgba(18, 18, 17, .06);
  --card-shadow-hover: 0 16px 48px rgba(18, 18, 17, .12), 0 3px 12px rgba(18, 18, 17, .08);
  --accent-glow: 0 0 0 4px rgba(189, 58, 27, .10);
}

[data-theme="dark"].typing-page {
  --tt-correct: #4fbf72;
  --tt-incorrect: #ff3b30;
  --tt-extra: #d9a529;
  --tt-missed: #6f6a60;
  --tt-caret: #f0c800;
  --tt-raw: #8ba6cc;
  --card-shadow: 0 8px 32px rgba(0, 0, 0, .38), 0 1.5px 6px rgba(0, 0, 0, .35);
  --card-shadow-hover: 0 16px 48px rgba(0, 0, 0, .55), 0 3px 12px rgba(0, 0, 0, .40);
}

/* ---------------------------------------------------------------- page rhythm — lifted typing section */
.typing-page .site-main { flex: 1 0 auto; padding-top: 40px; }

#view-test { padding-top: 2rem; margin-top: 0.5rem; }

@media (min-width: 861px) {
  #view-test { padding-top: 3rem; margin-top: 0.75rem; }
}

@media (max-width: 860px) {
  #view-test { padding-top: 1.75rem; margin-top: .4rem; }
}

.typing-page .container.section-header { margin-bottom: .35rem; }

.typing-guide {
  max-width: 76ch;
  margin: 4rem auto 2.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.typing-guide h2,
.typing-guide h3 {
  margin: 1.4rem 0 .65rem;
  color: var(--text-primary);
}

.typing-guide h2 { font-size: var(--text-xl); }
.typing-guide h3 { font-size: var(--text-lg); }
.typing-guide p,
.typing-guide dd { line-height: var(--lh-relaxed); }
.typing-guide dl { display: grid; gap: .75rem; margin: 1rem 0; }
.typing-guide dt { color: var(--text-primary); font-weight: 700; }
.typing-guide a { color: var(--accent); text-decoration: underline; text-underline-offset: .18em; }
.typing-page .tt-header-actions { opacity: .96; }

@media (max-width: 860px) {
  .typing-page .site-main { padding-top: 66px; }
}

.typing-shell {
  max-width: var(--tt-width, 880px);
  margin-inline: auto;
  transition: max-width var(--transition-normal);
}

/* ---------------------------------------------------------------- header pill */
.typing-page .site-header {
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
}

.tt-header-actions { display: flex; align-items: center; gap: .45rem; }

.tt-icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  box-shadow: 0 1px 6px rgba(18, 18, 17, .04);
  transition: transform var(--transition-fast), border-color var(--transition-fast),
              background var(--transition-fast), color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.tt-icon-btn:hover { border-color: var(--border-medium); color: var(--text-primary); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(18, 18, 17, .08); }
.tt-icon-btn:active { transform: translateY(0); }

.tt-icon-btn.active { background: var(--text-primary); color: var(--bg-primary); border-color: var(--text-primary); box-shadow: none; }

/* ---------------------------------------------------------------- views */
.tt-view { display: none; }
.tt-view.visible { display: block; animation: tt-view-in .32s cubic-bezier(.16, 1, .3, 1) both; }

@keyframes tt-view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------- mode toolbar — compact: Time/Mode left, Language right */
.mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem .9rem;
  padding: .35rem 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.mode-bar__left,
.mode-bar__right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem;
}

.mode-bar .chip-group {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 7px 10px;
  box-shadow: 0 1px 8px rgba(18, 18, 17, .03);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.mode-bar .chip-group:hover {
  box-shadow: var(--card-shadow);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.mode-bar__settings-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-secondary);
  box-shadow: 0 1px 8px rgba(18, 18, 17, .03);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.mode-bar__settings-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-medium);
  box-shadow: var(--card-shadow);
  transform: translateY(-1px);
}

.chip-group {
  display: flex;
  align-items: center;
  gap: .32rem;
  flex-wrap: wrap;
  position: relative;
}

.chip-group__label {
  font-family: var(--font-mono);
  font-size: .58rem;
  letter-spacing: .13em;
  color: var(--text-muted);
  text-transform: uppercase;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  margin-right: .15rem;
}

.chip {
  font-family: var(--font-mono);
  font-size: .71rem;
  letter-spacing: .07em;
  color: var(--text-secondary);
  background: transparent;
  padding: 5px 13px;
  border-radius: var(--r-pill);
  border: 1.5px solid transparent;
  transition: transform var(--transition-fast), background var(--transition-fast),
              border-color var(--transition-fast), color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.chip:hover { color: var(--text-primary); background: var(--surface-card); border-color: var(--border-medium); }

.chip.active {
  color: var(--accent);
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 14px rgba(189, 58, 27, .14);
}

[data-theme="dark"] .chip.active { background: #201513; box-shadow: 0 2px 14px rgba(224, 78, 44, .18); }

.chip-select {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .04em;
  color: var(--text-secondary);
  background: var(--surface-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--r-pill);
  padding: 5px 10px 5px 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237E796F' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.chip-select:hover { border-color: var(--border-medium); color: var(--text-primary); }
.chip-select:focus-visible { outline: none; box-shadow: var(--accent-glow); border-color: var(--accent); }

/* ---------------------------------------------------------------- daily badge */
.daily-badge {
  display: none;
  margin-top: .85rem;
  font-family: var(--font-mono);
  font-size: .63rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #7a2b14;
  background: linear-gradient(135deg, #fff6f1, #ffeee5);
  border: 1px solid #e9c0b0;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  box-shadow: 0 2px 10px rgba(189, 58, 27, .08);
}
.daily-badge.visible { display: inline-flex; align-items: center; gap: 6px; }
.daily-badge.visible::before { content: '●'; font-size: .55rem; color: var(--accent); }

[data-theme="dark"] .daily-badge { color: #ff9a7a; background: #231309; border-color: #4a2210; box-shadow: none; }

/* ---------------------------------------------------------------- live HUD — minimalist with hidden details */
.live-stats {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin: 0 0 1.1rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.live-stat--timer .live-stat__value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-primary);
}

.live-stat {
  display: inline-flex;
  align-items: baseline;
  gap: .3rem;
}

.live-stat__value {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.live-stat--detail .live-stat__value { font-size: 1rem; }
.live-stat--detail.is-unfocused {
  opacity: .08;
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
  transition: opacity .22s ease, filter .22s ease;
}

.live-stats.live-stats--expanded .live-stat--detail.is-unfocused {
  opacity: 1;
  filter: none;
  pointer-events: auto;
}

.live-stats__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-medium);
  border: 2px solid var(--surface-card);
  box-shadow: 0 0 0 4px var(--bg-primary);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

.live-stats__dot:hover { transform: scale(1.25); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-muted); }
.live-stats__dot.is-active { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-muted); }

.live-stat__label {
  font-size: .55rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  opacity: .72;
}

.stat-timer { color: var(--text-primary); }

.target-compare {
  display: none;
  font-size: .66rem;
  letter-spacing: .04em;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
}

.target-compare.visible { display: inline-flex; align-items: center; }

.target-compare.above { color: #1a7a45; border-color: rgba(46, 125, 79, .32); background: rgba(46, 125, 79, .08); }
.target-compare.below { color: var(--tt-incorrect); border-color: rgba(189, 58, 27, .22); background: rgba(189, 58, 27, .07); }

.progress-track {
  flex: 1 1 160px;
  height: 3px;
  background: var(--border-subtle);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin: 0 2px;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 140ms linear;
}

.test-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }

.test-actions .tt-icon-btn {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  box-shadow: none;
  width: 34px; height: 34px;
}
.test-actions .tt-icon-btn:hover { background: var(--surface-elevated); color: var(--text-primary); border-color: var(--border-subtle); }
[data-theme="dark"] .test-actions .tt-icon-btn { color: #8a8782; }

/* ---------------------------------------------------------------- typing stage — free, calm, spacious */
#typing-stage {
  position: relative;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 2rem 0 1.6rem;
  overflow: visible;
  max-width: min(100%, 1120px);
  margin-inline: auto;
}

#typing-stage:focus-within {
  border-color: transparent;
  box-shadow: none;
}

body.is-fullscreen #typing-stage { max-height: 100vh; }

.typing-viewport {
  --typing-line-height: calc(var(--tt-font-size, 24px) * 1.82);
  height: calc(var(--typing-line-height) * 4);
  max-height: calc(var(--typing-line-height) * 4);
  overflow: hidden;
  position: relative;
  box-sizing: content-box;
  padding-top: 0;
  padding-bottom: 0;
  scroll-behavior: auto;
}

.typing-viewport .typing-text {
  position: relative;
  will-change: transform;
  transition: transform 0.4s cubic-bezier(0.2, 1, 0.3, 1);
}

/* Floating caret — lives INSIDE .typing-text so the line-scroll transform
   carries it. The outer element moves only vertically, timed exactly like the
   text's scroll easing, so the caret stays pinned on screen while lines slide.
   The inner bar glides horizontally between characters (fast, Monkeytype-like)
   and carries the blink (a ::after layer over a solid parent never blinks). */
.tt-caret {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 1.4em;
  z-index: 3;
  pointer-events: none;
  will-change: transform;
  display: none;
  transition: transform .4s cubic-bezier(.2, 1, .3, 1);
}
.tt-caret__bar {
  position: absolute;
  inset: 0;
  background: #ffc400;
  border-radius: 2px;
  will-change: transform;
  transition: transform .12s cubic-bezier(.2, 0, .4, 1);
  animation: tt-caret-blink 1.2s step-end infinite;
}
[data-theme="dark"] .tt-caret__bar { background: #f0c800; }
@keyframes tt-caret-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.tt-word.is-active {
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin: 0;
  box-shadow: none;
}

.typing-text {
  font-family: var(--font-mono);
  font-size: var(--tt-font-size);
  line-height: 1.82;
  color: var(--text-light);
  user-select: none;
  font-variant-ligatures: none;
  letter-spacing: -.010em;
  word-spacing: .08em;
}

.typing-text.is-code { white-space: pre-wrap; }

.tt-word { display: inline-block; white-space: nowrap; }

.tt-char {
  position: relative;
  border-radius: 5px;
  padding: 1px 1px;
  margin: 0 -1px;
  transition: color 50ms linear, background 50ms linear, opacity 50ms linear;
}

.tt-char.is-correct { color: var(--tt-correct); }

.tt-char.is-incorrect {
  color: var(--tt-incorrect);
  background: rgba(209, 26, 42, .08);
  border-radius: 3px;
  box-shadow: none;
}
[data-theme="dark"] .tt-char.is-incorrect { color: #ff3b30; background: rgba(255, 59, 48, .16); }

.tt-char.is-missed {
  color: var(--text-light);
  opacity: .48;
  background: transparent;
}

.tt-char.tt-space.is-incorrect,
.tt-char.tt-space.is-missed {
  background: transparent;
  opacity: .65;
}

.tt-char.is-recovered {
  animation: tt-recover 220ms ease both;
}

@keyframes tt-recover {
  0% { background: rgba(46, 125, 79, .11); }
  100% { background: transparent; }
}
.tt-char.tt-newline { display: inline-block; width: 0; padding: 0; margin: 0; }

.tt-char.is-current {
  outline: none;
}

.tt-char.is-current::before {
  content: '';
  position: absolute;
  inset: -1px 0;
  background: transparent;
  border-left: 2.5px solid #c9a600;
  border-radius: 1px;
  animation: none;
  opacity: 1;
  pointer-events: none;
}

[data-theme="dark"] .tt-char.is-current::before { border-left-color: #f0c800; }

[data-caret="block"] .tt-char.is-current::before,
[data-caret="line"] .tt-char.is-current::before,
[data-caret="underline"] .tt-char.is-current::before {
  left: -1px;
  width: 2.5px;
  background: transparent;
  border-left: 2.5px solid #c9a600;
  border-radius: 1px;
}

[data-theme="dark"] [data-caret="block"] .tt-char.is-current::before,
[data-theme="dark"] [data-caret="line"] .tt-char.is-current::before,
[data-theme="dark"] [data-caret="underline"] .tt-char.is-current::before {
  border-left-color: #f0c800;
}

[data-caret="block"] .tt-char.is-current::after { display: none; }

[data-caret="underline"] .tt-char.is-current::before {
  inset: auto 0 -2px 0;
  height: 2px;
  width: auto;
  border-left: none;
  background: #c9a600;
  border-radius: 99px;
}

[data-theme="dark"] [data-caret="underline"] .tt-char.is-current::before { background: #f0c800; }

.typing-viewport:not(:focus-within) .tt-char.is-current::before,
.typing-viewport:not(:focus-within) .tt-char.is-current::after { animation: none; opacity: 1; }
.extra-chars {
  font-family: var(--font-mono);
  font-size: var(--tt-font-size);
  color: var(--tt-extra);
  background: rgba(166, 106, 0, .09);
  border-radius: 6px;
  word-break: break-all;
  padding: 0 4px;
  margin-left: 2px;
}

.typing-input-hidden {
  /* Must NOT live inside the scrolling viewport: the browser scrolls the
     nearest scroll container to reveal a focused textarea's caret, which
     undoes the 4-line group scroll as soon as the next key is typed.
     Pinning it to the window keeps it out of that scroll container. */
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: none;
  padding: 0;
  margin: 0;
  resize: none;
  overflow: hidden;
  white-space: pre;
  pointer-events: none;
  z-index: -1;
}

.idle-hint {
  display: none;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--ls-mono);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-medium);
  display: none;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  align-self: flex-start;
}

.idle-hint.visible {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  animation: hint-pop .35s cubic-bezier(.16, 1, .3, 1) both;
}

.idle-hint.visible::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: hint-pulse 1.6s ease-in-out infinite;
}

@keyframes hint-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes hint-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.82); } }

/* ---------------------------------------------------------------- overlays */
.stage-overlay {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(247, 245, 240, .78);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  z-index: 5;
  border-radius: inherit;
  padding: 1.5rem;
}
[data-theme="dark"] .stage-overlay { background: rgba(16, 16, 15, .74); }
.stage-overlay.open { display: flex; animation: overlay-in .22s both; }

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.countdown-number {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: clamp(4.5rem, 13vw, 6rem);
  color: var(--accent);
  line-height: 1;
  text-shadow: 0 10px 34px rgba(189, 58, 27, .22);
  animation: cd-pop .3s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes cd-pop { from { transform: scale(.72); opacity: .4; } to { transform: scale(1); opacity: 1; } }

.pause-card {
  text-align: center;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 1.75rem 2rem;
  box-shadow: var(--card-shadow);
  min-width: min(360px, 100%);
}

.pause-card h3 { font-size: var(--text-lg); margin-bottom: .35rem; }
.pause-card p  { color: var(--text-secondary); margin-bottom: 1.15rem; font-size: var(--text-sm); }

/* ---------------------------------------------------------------- scrim behind drawers */
/* The drawer must stack above the fixed site header (z-index 1000) —
   otherwise the header covers the drawer's close button and the panel
   becomes impossible to dismiss. */
.tt-scrim {
  position: fixed; inset: 0;
  background: rgba(18, 18, 17, .42);
  -webkit-backdrop-filter: blur(3px);
          backdrop-filter: blur(3px);
  z-index: 1099;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}
.tt-scrim.open { opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------------------- side drawers */
.side-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(430px, 94vw);
  background: var(--surface-card);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -22px 0 64px rgba(18, 18, 17, .18);
  z-index: 1100;
  transform: translateX(105%);
  transition: transform var(--transition-smooth);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0;
}

.side-panel.open { transform: translateX(0); }
.side-panel[aria-hidden="true"] { visibility: hidden; }
.side-panel[aria-hidden="false"] { visibility: visible; }

.side-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border-subtle);
  background:
    radial-gradient(520px 200px at 100% 0%, rgba(189, 58, 27, .06), transparent 60%),
    var(--surface-elevated);
}

.side-panel__header h2 { font-size: 1.05rem; letter-spacing: var(--ls-tight); }

.side-panel__body {
  overflow-y: auto;
  padding: 1.35rem 1.4rem 2rem;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

.side-panel__body::-webkit-scrollbar { width: 8px; }
.side-panel__body::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 999px; }

.settings-group { margin-bottom: 1.7rem; }

.settings-group__title {
  font-family: var(--font-mono);
  font-size: .64rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .7rem;
  padding-bottom: .4rem;
  border-bottom: 1px dashed var(--border-subtle);
}

.setting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .62rem 0;
  font-size: var(--text-sm);
}

.setting-row + .setting-row { border-top: 1px dashed var(--border-subtle); margin-top: .1rem; padding-top: .62rem; }

.setting-desc { font-size: var(--text-xs); color: var(--text-muted); display: block; margin-top: .2rem; line-height: 1.45; }

.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; }

.switch input {
  opacity: 0; width: 100%; height: 100%;
  position: absolute; inset: 0; cursor: pointer; margin: 0;
  z-index: 1;
}

.switch__track {
  position: absolute; inset: 0;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-medium);
  border-radius: 999px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  pointer-events: none;
}

.switch__track::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(18, 18, 17, .18);
  transition: transform var(--transition-normal), background var(--transition-fast), box-shadow var(--transition-fast);
}

.switch input:checked + .switch__track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(18px); background: #fff; box-shadow: 0 1px 8px rgba(189, 58, 27, .4); }

.range-input { width: 140px; accent-color: var(--accent); }

.number-input, .select-input {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--surface-card);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--r-pill);
  color: var(--text-primary);
  padding: .4rem .65rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.number-input:focus-visible, .select-input:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--accent-glow); }

.custom-textarea {
  width: 100%;
  min-height: 116px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--bg-primary);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--r-md);
  color: var(--text-primary);
  padding: .65rem .75rem;
  resize: vertical;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.custom-textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--accent-glow); }

#view-results .result-graph-stage .chart-wrap--unified canvas {
  max-height: min(34vh, 300px);
}

#view-results .result-graph-stage {
  min-height: 260px;
}

#view-results .result-hero--below { margin-top: .35rem; }

@media (max-height: 800px) {
  #view-results .result-graph-stage .chart-wrap--unified canvas {
    max-height: min(28vh, 250px);
  }
  #view-results .result-graph-stage { min-height: 220px; padding-top: .85rem; padding-bottom: .75rem; }
  #view-results .result-hero--below { padding-top: .4rem; }
}

/* ---------------------------------------------------------------- results — premium, animated reveal */
.result-validity {
  display: none;
  margin: 0 auto 1.1rem;
  max-width: 640px;
  font-family: var(--font-mono);
  font-size: .75rem;
  line-height: 1.6;
  color: var(--accent);
  background: rgba(189, 58, 27, .07);
  border: 1px solid rgba(189, 58, 27, .18);
  padding: .7rem .9rem;
  border-radius: var(--r-md);
}
.result-validity.visible { display: block; animation: tt-view-in .26s both; }

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-mono);
  font-size: .58rem;
  letter-spacing: .11em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  vertical-align: middle;
  margin-left: 8px;
  font-weight: 700;
}

.result-badge--afk {
  color: #7a2b14;
  background: rgba(189, 58, 27, .09);
  border: 1px solid rgba(189, 58, 27, .22);
}

.result-badge--invalid { color: var(--tt-incorrect); background: rgba(189, 58, 27, .07); border: 1px solid rgba(189, 58, 27, .20); }
.result-badge--warn    { color: #7a4a00; background: rgba(166, 106, 0, .08); border: 1px solid rgba(166, 106, 0, .20); }

#view-results .typing-shell--results { max-width: 1100px; }
#view-results .result-mode-line { margin-bottom: .5rem; }
#view-results .result-graph-stage {
  margin: 0 -.4rem .4rem;
  padding: 1.15rem 1.25rem 1rem;
  border-radius: var(--r-xl);
  background:
    radial-gradient(900px 420px at 50% 0%, rgba(189, 58, 27, .05), transparent 68%),
    var(--surface-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

#view-results .result-graph-stage .result-unified-wrap {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.result-hero {
  text-align: center;
  padding: 1.6rem 1rem .9rem;
}

.result-hero--below { padding-top: .75rem; }

.result-hero--premium .result-mode-line { opacity: .9; }

@media (min-width: 861px) {
  .result-hero--premium .result-mode-line { margin-top: -.2rem; }
}

.result-big__value.is-invalid {
  color: var(--text-muted) !important;
  text-decoration: line-through 2px rgba(189, 58, 27, .22);
}

.result-big__sub {
  font-family: var(--font-mono);
  font-size: .62rem;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-top: .2rem;
  min-height: 1em;
}

.result-big--animated .result-big__item {
  animation: result-pop .48s cubic-bezier(.16, 1, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

@keyframes result-pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.result-breakdown {
  display: none;
  gap: .6rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: .9rem;
  font-family: var(--font-mono);
  font-size: .68rem;
}

.result-breakdown.visible { display: flex; }

.result-breakdown__chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
}

.result-breakdown__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.result-mode-line {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--ls-tag);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.result-mode-line::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.result-big {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .85rem;
  margin-bottom: .6rem;
}

.result-big--large { gap: 1rem; }
.result-big--large .result-big__item { padding: 1.45rem 1rem 1.15rem; }
.result-big--large .result-big__value { font-size: clamp(2.8rem, 5.8vw, 3.9rem); }

.result-big__item {
  min-width: 0;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: 1.15rem .75rem 1rem;
  box-shadow: none;
  transition: transform 220ms ease, border-color var(--transition-fast), background var(--transition-fast);
}

#view-results .result-big__item { background: var(--surface-card); border-color: var(--border-subtle); box-shadow: var(--card-shadow); }
.result-big__item:hover { transform: translateY(-1px); }
#view-results .result-big__item:hover { box-shadow: var(--card-shadow-hover); }

.result-big__value {
  font-size: clamp(2.4rem, 5.6vw, 3.6rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: var(--ls-tight);
  font-variant-numeric: tabular-nums;
}

.result-big__value--accent { color: var(--accent); }

.result-big__label {
  font-family: var(--font-mono);
  font-size: .62rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: .35rem;
}

.result-compare {
  display: flex;
  justify-content: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: .9rem;
}

.compare-item {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: .42rem .8rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  box-shadow: 0 1px 8px rgba(18, 18, 17, .04);
}

.compare-item__label { color: var(--text-muted); }
.compare-item__value { font-weight: 700; }

.compare-item.up  { border-color: rgba(46, 125, 79, .30); color: #2e7d4f; background: rgba(46, 125, 79, .08); }
.compare-item.down { border-color: rgba(189, 58, 27, .28); color: var(--tt-incorrect); background: rgba(189, 58, 27, .07); }

.compare-note {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: .75rem;
  margin: 1.2rem 0;
}

.stat-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: .95rem .75rem 1rem;
  text-align: center;
  box-shadow: 0 2px 14px rgba(18, 18, 17, .05);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card--open {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  border-radius: var(--r-lg);
  padding: .85rem .5rem .35rem;
}

.stat-card--open:hover { transform: none; box-shadow: none; background: transparent; border-color: transparent; }
.stat-grid--open {
  margin: .35rem 0 1.4rem;
  gap: .35rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: .85rem;
}
.stat-grid--open .stat-card__label { font-size: .56rem; }

.stat-card:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(18, 18, 17, .08); }
.stat-card--open:hover { transform: none; box-shadow: none; }

.stat-card__value {
  font-family: var(--font-mono);
  font-size: 1.28rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-card__label {
  font-family: var(--font-mono);
  font-size: .58rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: .28rem;
}

.result-section-title {
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: .55rem;
  margin: 2.4rem 0 1.15rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.result-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border-subtle); margin-left: .5rem; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: .9rem;
}

/* chart card: premium rounded card with interactive hover */
.chart-card {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 1rem 1rem .9rem;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.chart-card::before {
  content: '';
  position: absolute; inset: 0 -1px 0 0;
  border-radius: inherit;
  background: radial-gradient(500px 180px at 100% 0%, rgba(189, 58, 27, .04), transparent 65%);
  pointer-events: none;
}

.chart-card h4 {
  font-family: var(--font-mono);
  font-size: .66rem;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.chart-card h4::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .95;
}

.chart-wrap {
  position: relative;
  border-radius: var(--r-sm);
  overflow: hidden;
}

.chart-card canvas {
  width: 100%;
  height: 190px;
  display: block;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--bg-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.35;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(18, 18, 17, .24);
  white-space: nowrap;
  transform: translate(-50%, -100%);
  margin-top: -10px;
  z-index: 3;
  opacity: 0;
  transition: opacity 120ms ease;
}

.chart-tooltip.visible { opacity: 1; }

.chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.chart-legend__item.muted { opacity: .36; }

.chart-legend__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* suggestions */
.suggestion-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.suggestion-list li {
  position: relative;
  padding: .85rem 1rem .85rem 1.1rem;
  margin-bottom: .6rem;
  border-radius: var(--r-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
}

.suggestion-list li::before {
  content: '';
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 3px;
  border-radius: var(--r-pill);
  background: var(--accent);
  opacity: .75;
}

/* review */
.review-text {
  font-family: var(--font-mono);
  font-size: 1.02rem;
  line-height: 1.82;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.45rem;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--card-shadow);
}

.rv-char.rv-correct { color: var(--tt-correct); }
.rv-char.rv-incorrect {
  color: var(--tt-incorrect);
  background: rgba(189, 58, 27, .10);
  border-radius: 4px;
  box-shadow: inset 0 -2px 0 rgba(189, 58, 27, .13);
  padding: 0 1px;
  margin: 0 -1px;
}
.rv-char.rv-missed {
  color: var(--text-light);
  text-decoration: underline dotted 1px var(--text-muted);
  text-underline-offset: 3px;
}

.rv-char.rv-extra {
  color: #fff;
  background: var(--tt-extra);
  border-radius: 4px;
  padding: 0 3px;
  margin: 0 1px;
}

.freq-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .38rem 0;
}

.freq-char {
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 2rem;
  text-align: center;
  background: var(--accent-muted);
  color: var(--accent);
  border: 1.5px solid rgba(189, 58, 27, .18);
  border-radius: var(--r-sm);
  padding: .2rem .32rem;
  font-size: .9rem;
}

.freq-bar { flex: 1; height: 8px; background: var(--bg-tertiary); border-radius: var(--r-pill); overflow: hidden; }
.freq-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff7a3a);
  border-radius: inherit;
  box-shadow: 0 1px 6px rgba(189, 58, 27, .22);
}
.freq-count { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* virtual keyboard */
.virtual-keyboard { margin-top: .2rem; }

.vk-row {
  display: flex;
  gap: .32rem;
  justify-content: center;
  margin-bottom: .34rem;
  flex-wrap: wrap;
}

.vk-key {
  font-family: var(--font-mono);
  font-size: .82rem;
  min-width: 2.05rem;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  color: var(--text-secondary);
  background: var(--surface-elevated);
  position: relative;
  box-shadow: 0 1px 0 rgba(18, 18, 17, .06);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.vk-key.has-errors {
  background: color-mix(in srgb, var(--tt-incorrect) calc(var(--heat, .5) * 72%), var(--surface-elevated));
  border-color: var(--tt-incorrect);
  color: var(--text-primary);
  box-shadow: 0 1px 6px rgba(189, 58, 27, .20);
}

.vk-key sup {
  position: absolute;
  top: -7px; right: -5px;
  font-size: .60rem;
  background: var(--tt-incorrect);
  color: #fff;
  border-radius: var(--r-pill);
  padding: 0 .3rem;
  line-height: 1.45;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(189, 58, 27, .28);
}

.result-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: 2rem 0 .5rem; }
.result-actions .btn { border-radius: var(--r-pill); }

/* ---------------------------------------------------------------- history (stacked cards) */
.history-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .7rem;
  margin: 1.2rem 0;
}

.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  margin-bottom: 1.15rem;
}

.history-filters select {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--r-pill);
  padding: .4rem .7rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.history-filters select:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--accent-glow); }
.history-filters .chip { padding: 5px 12px; }

.history-list {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

/* list row as a standalone rounded card */
.history-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .72rem .9rem .72rem .95rem;
  border-radius: var(--r-md);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 1px 6px rgba(18, 18, 17, .04);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity 180ms ease;
}

.history-row:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(18, 18, 17, .07); }

.history-row.removing { opacity: 0; transform: scale(.97); }

.history-row__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.history-row__date { color: var(--text-muted); font-size: .65rem; letter-spacing: .03em; }
.history-row__mode {
  color: var(--text-secondary);
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-row__badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.history-row__badge {
  font-size: .58rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  padding: 2px 7px;
  border-radius: var(--r-pill);
}

.history-row__badge--practice { color: #5b7ba6; }
.history-row__badge--daily { color: #7a2b14; border-color: #e8b09a; background: #fff3ef; }

.history-row__stats {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.history-row__wpm { font-weight: 800; font-size: .92rem; color: var(--accent); }
.history-row__acc, .history-row__cons { color: var(--text-secondary); }

.history-row__delete {
  width: 1.65rem; height: 1.65rem;
  border-radius: var(--r-pill);
  color: var(--text-muted);
  border: 1px solid transparent;
  background: transparent;
  flex-shrink: 0;
}

.history-row__delete:hover { color: var(--accent); background: var(--accent-muted); border-color: var(--accent); }

.history-empty {
  padding: 2rem 1.2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  background: var(--surface-elevated);
  border: 1px dashed var(--border-medium);
  border-radius: var(--r-lg);
}

.history-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1.15rem 0; }
.history-toolbar .btn { border-radius: var(--r-pill); }

/* ---------------------------------------------------------------- confirm + help — glass cards */
.modal-overlay-center {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(18, 18, 17, .38);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  /* Above the fixed site header (z-index 1000) so the dialog is not
     obscured and its buttons stay clickable. */
  z-index: 1200;
  padding: 1rem;
}
.modal-overlay-center.open { display: flex; animation: overlay-in .22s both; }

.confirm-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 1.7rem 1.75rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--card-shadow-hover);
  animation: card-pop .26s cubic-bezier(.16, 1, .3, 1) both;
}

.confirm-card h3 { margin-bottom: .4rem; }
.confirm-card p { color: var(--text-secondary); margin-bottom: 1.25rem; font-size: var(--text-sm); }
.confirm-card__actions { display: flex; gap: .6rem; justify-content: center; }
.confirm-card__actions .btn { border-radius: var(--r-pill); flex: 1; justify-content: center; }

.help-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 2rem 2rem 1.6rem;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--card-shadow-hover);
  animation: card-pop .26s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes card-pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }

.help-card h2 { margin-bottom: .25rem; }
.help-card .help-sub { color: var(--text-secondary); margin-bottom: 1.15rem; }
.help-card ol, .help-card ul { padding-left: 1.2rem; margin-bottom: 1.1rem; }
.help-card li { margin-bottom: .45rem; color: var(--text-secondary); font-size: var(--text-sm); }

#settings-reset-defaults.is-confirm { background: var(--accent); color: #fff; border-color: var(--accent); }

.kbd {
  font-family: var(--font-mono);
  font-size: .72rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: .08rem .38rem;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- focus mode */
body.focus-mode .focus-dim { opacity: .22; transition: opacity var(--transition-normal); }

/* ---------------------------------------------------------------- segmented toggle (Easy / Complex) */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
}

.segmented__option {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .04em;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.segmented__option.is-active {
  color: var(--accent);
  background: var(--surface-card);
  border-color: var(--border-medium);
  box-shadow: 0 2px 10px rgba(18, 18, 17, .08);
}

.setting-note {
  font-size: .78rem;
  color: var(--text-muted);
  margin: .45rem 0 0;
  line-height: 1.45;
}

/* ---------------------------------------------------------------- personal best + celebration */
.personal-best {
  margin-top: 1rem;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 7%, var(--surface-elevated)), var(--surface-elevated));
  border: 1px solid var(--border-medium);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.personal-best[hidden] { display: none !important; }

.personal-best__title {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: var(--ls-tag);
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.personal-best__meta { font-size: .78rem; color: var(--text-muted); margin-left: 8px; }

.personal-best__stats {
  display: flex;
  gap: 18px;
  align-items: baseline;
  flex-wrap: wrap;
}

.personal-best__value { font-size: 1.25rem; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.personal-best__label { font-size: .78rem; color: var(--text-muted); margin-left: 4px; }

.record-toast {
  position: fixed;
  left: 50%;
  top: 22px;
  transform: translateX(-50%) translateY(-8px);
  /* Above the fixed site header (z-index 1000) so the celebration toast
     is not hidden behind it. */
  z-index: 1300;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 14px 18px;
  min-width: 320px;
  max-width: min(420px, calc(100vw - 24px));
  background: var(--surface-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow-hover);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.record-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.record-toast__badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: .62rem;
  letter-spacing: .11em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  margin-bottom: 6px;
}

.record-toast__value { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.record-toast__unit { font-size: .9rem; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.record-toast__msg { margin: 6px 0 0; font-size: .82rem; color: var(--text-secondary); line-height: 1.4; }

.record-toast__close {
  margin-left: auto;
  width: 28px; height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.record-toast__confetti {
  position: absolute;
  inset: -6px -6px auto -6px;
  height: 36px;
  pointer-events: none;
  overflow: visible;
}

.confetti-piece {
  position: absolute;
  left: var(--x);
  top: 0;
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--accent);
  opacity: .92;
  animation: confetti-fall var(--d) ease-out forwards;
}

.confetti-piece:nth-child(3n) { background: #f2b24a; }
.confetti-piece:nth-child(3n+1) { background: #7fb07a; }
.confetti-piece:nth-child(5n) { background: #6b6bff; }

@keyframes confetti-fall {
  0% { transform: translateY(-6px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(42px) rotate(var(--r)); opacity: 0; }
}

.site-footer--typing {
  margin-top: auto;
  padding: 2.4rem 0 2rem;
  border-top: 1px solid var(--border-subtle);
  background: transparent;
}

.footer-typing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .035em;
  color: var(--text-muted);
}

.footer-typing a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .16s, border-color .16s;
}

.footer-typing a:hover { color: var(--text-primary); border-color: currentColor; }

/* ---------------------------------------------------------------- homepage card (kept in typing.css as legacy hook) */
.section--tool-strip { padding: var(--space-lg) 0; }

#view-results {
  animation: tt-view-in .32s both;
}

#view-results .result-actions {
  position: sticky;
  bottom: 16px;
  z-index: 10;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-pill);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: fit-content;
  margin-inline: auto;
}

/* unified graph — now the large background visual of the results page */
.result-unified-wrap {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.result-unified-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 .6rem;
  font-family: var(--font-mono);
}

.result-unified-title {
  font-size: .62rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.result-unified-hint {
  font-size: .60rem;
  letter-spacing: .04em;
  color: var(--text-muted);
  opacity: .72;
}

.chart-wrap--unified {
  border-radius: var(--r-lg);
  overflow: hidden;
  background: transparent;
}

.chart-wrap--unified canvas {
  height: 320px;
  display: block;
  width: 100%;
}

.result-unified-legend {
  display: flex;
  align-items: center;
  gap: .48rem;
  margin-top: .7rem;
  font-family: var(--font-mono);
  font-size: .62rem;
  letter-spacing: .06em;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.legend-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot--wpm  { background: var(--accent); }
.legend-dot--acc  { background: var(--tt-correct); }
.legend-dot--cons { background: #8a8f9e; }
.legend-sep { width: 10px; height: 1px; background: var(--border-subtle); margin: 0 .15rem; }
.legend-note { opacity: .75; }

.chart-card--ghost {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.chart-grid--breakdown {
  grid-template-columns: minmax(220px, 320px) 1fr;
  align-items: center;
}

.result-stats-inline {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem 1rem;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.result-stats-inline .muted { color: var(--text-muted); font-size: .68rem; }

@media (max-width: 860px) {
  .result-unified-wrap { margin: 0; }
  .chart-wrap--unified canvas { height: 240px; }
}

@media (max-width: 860px) {
  :root { --tt-font-size: 1.62rem; }
  #typing-stage { padding: 1.2rem 0 1rem; }
  .mode-bar { gap: .5rem; }
  .mode-bar .chip-group { padding: 6px 8px; }
  .result-big { grid-template-columns: repeat(2, 1fr); }
  #view-results .result-graph-stage { margin-inline: -.2rem; padding: .85rem .7rem .75rem; }
}

@media (max-width: 520px) {
  .typing-page .site-header .site-header__inner { gap: 8px; }
  .tt-header-actions { gap: 6px; }
  .live-stats { padding: 4px; gap: 4px; }
  .live-stat { padding: 6px 10px; }
  .live-stat__value { font-size: 1.15rem; }
}

/* ---------------------------------------------------------------- polished transitions */
button,
a,
.chip,
.chip-select,
.tt-icon-btn,
.mode-bar__settings-btn,
.result-big__item,
.stat-card,
.history-row {
  transition:
    color 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease,
    transform 180ms ease;
}

.side-panel,
.tt-scrim,
.modal-overlay-center,
.confirm-card,
.help-card,
.record-toast {
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.typing-text,
.tt-word,
.tt-char {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* Hide built-in caret since we use the floating .tt-caret now */
.typing-viewport .tt-char.is-current::before,
.typing-viewport .tt-char.is-current::after,
.tt-char.caret-here::before { display: none !important; }
@keyframes caret-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}