:root {
  color-scheme: light;
  --bg: #f7f5ff;
  --surface: #ffffff;
  --text: #302447;
  --muted: #695d78;
  --line: #e5ddf0;
  --green: #7550df;
  --green-soft: #eee6ff;
  --target: #70617e;
  --correct: #187861;
  --error: #bd365d;
  --error-bg: #ffe1ea;
  --ring: #a582ed;
  --header: #f0e9fc;
  --field: #fcfaff;
}
.dark {
  color-scheme: dark;
  --bg: #211a32;
  --surface: #2d2340;
  --text: #f1eaff;
  --muted: #c0b2d2;
  --line: #514064;
  --green: #c5a7ff;
  --green-soft: #42305e;
  --target: #c4b5d6;
  --correct: #84dfc7;
  --error: #ffb2c3;
  --error-bg: #663548;
  --ring: #c5a7ff;
  --header: #30223f;
  --field: #261d37;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 "Segoe UI", Arial, sans-serif;
}
button, input, textarea, select { font: inherit; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(30px, 3vw, 40px); line-height: 1.2; letter-spacing: -1.1px; font-weight: 700; }
h1 > span { color: #dc8c43; }
h2 { font-size: 25px; line-height: 1.3; font-weight: 650; letter-spacing: -.5px; }
h3 { font-size: 20px; line-height: 1.4; font-weight: 650; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}
svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.app-shell { min-height: 100vh; padding-bottom: 32px; }
main { width: 100%; max-width: 1360px; margin: 0 auto; padding: 0 32px; }
.view { max-width: 1280px; margin: 0 auto; }

.site-header {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) 250px auto;
  grid-template-areas: "brand navigation goal tools";
  align-items: center;
  gap: 26px;
  padding: 22px 32px;
  background: var(--header);
  border-bottom: 1px solid var(--line);
}
.brand { grid-area: brand; display: flex; align-items: center; gap: 15px; min-width: 0; font-size: 24px; font-weight: 750; letter-spacing: -.65px; }
.brand-copy { min-width: 0; }
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 54px;
  border-radius: 15px;
  background: #7550df;
  color: #fff;
  font: 44px/1 Georgia, serif;
  letter-spacing: -3px;
  padding-right: 4px;
  box-shadow: 4px 4px 0 #ffd365;
  flex-shrink: 0;
}
.brand-mark span { color: #ffd365; }
.brand small { display: block; max-width: 220px; margin-top: 2px; font-size: 13px; line-height: 1.4; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.site-header nav { grid-area: navigation; display: flex; justify-content: center; align-items: center; gap: 8px; min-width: 0; }
.nav-item { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 16px; min-height: 56px; border-radius: 12px; font-size: 16px; font-weight: 600; white-space: nowrap; color: var(--muted); }
.nav-item:hover { color: var(--green); background: var(--green-soft); }
.nav-item.active { color: #6540c4; background: #e4d8fc; }
.dark .nav-item.active { color: #e0ceff; background: #50376e; }
.nav-item[data-view="aprender"] svg { color: #d16c52; }
.nav-item[data-view="progreso"] svg { color: #248e7d; }
.dark .nav-item[data-view="aprender"] svg { color: #edac93; }
.dark .nav-item[data-view="progreso"] svg { color: #7fd3c3; }
.nav-dot { display: none; }
.daily-goal { grid-area: goal; min-width: 0; }
.goal-button { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 70px; border: 1px solid #daccf0; background: #e8dcfa; color: #62428c; padding: 12px 14px; border-radius: 12px; }
.goal-button:hover { background: #e0d1f6; }
.goal-heading { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.goal-heading svg { width: 16px; height: 16px; }
#goal-time { font-size: 14px; font-weight: 600; white-space: nowrap; }
.goal-track { grid-column: 1/-1; display: block; height: 5px; border-radius: 10px; background: #d0b9ee; overflow: hidden; }
#goal-bar { display: block; height: 100%; background: #8c5bd5; transition: width .2s; }
.dark .goal-button { background: #43305c; border-color: #594073; color: #e1ccff; }
.dark .goal-button:hover { background: #4d376b; }
.dark .goal-track { background: #654982; }
.dark #goal-bar { background: #bc95f7; }
.top-actions { grid-area: tools; display: flex; justify-content: flex-end; align-items: center; gap: 12px; flex-wrap: wrap; }
.icon-button { width: 48px; height: 48px; padding: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 11px; display: grid; place-items: center; }
.icon-button:hover { background: var(--green-soft); }
.connection-status { max-width: 1280px; margin: 18px auto 0; font-size: 14px; color: var(--muted); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px; padding: 11px 18px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 16px; font-weight: 600; text-align: center; }
.button:hover { background: var(--green-soft); border-color: #bda4e7; }
.button.primary { background: #7550df; color: #fff; border-color: #7550df; box-shadow: 0 4px 12px #7550df20; }
.button.primary:hover { background: #6640cf; border-color: #6640cf; }
.dark .button.primary { background: #966ce9; border-color: #966ce9; }
.dark .button.primary:hover { background: #a47af3; }
.button.small { min-height: 44px; padding: 9px 13px; font-size: 14px; }
.text-button { background: transparent; border: 0; color: var(--green); padding: 6px 0; font-size: 15px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.text-button:hover { text-decoration: underline; }
select, input[type="number"] { min-height: 46px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: var(--surface); color: var(--text); font-size: 16px; max-width: 100%; }
select { padding-right: 30px; }
input[type="number"] { width: 90px; }
input[type="checkbox"], input[type="radio"] { accent-color: #7550df; width: 18px; height: 18px; flex-shrink: 0; }
.dark input[type="checkbox"], .dark input[type="radio"] { accent-color: #bc95f7; }

#view-test > .practice-card { margin-top: 28px; }
.practice-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 8px 28px #5f3fa506; }
.config-row { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; padding: 22px 26px; border-bottom: 1px solid var(--line); }
.segmented { display: flex; align-items: stretch; gap: 4px; padding: 5px; background: var(--green-soft); border-radius: 11px; }
.segmented button { border: 0; border-radius: 8px; background: transparent; color: var(--muted); min-height: 46px; padding: 10px 16px; font-size: 15px; font-weight: 600; white-space: nowrap; }
.segmented button.selected { background: #7550df; color: #fff; box-shadow: 0 3px 8px #7550df20; }
.dark .segmented button.selected { background: #966ce9; }
.practice-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-left: auto; }
.sound-controls { display: flex; flex-wrap: wrap; align-items: center; }
.sound-button, .sound-picker-button, .focus-button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 12px; gap: 8px; font-size: 15px; color: var(--text); border: 1px solid var(--line); background: var(--surface); border-radius: 9px; white-space: nowrap; }
.sound-button { border-radius: 9px 0 0 9px; }
.sound-picker-button { border-radius: 0 9px 9px 0; margin-left: -1px; }
.sound-button svg { width: 22px; height: 22px; }
.sound-picker-button > span { font-size: 20px; line-height: 1; }
.focus-button > span { font-size: 24px; line-height: 1; }
.sound-button:hover, .sound-picker-button:hover, .focus-button:hover { background: var(--green-soft); text-decoration: none; }
.options-row { padding: 20px 26px 0; }
.duration-options { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.duration-options button { min-height: 44px; min-width: 57px; border: 1px solid transparent; border-radius: 8px; padding: 9px 13px; font-size: 16px; background: var(--green-soft); color: var(--text); }
.duration-options button:hover { border-color: #b99ce7; }
.duration-options button.selected { background: #7550df; color: #fff; box-shadow: 0 3px 8px #7550df25; }
.dark .duration-options button.selected { background: #966ce9; }
#custom-time-button { background: #fff0d7; color: #85561b; padding-left: 16px; padding-right: 16px; }
.dark #custom-time-button { background: #4a3b28; color: #f4d493; }
.text-settings { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 18px 24px; padding: 22px 26px 24px; }
.text-settings label { display: flex; flex-direction: column; gap: 7px; font-size: 14px; font-weight: 500; color: var(--muted); }
.text-settings select { min-width: 190px; }
#text-topic { min-width: 225px; }
.text-settings .check-setting, .text-settings .keyboard-option { display: flex; flex-direction: row; align-items: center; gap: 9px; min-height: 46px; color: var(--text); cursor: pointer; }
.text-settings input { margin: 0; }
.typing-area { margin: 0 26px; padding: 19px 24px 0; border: 1px solid var(--line); border-radius: 13px; background: var(--field); overflow: hidden; }
.typing-area:focus-within { border-color: #a58ae0; box-shadow: 0 0 0 3px #a58ae514; }
.typing-topline { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 22px; color: var(--muted); font-size: 14px; }
#typing-state { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.ready-dot { width: 6px; height: 6px; border-radius: 50%; background: #966ad8; flex-shrink: 0; }
#typing-progress { margin-left: auto; font-size: 14px; }
#typing-progress:empty { display: none; }
#typing-clock { margin-left: auto; background: var(--green-soft); color: var(--green); padding: 5px 11px; border-radius: 8px; font-size: 20px; line-height: 1.4; font-weight: 700; font-variant-numeric: tabular-nums; }
#typing-progress:not(:empty) + #typing-clock { margin-left: 0; }
.typing-stage { position: relative; margin-bottom: 20px; }
.target-text { position: relative; height: 190px; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; scroll-behavior: smooth; user-select: none; font: 27px/1.75 Consolas, "Courier New", monospace; letter-spacing: .25px; color: var(--target); }
.typing-stage.is-waiting .target-text { filter: blur(3px); opacity: .42; pointer-events: none; }
.target-text span.correct { color: var(--correct); }
.target-text span.incorrect { color: var(--error); background: var(--error-bg); text-decoration: underline; text-underline-offset: 4px; border-radius: 2px; }
.target-text span.cursor { position: relative; }
.target-text span.cursor::before { content: ""; position: absolute; width: 2px; height: 1.15em; background: var(--green); left: -1px; top: 0; animation: blink 1.1s step-end infinite; }
.typing-entry { position: absolute; inset: 0; z-index: 1; }
.typing-entry .button { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); min-height: 62px; padding: 14px 38px; border-radius: 12px; font-size: 21px; box-shadow: 0 7px 24px #7550df35; }
.typing-entry > span { position: absolute; left: 50%; top: calc(50% + 46px); transform: translateX(-50%); width: max-content; max-width: calc(100% - 12px); padding: 4px 8px; border-radius: 7px; background: var(--surface); color: var(--muted); font-size: 14px; line-height: 1.5; text-align: center; }
.typing-input { display: block; width: 100%; height: 74px; min-height: 74px; resize: none; border: 0; border-top: 1px dashed var(--line); border-radius: 0; background: transparent; color: var(--text); caret-color: var(--green); margin-top: 18px; padding: 15px 0; font: 20px/1.6 Consolas, "Courier New", monospace; }
.typing-input:focus { outline: 0; }
.typing-input::placeholder { font: 16px/1.6 "Segoe UI", sans-serif; color: var(--muted); }
.test-progress { height: 4px; margin: 0 -24px; background: var(--line); }
#test-progress-fill { display: block; height: 100%; background: linear-gradient(90deg,#ad86ef,#7550df); transition: width .15s linear; }
.practice-footer { display: flex; justify-content: center; padding: 24px; }
.practice-actions { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.practice-actions .button { min-height: 48px; padding: 11px 20px; font-size: 16px; }
.restart-button { background: var(--green-soft); color: var(--green); border-color: #dccbf5; }
.restart-button > span { font-size: 23px; line-height: 1; }
.new-test-button { background: #e4f5ef; color: #286f5d; border-color: #bfe3d4; }
.new-test-button:hover { background: #d2ede1; border-color: #88c7ad; }
.dark .new-test-button { background: #2b4b43; border-color: #41695d; color: #a0dfc8; }
.dark .restart-button { border-color: #62467e; }

.custom-time-fields { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding: 20px 26px 0; }
.custom-time-fields label { display: grid; gap: 7px; font-size: 14px; color: var(--muted); }
.custom-time-fields .secondary-text, .custom-time-fields .form-error { flex-basis: 100%; }
.secondary-text, .chart-caption { color: var(--muted); font-size: 14px; line-height: 1.65; }
.form-error { color: var(--error); font-size: 14px; margin-top: 7px; }
.custom-text-panel { padding: 20px 26px; }
.custom-text-panel > label { display: block; margin-bottom: 9px; font-size: 15px; font-weight: 500; }
.custom-text-panel textarea { width: 100%; min-height: 120px; resize: vertical; border: 1px solid var(--line); border-radius: 9px; padding: 14px; background: var(--field); color: var(--text); font-size: 16px; line-height: 1.65; }
.inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.inline-actions small { color: var(--muted); font-size: 14px; }
.custom-text-panel .inline-actions { justify-content: space-between; margin-top: 10px; }
.lesson-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 26px; margin: 18px 0; background: var(--green-soft); color: var(--text); font-size: 15px; }

.keyboard-panel { max-width: 850px; margin: 24px auto 0; padding: 23px 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.keyboard-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 15px; }
.keyboard-header strong { font-size: 16px; font-weight: 600; }
#finger-hint { color: var(--muted); font-size: 14px; }
.keyboard { max-width: 720px; margin: 0 auto; }
.key-row { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.key { display: grid; place-items: center; width: 50px; height: 44px; min-width: 0; border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 7px; background: var(--bg); font: 16px/1 Consolas, monospace; color: var(--text); }
.key.home-key { background: #fff0c9; border-color: #e9d7a1; color: #855f20; text-decoration: underline; text-underline-offset: 5px; }
.key.next-key, .key.home-key.next-key { background: #8960dc; border-color: #744bc6; color: #fff; }
.key.space-key { width: 280px; }
.dark .key.home-key { background: #4a3c28; border-color: #6b5736; color: #f2d493; }
.dark .key.next-key { background: #966ce9; border-color: #8054ca; color: #fff; }

.result-panel { margin: 24px 0 0; padding: 30px; border: 1px solid var(--line); border-top: 4px solid #b799ee; border-radius: 16px; background: var(--surface); }
.result-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.result-heading p { color: var(--muted); font-size: 16px; margin-top: 9px; }
.record-badge { flex-shrink: 0; font-size: 14px; background: #fff0c8; color: #88611f; border-radius: 9px; padding: 10px 13px; }
.dark .record-badge { background: #4b3e2c; color: #f1ce7a; }
.result-context { margin: 12px 0 24px; }
.result-layout { display: grid; grid-template-columns: minmax(300px, .9fr) minmax(0, 1.4fr); gap: 28px; margin-bottom: 28px; align-items: stretch; }
.result-summary { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: var(--field); overflow: hidden; min-width: 0; }
.result-score { padding: 12px 20px; text-align: center; background: var(--green-soft); border-bottom: 1px solid var(--line); }
.score-label { color: var(--green); font-size: 11px; font-weight: 700; letter-spacing: 1.8px; }
.result-score > div { display: flex; justify-content: center; align-items: baseline; gap: 9px; color: var(--green); line-height: 1.15; margin: 3px 0; }
.result-score strong { font-size: 44px; font-weight: 700; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; }
.result-score > div > span { font-size: 20px; font-weight: 650; }
.result-score p { font-size: 12px; color: var(--muted); }
.result-score p > span { white-space: nowrap; }
.result-metrics { display: flex; flex-direction: column; flex: 1; padding: 4px 22px; margin: 0; }
.metric-row { display: flex; flex: 1; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 5px 16px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.metric-row:last-child { border-bottom: 0; }
.metric-row dt { font-size: 15px; line-height: 1.3; }
.metric-row dt small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.metric-row dd { margin: 0 0 0 auto; font-size: 23px; font-weight: 600; letter-spacing: -.7px; line-height: 1.3; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-row:last-child dd { font-size: 20px; }
.metric-positive { color: var(--correct); }
.metric-speed { color: var(--green); }
.metric-error { color: var(--error); }
.metric-divider { color: var(--muted); font-weight: 400; }
.result-charts { display: grid; gap: 20px; min-width: 0; }
.result-chart-section { border: 1px solid var(--line); border-radius: 14px; padding: 22px 20px 18px; min-width: 0; }
.result-chart-section h3 { font-size: 19px; margin-bottom: 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.chart-legend > span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { display: inline-block; width: 20px; height: 0; border-top: 3px solid var(--green); }
.chart-legend .legend-gross { border-color: #a46d20; border-top-style: dashed; }
.dark .chart-legend .legend-gross { border-color: #e9bc73; }
.progress-chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.progress-chart-svg text { fill: var(--muted); stroke: none; font: 14px "Segoe UI", Arial, sans-serif; }
.progress-chart-svg .chart-line { fill: none; stroke: var(--green); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.progress-chart-svg .chart-grid { stroke: var(--line); stroke-dasharray: 3 5; }
.progress-chart-svg .chart-dot { fill: var(--green); stroke: var(--surface); stroke-width: 2; }
.progress-chart-svg .chart-gross { stroke: #a46d20; stroke-dasharray: 6 5; }
.dark .progress-chart-svg .chart-gross { stroke: #e9bc73; }
.precision-chart-svg .chart-line { stroke: var(--correct); }
.precision-chart-svg .chart-dot { fill: var(--correct); }
.chart-caption { margin-top: 12px; }
.speed-dashboard { background: #edf6fa; border: 1px solid var(--line); border-radius: 14px; padding: 26px 26px 18px; }
.dark .speed-dashboard { background: #282239; }
.performance-heading { display: flex; align-items: start; justify-content: space-between; gap: 28px; padding-bottom: 24px; margin-bottom: 16px; border-bottom: 1px dashed var(--line); }
.performance-primary { display: flex; gap: clamp(26px, 5vw, 76px); }
.performance-primary > div { min-width: 0; }
.performance-primary > div > span { font-size: 15px; font-weight: 650; color: var(--muted); }
.performance-primary p { display: flex; align-items: baseline; gap: 9px; margin: 0; line-height: 1.15; }
.performance-primary strong { color: var(--green); font-size: clamp(46px, 5.8vw, 80px); font-weight: 700; letter-spacing: -3px; font-variant-numeric: tabular-nums; }
.performance-primary small { font-size: 22px; color: var(--muted); font-weight: 600; }
.performance-secondary { display: grid; grid-template-columns: repeat(3, minmax(90px, 1fr)); gap: 18px 20px; margin: 0; }
.performance-secondary > div { padding-left: 14px; border-left: 1px solid var(--line); min-width: 0; }
.performance-secondary dt { font-size: 15px; color: var(--muted); }
.performance-secondary dd { margin: 2px 0 0; font-size: 24px; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
.speed-chart-view { position: relative; min-width: 0; border-radius: 8px; }
.speed-chart-view:focus-visible { outline: 2px solid var(--ring); outline-offset: 4px; }
.speed-chart-svg { overflow: hidden; }
.speed-chart-svg text { font-size: 16px; }
.speed-chart-svg .chart-grid { stroke: #cdd8e1; stroke-dasharray: 2 6; }
.dark .speed-chart-svg .chart-grid { stroke: var(--line); }
.speed-chart-svg .speed-gradient-top { stop-color: var(--green); stop-opacity: .25; }
.speed-chart-svg .speed-gradient-bottom { stop-color: var(--green); stop-opacity: 0; }
.speed-chart-svg .speed-area { stroke: none; }
.speed-chart-svg .speed-net { fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.speed-chart-svg .speed-raw { fill: none; stroke: var(--green); stroke-width: 1.4; opacity: .25; }
.speed-chart-svg .speed-average { stroke: var(--muted); stroke-dasharray: 5 6; stroke-width: 1; opacity: .8; }
.speed-chart-svg .speed-average-label { font-size: 14px; }
.speed-chart-svg .speed-final { fill: var(--green); stroke: var(--surface); stroke-width: 2; }
.speed-chart-svg .speed-final-label { fill: var(--green); font-size: 15px; font-weight: 650; }
.speed-chart-svg .speed-error { fill: #c32e48; stroke: none; }
.speed-chart-svg .event-halo { opacity: .17; }
.speed-chart-svg .speed-correction { fill: var(--surface); stroke: #d66a00; stroke-width: 2; }
.dark .speed-chart-svg .speed-error { fill: #ff8fa5; }
.dark .speed-chart-svg .speed-correction { stroke: #ffc174; }
.speed-chart-svg .speed-extreme line { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.speed-chart-svg .speed-extreme rect { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.speed-chart-svg .speed-extreme text { font-size: 14px; }
.speed-chart-svg .speed-peak rect { fill: var(--green-soft); stroke: var(--ring); }
.speed-chart-svg .speed-peak text { fill: var(--green); }
.speed-chart-svg .speed-crosshair line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 4; }
.speed-chart-svg .speed-crosshair circle { fill: var(--surface); stroke: var(--green); stroke-width: 2; }
.speed-tooltip { position: absolute; top: 0; max-width: min(430px, 100%); padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: 0 4px 18px #24193618; font-size: 15px; line-height: 1.5; pointer-events: none; z-index: 1; }
.speed-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 5px; color: var(--muted); font-size: 16px; }
.speed-legend > span { display: inline-flex; align-items: center; gap: 8px; }
.speed-legend i { display: inline-block; width: 21px; border-top: 3px solid var(--green); }
.speed-legend .legend-raw { border-top-width: 2px; opacity: .3; }
.speed-legend .legend-error { width: 10px; height: 10px; border: 0; border-radius: 50%; background: #c32e48; box-shadow: 0 0 0 4px #c32e4820; }
.speed-legend .legend-correction { width: 10px; height: 10px; border: 2px solid #d66a00; border-radius: 50%; background: var(--surface); }
.speed-legend .legend-axis { margin-left: auto; font-size: 14px; }
.speed-chart-note { color: var(--muted); font-size: 14px; margin: 16px 0 0; line-height: 1.6; }
.result-all-details { margin: 18px 0 24px; }
.result-all-details > summary { color: var(--green); font-size: 17px; padding: 10px 0; }
.result-all-details .result-layout { margin: 12px 0 0; }
.history-result-dialog .speed-chart-note { font-size: 14px; margin: 16px 0 0; }
.result-panel > .inline-actions { justify-content: center; }
.metrics-explanation { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 26px; font-size: 14px; color: var(--muted); }
.metrics-explanation p { margin-top: 12px; max-width: 850px; }
summary { cursor: pointer; }

.page-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 22px; margin: 34px 0 28px; }
.page-heading p { font-size: 16px; color: var(--muted); margin-top: 12px; }
.eyebrow { font-size: 14px; font-weight: 650; letter-spacing: 1px; color: var(--green); margin-bottom: 10px; }
.learning-intro { display: flex; gap: 24px; align-items: center; background: var(--green-soft); border-radius: 14px; padding: 28px; margin-bottom: 24px; }
.learning-intro p { color: var(--muted); font-size: 16px; margin-top: 9px; }
.intro-number { font: 36px/1.3 Georgia, serif; color: var(--green); white-space: nowrap; }
.lesson-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; }
.lesson-card { display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--line); border-top: 4px solid #c5a6ef; border-radius: 14px; padding: 25px; background: var(--surface); }
.lesson-card:nth-child(3n+2) { border-top-color: #ecc568; }
.lesson-card:nth-child(3n) { border-top-color: #67bfb6; }
.lesson-card.completed { border-color: #7db6a3; }
.lesson-card-top { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.lesson-card-top > span:first-child { color: var(--green); font-weight: 650; }
.completed-label { color: var(--correct); }
.lesson-card h3 { margin-top: 18px; }
.lesson-card p { color: var(--muted); font-size: 16px; margin: 9px 0 18px; }
.lesson-keys { font: 18px/1.6 Consolas, monospace; color: var(--green); margin-bottom: 20px; overflow-wrap: anywhere; }
.lesson-card .button { margin-top: auto; }
.error-practice-card { display: flex; align-items: center; justify-content: space-between; gap: 22px; background: var(--green-soft); padding: 28px; border-radius: 14px; margin: 25px 0; }
.error-practice-card p { color: var(--muted); font-size: 16px; margin-top: 9px; }
.coach-session-guide { padding: 14px 26px; margin: 0 0 18px; background: var(--field); border-block: 1px solid var(--line); }
.coach-session-guide strong { color: var(--green); font-size: 18px; }
.coach-session-guide p { margin-top: 4px; font-size: 17px; color: var(--text); }
.coach-feedback { margin: 0 0 22px; padding: 18px 22px; border: 1px solid var(--line); border-left: 4px solid var(--correct); border-radius: 12px; background: var(--field); }
.coach-feedback h3 { font-size: 22px; color: var(--correct); }
.coach-feedback p { margin-top: 7px; color: var(--text); font-size: 17px; }

.stats-row { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; margin-bottom: 25px; }
.stat { padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); min-width: 0; }
.stat-label { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat strong { font-size: 38px; font-weight: 600; letter-spacing: -1px; color: var(--green); }
.stat > div { margin: 8px 0; }
.stat small { display: block; font-size: 14px; color: var(--muted); }
.chart-card, .history-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; margin-bottom: 25px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; }
.section-title p { font-size: 15px; color: var(--muted); margin-top: 8px; }
.chart-filter { display: grid; gap: 7px; font-size: 14px; color: var(--muted); }
.chart-empty { display: grid; place-items: center; min-height: 180px; text-align: center; font-size: 16px; color: var(--muted); }
.table-wrapper { position: relative; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; font-size: 15px; }
th { font-size: 14px; font-weight: 600; color: var(--muted); padding: 0 16px 15px; border-bottom: 1px solid var(--line); }
td { padding: 17px 16px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: 0; }
td:nth-child(4) { color: var(--green); font-weight: 650; }
td small, .history-context { font-size: 14px; }
.history-context { display: block; color: var(--muted); font-weight: 400; margin-top: 4px; }
.history-card > .button { margin-top: 20px; }
.empty-state { text-align: center; padding: 40px 15px; }
.empty-state > span { font-size: 40px; color: var(--green); }
.empty-state h3 { margin: 10px 0; }
.empty-state p { font-size: 16px; color: var(--muted); margin-bottom: 22px; }
.progress-bottom { display: flex; justify-content: space-between; align-items: center; gap: 22px; margin: 0 0 28px; color: var(--muted); font-size: 14px; }
.danger { color: var(--error); }
.destructive { background: var(--error); color: var(--surface); border-color: var(--error); }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: calc(100% - 32px); max-width: 530px; max-height: calc(100vh - 32px); overflow-y: auto; }
dialog::backdrop { background: #241936a6; backdrop-filter: blur(3px); }
dialog p { color: var(--muted); font-size: 16px; margin: 12px 0 22px; }
dialog label { display: grid; gap: 8px; font-size: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.coach-dialog { max-width: 1040px; font-size: 18px; }
.coach-dialog h2 { font-size: 28px; }
.coach-dialog .button { font-size: 17px; min-height: 48px; }
.coach-dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.coach-dialog-heading .eyebrow { font-size: 14px; margin-bottom: 7px; }
.coach-dialog-heading form { flex-shrink: 0; }
.coach-dialog > p { margin: 12px 0 18px; font-size: 18px; color: var(--text); }
.coach-difficulties { display: grid; gap: 8px; }
.coach-difficulty { display: flex; width: 100%; align-items: center; gap: 15px; padding: 11px 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--field); color: var(--text); text-align: left; }
.coach-difficulty[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); }
.coach-key { display: grid; place-items: center; min-width: 52px; min-height: 52px; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--green); font: 32px/1.2 Consolas, monospace; }
.coach-difficulty-copy { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.coach-difficulty-copy strong { font-size: 20px; }
.coach-difficulty-copy > span { font-size: 18px; color: var(--text); }
.coach-difficulty-copy small { font-size: 16px; color: var(--text); }
.coach-choice { color: var(--green); margin-left: auto; visibility: hidden; }
.coach-difficulty[aria-pressed="true"] .coach-choice { visibility: visible; }
.coach-preview { margin-top: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; }
.coach-preview-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.coach-preview-heading h3 { font-size: 21px; }
.coach-preview-heading > span { font-size: 16px; color: var(--green); white-space: nowrap; }
.coach-preview > strong { font-size: 18px; color: var(--green); }
.coach-preview p { font-size: 18px; color: var(--text); margin: 7px 0 12px; }
.coach-plan-text { padding: 11px 13px; border-radius: 8px; background: var(--green-soft); font: 24px/1.6 Consolas, monospace; overflow-wrap: anywhere; }
.coach-preview .coach-plan-length { margin: 10px 0 0; font-size: 16px; }
.coach-method { margin-top: 16px; color: var(--text); font-size: 17px; }
.coach-method p { font-size: 17px; color: var(--text); margin: 9px 0; }
.coach-dialog > .coach-legacy-note { padding: 11px 14px; margin-top: 12px; background: var(--green-soft); border-radius: 9px; font-size: 16px; }
.coach-dialog .dialog-actions { margin-top: 18px; }
.history-result-dialog { max-width: 1140px; padding: 28px; }
.history-result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.history-result-heading p { margin: 8px 0 0; }
.history-result-heading form { flex-shrink: 0; }
.history-result-dialog .result-layout { margin-bottom: 18px; }
.history-result-dialog .chart-caption { font-size: 14px; margin-bottom: 0; }
.history-result-dialog .history-result-note, .history-result-dialog .legacy-result-note { font-size: 14px; margin: 14px 0 0; }
.history-result-dialog .legacy-result-note { margin-bottom: 20px; padding: 12px 16px; background: var(--green-soft); border-radius: 9px; }
.sound-options { border: 0; margin: 0; padding: 0; }
.sound-option { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.sound-option label { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.sound-option input { margin: 0; }
.sound-option strong { display: block; font-size: 16px; font-weight: 600; }
.sound-option small { display: block; font-size: 14px; line-height: 1.5; color: var(--muted); margin-top: 5px; }
.sound-option .button { flex-shrink: 0; }
dialog .sound-preview-status { margin: 14px 0 0; min-height: 22px; font-size: 14px; color: var(--green); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); z-index: 10; border: 1px solid var(--line); background: var(--text); color: var(--surface); border-radius: 10px; padding: 13px 20px; font-size: 15px; box-shadow: 0 6px 25px #24193630; }

body.focus-mode .site-header { display: none; }
body.focus-mode main { max-width: 1280px; padding-top: 12px; }
@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 1300px) {
  .site-header { grid-template-columns: 1fr 250px auto; grid-template-areas: "brand goal tools" "navigation navigation navigation"; padding: 20px 26px; gap: 18px; }
  .site-header nav { justify-content: center; }
  .practice-tools { margin-left: 0; }
  .config-row { justify-content: space-between; }
}
@media (max-width: 1000px) {
  .config-row { justify-content: center; }
  .practice-tools { justify-content: center; }
  .result-heading { flex-wrap: wrap; }
  .error-practice-card { align-items: flex-start; flex-direction: column; }
  .stats-row { gap: 12px; }
  .stat { padding: 20px; }
  .result-layout { grid-template-columns: minmax(290px, 1fr) minmax(0, 1.2fr); gap: 20px; }
  .result-chart-section { padding-left: 14px; padding-right: 14px; }
  .performance-heading { flex-wrap: wrap; }
  .performance-secondary { width: 100%; }
}
@media (max-width: 700px) {
  main { padding: 0 18px; }
  .site-header { grid-template-columns: minmax(0,1fr) auto; grid-template-areas: "brand tools" "navigation navigation" "goal goal"; gap: 16px; padding: 18px; }
  .brand { font-size: 21px; gap: 12px; }
  .brand-mark { width: 44px; height: 46px; font-size: 38px; border-radius: 12px; }
  .brand small { font-size: 12px; }
  .top-actions { max-width: 112px; gap: 9px; }
  .site-header nav { width: 100%; gap: 5px; align-items: stretch; }
  .nav-item { flex: 1; white-space: normal; padding: 11px 7px; gap: 7px; min-height: 50px; font-size: 15px; text-align: center; }
  .nav-item svg { display: none; }
  .goal-button { min-height: 64px; padding: 11px 14px; }
  #view-test > .practice-card { margin-top: 20px; }
  .config-row { padding: 16px; gap: 15px; }
  .segmented { width: 100%; gap: 3px; padding: 4px; }
  .segmented button { flex: 1; font-size: 14px; padding: 10px 8px; }
  .practice-tools { gap: 10px; width: 100%; }
  .sound-button, .sound-picker-button, .focus-button { font-size: 14px; padding: 10px; }
  .sound-button svg { width: 20px; height: 20px; }
  .options-row { padding: 18px 16px 0; }
  .duration-options { gap: 7px; }
  .duration-options button { min-width: 53px; font-size: 15px; padding: 9px 11px; }
  .text-settings { padding: 20px 16px; gap: 14px 18px; }
  .text-settings > label:not(.check-setting):not(.keyboard-option) { flex: 1 1 190px; }
  .text-settings select, #text-topic { min-width: 0; width: 100%; }
  .typing-area { margin: 0 16px; padding: 16px 16px 0; }
  .typing-topline { gap: 10px; margin-bottom: 18px; }
  #typing-state { font-size: 14px; }
  #typing-clock { font-size: 19px; }
  #typing-progress { order: 3; flex-basis: 100%; margin-left: 0; font-size: 14px; }
  #typing-progress:not(:empty) + #typing-clock { margin-left: auto; }
  .target-text { font-size: 23px; line-height: 1.75; }
  .typing-entry .button { font-size: 20px; min-height: 60px; padding: 14px 30px; }
  .typing-input { font-size: 18px; }
  .test-progress { margin-left: -16px; margin-right: -16px; }
  .practice-footer { padding: 22px 16px; }
  .practice-actions { gap: 10px; }
  .practice-actions .button { font-size: 15px; padding: 10px 14px; }
  .custom-time-fields { padding: 18px 16px 0; }
  .custom-text-panel { padding: 18px 16px; }
  .lesson-banner { padding: 12px 16px; flex-wrap: wrap; }
  .keyboard-panel { padding: 18px 12px; margin-top: 20px; }
  .keyboard-header { padding: 0 5px; margin-bottom: 15px; }
  .key-row { gap: 4px; margin-top: 4px; }
  .key { width: 42px; height: 37px; font-size: 15px; border-radius: 5px; }
  .key.space-key { width: 210px; }
  .result-panel { padding: 22px 18px; }
  .result-heading { gap: 14px; }
  .result-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .result-metrics { padding-left: 17px; padding-right: 17px; }
  .metric-row { gap: 7px 12px; flex-wrap: wrap; }
  .metric-row dd { margin-left: auto; }
  .metric-row dt { font-size: 16px; }
  .metric-row dd { font-size: 24px; }
  .metric-row:last-child { flex-wrap: wrap; }
  .metric-row:last-child dd { font-size: 21px; }
  .result-chart-section h3 { font-size: 18px; }
  .speed-dashboard { padding: 20px 14px 16px; }
  .performance-heading { gap: 22px; padding-bottom: 20px; }
  .performance-primary { width: 100%; gap: 20px; justify-content: space-between; }
  .performance-primary > div > span { font-size: 14px; }
  .performance-primary strong { font-size: clamp(35px, 8.5vw, 56px); letter-spacing: -2px; }
  .performance-primary small { font-size: 16px; }
  .performance-primary p { gap: 5px; }
  .performance-secondary { gap: 14px 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .performance-secondary > div { padding-left: 8px; }
  .performance-secondary dt { font-size: 13px; }
  .performance-secondary dd { font-size: 19px; overflow-wrap: anywhere; }
  .speed-legend { font-size: 15px; gap: 12px 18px; }
  .speed-legend .legend-axis { margin-left: 0; flex-basis: 100%; }
  .speed-chart-note { font-size: 14px; }
  .page-heading { margin: 28px 0 24px; }
  .learning-intro { align-items: flex-start; padding: 22px; gap: 17px; }
  .intro-number { font-size: 28px; }
  .learning-intro h2 { font-size: 22px; }
  .lesson-grid { grid-template-columns: 1fr; gap: 18px; }
  .lesson-card { padding: 22px; }
  .error-practice-card { padding: 23px; }
  .stats-row { grid-template-columns: 1fr; gap: 12px; }
  .stat { padding: 20px; }
  .stat strong { font-size: 34px; }
  .chart-card, .history-card { padding: 22px 16px; }
  .section-title { flex-wrap: wrap; gap: 15px; }
  .progress-bottom { flex-direction: column; align-items: flex-start; gap: 12px; }
  dialog { padding: 24px 20px; }
  .history-result-dialog { padding: 22px 16px; }
  .history-result-heading h2 { font-size: 22px; }
  .coach-dialog-heading h2 { font-size: 24px; }
  .coach-difficulty { padding: 11px; gap: 11px; }
  .coach-key { min-width: 44px; min-height: 46px; font-size: 28px; }
  .coach-preview { padding: 14px; }
  .coach-preview-heading { flex-wrap: wrap; gap: 5px; }
  .coach-session-guide { padding: 13px 16px; }
  .sound-option { flex-wrap: wrap; gap: 12px; }
  .sound-option label { flex: 1 1 165px; }
  .sound-option .button { margin-left: 28px; }
}
@media (max-width: 380px) {
  main { padding-left: 14px; padding-right: 14px; }
  .site-header { padding-left: 14px; padding-right: 14px; }
  .brand { font-size: 19px; }
  .brand-mark { width: 40px; height: 43px; font-size: 35px; }
  .top-actions { max-width: 100px; }
  .config-row { padding-left: 12px; padding-right: 12px; }
  .segmented button { padding-left: 6px; padding-right: 6px; }
  .typing-area { margin-left: 12px; margin-right: 12px; padding-left: 12px; padding-right: 12px; }
  .test-progress { margin-left: -12px; margin-right: -12px; }
  .target-text { font-size: 22px; }
  .typing-entry > span { padding-left: 4px; padding-right: 4px; }
  .key-row { gap: 3px; }
  .key { height: 34px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
