:root {
  --ink: #1b2430;
  --ink-soft: #3d4a5c;
  --muted: #5c6b7a;
  --paper: #f4efe4;
  --paper-2: #fffdf8;
  --line: #d7cfc0;
  --teal: #0b6e6e;
  --teal-deep: #084f4f;
  --coral: #c45c3e;
  --gold: #d4a017;
  --sky: #2f4f73;
  --ok: #2d6a4f;
  --bad: #9b2226;
  --shadow: 0 10px 28px rgba(27, 36, 48, 0.08);
  --radius: 18px;
  --font: "Be Vietnam Pro", "Segoe UI", sans-serif;
  --display: "Fraunces", "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(11, 110, 110, 0.08), transparent 55%),
    radial-gradient(700px 380px at 100% 10%, rgba(196, 92, 62, 0.07), transparent 50%),
    var(--paper);
  line-height: 1.6;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 20;
  background: var(--ink);
  color: #fff;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
}

.skip-link:focus {
  top: 0.75rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.4rem 1.15rem 1.2rem;
  background: linear-gradient(180deg, #12363a 0%, #0c2428 100%);
  color: #e8efe9;
  overflow: auto;
}

.rail-back {
  color: #b7d4ce;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}

.rail-back:hover {
  color: #fff;
}

.rail-kicker {
  margin: 1.15rem 0 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8fb8b2;
}

.rail-title {
  margin: 0 0 1.1rem;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
}

.stations {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stations li + li {
  margin-top: 0.2rem;
}

.stations button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.86rem;
  padding: 0.42rem 0.5rem;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}

.stations button:hover,
.stations button.is-current {
  background: rgba(255, 255, 255, 0.08);
}

.stations .n {
  flex: 0 0 1.3rem;
  font-weight: 700;
  color: #e0b54a;
}

.rail-score {
  margin-top: 1.4rem;
  padding: 0.75rem 0.8rem;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  font-size: 0.85rem;
}

.rail-score-label {
  display: block;
  color: #8fb8b2;
  margin-bottom: 0.15rem;
}

.rail-score strong {
  font-size: 1.4rem;
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  padding: 1rem 1.6rem 0;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.progress-track {
  height: 7px;
  background: #e4ddd0;
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 11%;
  background: linear-gradient(90deg, var(--teal), #3d9b8f);
  border-radius: inherit;
  transition: width 0.35s ease;
}

.screen-host {
  flex: 1;
  padding: 1.1rem 1.7rem 1.4rem;
  outline: none;
}

.screen {
  display: none;
  animation: rise 0.35s ease;
}

.screen.is-active {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--coral);
}

h2 {
  margin: 0 0 0.55rem;
  font-family: var(--display);
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  line-height: 1.2;
  font-weight: 700;
}

h2 em {
  font-style: italic;
  color: var(--teal-deep);
}

.lead {
  margin: 0 0 1.15rem;
  max-width: 62ch;
  color: var(--ink-soft);
}

.subhead {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.62rem 1.15rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible,
.goal-card:focus-visible,
.tab:focus-visible,
.flip:focus-visible,
.carrier:focus-visible,
.sort-chip:focus-visible,
.stations button:focus-visible,
.choice:focus-within,
.rain-table button:focus-visible {
  outline: 3px solid #e0b54a;
  outline-offset: 2px;
}

.btn-primary {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 6px 16px rgba(11, 110, 110, 0.22);
}

.btn-primary:hover {
  background: var(--teal-deep);
}

.btn-secondary {
  background: #ead9c6;
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--sky);
  border: 1px solid var(--line);
}

.nav-bar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1.6rem 1.1rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  bottom: 0;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.6rem;
  align-items: center;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 1.6rem 1.5rem;
  box-shadow: var(--shadow);
}

.badge {
  display: inline-block;
  margin: 0 0 0.7rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: #e7f3f1;
  color: var(--teal-deep);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hero-facts {
  margin: 0 0 1.1rem;
  padding-left: 1.15rem;
  color: var(--ink-soft);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hero-visual {
  margin: 0;
  text-align: center;
}

.hero-visual svg {
  width: min(100%, 320px);
  height: auto;
}

.viz-card {
  fill: #eef6f4;
  stroke: #0b6e6e;
  stroke-width: 2;
}

.viz-card-mid {
  fill: #fff6e8;
  stroke: #d4a017;
}

.viz-card-end {
  fill: #fdece6;
  stroke: #c45c3e;
}

.viz-num,
.viz-word {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  fill: var(--ink);
}

.viz-cap {
  font-size: 11px;
  fill: var(--muted);
}

.hero-visual figcaption {
  font-size: 0.85rem;
  color: var(--muted);
}

.goal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.goal-grid .goal-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.goal-card {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow);
}

.goal-icon {
  display: inline-grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: #12363a;
  color: #f4efe4;
  font-weight: 800;
  font-size: 0.85rem;
  margin-bottom: 0.45rem;
}

.goal-title {
  display: block;
  font-weight: 700;
}

.goal-body {
  display: none;
  margin-top: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.goal-card.is-open .goal-body,
.goal-card[aria-expanded="true"] .goal-body {
  display: block;
}

.note-card,
.insight,
.task-panel,
.open-box,
.teacher-box {
  margin-top: 1.15rem;
  padding: 0.95rem 1.05rem;
  border-radius: 16px;
  background: #fff8ea;
  border: 1px dashed #d8b56a;
}

.insight {
  background: #e7f3f1;
  border-color: #7fb3ad;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.tab {
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft);
}

.tab.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.situation {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1rem;
}

.situation-visual {
  display: grid;
  place-items: center;
  min-height: 180px;
  border-radius: 16px;
  background: #eef4f1;
}

.sit-thermo {
  background: linear-gradient(180deg, #fde8e4, #fff);
}

.thermo {
  position: relative;
  height: 110px;
}

.thermo-tube {
  width: 16px;
  height: 88px;
  margin: 0 auto;
  border: 3px solid #9b2226;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #fff;
  overflow: hidden;
}

.thermo-fill {
  display: block;
  height: 70%;
  margin-top: 30%;
  background: #c1121f;
}

.thermo-bulb {
  width: 28px;
  height: 28px;
  margin: -6px auto 0;
  border-radius: 50%;
  background: #c1121f;
  border: 3px solid #9b2226;
}

.sit-readout {
  margin: 0.4rem 0 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
}

.mini-sheet {
  width: 86%;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.9rem;
}

.mini-sheet caption {
  font-weight: 700;
  padding-bottom: 0.3rem;
}

.mini-sheet th,
.mini-sheet td {
  border: 1px solid #c9d4cf;
  padding: 0.25rem 0.4rem;
}

.sit-bell {
  background: linear-gradient(180deg, #dce9f5, #fff);
}

.sign-board {
  background: #2f4f73;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
}

.bell {
  font-size: 2rem;
  margin-top: 0.4rem;
}

.situation-body h3 {
  margin: 0 0 0.3rem;
}

.situation-body label,
.apply-form label,
.open-box label,
.own-q {
  display: block;
  margin: 0.65rem 0;
  font-weight: 600;
  font-size: 0.92rem;
}

textarea,
input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid #cfc6b6;
  background: #fff;
  resize: vertical;
}

.reveal {
  margin-top: 0.7rem;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background: #e7f3f1;
}

.reveal p {
  margin: 0.25rem 0;
}

.flip-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  perspective: 900px;
}

.flip {
  min-height: 168px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.flip-inner {
  display: block;
  height: 168px;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
  position: relative;
}

.flip.is-flipped .flip-inner,
.flip[aria-pressed="true"] .flip-inner {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.flip-front {
  background: var(--paper-2);
}

.flip-back {
  background: #12363a;
  color: #f3f7f5;
  transform: rotateY(180deg);
  font-size: 0.95rem;
}

.flip-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.flip-word {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 700;
}

.flip-hint {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.pipeline {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.3rem 0 0.4rem;
  flex-wrap: wrap;
}

.pipe-node {
  flex: 1 1 180px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 1rem;
}

.pipe-node-info {
  background: #fdece6;
  border-color: #e8b3a3;
}

.pipe-label {
  display: block;
  font-weight: 800;
}

.pipe-arrow {
  font-weight: 700;
  color: var(--teal);
}

.carrier-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.55rem;
}

.carrier {
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: 14px;
  padding: 0.7rem 0.4rem;
  font: inherit;
  cursor: pointer;
}

.carrier.is-on {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(11, 110, 110, 0.15);
}

.carrier-emoji {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 0.2rem;
}

.carrier-detail {
  margin-top: 0.75rem;
  padding: 0.8rem 0.9rem;
  border-radius: 14px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}

.sort-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 3rem;
  margin-bottom: 0.85rem;
}

.sort-chip {
  border: 1px solid #c9bba4;
  background: #fff;
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.sort-chip.is-held {
  background: #12363a;
  color: #fff;
  border-color: #12363a;
}

.sort-chip.is-ok {
  background: #d8f3dc;
  border-color: #2d6a4f;
}

.sort-chip.is-bad {
  background: #fde2e1;
  border-color: #9b2226;
}

.sort-bins {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
}

.bin {
  background: var(--paper-2);
  border: 1px dashed #b7c4bc;
  border-radius: 16px;
  padding: 0.7rem;
  min-height: 170px;
}

.bin.is-target {
  border-color: var(--teal);
  background: #eef7f5;
}

.bin h3 {
  margin: 0;
  font-size: 1rem;
}

.bin-hint {
  margin: 0.15rem 0 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.bin-drop {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 4.5rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.inline-feedback {
  margin: 0;
  font-weight: 600;
}

.inline-feedback.is-ok {
  color: var(--ok);
}

.inline-feedback.is-bad {
  color: var(--bad);
}

.story-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.story {
  background: var(--paper-2);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  border-left: 5px solid var(--gold);
}

.story h3 {
  margin: 0 0 0.3rem;
}

.story p {
  margin: 0;
  color: var(--ink-soft);
}

.question-picks {
  border: 0;
  padding: 0;
  margin: 0.6rem 0;
  display: grid;
  gap: 0.4rem;
}

.question-picks label {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  font-weight: 500;
}

.question-picks label.is-good {
  background: #d8f3dc;
  border-color: #2d6a4f;
}

.question-picks label.is-weak {
  background: #fde2e1;
  border-color: #e0b4b4;
}

.quiz {
  margin: 0;
  padding-left: 1.2rem;
}

.quiz > li {
  margin: 0 0 0.95rem;
}

.quiz fieldset {
  border: 0;
  margin: 0.35rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.quiz label {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
}

.quiz label.is-right {
  background: #d8f3dc;
  border-color: #2d6a4f;
}

.quiz label.is-wrong {
  background: #fde2e1;
  border-color: #9b2226;
}

.table-wrap {
  overflow-x: auto;
  margin: 0.6rem 0;
}

.rain-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper-2);
}

.rain-table caption {
  text-align: left;
  font-weight: 700;
  padding-bottom: 0.4rem;
}

.rain-table th,
.rain-table td {
  border: 1px solid #d2c8b6;
  padding: 0.45rem;
  text-align: center;
}

.rain-table button {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: var(--teal-deep);
  width: 100%;
}

.rain-table .is-hi {
  background: #fff3c4;
}

.table-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.choice-row {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.choice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
}

.choice:has(input:checked) {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(11, 110, 110, 0.12);
}

.apply-form {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
}

.form-hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.takeaways {
  padding-left: 1.2rem;
}

.takeaways li {
  margin-bottom: 0.45rem;
}

.scoreboard {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 16px;
  background: #12363a;
  color: #eef5f3;
}

.scoreboard strong {
  font-family: var(--display);
  font-size: 1.8rem;
}

.checklist {
  display: grid;
  gap: 0.4rem;
}

.checklist label {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.teacher-toggle {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: var(--sky);
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.teacher-body {
  margin-top: 0.6rem;
}

.teacher-body ul {
  margin: 0.3rem 0;
  padding-left: 1.15rem;
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  .rail {
    position: relative;
    height: auto;
    padding-bottom: 0.8rem;
  }

  .stations {
    display: flex;
    gap: 0.25rem;
    overflow: auto;
  }

  .stations li {
    flex: 0 0 auto;
  }

  .stations button {
    width: auto;
    white-space: nowrap;
  }

  .rail-score {
    display: none;
  }

  .hero,
  .situation,
  .goal-grid,
  .flip-row,
  .sort-bins,
  .story-grid,
  .carrier-grid {
    grid-template-columns: 1fr;
  }

  .carrier-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .rail,
  .nav-bar,
  .topbar,
  .skip-link {
    display: none !important;
  }

  .app,
  .stage,
  .screen-host {
    display: block;
  }

  .screen {
    display: block !important;
    break-inside: avoid;
    margin-bottom: 1.2rem;
  }
}
