:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #21332f;
  background: #f5f1e8;
  font-synthesis: none;
  --ink: #21332f;
  --muted: #60706b;
  --paper: #fffdf8;
  --line: #d9ded7;
  --green: #146c5a;
  --green-dark: #0d5244;
  --teal-soft: #dff2eb;
  --amber: #d58a22;
  --red: #a94336;
  --score-g-tint: #f3e8ff;
  --score-g-border: #7e22ce;
  --score-g-chip: #6d28d9;
  --score-g-foreground: #4c1d95;
  --score-so-tint: #dbeafe;
  --score-so-border: #2563eb;
  --score-so-chip: #1d4ed8;
  --score-so-foreground: #1e3a8a;
  --score-o-tint: #fee2e2;
  --score-o-border: #dc2626;
  --score-o-chip: #b91c1c;
  --score-o-foreground: #7f1d1d;
  --score-sc-tint: #d1fae5;
  --score-sc-border: #059669;
  --score-sc-chip: #047857;
  --score-sc-foreground: #064e3b;
  --score-r-tint: #ffedd5;
  --score-r-border: #c2410c;
  --score-r-chip: #9a3412;
  --score-r-foreground: #7c2d12;
  --score-dk-tint: #e2e8f0;
  --score-dk-border: #64748b;
  --score-dk-chip: #475569;
  --score-dk-foreground: #1e293b;
  --score-s-tint: #fae8ff;
  --score-s-border: #c026d3;
  --score-s-chip: #a21caf;
  --score-s-foreground: #701a75;
  --score-re-tint: #cffafe;
  --score-re-border: #0891b2;
  --score-re-chip: #0e7490;
  --score-re-foreground: #164e63;
  --addition-tint: #fef3c7;
  --addition-border: #b45309;
  --addition-chip: #a16207;
  --addition-foreground: #713f12;
  --shadow: 0 18px 50px rgb(49 61 53 / 14%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 5%, rgb(255 255 255 / 82%) 0 12%, transparent 35%),
    #f5f1e8;
}

button, input, textarea { font: inherit; }

button { touch-action: manipulation; }

.site-header {
  min-height: 72px;
  padding: 14px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgb(33 51 47 / 10%);
  background: rgb(255 253 248 / 76%);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: var(--green);
  font-family: Georgia, serif;
  font-size: 22px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.identity[hidden] { display: none; }

.identity-name {
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.identity-age {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--teal-soft);
  font-size: 13px;
  font-weight: 750;
}

.page-shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(28px, 6vw, 72px) 0;
}

.notice {
  max-width: 680px;
  margin: 36px auto;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

.notice-error {
  color: #7b2e26;
  border-color: #e4b9b2;
  background: #fff3f0;
}

.assessment, .review { max-width: 940px; margin: 0 auto; }

.step-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px 28px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(32px, 5vw, 48px); line-height: 1.05; letter-spacing: -0.03em; }

.hint { max-width: 760px; margin: 12px 0 0; color: var(--muted); line-height: 1.55; }

.timer-panel {
  min-width: 250px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border-radius: 14px;
  color: white;
  background: var(--green-dark);
  box-shadow: 0 8px 22px rgb(13 82 68 / 18%);
}

.timer-label {
  display: block;
  margin-bottom: 2px;
  color: #dff2eb;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#elapsed-seconds {
  display: block;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.timer-toggle {
  min-height: 40px;
  padding: 8px 12px;
  color: var(--green-dark);
  border-color: white;
  background: white;
  font-size: 14px;
}

.timer-toggle:hover { background: var(--teal-soft); }

.passage-card {
  min-height: 250px;
  padding: clamp(24px, 5vw, 54px);
  border: 1px solid rgb(33 51 47 / 12%);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.sentence {
  --sentence-row-gap: 25px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.35;
}

.comprehension {
  min-width: 0;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.comprehension h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
}

.question-text {
  margin: 0 0 12px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.45;
}

.expected-answer {
  margin: 0 0 22px;
  overflow-wrap: anywhere;
  color: var(--muted);
  line-height: 1.5;
}

.expected-answer-label {
  display: block;
  margin-bottom: 2px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.response-label {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 800;
}

#student-response {
  display: block;
  width: 100%;
  min-height: 110px;
  padding: 11px 12px;
  resize: vertical;
  border: 1px solid #afbbb5;
  border-radius: 10px;
  color: var(--ink);
  background: white;
  line-height: 1.5;
}

#student-response:focus {
  outline: 3px solid rgb(20 108 90 / 18%);
  border-color: var(--green);
}

.correctness-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px 18px;
  margin-top: 18px;
}

.correctness {
  min-width: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  border: 0;
}

.correctness legend {
  width: 100%;
  margin-bottom: 7px;
  padding: 0;
  font-size: 14px;
  font-weight: 800;
}

.correctness label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.correctness input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.word {
  position: relative;
  min-height: 52px;
  padding: 4px 0 6px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 7px 7px 3px 3px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.word-unit {
  display: inline-flex;
  min-width: 0;
  max-width: calc(100% - 20px);
  flex-direction: column;
  align-items: flex-start;
  margin-block: calc(var(--sentence-row-gap) / 2);
}

.word-row {
  display: inline-flex;
  align-items: flex-start;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.word-inert {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  pointer-events: none;
}

.inert-group {
  min-height: 52px;
  margin-block: calc(var(--sentence-row-gap) / 2);
  display: inline-flex;
  align-items: center;
  pointer-events: none;
}

.word-unit + .inert-group,
.inert-group + .inert-group {
  margin-inline-start: 0.25em;
}

.word:hover { background: #eef4ef; border-bottom-color: #91afa4; }
.word:focus-visible { outline: 3px solid var(--green-dark); outline-offset: 3px; background: #eef4ef; border-bottom-color: #91afa4; }

.word[data-score="G"], .word-menu > button[data-score="G"] {
  --score-tint: var(--score-g-tint);
  --score-border: var(--score-g-border);
  --score-chip: var(--score-g-chip);
  --score-foreground: var(--score-g-foreground);
}

.word[data-score="SO"], .word-menu > button[data-score="SO"] {
  --score-tint: var(--score-so-tint);
  --score-border: var(--score-so-border);
  --score-chip: var(--score-so-chip);
  --score-foreground: var(--score-so-foreground);
}

.word[data-score="O"], .word-menu > button[data-score="O"] {
  --score-tint: var(--score-o-tint);
  --score-border: var(--score-o-border);
  --score-chip: var(--score-o-chip);
  --score-foreground: var(--score-o-foreground);
}

.word[data-score="SC"], .word-menu > button[data-score="SC"] {
  --score-tint: var(--score-sc-tint);
  --score-border: var(--score-sc-border);
  --score-chip: var(--score-sc-chip);
  --score-foreground: var(--score-sc-foreground);
}

.word[data-score="R"], .word-menu > button[data-score="R"] {
  --score-tint: var(--score-r-tint);
  --score-border: var(--score-r-border);
  --score-chip: var(--score-r-chip);
  --score-foreground: var(--score-r-foreground);
}

.word[data-score="DK"], .word-menu > button[data-score="DK"] {
  --score-tint: var(--score-dk-tint);
  --score-border: var(--score-dk-border);
  --score-chip: var(--score-dk-chip);
  --score-foreground: var(--score-dk-foreground);
}

.word[data-score="S"], .word-menu > button[data-score="S"] {
  --score-tint: var(--score-s-tint);
  --score-border: var(--score-s-border);
  --score-chip: var(--score-s-chip);
  --score-foreground: var(--score-s-foreground);
}

.word[data-score="RE"], .word-menu > button[data-score="RE"] {
  --score-tint: var(--score-re-tint);
  --score-border: var(--score-re-border);
  --score-chip: var(--score-re-chip);
  --score-foreground: var(--score-re-foreground);
}

.word[data-score] {
  color: var(--score-foreground);
  background: var(--score-tint);
  border-bottom-color: var(--score-border);
}

.score-chip {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 25px;
  height: 23px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: var(--green);
  font: 800 11px/1 ui-sans-serif, system-ui, sans-serif;
}

.word[data-score] .score-chip { background: var(--score-chip); }

.replacement-word {
  width: 100%;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--score-s-foreground);
  text-align: center;
  white-space: normal;
  font: 700 12px/1.2 ui-sans-serif, system-ui, sans-serif;
}

.line-break {
  flex-basis: 100%;
  width: 0;
  height: 0;
}

.gap {
  align-self: flex-start;
  width: 20px;
  min-height: 40px;
  margin: calc(var(--sentence-row-gap) / 2) -2px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #82908b;
  background: transparent;
  cursor: pointer;
  font: 700 18px/1 ui-sans-serif, system-ui, sans-serif;
}

.gap:hover { color: white; background: var(--amber); }
.gap:focus-visible { outline: 3px solid var(--green-dark); outline-offset: 3px; color: #4d2b00; background: #ffd58e; }

.gap.has-addition {
  width: auto;
  max-width: 180px;
  min-height: 36px;
  padding: 4px 9px;
  overflow: hidden;
  color: var(--addition-foreground);
  border: 1px solid var(--addition-border);
  background: var(--addition-tint);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.navigation {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.button {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 750;
}

.button:focus-visible { outline: 3px solid rgb(20 108 90 / 24%); outline-offset: 2px; }
.button:disabled,
.button[aria-disabled="true"] { cursor: default; opacity: 0.45; }
.button-primary { color: white; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: var(--ink); border-color: var(--line); background: var(--paper); }
.button-danger { color: var(--red); border-color: #e8c4be; background: #fff7f5; }
.button-small { min-height: 38px; padding: 8px 12px; font-size: 14px; }

.popover {
  position: fixed;
  z-index: 20;
  width: min(280px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 8px;
  border: 1px solid #cfd8d2;
  border-radius: 14px;
  background: white;
  box-shadow: 0 16px 44px rgb(32 48 43 / 24%);
}

.word-menu > button {
  width: 100%;
  min-height: 39px;
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.word-menu > button:hover { background: #edf5f1; }
.word-menu > button:focus-visible { outline: 2px solid var(--green-dark); outline-offset: -2px; background: #edf5f1; }
.word-menu > button[aria-checked="true"] { color: var(--green-dark); background: var(--teal-soft); }
.word-menu > button b { font-size: 12px; }

.word-menu > button[data-score]:not([data-score=""]) b {
  min-width: 28px;
  padding: 5px;
  border-radius: 999px;
  color: white;
  background: var(--score-chip);
  text-align: center;
}

.word-menu > button[data-score]:not([data-score=""]):hover,
.word-menu > button[data-score]:not([data-score=""]):focus-visible,
.word-menu > button[data-score]:not([data-score=""])[aria-checked="true"] {
  color: var(--score-foreground);
  background: var(--score-tint);
}

.popover-form { padding: 9px; border-top: 1px solid #e5e9e6; }
.substitute-popover .popover-form, .addition-popover .popover-form { border-top: 0; }
.popover-form label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 800; }
.popover-form input { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid #afbbb5; border-radius: 8px; color: var(--ink); background: white; }
.popover-form input:focus { outline: 3px solid rgb(20 108 90 / 18%); border-color: var(--green); }
.field-error { margin: 7px 0; color: var(--red); font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.review > p:not(.eyebrow) { color: var(--muted); }
.review-texts { display: grid; gap: 12px; margin: 24px 0; }
.review-item { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.review-item h2 { margin: 0 0 5px; font-size: 18px; }
.review-item p { margin: 0; color: var(--muted); }
.review-item-body { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
.review-summary { flex: 1 1 520px; min-width: 0; }
.review-time-edit { flex: 0 0 auto; }
.review-time-form { display: flex; align-items: end; flex: 1 1 100%; flex-wrap: wrap; gap: 8px; }
.review-time-form h3 { flex: 1 1 100%; margin: 0; font-size: 15px; }
.review-time-field { display: grid; flex: 1 1 210px; gap: 6px; min-width: 0; font-size: 13px; font-weight: 800; }
.review-time-field input { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid #afbbb5; border-radius: 8px; color: var(--ink); background: white; }
.review-time-field input:focus { outline: 3px solid rgb(20 108 90 / 18%); border-color: var(--green); }
.review-item .review-time-error { flex: 1 1 100%; margin: 0; color: var(--red); font-size: 13px; }
.review-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
#submission-status:not(:empty) { max-width: 940px; margin: 18px auto 0; padding: 14px 16px; border-radius: 12px; color: var(--green-dark); background: var(--teal-soft); font-weight: 700; }
#submission-status [role="alert"] { color: #7b2e26; }

.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; }

[hidden] { display: none !important; }

@media (max-width: 620px) {
  .site-header { min-height: 62px; padding: 10px 14px; }
  .brand > span:last-child { display: none; }
  .identity-name { max-width: 56vw; }
  .page-shell { width: min(100% - 20px, 1080px); padding: 22px 0; }
  .step-heading { grid-template-columns: minmax(0, 1fr); }
  .hint { font-size: 14px; }
  .timer-panel { width: 100%; min-width: 0; }
  .passage-card { min-height: 190px; padding: 24px 14px; border-radius: 18px; }
  .sentence { --sentence-row-gap: 18px; font-size: 25px; }
  .comprehension { margin-top: 24px; padding-top: 22px; }
  .correctness-actions { align-items: stretch; }
  .navigation { margin-top: 16px; }
  .review-actions { justify-content: stretch; }
  .review-actions .button { flex: 1 1 100%; }
  .review-time-form .button { flex: 1 1 auto; }
  .button { padding-inline: 12px; }
}
