:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --ink: #20252b;
  --muted: #606b66;
  --line: #dfe4dc;
  --panel: #ffffff;
  --blue: #3768c9;
  --orange: #b95f2c;
  --green: #247a56;
  --violet: #6656b8;
  --red: #c94141;
  --yellow: #c79020;
  --ok: #22845d;
  --shadow: 0 12px 32px rgba(34, 42, 36, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
select,
input,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 22px 32px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

.topbar > div {
  width: min(1180px, 100%);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1.08;
}

h2 {
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1.12;
}

h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px 12px;
}

.layout {
  display: grid;
  grid-template-columns: 204px minmax(0, 1fr);
  min-height: calc(100vh - 99px);
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: grid;
  align-content: start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.42);
}

.subjectNav {
  display: grid;
  gap: 8px;
}

.subjectNav[hidden] {
  display: none;
}

.sideLabel {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin: 16px 12px 4px;
  text-transform: uppercase;
}

.nav {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 11px 13px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 42px;
}

.nav.active,
.nav:hover {
  background: #e8efe8;
}

.content {
  width: min(1180px, calc(100vw - 252px));
  padding: 28px;
  margin: 0 auto;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 22px;
}

.hero,
.sectionHead,
.startHero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.hero p {
  color: var(--muted);
  max-width: 760px;
  margin-top: 8px;
  line-height: 1.5;
}

.startHero {
  background: #eef4ed;
  color: var(--ink);
  min-height: 132px;
}

.startHero .label,
.startHero p {
  color: var(--muted);
}

.startHero h2 {
  max-width: 760px;
}

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

.choiceGrid.homeChoices {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.choiceCard {
  min-height: 210px;
  display: grid;
  align-content: center;
  gap: 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 28px;
  cursor: pointer;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.choiceCard::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--green);
}

.choiceCard:hover,
.choiceCard:focus-visible {
  transform: translateY(-2px);
  border-color: #aec5b4;
  outline: 0;
}

.choiceCard strong {
  font-size: 22px;
  line-height: 1.15;
}

.choiceCard span:last-child {
  color: var(--muted);
  line-height: 1.45;
  font-weight: 800;
}

.choiceKicker {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.mainChoice {
  grid-column: span 2;
  background: #e8f6ec;
  border-color: #b9dec5;
}

.homeChoices .choiceCard {
  min-height: 220px;
  align-content: center;
}

.homeChoices .choiceCard strong {
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1;
}

.grid {
  display: grid;
  gap: 18px;
}

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

.panel,
.task {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.statusGrid {
  display: grid;
  gap: 10px;
}

.statusRow {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #eef1ec;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.dot.red {
  background: var(--red);
}

.dot.yellow {
  background: var(--yellow);
}

.dot.green {
  background: var(--ok);
}

.primary,
.quiet,
.answerButton {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
  cursor: pointer;
  background: white;
  color: var(--ink);
}

.primary {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.primary:hover,
.quiet:hover,
.answerButton:hover {
  transform: translateY(-1px);
}

.legend,
.answers,
.toolbar,
.moduleBar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar {
  align-items: end;
}

.moduleBar {
  align-items: center;
}

.moduleButton {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 13px;
  min-height: 42px;
  cursor: pointer;
  font-weight: 800;
}

.moduleButton.active,
.moduleButton:hover {
  background: #e8f6ec;
  border-color: #9bd4ad;
  color: #174b34;
}

.toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  color: white;
  font-weight: 700;
  font-size: 13px;
}

.blue {
  background: var(--blue);
}

.orange {
  background: var(--orange);
}

.green {
  background: var(--green);
}

.violet {
  background: var(--violet);
}

.task {
  min-height: 340px;
}

.taskMeta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.decoderMarks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}

.stagePill,
.decoderMark {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #cfd9d0;
  border-radius: 8px;
  background: #f7fbf7;
  color: #274435;
  font-size: 12px;
  font-weight: 800;
}

.stagePill {
  background: #1f4f37;
  border-color: #1f4f37;
  color: white;
}

.stagePill.text_smart,
.stagePill.u4_start,
.stagePill.u4_later {
  background: #fff4df;
  border-color: #e4c27f;
  color: #714f14;
}

.decoderMark strong {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.practiceRhythm {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.practiceRhythm span {
  min-height: 48px;
  padding: 10px;
  border: 1px solid #dbe6dc;
  border-radius: 8px;
  background: #f7faf6;
  color: #3d4a42;
  font-size: 13px;
  line-height: 1.35;
}

.practiceRhythm strong {
  display: block;
  color: #1f4f37;
  font-size: 11px;
  text-transform: uppercase;
}

.paperRhythm {
  margin-bottom: 4px;
}

.writingCoach {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid #cfe1d3;
  border-radius: 8px;
  background: #f4faf5;
}

.writingCoach p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

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

.phraseGrid span {
  padding: 9px 10px;
  border: 1px solid #dbe7dd;
  border-radius: 8px;
  background: white;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.conditionalTrainerBar {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf7;
}

.conditionalTrainerBar > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.barLabel {
  min-width: 54px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.miniToggle {
  min-height: 34px;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  background: white;
}

.miniToggle.active {
  border-color: #9db7a6;
  background: #e8f1ea;
  color: #183f2b;
}

.nextToggle {
  justify-self: start;
}

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

.conditionalHintGrid span {
  display: grid;
  gap: 3px;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.conditionalHintGrid strong {
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
}

.prompt {
  font-size: 22px;
  line-height: 1.4;
  margin-bottom: 18px;
}

.sentence {
  background: #f4f6f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin: 14px 0;
  font-size: 20px;
  line-height: 1.5;
}

.answers {
  margin-top: 18px;
}

.answerButton {
  min-width: 180px;
  text-align: left;
}

.answerButton:disabled {
  cursor: default;
  opacity: 0.82;
}

.answerButton.isCorrect {
  border-color: #9bd4ad;
  background: #e8f6ec;
  color: #174b34;
  font-weight: 800;
}

.answerButton.isWrong {
  border-color: #efb2a8;
  background: #fff0ed;
  color: #8d2c22;
  font-weight: 800;
}

.feedback {
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  line-height: 1.5;
  background: #eef6f0;
  border: 1px solid #c9e7d2;
}

.feedback.warn {
  background: #fff7e5;
  border-color: #f0d49a;
}

.feedbackBlock {
  display: grid;
  gap: 12px;
}

.feedbackBlock p {
  line-height: 1.5;
  margin: 0;
}

.feedbackLine {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.feedbackLabel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.successLine .feedbackLabel {
  color: #174b34;
  border-color: #9bd4ad;
}

.correctionLine .feedbackLabel {
  color: #8d2c22;
  border-color: #efb2a8;
}

.answerInline {
  display: inline-block;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
  padding: 2px 7px;
  font-weight: 800;
}

.feedbackAction {
  justify-self: start;
  margin-top: 4px;
}

.inlinePaper {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #d9d1bf;
  border-radius: 8px;
  background: #fffaf0;
}

.inlinePaper.mini {
  padding: 12px;
}

.inlinePaper.medium {
  border-color: #c9d8c8;
  background: #f5fbf5;
}

.inlinePaper > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.paperLabel {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #d9c79f;
  border-radius: 8px;
  background: white;
  color: #7a5622;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.inlinePaper ol {
  margin: 0;
  padding-left: 22px;
  line-height: 1.55;
}

.paperHint {
  margin: 0;
  color: #75592c;
  font-size: 13px;
  line-height: 1.45;
}

.reserveIntro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #d9d1bf;
  border-radius: 8px;
  background: #fffaf0;
}

.paperBox {
  display: grid;
  gap: 14px;
}

.flashcard {
  display: grid;
  align-content: center;
  gap: 14px;
  min-height: 220px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #f8faf6;
  padding: 24px;
}

.vocabWord {
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1;
  font-weight: 800;
}

.vocabMeaning {
  color: var(--muted);
  font-size: 20px;
  line-height: 1.4;
}

.tagRow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 700;
}

.paperBox ol {
  margin: 0;
  padding-left: 22px;
  line-height: 1.7;
}

.recommendation {
  display: grid;
  gap: 8px;
  line-height: 1.5;
}

@media (max-width: 780px) {
  .topbar,
  .hero,
  .sectionHead {
    align-items: stretch;
    flex-direction: column;
  }

  .layout,
  .grid.two,
  .choiceGrid,
  .choiceGrid.homeChoices {
    grid-template-columns: 1fr;
  }

  .phraseGrid {
    grid-template-columns: 1fr;
  }

  .practiceRhythm {
    grid-template-columns: 1fr;
  }

  .conditionalHintGrid {
    grid-template-columns: 1fr;
  }

  .content {
    width: 100%;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 10px;
    background: white;
    position: sticky;
    top: 86px;
    z-index: 4;
  }

  .subjectNav {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .sideLabel {
    display: none;
  }

  .nav {
    white-space: nowrap;
    min-height: 38px;
    padding: 9px 12px;
  }

  .content {
    padding: 16px;
  }

  .answerButton {
    width: 100%;
  }

  .mainChoice {
    grid-column: auto;
  }

  .homeChoices .choiceCard {
    min-height: 158px;
  }

  .feedbackLine {
    grid-template-columns: 1fr;
  }
}
