* {
  box-sizing: border-box;
}

:root {
  --background: #f7f7f7;
  --surface: #ffffff;
  --text: #111111;
  --muted: #666666;
  --line: #dddddd;
  --soft-line: #e9e9e9;
  --accent: #111111;
  --error: #b3261e;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.5;
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.logo {
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link,
.menu-button,
.setting {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nav-link {
  padding: 8px 10px;
  font-size: 13px;
}

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

.menu-button {
  display: none;
  font-size: 18px;
  padding: 8px;
}

.container {
  width: min(980px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 90px;
}

.page {
  display: none;
}

.page.active-page {
  display: block;
}

.page-heading {
  margin-bottom: 28px;
}

.eyebrow,
.section-title {
  margin: 0 0 14px;
  font-size: 13px;
  letter-spacing: 0.04em;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 500;
  letter-spacing: -0.03em;
}

.muted {
  color: var(--muted);
  max-width: 680px;
}

.test-settings {
  display: flex;
  gap: 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.setting {
  padding: 0;
  font-size: 13px;
  color: var(--muted);
}

.setting:hover,
.setting.active {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.typing-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 28px;
  border-radius: 10px;
}

.typing-surface {
  height: 136px;
  min-height: 136px;
  padding: 4px 0 18px;
  font-size: 19px;
  line-height: 2.05;
  letter-spacing: 0.01em;
  outline: none;
  cursor: text;
  user-select: none;
  overflow: hidden;
  scroll-behavior: auto;
}

.typing-surface:focus {
  outline: none;
}

.typing-word {
  display: inline;
  color: #b7b7b7;
}

.typing-word.current {
  color: #b7b7b7;
}

.typing-char {
  color: #b7b7b7;
}

.typing-char.correct {
  color: #111;
}

.typing-char.incorrect {
  color: #c62828;
}

.typing-char.extra {
  color: #c62828;
}

.typing-char.current {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.typing-space {
  white-space: pre;
}

.typing-capture {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

.performance-grid div,
.result-grid div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.performance-grid span,
.result-grid span {
  font-size: 12px;
  color: var(--muted);
}

.performance-grid strong,
.result-grid strong {
  font-size: 16px;
  font-weight: 500;
}

.performance {
  margin-top: 48px;
  padding: 26px 0;
  border-top: 1px solid var(--line);
}

.performance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  margin-bottom: 18px;
}

.session-note {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.analysis-block {
  margin-top: 30px;
}

.subheading {
  margin-bottom: 12px;
}

.weak-keys {
  width: min(430px, 100%);
}

.weak-keys div {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 7px 0;
}

.weak-keys span {
  width: 13px;
  font-size: 13px;
}

.weak-keys i {
  height: 18px;
  background: #111;
  display: block;
  border-left: 2px solid #c98b2e;
}

.analysis-block p:not(.subheading) {
  margin: 6px 0;
}

.simple-list {
  margin-top: 30px;
  border-top: 1px solid var(--line);
}

.simple-list div {
  padding: 14px 0;
  border-bottom: 1px solid var(--soft-line);
}

@media (max-width: 700px) {
  .site-header {
    width: min(100% - 28px, 1180px);
    min-height: 64px;
  }

  .container {
    width: min(100% - 28px, 980px);
    padding-top: 36px;
  }

  .nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 14px;
    right: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 8px;
    flex-direction: column;
    align-items: stretch;
    z-index: 10;
  }

  .nav.open {
    display: flex;
  }

  .nav-link {
    text-align: left;
    padding: 11px 10px;
  }

  .menu-button {
    display: block;
  }

  .typing-panel {
    padding: 18px;
  }

  .typing-surface {
    height: 108px;
    min-height: 108px;
    font-size: 15px;
    line-height: 1.8;
  }

  .performance-grid {
    grid-template-columns: 1fr 1fr;
    gap: 22px 18px;
  }

  .performance {
    margin-top: 34px;
  }
}

@media (max-width: 430px) {
  .typing-surface.test-finished {
    opacity: 0.7;
  }
}


/* TEST AREA LAYOUT — authoritative */
.above-test {
  width: 100%;
  height: 34px;
  display: flex;
  justify-content: flex-end !important;
  align-items: center;
}

.timer-display {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 13px;
}

.timer-display span {
  color: var(--text);
}

.timer-display strong {
  font-size: 15px;
  font-weight: 500;
}

.below-test {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center !important;
  gap: 28px;
  padding: 0;
  background: #f2f2f2;
  border: 0;
}

.below-test-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-top: 24px;
  margin-left: 0 !important;
}

.restart-button {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  color: var(--text);
  padding: 0 !important;
  margin: 0;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  appearance: none;
  -webkit-appearance: none;
}

.restart-icon {
  display: inline-block;
  font-family: Arial, sans-serif;
  font-size: 17px;
  line-height: 1;
}

.test-status {
  color: var(--muted);
  font-size: 13px;
}

.restart-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.restart-button:focus-visible {
  outline: 1px solid var(--text) !important;
  outline-offset: 4px;
  border-radius: 3px;
}

.test-result {
  margin-top: 22px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 180px));
  gap: 40px;
}

.typing-surface.test-finished {
  opacity: 0.7;
}

@media (max-width: 700px) {
  .above-test {
    height: 32px;
  }

  .below-test {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .below-test-actions {
    margin-left: auto;
  }
}

@media (max-width: 430px) {
  .below-test-actions {
    margin-left: 0;
    width: 100%;
  }

  .result-preview {
    gap: 20px;
  }
}
