/* ==========================================================================
   Keyflow — centralized color system
   Inspired by typing.com's friendly educational palette
   Primary yellow: #F1BC3F  |  Secondary blue: #4299E1  |  Accent blue: #3182CE
   ========================================================================== */

:root {
  color-scheme: light;
  background: var(--color-background);
  scrollbar-gutter: stable;

  /* -- Palette (typing.com inspired) -- */
  --color-primary: #F1BC3F;        /* yellow — primary actions & highlights */
  --color-primary-hover: #D9A32B;
  --color-secondary: #4299E1;      /* blue — interactive / active states */
  --color-accent: #3182CE;         /* accent blue — hover / pressed / focus */
  --color-white: #FFFFFF;
  --color-background: #F7F8FA;     /* light neutral page background */
  --color-surface: #FFFFFF;        /* white card surface */
  --color-surface-soft: #FBFCFD;   /* off-white subtle surface */
  --color-light-gray: #D2D3D6;     /* borders / dividers */
  --color-medium-gray: #7A7D82;    /* secondary text */
  --color-dark-gray: #4D5259;      /* tertiary text */
  --color-text-primary: #374151;   /* main body text */
  --color-text-secondary: #4D5259; /* muted body text */

  /* -- Borders -- */
  --color-border: #D2D3D6;
  --color-border-soft: #E4E6E9;

  /* -- States -- */
  --color-success: #16A34A;
  --color-success-soft: #ECFDF5;
  --color-error: #DC2626;
  --color-error-soft: #FEF2F2;

  /* -- Focus ring -- */
  --color-focus: #3182CE;
  --color-focus-ring: color-mix(in srgb, var(--color-accent), transparent 65%);

  /* -- Legacy aliases (kept so every existing component rule keeps working) -- */
  --page: var(--color-background);
  --surface: var(--color-surface);
  --surface-soft: var(--color-surface-soft);
  --ink: var(--color-text-primary);
  --muted: var(--color-medium-gray);
  --muted-dark: var(--color-dark-gray);
  --line: var(--color-border);
  --green: var(--color-secondary);
  --green-deep: var(--color-accent);
  --green-soft: #EFF6FF;
  --red: var(--color-error);
  --red-soft: var(--color-error-soft);

  --serif: Georgia, "Times New Roman", serif;
  --sans: "DM Sans", "Segoe UI", sans-serif;
  --mono: "DM Mono", Consolas, monospace;

  font-family: var(--sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

/* Dark theme (site-wide toggle) — complementary dark variant */
html.dark {
  color-scheme: dark;
  --page: #0F172A;
  --surface: #1E293B;
  --surface-soft: #2D3748;
  --ink: #F1F5F9;
  --muted: #94A3B8;
  --muted-dark: #CBD5E1;
  --line: #334155;
  --green: #60A5FA;
  --green-deep: #3B82F6;
  --green-soft: #1E3A8A;
  --red: #F87171;
  --red-soft: #450A0A;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; background: var(--page); color: var(--ink); }
button, textarea { font: inherit; }
button { color: inherit; }

.app-shell { width: min(1192px, calc(100% - 72px)); min-height: 100vh; margin: 0 auto; display: flex; flex-direction: column; }

.topbar { height: 82px; display: grid; grid-template-columns: minmax(0, 1fr) max-content minmax(0, 1fr); align-items: center; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-size: 19px; font-weight: 700; letter-spacing: -1px; }
.brand { grid-column: 1; justify-self: start; }
.brand-mark { width: 23px; height: 23px; padding: 4px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; border-radius: 7px; background: var(--green); transform: rotate(-8deg); }
.brand-mark span { border-radius: 2px; background: var(--green-soft); }
.brand-mark span:nth-child(2) { opacity: .7; }.brand-mark span:nth-child(3) { opacity: .55; }

.main-nav { grid-column: 2; justify-self: center; display: flex; gap: 31px; align-items: center; height: 100%; }
.nav-link { display: inline-flex; align-items: center; height: 100%; padding: 0 2px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted-dark); cursor: pointer; font-size: 13px; font-weight: 500; text-decoration: none; transition: color .18s, border-color .18s; }
.nav-link:hover, .nav-link.active { color: var(--ink); }
.nav-link.active { border-bottom-color: var(--green); }

.topbar-actions { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 17px; }

.language-switch { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.language-button { min-width: 24px; padding: 4px 5px; border: 0; border-radius: 4px; background: transparent; color: var(--muted-dark); cursor: pointer; font-size: 8px; font-weight: 600; }
.language-button.selected { background: var(--green-soft); color: var(--green-deep); }
.language-button:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }

.streak-pill { display: flex; align-items: center; gap: 7px; color: var(--muted-dark); font-size: 11px; }
.streak-dot, .live-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--green-deep); box-shadow: 0 0 0 3px var(--color-focus-ring); }
.icon-button { display: grid; width: 33px; height: 33px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer; color: var(--muted-dark); }
.icon-button svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.moon-icon { display: none; }
html.dark .sun-icon { display: none; }
html.dark .moon-icon { display: block; }

main { flex: 1; padding: 30px 0 65px; position: relative; }

@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 39px; }

.eyebrow { margin: 0 0 13px; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 1.45px; }
.eyebrow-line { width: 15px; height: 1px; display: inline-block; background: var(--green); }

h1 { margin: 0; font-size: clamp(32px, 4vw, 41px); font-weight: 500; letter-spacing: -1.7px; line-height: 1.15; }
.page-heading h2 { margin: 0; font-size: clamp(30px, 3.8vw, 38px); font-weight: 500; letter-spacing: -1.5px; line-height: 1.15; }

.serif-accent { color: var(--green); font-family: var(--serif); font-weight: 400; font-style: italic; letter-spacing: -1.2px; }
.page-description { margin: 10px 0 0; color: var(--muted-dark); font-size: 13px; }

.mode-label { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 30px; background: var(--surface); color: var(--muted-dark); font-size: 11px; }
.mode-label .live-dot { width: 6px; height: 6px; }

.practice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 248px; gap: 23px; align-items: start; }
.practice-main { min-width: 0; }

.practice-toolbar { height: 43px; display: flex; justify-content: space-between; align-items: flex-start; }
.text-source { display: flex; align-items: center; gap: 9px; color: var(--muted-dark); font-size: 11px; }
.source-icon { display: grid; width: 23px; height: 23px; place-items: center; border-radius: 6px; background: var(--surface-soft); color: var(--green); font-family: var(--serif); font-size: 14px; }
.toolbar-divider { width: 1px; height: 12px; background: var(--line); }
#practice-length { color: var(--muted); font-size: 10px; }

.subtle-button { display: flex; align-items: center; gap: 6px; padding: 5px 0; border: 0; background: transparent; color: var(--muted-dark); cursor: pointer; font-size: 11px; }
.subtle-button:hover { color: var(--green-deep); }
.subtle-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

.typing-card, .test-card, .aside-card, .keyboard-card { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: 0 3px 14px rgba(36,54,45,.025); }
.typing-card { overflow: hidden; }

.passage-wrap { min-height: 236px; position: relative; padding: 28px 30px 24px; cursor: text; }
.passage { min-height: 179px; color: var(--muted); font-family: var(--mono); font-size: 15px; line-height: 2.15; letter-spacing: -.3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.char { position: relative; }
.char.correct { color: var(--color-success); }
.char.incorrect { color: var(--color-error); background: var(--color-error-soft); border-radius: 2px; }
.char.current::before { content: ""; position: absolute; top: 2px; bottom: 1px; left: -2px; width: 2px; border-radius: 2px; background: var(--green); animation: cursorBlink 1s steps(2, start) infinite; }
.char.current.incorrect::before { background: var(--color-error); }
@keyframes cursorBlink { to { visibility: hidden; } }

.typing-input { position: absolute; width: 1px; height: 1px; top: 2px; left: 2px; padding: 0; border: 0; opacity: .01; resize: none; overflow: hidden; }

.focus-prompt { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); padding: 10px 15px; border: 1px solid var(--line); border-radius: 30px; background: var(--surface); color: var(--muted-dark); box-shadow: 0 3px 12px rgba(42,57,49,.05); cursor: pointer; font-size: 11px; white-space: nowrap; transition: opacity .2s, transform .2s; }
.focus-prompt:hover { color: var(--green-deep); transform: translate(-50%,-52%); }
.focus-prompt.is-hidden { opacity: 0; pointer-events: none; }

.typing-card-footer, .test-footer { min-height: 42px; padding: 0 19px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }

kbd { padding: 2px 4px; border: 1px solid var(--color-light-gray); border-radius: 3px; background: var(--surface-soft); font-family: var(--mono); font-size: 8px; }

.input-hint { display: flex; align-items: center; gap: 6px; }
.tiny-key { width: 10px; height: 8px; border: 1px solid var(--color-light-gray); border-radius: 2px; }

.practice-stats { min-height: 96px; padding: 22px 4px 0; display: flex; align-items: flex-start; gap: 42px; }
.stat-block { min-width: 75px; }
.stat-label { display: block; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 1.15px; }
.stat-value { display: flex; align-items: baseline; gap: 5px; margin-top: 5px; color: var(--ink); font-family: var(--mono); font-size: 23px; letter-spacing: -.8px; }
.stat-value small, .test-live-stats small { color: var(--muted); font-family: var(--sans); font-size: 10px; letter-spacing: 0; }
.stat-note { display: flex; align-items: center; gap: 7px; margin: 13px 0 0 auto; color: var(--muted); font-size: 10px; }
.note-sparkle { color: var(--green-deep); font-size: 14px; }

.practice-aside { display: flex; flex-direction: column; gap: 13px; }

.aside-card { padding: 16px 17px; }
.aside-card-top { display: flex; align-items: center; gap: 8px; }
.mini-icon { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 7px; font-size: 15px; }
.soft-green { background: var(--green-soft); color: var(--green-deep); }
.card-kicker { color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 1.1px; }

.session-message { margin: 15px 0 13px; font-family: var(--serif); font-size: 17px; font-style: italic; }
.session-divider { height: 1px; background: var(--line); margin-bottom: 12px; }
.session-row { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; color: var(--muted-dark); font-size: 10px; }
.session-row strong { color: var(--ink); font-family: var(--mono); font-size: 13px; font-weight: 500; }
.session-row small { color: var(--muted); font-family: var(--sans); font-size: 9px; }

.tip-card { position: relative; padding-top: 16px; background: var(--surface-soft); border-color: var(--line); border: 1px solid var(--line); }
.tip-icon { position: absolute; right: 16px; top: 13px; color: var(--green); font-size: 17px; }
.tip-card .card-kicker { margin: 0; }
.tip-copy { margin: 12px 0 14px; color: var(--muted-dark); font-family: var(--serif); font-size: 14px; line-height: 1.55; }
.tip-caption { color: var(--muted); font-size: 8px; letter-spacing: .9px; }

.aside-lesson-link { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; }
.aside-lesson-link:hover { border-color: var(--line); }
.lesson-link-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-soft); color: var(--muted); font-size: 15px; }
.aside-lesson-link strong, .aside-lesson-link small { display: block; }
.aside-lesson-link strong { font-size: 10px; font-weight: 600; }
.aside-lesson-link small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.link-arrow { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ==========================================================================
   Buttons — consistent color system
   Primary: blue bg / white text
   Secondary: yellow bg / dark text
   Tertiary (subtle / text): neutral bg / dark text
   ========================================================================== */
.primary-button {
  display: inline-flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border: 0;
  border-radius: 6px;
  background: var(--color-secondary);
  color: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: background .2s ease, transform .1s ease;
}
.primary-button:hover { background: var(--color-accent); transform: translateY(-1px); }
.primary-button:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: 4px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 30px;
  border-radius: 10px;
  background: var(--color-secondary);
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 10px 20px -4px var(--color-focus-ring);
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.btn-primary:hover { background: var(--color-accent); transform: translateY(-2px); }
.btn-primary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: 6px; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 15px 26px;
  border-radius: 10px;
  background: var(--color-primary);
  border: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s ease, transform .2s ease;
}
.btn-secondary:hover { background: var(--color-primary-hover); transform: translateY(-2px); }
.btn-secondary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: 6px; }

.text-button {
  padding: 5px;
  border: 0;
  background: transparent;
  color: var(--muted-dark);
  cursor: pointer;
  font-size: 10px;
}
.text-button:hover { color: var(--green-deep); }
.text-button:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: 4px; }

.timer-display { display: flex; align-items: center; gap: 9px; margin-bottom: 3px; color: var(--green-deep); font-family: var(--mono); font-size: 26px; }
.timer-icon { color: var(--green); font-size: 24px; }

.test-controls { display: flex; align-items: center; justify-content: space-between; margin: -5px 0 16px; }

.duration-picker { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.duration-button { padding: 7px 12px; border: 0; border-radius: 5px; background: transparent; color: var(--muted-dark); cursor: pointer; font-size: 10px; }
.duration-button.selected { background: var(--green-soft); color: var(--green-deep); box-shadow: 0 1px 3px rgba(30,50,40,.1); }
.random-note { color: var(--muted); font-size: 10px; }
.random-note span { margin-right: 5px; color: var(--green); font-size: 14px; }

.test-card { overflow: hidden; }
.test-passage-wrap { min-height: 246px; padding: 28px 30px 24px; position: relative; cursor: text; }
.test-passage { min-height: 186px; }
.test-footer { min-height: 47px; }
.test-footer .subtle-button { font-size: 10px; }

.test-live-stats { display: flex; gap: 65px; padding: 24px 6px; }
.test-live-stats > div { min-width: 74px; }
.test-live-stats strong { display: block; margin-top: 6px; font-family: var(--mono); font-size: 21px; font-weight: 400; }
.test-live-stats small { font-weight: 400; }

.results-overlay { position: absolute; inset: 150px 0 0; z-index: 2; display: grid; place-items: center; padding: 22px; background: rgba(247,248,250,.8); backdrop-filter: blur(5px); }
.results-overlay[hidden] { display: none; }

.results-card { width: min(430px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: 0 14px 40px rgba(33,50,41,.12); text-align: center; animation: appear .25s ease both; }
.results-flower { display: inline-block; margin-bottom: 12px; color: var(--green); font-size: 22px; }
.results-card .eyebrow { justify-content: center; margin-bottom: 9px; }
.results-card h2 { margin: 0; font-size: 30px; font-weight: 500; letter-spacing: -1.1px; }
.results-subtitle { margin: 8px 0 21px; color: var(--muted-dark); font-size: 11px; }

.results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--line); text-align: left; }
.results-grid > div { padding: 12px 14px; background: var(--surface); }
.results-grid span { display: block; color: var(--muted); font-size: 9px; }
.results-grid strong { display: block; margin-top: 4px; font-family: var(--mono); font-size: 21px; font-weight: 400; }
.results-grid strong small { font-family: var(--sans); font-size: 10px; }

.result-actions { display: grid; justify-items: center; gap: 10px; margin-top: 20px; }

/* Lessons */
.lessons-heading { margin-bottom: 34px; }
.lesson-progress-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.lesson-progress-summary > span:last-child strong, .lesson-progress-summary > span:last-child small { display: block; }
.lesson-progress-summary strong { font-size: 10px; font-weight: 600; }
.lesson-progress-summary small { margin-top: 4px; color: var(--muted); font-size: 9px; }

.progress-ring { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--green) var(--progress, 0%), var(--color-border) 0deg); position: relative; font-family: var(--mono); font-size: 8px; }
.progress-ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--page); }
.progress-ring span { position: relative; z-index: 1; }

.lesson-layout { display: grid; grid-template-columns: 225px minmax(0, 1fr); gap: 24px; align-items: start; }
.lesson-sidebar { padding: 15px 0 0; }
.sidebar-heading { margin: 0 0 12px 4px; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 1.2px; }

.lesson-list { display: flex; flex-direction: column; gap: 5px; }
.lesson-option { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.lesson-option:hover { background: color-mix(in srgb, var(--color-secondary), transparent 92%); }
.lesson-option.selected { border-color: var(--line); background: var(--surface); box-shadow: 0 2px 8px rgba(36,54,45,.025); }
.lesson-index { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-soft); color: var(--muted); font-family: var(--mono); font-size: 10px; }
.lesson-option.selected .lesson-index { background: var(--green-soft); color: var(--green-deep); }
.lesson-option.completed .lesson-index { background: var(--color-success); color: #fff; }
.lesson-option strong, .lesson-option small { display: block; }
.lesson-option strong { font-size: 10px; font-weight: 600; }
.lesson-option small { margin-top: 3px; color: var(--muted); font-size: 9px; }

.path-note { display: flex; gap: 9px; margin: 23px 4px 30px; padding: 12px; border-radius: 8px; background: var(--surface-soft); }
.path-note > span { color: var(--green); }
.path-note p { margin: 0; color: var(--muted-dark); font-size: 9px; line-height: 1.6; }

.lesson-main { min-width: 0; }
.lesson-detail { position: relative; padding: 19px 22px 17px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.lesson-detail-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.lesson-level { color: var(--green); font-size: 8px; font-weight: 700; letter-spacing: 1px; }
.lesson-detail h2 { margin: 7px 0 0; font-size: 20px; font-weight: 500; letter-spacing: -.5px; }
.lesson-detail p { max-width: 570px; margin: 8px 0 0; color: var(--muted-dark); font-size: 10px; line-height: 1.7; }
.lesson-duration { padding: 6px 9px; border-radius: 20px; background: var(--surface-soft); color: var(--muted); font-size: 9px; white-space: nowrap; }
.lesson-practice-label { margin-top: 14px; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 1px; }
.lesson-practice-text { margin-top: 4px; color: var(--green-deep); font-family: var(--mono); font-size: 15px; letter-spacing: .4px; }
.lesson-progress { height: 3px; overflow: hidden; margin-top: 13px; border-radius: 3px; background: var(--color-border); }
.lesson-progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width .2s; }
.lesson-progress-caption { margin-top: 6px; color: var(--muted); font-size: 8px; }

.keyboard-card { margin-top: 13px; padding: 16px 18px 13px; }
.keyboard-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.keyboard-header .card-kicker { margin: 0; }
.keyboard-caption { margin: 5px 0 0; color: var(--muted); font-size: 9px; }
.keyboard-tools { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.layout-picker { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.layout-picker-label { padding: 0 5px; color: var(--muted); font-size: 7px; font-weight: 700; letter-spacing: .8px; }
.layout-button { padding: 5px 7px; border: 0; border-radius: 4px; background: transparent; color: var(--muted-dark); cursor: pointer; font-size: 8px; font-weight: 600; }
.layout-button.selected { background: var(--green-soft); color: var(--green-deep); box-shadow: 0 1px 3px rgba(30,50,40,.1); }
.layout-button:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.keyboard-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 7px; font-weight: 700; letter-spacing: .8px; }
.keyboard-status .live-dot { width: 5px; height: 5px; }

.keyboard { display: flex; flex-direction: column; gap: 5px; width: 100%; max-width: 496px; margin: 18px auto 0; }
.key-row { display: flex; justify-content: center; gap: 4px; }
.key { width: 30px; height: 27px; display: grid; place-items: center; border: 1px solid var(--color-border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-soft); color: var(--muted); font-family: var(--mono); font-size: 9px; text-transform: lowercase; transition: background .12s, color .12s, border-color .12s, transform .12s; }
.key.home-key { background: var(--surface-soft); }
.key.active-key { border-color: var(--green); border-bottom-color: var(--green-deep); background: var(--green-soft); color: var(--green-deep); transform: translateY(-2px); }
.key.space-key { width: 175px; }
.keyboard-legend { display: flex; justify-content: center; gap: 16px; margin-top: 13px; color: var(--muted); font-size: 8px; }
.keyboard-legend span { display: flex; align-items: center; gap: 5px; }
.keyboard-legend i { width: 8px; height: 8px; display: inline-block; border: 1px solid var(--color-border); border-radius: 2px; background: var(--surface-soft); }
.keyboard-legend .legend-active { border-color: var(--green); background: var(--green-soft); }
.keyboard-legend .legend-home { background: var(--surface-soft); }

.site-footer { min-height: 49px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.site-footer a { color: var(--green-deep); text-underline-offset: 3px; }
.footer-heart { margin-left: 4px; color: var(--green); }

/* Home layout (existing structure retained) */
.home-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); gap: 48px; align-items: start; }
.home-main { min-width: 0; }
.home-main .page-heading { margin-bottom: 30px; }
.home-main .home-intro { max-width: 620px; color: var(--muted-dark); font-size: 14px; line-height: 1.8; }
.home-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 32px; }
.home-actions .primary-button { text-decoration: none; }
.home-links { display: grid; gap: 12px; }
.home-link-card { padding: 17px 18px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); text-decoration: none; }
.home-link-card:hover { border-color: var(--line); }
.home-link-card strong, .home-link-card span { display: block; }
.home-link-card strong { font-size: 13px; font-weight: 600; }
.home-link-card span { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.home-layout .seo-overview { max-width: none; margin: 0; padding: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 12px; line-height: 1.75; }
.home-layout .seo-overview h2 { font-size: 20px; }
.home-layout .seo-overview h2:first-child { margin-bottom: 13px; }

.faq-section { max-width: 800px; margin: 52px auto 0; }
.faq-section > h2 { margin: 0 0 16px; color: var(--ink); font-size: 23px; font-weight: 500; letter-spacing: -.5px; }
.faq-list { border-top: 1px solid var(--line); }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-item summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 2px; color: var(--ink); cursor: pointer; font-size: 13px; font-weight: 600; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; flex: 0 0 auto; color: var(--green); font-family: var(--mono); font-size: 18px; font-weight: 400; }
.faq-item[open] summary::after { content: "−"; }
.faq-item summary:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 3px; }
.faq-answer { padding: 0 28px 15px 2px; color: var(--muted-dark); font-size: 12px; line-height: 1.7; }
.faq-answer p { margin: 0; }

@supports selector(details::details-content) {
  .faq-item::details-content { height: 0; overflow: clip; transition: height .2s ease, content-visibility .2s allow-discrete; }
  .faq-item[open]::details-content { height: auto; }
}
@supports (interpolate-size: allow-keywords) {
  .faq-item { interpolate-size: allow-keywords; }
}

.seo-overview, .seo-article { margin: 56px auto 0; color: var(--muted-dark); font-size: 14px; line-height: 1.8; }
.seo-overview h2, .seo-article h2 { margin: 32px 0 10px; color: var(--ink); font-size: 23px; font-weight: 500; letter-spacing: -.5px; line-height: 1.3; }
.seo-overview h2:first-child, .seo-article h2:first-child { margin-top: 0; }
.seo-overview p, .seo-article p { margin: 0 0 16px; }
.seo-overview a, .seo-article a:not(.primary-button) { color: var(--green-deep); text-underline-offset: 3px; }
.seo-article { margin-top: 0; }
.seo-article .page-heading { margin-bottom: 30px; }
.seo-article .page-description { max-width: 680px; font-size: 15px; line-height: 1.7; }
.seo-article h3 { margin: 22px 0 7px; color: var(--ink); font-size: 16px; font-weight: 600; }
.seo-article ul { padding-left: 22px; }
.seo-article li { margin: 8px 0; }
.seo-article .primary-button { margin: 12px 0 30px; color: white; text-decoration: none; }

html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition-property: color, background-color, border-color, box-shadow, fill, stroke;
  transition-duration: 240ms;
  transition-timing-function: ease-in-out;
}

/* ==========================================================================
   Home Hero — light theme (typing.com inspired, bright & welcoming)
   ========================================================================== */
.home-hero {
  min-height: 68vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--page);
  color: var(--ink);
  padding: 70px 20px 90px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--green-soft);
  border: 1px solid var(--color-border);
  color: var(--green-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.9px;
  margin-bottom: 26px;
}
.hero-title {
  font-size: clamp(44px, 9vw, 80px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -2.5px;
  margin: 0 0 18px;
  color: var(--ink);
}
.hero-title .serif-accent,
.hero-title strong { color: var(--green); }
.hero-sub {
  font-size: clamp(14px, 2.6vw, 18px);
  color: var(--muted-dark);
  max-width: 660px;
  margin: 0 auto 40px;
  line-height: 1.65;
}
.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 56px;
  flex-wrap: wrap;
}
.hero-typing {
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 24px 22px;
  box-shadow: 0 10px 30px -6px rgba(0,0,0,.06);
}
.typing-preview {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 17px;
  line-height: 1.7;
  letter-spacing: 0.2px;
  resize: none;
  outline: none;
  padding: 0;
  min-height: 92px;
}
.typing-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  color: var(--muted-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.stat-icon { margin-right: 7px; color: var(--green); font-size: 14px; }

/* Small screens */
@media (max-width: 520px) {
  .home-hero { padding: 50px 16px 70px; }
  .hero-title { font-size: 36px; }
  .hero-actions { flex-direction: column; align-items: center; }
  .btn-primary, .btn-secondary { width: 100%; max-width: 280px; justify-content: center; }
  .hero-typing { padding: 20px 16px 16px; }
}

/* ==========================================================================
   Dark mode overrides (complementary dark variant)
   ========================================================================== */
html.dark .passage { color: var(--muted-dark); }
html.dark .brand-mark span { background: var(--surface-soft); }
html.dark .source-icon, html.dark .lesson-index { background: var(--surface-soft); }
html.dark .tip-card, html.dark .path-note { background: var(--surface-soft); border-color: var(--line); }
html.dark .tip-copy, html.dark .path-note p { color: var(--muted-dark); }
html.dark .duration-picker { background: var(--surface-soft); }
html.dark .duration-button.selected, html.dark .layout-button.selected { background: var(--green-soft); color: var(--green-deep); }
html.dark .layout-picker, html.dark .language-switch { background: var(--surface-soft); }
html.dark .language-button.selected { background: var(--green-soft); color: var(--green-deep); }
html.dark .focus-prompt { box-shadow: 0 3px 12px rgba(0,0,0,.35); }
html.dark .typing-card, html.dark .test-card, html.dark .aside-card, html.dark .keyboard-card, html.dark .lesson-detail, html.dark .results-card { box-shadow: none; }
html.dark .key { border-color: var(--line); border-bottom-color: var(--line); background: var(--surface-soft); color: var(--muted-dark); }
html.dark .key.home-key { background: var(--surface-soft); }
html.dark .key.active-key { border-color: var(--green); background: var(--green-soft); color: var(--green-deep); }
html.dark .test-live-stats strong { color: var(--ink); }
html.dark .results-overlay { background: rgba(15,23,42,.82); }
html.dark .progress-ring::before { background: var(--page); }
html.dark .ad-slot { border-color: var(--line); }

@media (max-width: 900px) {
  .app-shell { width: min(100% - 44px, 740px); }
  .home-layout { grid-template-columns: minmax(0, 1.35fr) minmax(220px, .75fr); gap: 24px; }
  .practice-layout { grid-template-columns: minmax(0, 1fr) 210px; gap: 15px; }
  .practice-stats { gap: 22px; }
  .stat-note { font-size: 9px; }
  .lesson-layout { grid-template-columns: 190px minmax(0,1fr); gap: 16px; }
  .key { width: 25px; height: 25px; }
  .keyboard { gap: 4px; }
  .key-row { gap: 3px; }
}
@media (max-width: 680px) {
  .app-shell { width: calc(100% - 34px); }
  .topbar { height: 68px; }
  .brand { font-size: 17px; }
  .main-nav { gap: 17px; }
  .nav-link { font-size: 11px; }
  .streak-pill { display: none; }
  .topbar-actions { gap: 0; }
  main { padding: 39px 0 43px; }
  .page-heading { margin-bottom: 28px; }
  .page-description { max-width: 330px; font-size: 12px; }
  .mode-label { font-size: 9px; padding: 8px 10px; }
  .home-layout { grid-template-columns: 1fr; gap: 30px; }
  .home-layout .seo-overview { order: 2; }
  .practice-layout { grid-template-columns: 1fr; }
  .practice-aside { display: grid; grid-template-columns: 1fr 1fr; }
  .aside-lesson-link { grid-column: 1 / -1; }
  .passage-wrap { min-height: 226px; padding: 22px 20px; }
  .passage { font-size: 14px; line-height: 2.05; }
  .practice-stats { gap: 24px; min-height: 83px; }
  .stat-note { display: none; }
  .test-passage-wrap { padding: 23px 20px; min-height: 232px; }
  .test-live-stats { justify-content: space-between; gap: 10px; }
  .test-live-stats > div { min-width: 0; }
  .results-overlay { inset: 115px 0 0; }
  .lesson-layout { grid-template-columns: 1fr; gap: 16px; }
  .lesson-sidebar { padding: 0; }
  .lesson-list { flex-direction: row; overflow-x: auto; padding: 0 0 5px; }
  .lesson-option { min-width: 142px; width: auto; }
  .path-note { display: none; }
  .lessons-heading { align-items: center; }
  .lesson-progress-summary { gap: 7px; }
  .lesson-progress-summary > span:last-child { display: none; }
  .keyboard-card { padding: 14px 10px; }
  .key { width: min(5.5vw, 28px); height: 25px; font-size: 8px; }
  .key-row { gap: 2px; }
  .keyboard { margin-top: 16px; }
  .keyboard-status { font-size: 6px; }
  .lesson-detail { padding: 16px; }
  .seo-overview, .seo-article { margin-top: 38px; font-size: 13px; }
  .home-layout .seo-overview, .seo-article { margin-top: 0; }
  .faq-section { margin-top: 38px; }
  .seo-overview h2, .seo-article h2, .faq-section > h2 { font-size: 20px; }
}
@media (max-width: 520px) {
  .topbar { height: auto; min-height: 75px; padding-top: 7px; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 36px 31px; align-content: start; }
  .brand { grid-column: 1; grid-row: 1; align-self: center; }
  .main-nav { grid-column: 1 / -1; grid-row: 2; justify-self: center; height: 31px; justify-content: center; }
  .topbar-actions { grid-column: 2; grid-row: 1; align-self: center; }
}
@media (max-width: 430px) {
  .app-shell { width: calc(100% - 28px); }
  .main-nav { gap: 11px; }
  .nav-link { font-size: 10px; }
  .topbar { height: auto; min-height: 75px; padding-top: 7px; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 36px 31px; align-content: start; }
  .brand { grid-column: 1; grid-row: 1; align-self: center; gap: 7px; font-size: 16px; }
  .main-nav { grid-column: 1 / -1; grid-row: 2; justify-self: center; height: 31px; justify-content: center; gap: 26px; }
  .topbar-actions { grid-column: 2; grid-row: 1; align-self: center; gap: 6px; }
  .language-switch { padding: 2px; }
  .language-button { min-width: 22px; padding: 4px; }
  .brand-mark { width: 20px; height: 20px; }
  .icon-button { width: 30px; height: 30px; }
  .page-heading { align-items: flex-start; gap: 10px; }
  .mode-label { margin-top: 7px; white-space: nowrap; }
  .practice-stats { justify-content: space-between; gap: 8px; }
  .stat-block { min-width: 64px; }
  .stat-value { font-size: 20px; }
  .practice-aside { grid-template-columns: 1fr; }
  .aside-lesson-link { grid-column: auto; }
  .tip-card { min-height: 145px; }
  .test-controls { align-items: flex-start; }
  .random-note { margin-top: 9px; font-size: 9px; }
  .test-live-stats { gap: 7px; }
  .test-live-stats strong { font-size: 17px; }
  .test-live-stats .stat-label { font-size: 7px; }
  .lesson-option { min-width: 128px; padding: 9px 7px; gap: 7px; }
  .lesson-option strong { font-size: 9px; }
  .lesson-index { width: 25px; height: 25px; flex-basis: 25px; }
  .key { width: 5.3vw; height: 22px; }
  .key.space-key { width: 32vw; }
  .keyboard-card { padding-inline: 8px; }
  .site-footer { font-size: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-width: 680px) { .lesson-layout { grid-template-columns: minmax(0, 1fr); } }

.ad-slot { overflow: hidden; border: 1px dashed var(--color-border); border-radius: 9px; background: var(--surface-soft); }
.ad-slot-sidebar { min-height: 180px; }
.ad-slot-footer { width: min(100%, 728px); min-height: 100px; margin: 20px auto 30px; }
.ad-placeholder { min-height: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; padding: 18px; text-align: center; }
.ad-placeholder[hidden] { display: none; }
.ad-label { color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 1px; }
.ad-placeholder p { max-width: 280px; margin: 0; color: var(--muted-dark); font-size: 10px; line-height: 1.5; }
.ad-slot ins.adsbygoogle { display: block; min-height: 100px; }
.ad-slot-sidebar ins.adsbygoogle { min-height: 180px; }
