:root {
  --bg: #f3eee6;
  --paper: rgba(255, 251, 246, 0.94);
  --ink: #1f2721;
  --muted: #5b584f;
  --line: rgba(31, 39, 33, 0.12);
  --warm: #b6642d;
  --cool: #275f78;
  --sage: #2f705d;
  --accent: #d78432;
  --good: #23664b;
  --bad: #9e382d;
  --shadow: 0 26px 58px rgba(60, 46, 26, 0.13);
  --radius-xl: 32px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(182, 100, 45, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(39, 95, 120, 0.12), transparent 24%),
    linear-gradient(180deg, #fbf8f3 0%, #f4ede4 54%, #e9dfd2 100%);
}

.page-aura {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.38;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.44) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.42) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black 36%, transparent 82%);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 68px;
}

.hero,
.panel {
  position: relative;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding: 38px 36px 34px;
  border-radius: 36px;
}

.panel {
  margin-top: 24px;
  padding: 26px;
  border-radius: 30px;
}

.hero::after,
.panel::after {
  content: "";
  position: absolute;
  right: -100px;
  bottom: -120px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(39, 95, 120, 0.12), transparent 72%);
}

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

h1 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

h2 {
  margin: 6px 0 0;
  font-size: clamp(1.5rem, 2.7vw, 2.2rem);
}

h3 {
  margin: 0;
  font-size: 1.08rem;
}

.eyebrow,
.step,
.mini-kicker,
.field-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
}

.intro-list,
.dual-points,
.panel-copy,
.feedback-line {
  color: #4d4a43;
  line-height: 1.65;
}

.intro-list,
.dual-points {
  margin: 0;
  padding-left: 22px;
}

.intro-list li + li,
.dual-points li + li {
  margin-top: 8px;
}

.hero-copy {
  max-width: 940px;
  padding: 12px 12px 8px;
}

.dual-coding-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 0.92fr);
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(249, 244, 236, 0.82));
}

.dual-card,
.field-card,
.sim-card,
.wave-card {
  min-width: 0;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.dual-card {
  padding: 18px;
}

.dual-link {
  align-self: center;
  justify-self: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 10px 8px;
  border-radius: 999px;
  background: rgba(39, 95, 120, 0.1);
  color: var(--cool);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.dual-diagram {
  width: 100%;
  height: auto;
  margin-top: 12px;
}

.diagram-block rect,
.timing-card rect {
  fill: rgba(255, 255, 255, 0.85);
  stroke: rgba(31, 39, 33, 0.12);
  stroke-width: 2;
}

.diagram-block text {
  text-anchor: middle;
  fill: #a84f24;
  font-size: 26px;
  font-weight: 800;
}

.diagram-lines line,
.edge-line {
  stroke: #31566d;
  stroke-width: 4;
  stroke-linecap: round;
}

.diagram-labels text,
.timing-label,
.axis-digit {
  fill: #243d4a;
  font-weight: 700;
}

.timing-label {
  font-size: 18px;
}

.timing-label-large {
  fill: #b02d1f;
  font-size: 28px;
  font-weight: 900;
}

.axis-digit {
  fill: #111;
  font-size: 20px;
  font-weight: 900;
}

.axis-guide {
  stroke: rgba(160, 166, 169, 0.8);
  stroke-width: 4;
}

.axis-guide.soft {
  stroke-width: 2;
  opacity: 0.42;
}

.axis-arrow {
  fill: rgba(160, 166, 169, 0.8);
}

.orange-edge {
  stroke: #ec8a2d;
  stroke-width: 6;
  stroke-linecap: round;
}

.orange-arrow {
  fill: #ec8a2d;
}

.clock-marker {
  fill: url(#dffWarm);
}

.wave {
  fill: none;
  stroke-width: 5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.d-wave {
  stroke: url(#dffWarm);
}

.c-wave {
  stroke: url(#dffCool);
}

.q-wave {
  stroke: #2f705d;
}

.speech-bubble-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.speech-bubble {
  max-width: 280px;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #31404a;
  background: rgba(245, 240, 231, 0.96);
  border: 1px solid rgba(49, 64, 74, 0.1);
}

.speech-bubble-left {
  border-bottom-left-radius: 6px;
}

.speech-bubble-right {
  margin-left: auto;
  border-bottom-right-radius: 6px;
}

.panel-warm {
  border-top: 5px solid rgba(182, 100, 45, 0.84);
}

.panel-cool {
  border-top: 5px solid rgba(39, 95, 120, 0.84);
}

.panel-heading,
.sim-head,
.subtle-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:focus-visible,
textarea:focus-visible,
.wave-input-cell:focus-visible {
  outline: 3px solid rgba(39, 95, 120, 0.26);
  outline-offset: 2px;
}

.button.primary {
  background: linear-gradient(135deg, var(--warm), #ca7f3a);
  color: #fff;
  box-shadow: 0 14px 28px rgba(182, 100, 45, 0.24);
}

.button.secondary {
  background: rgba(39, 95, 120, 0.1);
  color: var(--cool);
}

.button.ghost {
  background: rgba(47, 112, 93, 0.1);
  color: var(--sage);
}

.sim-card {
  padding: 18px;
}

.sim-link {
  color: var(--cool);
  font-weight: 800;
  text-decoration: none;
}

.sim-frame {
  width: 100%;
  min-height: 760px;
  margin-top: 14px;
  border: 0;
  border-radius: 18px;
  background: #efe7dc;
}

.question-grid {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.question-grid-single {
  grid-template-columns: minmax(0, 1fr);
}

.question-grid-padded {
  margin-top: 22px;
}

.field-card {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.field-card-wide {
  width: 100%;
}

textarea {
  width: 100%;
  border: 1px solid rgba(31, 39, 33, 0.14);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  line-height: 1.5;
  resize: vertical;
  background: rgba(252, 249, 244, 0.96);
  color: var(--ink);
}

.waveform-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.wave-card {
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 244, 237, 0.92));
}

.wave-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.wave-meta h3 {
  font-size: 1.02rem;
}

.state-pill {
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  background: rgba(39, 95, 120, 0.08);
  color: var(--cool);
}

.state-pill.is-correct {
  background: rgba(35, 102, 75, 0.14);
  color: var(--good);
}

.state-pill.is-incorrect {
  background: rgba(158, 56, 45, 0.14);
  color: var(--bad);
}

.wave-instructions {
  margin: 0 0 14px;
  color: #5c584f;
  line-height: 1.55;
}

.wave-board {
  display: grid;
  gap: 10px;
}

.wave-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.wave-label {
  font-weight: 900;
  font-size: 1.4rem;
  color: #b02d1f;
  text-align: center;
}

.wave-label.wave-label-q {
  color: var(--sage);
}

.wave-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 0;
  border: 1px solid rgba(31, 39, 33, 0.1);
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 244, 237, 0.96));
}

.wave-track::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  background: rgba(31, 39, 33, 0.15);
  pointer-events: none;
}

.wave-cell,
.wave-input-cell {
  position: relative;
  min-height: 64px;
  border: 0;
  border-right: 1px solid rgba(31, 39, 33, 0.08);
  background: transparent;
  padding: 0;
}

.wave-cell:last-child,
.wave-input-cell:last-child {
  border-right: 0;
}

.wave-cell::after,
.wave-input-cell::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 999px;
}

.wave-cell.is-high::after,
.wave-input-cell.is-high::after {
  top: 15px;
}

.wave-cell.is-low::after,
.wave-input-cell.is-low::after {
  bottom: 15px;
}

.wave-cell::after {
  background: #232323;
}

.wave-row[data-wave-kind="q"] .wave-input-cell::after {
  background: var(--sage);
}

.wave-input-cell {
  cursor: pointer;
}

.wave-input-cell:hover {
  background: rgba(47, 112, 93, 0.08);
}

.wave-input-cell.is-rising::before,
.wave-cell.is-rising::before {
  content: "↑";
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  font-weight: 900;
  color: var(--accent);
}

.wave-segment-rise {
  position: absolute;
  top: 15px;
  bottom: 15px;
  width: 3px;
  left: -1px;
  border-radius: 999px;
  background: currentColor;
}

.wave-cell.is-high,
.wave-cell.is-low {
  color: #232323;
}

.wave-input-cell.is-high,
.wave-input-cell.is-low {
  color: var(--sage);
}

.wave-note,
.model-note {
  margin: 12px 0 0;
  color: #5d574f;
  line-height: 1.55;
}

.model-answer {
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(47, 112, 93, 0.16);
  background: rgba(229, 244, 238, 0.78);
}

.model-answer[hidden] {
  display: none;
}

.feedback-line {
  min-height: 1.5em;
  margin: 18px 0 0;
}

.feedback-line.is-good {
  color: var(--good);
  font-weight: 800;
}

.feedback-line.is-bad {
  color: var(--bad);
  font-weight: 800;
}

.floating-download {
  display: grid;
  justify-items: center;
  gap: 12px;
  background: transparent;
  box-shadow: none;
  border: 0;
  padding-top: 0;
}

.floating-download::after {
  display: none;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.95em;
}

@media (max-width: 1080px) {
  .dual-coding-panel {
    grid-template-columns: 1fr;
  }

  .dual-link {
    writing-mode: horizontal-tb;
    transform: none;
  }

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

@media (max-width: 720px) {
  .shell {
    width: min(100%, calc(100% - 18px));
    padding-top: 18px;
  }

  .hero,
  .panel {
    padding: 22px 18px;
    border-radius: 24px;
  }

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

  .wave-label {
    font-size: 1.1rem;
  }

  .wave-cell,
  .wave-input-cell {
    min-height: 56px;
  }
}
