:root {
  color-scheme: light;
  color: #172536;
  background: #f5f7fa;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
  --blue: #175ba0;
  --subtle: #475c72;
  --line: #dce4ec;
  --columns: minmax(0, 31%) minmax(0, 1fr);
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--blue); }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #559bf0; outline-offset: 3px; }

main {
  max-width: 78rem;
  padding: 1.5rem clamp(0.875rem, 3vw, 2.25rem) 3rem;
  margin: auto;
}

.lesson-nav, .topics, .options, .answer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.lesson-nav { margin-bottom: 1.25rem; }

.nav-link, .topic-link, .option, .check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: #fff;
  color: var(--blue);
  font-weight: 650;
  text-decoration: none;
}

.nav-link:hover, .topic-link:hover, .option:hover { background: #edf5fd; }

.nav-link[aria-current="page"], .topic-link[aria-current="location"] {
  background: #e7f0fa;
  border-color: #b2cbea;
}

h1 { margin: 0 0 0.4rem; font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -0.03em; }
.lead { margin: 0 0 1.1rem; color: var(--subtle); }

.topics { margin-bottom: 1.15rem; }
.topic-link { font-size: 0.875rem; }
.topic-select { display: none; }

.exercise-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.35rem 1rem;
  margin-bottom: 0.75rem;
}

.exercise-summary h2 { margin: 0; font-size: clamp(1.3rem, 3vw, 1.7rem); }
.progress { margin: 0; color: var(--subtle); font-size: 0.9rem; }
.progress strong { color: var(--blue); }

.worksheet { border: 1px solid var(--line); border-radius: 1rem; background: #fff; }
.worksheet-columns, .question { display: grid; grid-template-columns: var(--columns); }

.worksheet-columns {
  background: #eaf2fa;
  border-radius: 1rem 1rem 0 0;
  color: #254969;
  font-size: 0.86rem;
  font-weight: 700;
}

.worksheet-columns > div, .rule, .practice { padding: 1rem 1.25rem; }
.question { border-top: 1px solid var(--line); }
.rule { background: #f9fbfd; border-inline-end: 1px solid var(--line); }
.question:last-child .rule { border-end-start-radius: 1rem; }
.rule h3 { margin: 0 0 0.55rem; color: var(--subtle); font-size: 0.85rem; }
.formula { margin: 0; color: #173f6e; font-size: 1.08rem; font-weight: 720; overflow-wrap: anywhere; }
.practice { min-width: 0; }
.prompt { margin: 0 0 0.65rem; font-size: 1.1rem; font-weight: 680; }
.root-word { padding: 0.15em 0.4em; border-radius: 0.35rem; background: #edf4fb; color: #214f7b; font-size: 0.86em; }
.translation {
  margin: 0 0 0.75rem;
  padding: 0.45rem 0.65rem;
  border-inline-start: 3px solid #aac5e3;
  background: #f2f7fc;
  color: var(--subtle);
}
.translation strong { color: #254969; }
.options { margin-bottom: 0.65rem; }
.option[aria-pressed="true"] { background: #e7f0fa; border-color: #91b4dc; }
.answer-controls input { flex: 1 1 12rem; min-width: 0; min-height: 44px; padding: 0.5rem 0.65rem; border: 1px solid #abbdd0; border-radius: 0.625rem; }
.check { border-color: #175ba0; background: #175ba0; color: #fff; }
.check:hover { background: #164d88; }

.feedback { min-height: 1.35em; margin: 0.5rem 0 0; font-size: 0.9rem; }
.feedback[data-status="correct"] { color: #14613d; }
.feedback[data-status="wrong"] { color: #963320; }
.solution { margin-top: 0.35rem; }
.solution summary { width: fit-content; min-height: 44px; padding-block: 0.6rem; color: var(--blue); font-weight: 650; cursor: pointer; }

.solution-body {
  margin-top: 0.25rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: #f7fafc;
}

.solution-body p { margin: 0.3rem 0; }
.solution-body p:first-child { margin-top: 0; }
.solution-body p:last-child { margin-bottom: 0; }
.solution-body .completed { color: #1a4572; font-weight: 650; }
.lesson-note { margin: 1rem 0 0; color: var(--subtle); font-size: 0.875rem; }
.noscript { padding: 1rem; }

@media (max-width: 720px) {
  .topics { display: none; }
  .topic-select {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    color: var(--subtle);
    font-weight: 650;
  }
  .topic-select select {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0.4rem 0.6rem;
    border: 1px solid #abbdd0;
    border-radius: 0.625rem;
    color: #172536;
    background: #fff;
  }
  .worksheet-columns { display: none; }
  .question { grid-template-columns: minmax(0, 1fr); }
  .question:first-child { border-top: 0; }
  .question:first-child .rule { border-radius: 1rem 1rem 0 0; }
  .question:last-child .rule { border-radius: 0; }
  .rule { border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .rule, .practice { padding: 0.85rem 0.9rem; }
}

@media (max-width: 400px) {
  .answer-controls input { flex-basis: 100%; }
}
