:root {
  --ink: #2f1d1f;
  --muted: #7c6465;
  --paper: #ffffff;
  --line: rgba(47, 29, 31, 0.1);
  --soft: #fdf8f6;
  --brand: #5c4b4b;
  --brand-strong: #362525;
  --accent: #bfa7a7;
  --accent-soft: #f2e7ea;
  --green: #3a8f6b;
  --red: #c94848;
  --yellow: #f2b04a;
  --shadow: 0 20px 44px rgba(47, 29, 31, 0.08);
  --card-shadow: 0 12px 28px rgba(47, 29, 31, 0.07);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xl: 32px;
  --font-heading: "Arial Rounded MT Bold", "Aptos Rounded", "Nunito", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top right, rgba(201, 152, 167, 0.14), transparent 26%),
    linear-gradient(180deg, #fdf8f6 0%, #f8f3f1 100%);
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 12px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

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

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.station-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tab,
.secondary-action,
.help-toggle {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 12px;
}

.tab.is-active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

main {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 30px 0 80px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: grid;
  gap: 22px;
}

.start-screen {
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
  align-items: stretch;
}

.intro,
.progress-panel,
.station-head,
.learning-card,
.exercise-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.intro {
  min-height: 460px;
  display: grid;
  align-content: center;
  gap: 20px;
  padding: clamp(28px, 6vw, 64px);
  background:
    linear-gradient(135deg, rgba(191, 167, 167, 0.26), transparent 42%),
    linear-gradient(160deg, #ffffff, #fdf8f6);
}

.eyebrow {
  width: fit-content;
  margin: 0;
  border: 1px solid rgba(92, 75, 75, 0.18);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--brand);
  font-weight: 800;
  padding: 6px 10px;
}

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

h1 {
  max-width: 12ch;
  margin-bottom: 0;
  font-family: var(--font-heading);
  font-size: clamp(40px, 7vw, 72px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.15;
}

h3 {
  margin-bottom: 6px;
}

.lead {
  max-width: 66ch;
  color: var(--muted);
  font-size: 19px;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-action,
.check-button {
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  min-height: 44px;
  padding: 10px 16px;
  font-weight: 800;
  box-shadow: 3px 3px 0 var(--accent);
}

.primary-action:hover,
.check-button:hover {
  background: var(--brand-strong);
}

.progress-panel {
  padding: 24px;
}

.progress-meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--accent-soft);
}

.progress-meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--green);
  transition: width 180ms ease;
}

.progress-list {
  display: grid;
  gap: 12px;
  padding-left: 0;
  list-style: none;
}

.progress-list li {
  display: flex;
  gap: 10px;
  align-items: center;
}

[data-progress-dot] {
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  flex: 0 0 auto;
}

[data-progress-dot].is-complete {
  border-color: var(--green);
  background: var(--green);
}

.station-head {
  display: grid;
  gap: 10px;
  padding: clamp(24px, 5vw, 44px);
  background:
    linear-gradient(120deg, rgba(242, 231, 234, 0.84), transparent 42%),
    #fff;
}

.station-head h1 {
  max-width: 16ch;
  font-size: clamp(36px, 6vw, 62px);
}

.station-head p:last-child {
  max-width: 76ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
}

.learning-card,
.exercise-card {
  padding: clamp(20px, 4vw, 32px);
}

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

.two-columns > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 16px;
}

.card-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.help-text {
  border-left: 4px solid var(--yellow);
  background: #fff8df;
  padding: 12px 14px;
  color: #5f4b12;
}

.decision-grid,
.sort-list,
.checkbox-list,
.conversion-table,
.order-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.decision-row,
.sort-row,
.check-row,
.convert-row,
.order-row {
  display: grid;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.decision-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.sort-row,
.convert-row {
  grid-template-columns: minmax(0, 1fr) minmax(160px, auto);
}

.order-row {
  grid-template-columns: 76px minmax(0, 1fr);
}

.check-row {
  grid-template-columns: 28px minmax(0, 1fr);
}

.decision-row label,
.check-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

input[type="radio"],
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(47, 29, 31, 0.18);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 8px 10px;
}

.inline-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-inputs label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-inputs input {
  width: 84px;
}

.place-value-demo,
.bit-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 70px));
  gap: 8px;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  margin: 14px 0;
  text-align: center;
}

.place-value-demo span,
.bit-grid span {
  color: var(--muted);
  font-weight: 800;
}

.bit {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.bit.is-on {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.sum-line {
  margin-bottom: 0;
  font-weight: 800;
}

.convert-row input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  text-align: center;
}

.feedback {
  min-height: 28px;
  margin: 12px 0 0;
  font-weight: 800;
}

.feedback.is-good {
  color: var(--green);
}

.feedback.is-bad {
  color: var(--red);
}

.row-good {
  border-color: rgba(58, 143, 107, 0.5);
  background: rgba(58, 143, 107, 0.08);
}

.row-bad {
  border-color: rgba(181, 63, 56, 0.5);
  background: rgba(181, 63, 56, 0.06);
}

.method-list {
  margin-bottom: 0;
}

.trainer {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(100px, 160px);
  gap: 10px;
  align-items: center;
}

#trainer-output {
  grid-column: 1 / -1;
  display: block;
  min-height: 72px;
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 20px clamp(16px, 4vw, 40px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.86);
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
  }

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

  .tab {
    min-height: 42px;
    padding: 8px 10px;
  }

  .footer {
    align-items: stretch;
    flex-direction: column;
  }

  main {
    width: min(100% - 22px, 1180px);
    padding-top: 22px;
  }

  .start-screen,
  .two-columns {
    grid-template-columns: 1fr;
  }

  .intro {
    min-height: auto;
  }

  .decision-row,
  .sort-row,
  .convert-row,
  .order-row {
    grid-template-columns: 1fr;
  }

  .card-title {
    align-items: stretch;
    flex-direction: column;
  }

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

@media (max-width: 520px) {
  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .station-head,
  .learning-card,
  .exercise-card,
  .intro,
  .progress-panel {
    border-radius: var(--radius);
  }

  .station-head h1 {
    font-size: 34px;
    max-width: 14ch;
  }

  .intro h1 {
    font-size: 38px;
  }

  .lead {
    font-size: 17px;
  }

  .inline-inputs {
    display: grid;
    grid-template-columns: 1fr;
  }

  .inline-inputs label {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .inline-inputs input {
    width: min(100%, 150px);
  }
}

@media print {
  .topbar,
  .footer,
  .start-actions,
  .check-button,
  .help-toggle {
    display: none;
  }

  body {
    background: #fff;
  }

  main {
    width: 100%;
    padding: 0;
  }

  .screen {
    display: block;
    margin-bottom: 18px;
  }

  .intro,
  .progress-panel,
  .station-head,
  .learning-card,
  .exercise-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
  font-family: var(--font-heading);
