:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5c6b79;
  --line: #d9e1e8;
  --panel: #ffffff;
  --soft: #f4f7fa;
  --brand: #123c69;
  --brand-2: #0c7c59;
  --accent: #b8872b;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(23, 33, 43, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(18, 60, 105, 0.08), rgba(12, 124, 89, 0.03) 42%, transparent),
    #f8fafc;
}

button,
input,
textarea {
  font: inherit;
}

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

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 70px;
  height: 70px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.support,
footer,
.eyebrow,
label span,
.stats-grid small {
  color: var(--muted);
}

.support {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.support span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
}

main {
  flex: 1;
  display: grid;
  align-items: center;
  padding: 22px 0 40px;
}

.intro-panel,
.test-panel,
.result-panel,
.verify-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.intro-panel {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 34px;
  padding: clamp(24px, 4vw, 46px);
}

.intro-copy {
  align-self: center;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  color: #102131;
}

h1 {
  max-width: 11ch;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.02;
}

h2 {
  font-size: clamp(1.5rem, 2.2vw, 2.25rem);
}

.intro-copy p:last-child {
  max-width: 48ch;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.student-form {
  display: grid;
  gap: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
}

label span,
legend {
  font-size: 0.9rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input {
  min-height: 46px;
  padding: 0 13px;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(18, 60, 105, 0.12);
}

.duration-select {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.duration-select legend {
  padding: 0 8px;
}

.duration-select label {
  position: relative;
}

.duration-select input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.duration-select span {
  min-height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.duration-select input:checked + span {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn {
  color: #fff;
  background: var(--brand);
}

.secondary-btn {
  color: var(--brand);
  border: 1px solid rgba(18, 60, 105, 0.28);
  background: #fff;
}

.ghost-btn {
  color: var(--muted);
  background: transparent;
}

.primary-btn:hover {
  background: #0d3158;
}

.secondary-btn:hover,
.ghost-btn:hover {
  background: var(--soft);
}

.test-panel,
.result-panel,
.verify-panel {
  padding: clamp(20px, 3.5vw, 36px);
}

.test-header,
.result-heading,
.test-actions,
.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.timer {
  min-width: 128px;
  min-height: 64px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand-2);
  font-size: 2rem;
  font-weight: 800;
}

.stats-grid,
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.stats-grid div,
.result-grid div {
  min-height: 94px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.stats-grid span,
.result-grid strong {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--brand);
}

.sample-text {
  min-height: 188px;
  max-height: 260px;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 1.18rem;
  line-height: 1.8;
}

.sample-text span {
  border-radius: 3px;
}

.sample-text .correct {
  color: var(--brand-2);
  background: rgba(12, 124, 89, 0.08);
}

.sample-text .incorrect {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.12);
}

.sample-text .current {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.typing-area-label {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.typing-area {
  min-height: 150px;
  resize: vertical;
  padding: 16px;
  font-size: 1.05rem;
  line-height: 1.6;
}

.test-actions,
.result-actions {
  margin-top: 20px;
  justify-content: flex-start;
}

.result-badge {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 16px;
  color: #fff;
  background: var(--brand-2);
  font-weight: 800;
}

.hidden {
  display: none;
}

.verify-panel {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}

.verify-heading {
  max-width: 680px;
}

.verify-heading h1 {
  max-width: none;
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.verify-heading p:last-child,
.verify-note {
  color: var(--muted);
  line-height: 1.6;
}

.verify-status {
  width: fit-content;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  margin-top: 22px;
  border-radius: 999px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.verify-status.valid {
  background: var(--brand-2);
}

.verify-status.partial {
  background: var(--accent);
}

.verify-status.invalid {
  background: var(--danger);
}

.verify-note {
  margin-top: 10px;
}

.verify-home {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 18px;
  text-decoration: none;
}

footer {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
}

@media (max-width: 820px) {
  .topbar,
  footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }

  .intro-panel {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: 14ch;
  }

  .form-grid,
  .stats-grid,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
  }

  .support {
    display: none;
  }

  .brand img {
    width: 58px;
    height: 58px;
  }

  .duration-select,
  .form-grid,
  .stats-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .sample-text {
    font-size: 1rem;
  }

  .timer {
    width: 100%;
  }
}
