:root {
  --sky: #6db1e8;
  --sky-dark: #4a9ad4;
  --mint: #9df2b2;
  --mint-hover: #7ee99a;
  --white: #ffffff;
  --ink: #1c1b1b;
  --ink-muted: #414751;
  --surface: #fcf9f8;
  --footer-bg: #f0eded;
  --error-bg: #ffdad6;
  --error-text: #93000a;
  --correct-fade: rgba(28, 27, 27, 0.35);
  --border: 3px solid var(--ink);
  --shadow: 4px 4px 0 0 var(--ink);
  --shadow-sm: 3px 3px 0 0 var(--ink);
  --radius: 1rem;
  --radius-pill: 9999px;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: "Space Grotesk", monospace;
  --max-w: 1000px;
  --margin-mobile: 16px;
  --page-margin: var(--margin-mobile);
  --section-gap: 4rem;
  --card-padding-y: 3rem;
  --card-padding-x: 2.75rem;

  /* Semantic Theme Variables */
  --header-bg: rgba(109, 177, 232, 0.92);
  --cloud-bg: rgba(255, 255, 255, 0.25);
  --pill-bg: rgba(255, 255, 255, 0.9);
  --pill-btn-bg: rgba(255, 255, 255, 0.85);
  --stats-bar-bg: rgba(255, 255, 255, 0.55);
  --stats-bar-border: 2px solid rgba(28, 27, 27, 0.2);
  --chart-card-bg: rgba(255, 255, 255, 0.5);
  --chart-card-border: 2px solid rgba(28, 27, 27, 0.15);
  --chart-labels-color: rgba(28, 27, 27, 0.6);
  --blog-thumb-bg: #e5e2e1;
  --results-overlay-bg: rgba(255, 255, 255, 0.97);
  --section-meta-color: rgba(28, 27, 27, 0.6);
  --section-label-color: rgba(28, 27, 27, 0.7);
  --info-back-bg: rgba(255, 255, 255, 0.85);

  /* Chart & Typography Variables */
  --chart-bar-bg: rgba(109, 177, 232, 0.6);
  --chart-bar-border: 2px solid rgba(28, 27, 27, 0.2);
  --chart-bar-latest-bg: var(--sky-dark);
  --chart-empty-color: rgba(28, 27, 27, 0.5);
  --hero-title-gradient: linear-gradient(135deg, var(--ink) 30%, var(--ink-muted) 100%);

  /* Light-mode only tokens (hardcoded values made into variables) */
  --divider: #eae7e7;
  --table-header-bg: #f6f3f2;
  --profile-stat-bg: #f6f3f2;
  --blog-btn-hover-bg: #f6f3f2;
  --featured-thumb-bg: #e5e2e1;
  --modal-backdrop-bg: rgba(28, 27, 27, 0.4);
  --posts-count-bg: rgba(255, 255, 255, 0.6);
  --posts-count-border: rgba(28, 27, 27, 0.15);
  --footer-border: rgba(28, 27, 27, 0.1);
  --blogs-subtitle-color: rgba(255, 255, 255, 0.85);
}

/* ─────────────────────────────────────────────────────────────────────────
   PROFESSIONAL DARK MODE
   Deep navy base (#0d1117) · Elevated surfaces (#161d2b, #1e2a3b)
   Emerald accent (#10b981) · Slate text (#e2e8f0, #94a3b8)
   ───────────────────────────────────────────────────────────────────────── */
html.dark-theme {
  /* Core palette */
  --sky: #0d1117;
  --sky-dark: #080c12;
  --mint: #10b981;
  --mint-hover: #34d399;
  --white: #161d2b;
  --ink: #e2e8f0;
  --ink-muted: #94a3b8;
  --surface: #0d1117;
  --footer-bg: #080c12;
  --error-bg: #3b0a1a;
  --error-text: #fb7185;
  --correct-fade: rgba(226, 232, 240, 0.3);

  /* Shadows use emerald tint instead of hard black */
  --border: 3px solid rgba(226, 232, 240, 0.12);
  --shadow: 4px 4px 0 0 rgba(16, 185, 129, 0.25);
  --shadow-sm: 3px 3px 0 0 rgba(16, 185, 129, 0.2);

  /* Header: frosted dark glass */
  --header-bg: rgba(13, 17, 23, 0.85);

  /* Background particles */
  --cloud-bg: rgba(16, 185, 129, 0.04);

  /* Controls */
  --pill-bg: rgba(22, 29, 43, 0.9);
  --pill-btn-bg: rgba(22, 29, 43, 0.9);

  /* Stats bar */
  --stats-bar-bg: rgba(22, 29, 43, 0.7);
  --stats-bar-border: 2px solid rgba(226, 232, 240, 0.1);

  /* Charts */
  --chart-card-bg: rgba(22, 29, 43, 0.5);
  --chart-card-border: 2px solid rgba(226, 232, 240, 0.08);
  --chart-labels-color: #64748b;
  --chart-bar-bg: rgba(16, 185, 129, 0.25);
  --chart-bar-border: 2px solid rgba(16, 185, 129, 0.4);
  --chart-bar-latest-bg: #10b981;
  --chart-empty-color: #475569;

  /* Blog thumbnails */
  --blog-thumb-bg: #1a2436;
  --featured-thumb-bg: #1a2436;

  /* Results overlay */
  --results-overlay-bg: rgba(13, 17, 23, 0.96);

  /* Section labels */
  --section-meta-color: #64748b;
  --section-label-color: #94a3b8;

  /* Info / misc */
  --info-back-bg: #161d2b;

  /* Hero gradient: white → emerald */
  --hero-title-gradient: linear-gradient(135deg, #ffffff 20%, #10b981 100%);

  /* Formerly hardcoded tokens */
  --divider: rgba(226, 232, 240, 0.08);
  --table-header-bg: rgba(22, 29, 43, 0.8);
  --profile-stat-bg: rgba(22, 29, 43, 0.8);
  --blog-btn-hover-bg: rgba(16, 185, 129, 0.12);
  --modal-backdrop-bg: rgba(0, 0, 0, 0.7);
  --posts-count-bg: rgba(22, 29, 43, 0.8);
  --posts-count-border: rgba(226, 232, 240, 0.1);
  --footer-border: rgba(226, 232, 240, 0.06);
  --blogs-subtitle-color: rgba(226, 232, 240, 0.7);
}

/* Smooth transition on all theme-aware properties */
html.dark-theme *,
html.dark-theme *::before,
html.dark-theme *::after {
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease,
    fill 0.3s ease;
}

/* Override for elements where transition would look bad */
html.dark-theme .typing-text,
html.dark-theme .char,
html.dark-theme .caret {
  transition: none;
}


*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  font-family: var(--font);
  background: var(--sky);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Cloud background — drift right to left */
@keyframes cloud-drift {
  from {
    transform: translateX(110vw);
  }
  to {
    transform: translateX(calc(-100% - 12vw));
  }
}

.cloud-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud {
  position: absolute;
  left: 0;
  background: var(--cloud-bg);
  border-radius: 50%;
  animation: cloud-drift linear infinite;
  will-change: transform;
}

.cloud-1 {
  width: 200px;
  height: 80px;
  top: 10%;
  border-radius: 50px;
  box-shadow: 60px 10px 0 -10px rgba(255, 255, 255, 0.2), 120px 0 0 -20px rgba(255, 255, 255, 0.15);
  animation-duration: 52s;
  animation-delay: 0s;
}

.cloud-2 {
  width: 160px;
  height: 60px;
  top: 32%;
  border-radius: 40px;
  animation-duration: 68s;
  animation-delay: -18s;
}

.cloud-3 {
  width: 120px;
  height: 50px;
  top: 58%;
  border-radius: 35px;
  animation-duration: 44s;
  animation-delay: -32s;
}

.cloud-4 {
  width: 180px;
  height: 70px;
  top: 78%;
  border-radius: 45px;
  box-shadow: 50px 8px 0 -8px rgba(255, 255, 255, 0.18);
  animation-duration: 76s;
  animation-delay: -8s;
}

.cloud-5 {
  width: 140px;
  height: 55px;
  top: 45%;
  border-radius: 38px;
  animation-duration: 58s;
  animation-delay: -40s;
}

@media (prefers-reduced-motion: reduce) {
  .cloud {
    animation: none;
    opacity: 0.2;
  }
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--page-margin);
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  font-size: 1.25rem;
}

.logo-icon {
  font-size: 1.5rem;
}

.nav {
  display: flex;
  gap: 2rem;
}

.nav-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.nav-link:hover,
.nav-link.active {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 4px;
}

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

.icon-btn {
  width: 42px;
  height: 42px;
  border: var(--border);
  border-radius: 50%;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: transform 0.1s, box-shadow 0.1s;
}

.icon-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 0 var(--ink);
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.6rem 1.25rem;
  border: var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-primary {
  background: var(--mint);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  background: var(--mint-hover);
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 0 var(--ink);
}

.btn-primary:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.btn-full {
  width: 100%;
}

/* Main layout */
main {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-margin) 3rem;
}

.hero {
  padding-top: 1rem;
}

.hero-title {
  text-align: center;
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  /* White → mint gradient text */
  background: var(--hero-title-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  /* Subtle glow so it lifts off the sky background */
  filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.18));
}

/* Controls */
.controls-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.controls-left {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.pill-select {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--pill-bg);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 2px 2px 0 0 var(--ink);
}

.pill-select select {
  border: none;
  background: transparent;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--ink);
  outline: none;
}

.pill-btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.45rem 1rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--pill-btn-bg);
  cursor: pointer;
  box-shadow: 2px 2px 0 0 var(--ink);
  transition: background 0.15s, transform 0.1s;
}

.pill-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 0 var(--ink);
}

.pill-btn.active {
  background: var(--mint);
}

/* Custom time input (shown when "Custom" is selected) */
.custom-time-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pill-input {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.875rem;
  width: 5ch;
  padding: 0.4rem 0.6rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--pill-btn-bg);
  box-shadow: 2px 2px 0 0 var(--ink);
  outline: none;
  text-align: center;
  color: var(--ink);
  -moz-appearance: textfield;
}

.pill-input::-webkit-outer-spin-button,
.pill-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pill-input:focus {
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(157, 242, 178, 0.6), 2px 2px 0 0 var(--ink);
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 1.25rem;
  background: var(--stats-bar-bg);
  border: var(--stats-bar-border);
  border-radius: var(--radius-pill);
  padding: 0.5rem 1.25rem;
  font-family: var(--font-mono);
  flex-shrink: 0;
  white-space: nowrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 3rem;
}

.stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Typing card */
.typing-card {
  position: relative;
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--card-padding-y) var(--card-padding-x) 2rem;
  margin-bottom: var(--section-gap);
}

.typing-card.focused {
  outline: 3px solid var(--mint);
  outline-offset: 2px;
}

.typing-wrapper {
  outline: none;
  cursor: text;
  /* Show exactly 4 lines: font ~1.75rem × line-height 1.75 × 4 lines */
  height: calc(1.75rem * 1.75 * 4);
  overflow: hidden;
  position: relative;
  padding: 0.5rem 0;
}

.typing-wrapper:focus-within {
  outline: none;
}

.typing-text {
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  font-weight: 500;
  line-height: 1.75;
  color: var(--ink-muted);
  word-wrap: break-word;
  user-select: none;
  /* Smooth line-by-line scrolling as user progresses */
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.char {
  position: relative;
}

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

.char.current {
  color: var(--ink);
  border-bottom: 3px solid var(--mint);
  border-radius: 2px;
}

.char.incorrect {
  color: var(--error-text);
  background: var(--error-bg);
  border-radius: 2px;
}

.char.extra {
  color: var(--error-text);
  background: var(--error-bg);
  text-decoration: underline;
}

.char.pending {
  color: var(--ink-muted);
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--ink);
  margin-left: -1px;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}


@keyframes blink {
  50% {
    opacity: 0;
  }
}

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


.typing-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: text;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  z-index: 2;
}

.typing-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
}

.circle-btn {
  width: 48px;
  height: 48px;
  border: var(--border);
  border-radius: 50%;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: transform 0.1s, box-shadow 0.1s;
}

.circle-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 0 var(--ink);
}

/* Timer badge — always-visible corner countdown */
.timer-badge {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--sky);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 0.3rem 0.9rem;
  box-shadow: 2px 2px 0 0 var(--ink);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.3s;
}

.timer-badge::before {
  content: "⏱";
  font-size: 0.75rem;
}

.timer-badge-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  min-width: 2.5rem;
  text-align: center;
}

.timer-badge.urgent {
  background: var(--error-bg);
  border-color: var(--error-text);
  box-shadow: 2px 2px 0 0 var(--error-text);
}

.timer-badge.urgent .timer-badge-value {
  color: var(--error-text);
}

/* Results overlay */
.results-overlay {
  position: absolute;
  inset: 0;
  background: var(--results-overlay-bg);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.results-overlay[hidden] {
  display: none !important;
}

.results-title {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
}

.results-grid {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.result-item {
  text-align: center;
}

.result-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.result-value {
  font-size: 2rem;
  font-weight: 800;
}

/* Performance chart */
.performance-section {
  margin-bottom: var(--section-gap);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--section-label-color);
}

.section-meta {
  font-size: 0.8rem;
  color: var(--section-meta-color);
}

.chart-card {
  background: var(--chart-card-bg);
  border: var(--chart-card-border);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1rem;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--chart-labels-color);
  margin-bottom: 0.75rem;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem;
  height: 120px;
  padding-top: 0.5rem;
}

.chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  max-width: 48px;
  background: var(--chart-bar-bg);
  border: var(--chart-bar-border);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

.chart-bar.latest {
  background: var(--chart-bar-latest-bg);
  border-color: var(--ink);
}

.chart-bar-label {
  font-size: 0.65rem;
  margin-top: 0.35rem;
  font-family: var(--font-mono);
  opacity: 0.7;
}

.chart-empty {
  width: 100%;
  text-align: center;
  color: var(--chart-empty-color);
  font-size: 0.9rem;
  padding: 2rem 0;
}

/* Blogs section on index */
.blogs-section {
  margin-bottom: var(--section-gap);
}

.blogs-header {
  margin-bottom: 1.5rem;
}

.blogs-title {
  font-size: 1.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.blogs-more-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 1px;
  transition: opacity 0.15s;
}

.blogs-more-link:hover {
  opacity: 0.7;
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.blog-card {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-align: left;
}

.blog-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 0 var(--ink);
}

.blog-thumb {
  height: 140px;
  background: var(--blog-thumb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  border-bottom: var(--border);
}

.blog-body {
  padding: 1rem 1.25rem 1.25rem;
}

.blog-date {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  margin-bottom: 0.5rem;
}

.blog-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.blog-card p {
  font-size: 0.875rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* ─── Blogs page ─── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.blogs-page-hero {
  padding: 2.5rem 0 2rem;
  text-align: center;
}

.blogs-page-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  color: var(--ink);
  text-shadow: none;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.blogs-page-subtitle {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--blogs-subtitle-color);
  max-width: 520px;
  margin: 0 auto;
}

/* Featured post card */
.blog-featured-section {
  margin-bottom: 3rem;
}

.blog-featured-card {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 260px 1fr;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.blog-featured-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 0 var(--ink);
}

.blog-featured-thumb {
  background: var(--featured-thumb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  border-right: var(--border);
  min-height: 220px;
}

.blog-featured-content {
  padding: 2rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.blog-featured-title {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.25;
}

.blog-featured-excerpt {
  font-size: 0.95rem;
  color: var(--ink-muted);
  line-height: 1.65;
  flex: 1;
}

.blog-featured-read {
  align-self: flex-start;
  margin-top: 0.5rem;
}

/* Posts count badge */
.posts-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--posts-count-bg);
  border: 2px solid var(--posts-count-border);
  border-radius: var(--radius-pill);
  padding: 0.2rem 0.75rem;
  color: var(--ink-muted);
}

/* Blog read modal */
.blog-read-modal {
  width: min(640px, calc(100vw - 2rem));
}

.blog-read-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: 1rem;
}

/* Old blog page hero (kept for fallback) */
.page-hero-title {
  text-align: center;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: var(--ink);
  text-shadow: none;
  letter-spacing: -0.02em;
  margin-bottom: 2rem;
}

.blog-editor-card {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2.25rem;
  margin-bottom: var(--section-gap);
}

.blog-editor-card h2 {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 1.25rem;
}

.blog-form textarea {
  font-family: var(--font);
  padding: 0.75rem 0.9rem;
  border: 2px solid var(--divider);
  border-radius: 0.5rem;
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 140px;
  width: 100%;
  background: var(--white);
  color: var(--ink);
}

.blog-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn-secondary {
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 0 var(--ink);
}

.blog-post-full {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--ink-muted);
  white-space: pre-wrap;
}

.blog-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.blog-card-actions button {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--white);
  cursor: pointer;
}

.blog-card-actions button:hover {
  background: var(--blog-btn-hover-bg);
}

.blog-card-actions .delete-btn:hover {
  background: var(--error-bg);
}

/* Leaderboard */
.leaderboard-section {
  margin-bottom: var(--section-gap);
}

.leaderboard-card {
  background: transparent;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  overflow: hidden;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 0.85rem 1.25rem;
  text-align: left;
  border-bottom: 2px solid var(--divider);
}

.leaderboard-table th {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  background: transparent;
  color: var(--ink-muted);
}

.leaderboard-table tr:last-child td {
  border-bottom: none;
}

.leaderboard-table tr:nth-child(1) td:first-child {
  font-weight: 800;
}

.empty-row {
  text-align: center;
  color: var(--ink-muted);
  padding: 2rem !important;
}

/* Footer */
.footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem max(var(--page-margin), calc((100vw - var(--max-w)) / 2));
  width: 100%;
  background: var(--footer-bg);
  border-top: 2px solid var(--footer-border);
}

.footer-copy {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.footer-nav {
  display: flex;
  gap: 1.5rem;
}

.footer-nav a {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.footer-nav a:hover {
  text-decoration: underline;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop-bg);
  z-index: 200;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 201;
  width: min(440px, calc(100vw - 2rem));
  max-height: 90vh;
  overflow-y: auto;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: 8px 8px 0 0 var(--ink);
  padding: 0;
  background: var(--white);
}

.modal::backdrop {
  background: var(--modal-backdrop-bg);
}

.modal[open] {
  display: block;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 2px solid var(--divider);
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--white);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}

.setting-row:last-child {
  border-bottom: none;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-field span {
  font-weight: 600;
  font-size: 0.875rem;
}

.form-field input {
  font-family: var(--font);
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--ink);
  border-radius: 0.5rem;
  font-size: 1rem;
  background: var(--white);
  color: var(--ink);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
  text-align: center;
  margin-top: 0.75rem;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.profile-stat {
  background: var(--profile-stat-bg);
  border: 2px solid var(--divider);
  border-radius: 0.75rem;
  padding: 1rem;
  text-align: center;
}

.profile-stat-value {
  font-size: 1.75rem;
  font-weight: 800;
}

.profile-stat-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.profile-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

@media (min-width: 769px) {
  :root {
    --section-gap: 5rem;
    --card-padding-y: 3.5rem;
    --card-padding-x: 3.25rem;
  }
}

@media (min-width: 1400px) {
  :root {
    --max-w: 920px;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-wrap: wrap;
    padding: 1rem;
  }

  .nav {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 1.5rem;
  }

  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .controls-left {
    justify-content: center;
  }

  .stats-bar {
    justify-content: space-around;
  }

  .typing-card {
    padding: 3.5rem 1.25rem 1.5rem; /* top pushes text below the timer badge */
    min-height: 200px;
  }

  .typing-wrapper {
    min-height: 110px;
    padding: 0.25rem 0;
  }

  /* Results overlay: keep stats in a row so they fit without needing huge height */
  .results-grid {
    flex-direction: row;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .result-value {
    font-size: 1.5rem;
  }

  .results-title {
    font-size: 1.4rem;
    margin-bottom: 1rem;
  }

  .results-overlay {
    padding: 1.5rem 1rem;
    overflow-y: auto;
  }

  .footer {
    flex-direction: column;
    text-align: center;
  }

  .blog-featured-card {
    grid-template-columns: 1fr;
  }

  .blog-featured-thumb {
    min-height: 140px;
    border-right: none;
    border-bottom: var(--border);
  }

  .timer-badge {
    top: 0.6rem;
    right: 0.75rem;
    padding: 0.15rem 0.55rem;
    font-size: 0.85rem;
  }

  .timer-badge-value {
    font-size: 0.9rem;
    min-width: 2rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE ENHANCEMENTS
   Extra polish applied only in dark mode
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Stars / particle background replaces clouds in dark mode ── */
html.dark-theme .cloud {
  opacity: 0;
  animation: none;
}

html.dark-theme .cloud-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 8%  12%, rgba(255,255,255,0.5)  0%, transparent 100%),
    radial-gradient(1px 1px at 22% 55%, rgba(255,255,255,0.3)  0%, transparent 100%),
    radial-gradient(2px 2px at 38% 28%, rgba(16,185,129,0.6)   0%, transparent 100%),
    radial-gradient(1px 1px at 52% 73%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 67% 18%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(2px 2px at 78% 62%, rgba(16,185,129,0.5)   0%, transparent 100%),
    radial-gradient(1px 1px at 91% 42%, rgba(255,255,255,0.3)  0%, transparent 100%),
    radial-gradient(1px 1px at 13% 82%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 58% 8%,  rgba(255,255,255,0.4)  0%, transparent 100%),
    radial-gradient(1px 1px at 33% 92%, rgba(16,185,129,0.35)  0%, transparent 100%),
    radial-gradient(1px 1px at 47% 47%, rgba(255,255,255,0.2)  0%, transparent 100%),
    radial-gradient(1px 1px at 72% 88%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 3%  65%, rgba(255,255,255,0.2)  0%, transparent 100%),
    radial-gradient(1px 1px at 85% 5%,  rgba(16,185,129,0.4)   0%, transparent 100%);
  pointer-events: none;
  animation: twinkle 5s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0%   { opacity: 0.7; }
  50%  { opacity: 0.3; }
  100% { opacity: 0.7; }
}

/* ── Header: frosted dark glass ── */
html.dark-theme .header {
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid rgba(226, 232, 240, 0.07);
  box-shadow: 0 1px 0 rgba(16, 185, 129, 0.08), 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ── Logo: emerald glow on hover ── */
html.dark-theme .logo:hover .logo-text {
  color: #10b981;
}

/* ── Icon buttons: subtle glow ring ── */
html.dark-theme .icon-btn {
  background: rgba(22, 29, 43, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.12);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html.dark-theme .icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.4), 0 4px 16px rgba(16, 185, 129, 0.2);
  background: rgba(16, 185, 129, 0.08);
}

/* ── Primary button: emerald glow ── */
html.dark-theme .btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

html.dark-theme .btn-primary:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

html.dark-theme .btn-primary:active {
  transform: translateY(0px);
  box-shadow: 0 1px 6px rgba(16, 185, 129, 0.3);
}

/* ── Secondary button ── */
html.dark-theme .btn-secondary {
  background: rgba(22, 29, 43, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.12);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

html.dark-theme .btn-secondary:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

/* ── Pill controls ── */
html.dark-theme .pill-select,
html.dark-theme .pill-btn,
html.dark-theme .pill-input {
  background: rgba(22, 29, 43, 0.85);
  border: 1px solid rgba(226, 232, 240, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

html.dark-theme .pill-btn:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  transform: translateY(-1px);
}

html.dark-theme .pill-btn.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.5);
  color: #10b981;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25), 0 2px 8px rgba(16, 185, 129, 0.15);
}

html.dark-theme .pill-input:focus {
  background: rgba(22, 29, 43, 0.95);
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

html.dark-theme .pill-select select {
  background: transparent;
  color: var(--ink);
}

/* ── Stats bar ── */
html.dark-theme .stats-bar {
  background: rgba(22, 29, 43, 0.6);
  border: 1px solid rgba(226, 232, 240, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(8px);
}

html.dark-theme #stat-wpm {
  color: #10b981;
  text-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

/* ── Typing card: elevated glass ── */
html.dark-theme .typing-card {
  background: rgba(22, 29, 43, 0.7);
  border: 1px solid rgba(226, 232, 240, 0.1);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

html.dark-theme .typing-card.focused {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow:
    0 0 0 1px rgba(16, 185, 129, 0.15),
    0 0 28px rgba(16, 185, 129, 0.08),
    0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ── Caret: bright emerald glow ── */
html.dark-theme .caret {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8), 0 0 16px rgba(16, 185, 129, 0.4);
}

/* ── Typing text states ── */
html.dark-theme .char.correct {
  color: rgba(226, 232, 240, 0.22);
}

html.dark-theme .char.current {
  border-bottom: 3px solid #10b981;
}

html.dark-theme .char.incorrect {
  color: #fb7185;
  background: rgba(59, 10, 26, 0.7);
}

html.dark-theme .char.extra {
  color: #fb7185;
  background: rgba(59, 10, 26, 0.6);
}

/* ── Timer badge ── */
html.dark-theme .timer-badge {
  background: rgba(13, 17, 23, 0.9);
  border: 1px solid rgba(16, 185, 129, 0.25);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4), 0 0 8px rgba(16, 185, 129, 0.08);
  backdrop-filter: blur(8px);
}

html.dark-theme .timer-badge-value {
  color: #10b981;
}

html.dark-theme .timer-badge.urgent {
  background: rgba(59, 10, 26, 0.9);
  border-color: rgba(251, 113, 133, 0.5);
  box-shadow: 0 0 16px rgba(251, 113, 133, 0.2);
}

html.dark-theme .timer-badge.urgent .timer-badge-value {
  color: #fb7185;
  text-shadow: 0 0 8px rgba(251, 113, 133, 0.5);
}

/* ── Circle action buttons ── */
html.dark-theme .circle-btn {
  background: rgba(22, 29, 43, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

html.dark-theme .circle-btn:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
  transform: translateY(-1px);
}

/* ── Results overlay ── */
html.dark-theme .results-overlay {
  background: rgba(13, 17, 23, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

html.dark-theme .result-value {
  color: #10b981;
  text-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

/* ── Chart card ── */
html.dark-theme .chart-card {
  background: rgba(22, 29, 43, 0.4);
  border: 1px solid rgba(226, 232, 240, 0.07);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
}

html.dark-theme .chart-bar.latest {
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

/* ── Blog cards ── */
html.dark-theme .blog-card {
  background: rgba(22, 29, 43, 0.7);
  border: 1px solid rgba(226, 232, 240, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
}

html.dark-theme .blog-card:hover {
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.1), 0 8px 32px rgba(0, 0, 0, 0.4);
  transform: translate(-2px, -2px);
}

html.dark-theme .blog-date {
  border-color: rgba(16, 185, 129, 0.35);
  color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

html.dark-theme .blog-featured-card {
  background: rgba(22, 29, 43, 0.7);
  border: 1px solid rgba(226, 232, 240, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
}

html.dark-theme .blog-featured-card:hover {
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.1), 0 12px 40px rgba(0, 0, 0, 0.5);
}

html.dark-theme .blog-card-actions button {
  background: rgba(22, 29, 43, 0.8);
  border: 1px solid rgba(226, 232, 240, 0.1);
  color: var(--ink);
}

/* ── Leaderboard ── */
html.dark-theme .leaderboard-card {
  background: transparent;
  border: 1px solid rgba(226, 232, 240, 0.08);
  box-shadow: none;
  backdrop-filter: none;
}

html.dark-theme .leaderboard-table tr:hover td {
  background: rgba(16, 185, 129, 0.05);
}

html.dark-theme .leaderboard-table tr:nth-child(1) td:first-child {
  color: #10b981;
}

/* ── Modals ── */
html.dark-theme .modal {
  background: rgba(22, 29, 43, 0.95);
  border: 1px solid rgba(226, 232, 240, 0.1);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(16, 185, 129, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

html.dark-theme .modal-close {
  background: rgba(22, 29, 43, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.1);
  color: var(--ink);
}

html.dark-theme .modal-close:hover {
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.3);
  color: #fb7185;
}

html.dark-theme .form-field input,
html.dark-theme .blog-form textarea {
  background: rgba(13, 17, 23, 0.6);
  border: 1px solid rgba(226, 232, 240, 0.12);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

html.dark-theme .form-field input:focus,
html.dark-theme .blog-form textarea:focus {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1), inset 0 2px 4px rgba(0, 0, 0, 0.3);
  outline: none;
}

/* ── Blog editor card ── */
html.dark-theme .blog-editor-card {
  background: rgba(22, 29, 43, 0.7);
  border: 1px solid rgba(226, 232, 240, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
}

/* ── Footer ── */
html.dark-theme .footer {
  background: rgba(8, 12, 18, 0.95);
  border-top: 1px solid rgba(226, 232, 240, 0.06);
  backdrop-filter: blur(12px);
}

/* ── Profile stat boxes ── */
html.dark-theme .profile-stat {
  background: rgba(13, 17, 23, 0.5);
  border: 1px solid rgba(226, 232, 240, 0.08);
}

html.dark-theme .profile-stat-value {
  color: #10b981;
}

/* ── Nav links ── */
html.dark-theme .nav-link.active {
  color: #10b981;
  text-decoration-color: #10b981;
}

html.dark-theme .nav-link:hover {
  color: #10b981;
  opacity: 1;
}

/* ── Blogs more link ── */
html.dark-theme .blogs-more-link {
  color: #10b981;
  border-bottom-color: rgba(16, 185, 129, 0.4);
}

/* ── Hero title glow ── */
html.dark-theme .hero-title {
  filter: drop-shadow(0 0 24px rgba(16, 185, 129, 0.25));
}

/* ── Custom scrollbar ── */
html.dark-theme ::-webkit-scrollbar {
  width: 6px;
}

html.dark-theme ::-webkit-scrollbar-track {
  background: rgba(13, 17, 23, 0.8);
}

html.dark-theme ::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.3);
  border-radius: 3px;
}

html.dark-theme ::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 185, 129, 0.5);
}

/* ── Text selection highlight ── */
html.dark-theme ::selection {
  background: rgba(16, 185, 129, 0.25);
  color: #e2e8f0;
}
