:root {
  --bg: #f4efe3;
  --bg-soft: #fff9ee;
  --surface: rgba(255, 250, 242, 0.86);
  --surface-strong: #fffdf9;
  --text: #1e2430;
  --muted: #55606f;
  --accent: #d85f3f;
  --accent-dark: #8b3e2a;
  --secondary: #15616d;
  --secondary-soft: #d9eef0;
  --gold: #f2b84b;
  --line: rgba(30, 36, 48, 0.12);
  --success: #2f8f6d;
  --shadow: 0 20px 45px rgba(55, 42, 20, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-y: auto;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(242, 184, 75, 0.28), transparent 28%),
    radial-gradient(circle at top right, rgba(21, 97, 109, 0.18), transparent 22%),
    linear-gradient(180deg, #f8f0e0 0%, #f4efe3 45%, #eaf2ef 100%);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

img {
  display: block;
  max-width: 100%;
}

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.2rem 0 4rem;
}

main {
  scroll-margin-top: 5.5rem;
}

.top-nav {
  position: sticky;
  top: 0.5rem;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  padding: 0.9rem;
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.84);
  border: 1px solid rgba(30, 36, 48, 0.08);
  box-shadow: 0 12px 28px rgba(55, 42, 20, 0.14);
  backdrop-filter: blur(14px);
}

.nav-pill,
.energy-button,
.flow-button {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  font-weight: 800;
  background: rgba(21, 97, 109, 0.08);
  color: var(--secondary);
  transition: transform 180ms ease, background-color 180ms ease, color 180ms ease;
}

.nav-pill:hover,
.energy-button:hover,
.flow-button:hover {
  transform: translateY(-2px);
}

.nav-pill.active,
.energy-button.active,
.flow-button.active {
  background: var(--secondary);
  color: #effcff;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2rem;
  align-items: center;
  padding: 2rem;
  margin-top: 1rem;
  border-radius: calc(var(--radius-xl) + 8px);
  background: linear-gradient(135deg, rgba(255, 252, 246, 0.9), rgba(250, 241, 224, 0.84));
  border: 1px solid rgba(216, 95, 63, 0.12);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -60px -80px auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(216, 95, 63, 0.12);
  filter: blur(8px);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  color: var(--accent-dark);
  font-weight: 700;
}

.hero h1,
.study-tip h2,
.quiz-header h2,
.unit-card h3 {
  font-family: Georgia, "Times New Roman", serif;
}

.hero h1 {
  font-size: clamp(2.4rem, 4vw, 4.6rem);
  line-height: 0.95;
  margin: 0;
}

.lead {
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: 62ch;
}

.hero-actions,
.quiz-actions,
.choice-group,
.step-buttons,
.sort-targets,
.sort-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button,
.step-buttons button,
.compare-button,
.sort-chip,
.sort-target {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.95rem 1.35rem;
  text-decoration: none;
  font-weight: 700;
}

.button:hover,
.step-buttons button:hover,
.compare-button:hover,
.sort-chip:hover,
.sort-target:hover {
  transform: translateY(-2px);
}

.primary {
  background: var(--accent);
  color: #fff7f1;
  box-shadow: 0 12px 24px rgba(216, 95, 63, 0.26);
}

.secondary {
  background: rgba(21, 97, 109, 0.1);
  color: var(--secondary);
  border: 1px solid rgba(21, 97, 109, 0.16);
}

.lesson-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.meta-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(30, 36, 48, 0.08);
  backdrop-filter: blur(8px);
}

.meta-number {
  display: block;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--secondary);
}

.meta-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.hero-visual {
  position: relative;
  animation: float 6s ease-in-out infinite;
}

.hero-visual img {
  width: min(100%, 420px);
  margin: 0 auto;
  filter: drop-shadow(0 18px 30px rgba(21, 97, 109, 0.18));
}

.unit-grid {
  display: block;
}

.unit-card,
.study-tip,
.quiz-section {
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid rgba(30, 36, 48, 0.08);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.unit-card {
  padding: 1.35rem;
  position: relative;
  overflow: clip;
}

.wide {
  grid-column: auto;
}

.unit-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.unit-header img {
  width: 180px;
  max-height: 220px;
  object-fit: contain;
  flex: 0 0 auto;
}

.large-unit-figure {
  margin: 1.1rem 0;
  padding: 1.1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(30, 36, 48, 0.1);
}

.large-unit-figure img {
  width: min(100%, 620px);
  max-height: 560px;
  object-fit: contain;
  margin: 0 auto;
}

.large-unit-figure figcaption {
  margin-top: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.nervous-figure img {
  width: min(100%, 520px);
}

.unit-number {
  margin: 0 0 0.2rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.unit-card p {
  line-height: 1.7;
  color: var(--muted);
}

.key-idea {
  margin: 1rem 0;
  padding: 1rem 1.1rem;
  border-left: 6px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: linear-gradient(90deg, rgba(216, 95, 63, 0.12), rgba(255, 255, 255, 0.5));
  color: var(--text);
}

.interactive-panel {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  border: 1px solid rgba(21, 97, 109, 0.12);
}

.interactive-panel.dual {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 1rem;
  align-items: start;
}

.panel-title {
  margin-top: 0;
  font-weight: 800;
  color: var(--secondary);
}

.step-buttons button,
.compare-button,
.sort-chip,
.sort-target {
  padding: 0.8rem 1rem;
  background: rgba(21, 97, 109, 0.08);
  color: var(--secondary);
  font-weight: 700;
}

.step-buttons button.active,
.compare-button.active,
.sort-target.active {
  background: var(--secondary);
  color: #effcff;
}

.step-output {
  min-height: 78px;
  margin-top: 0.9rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  line-height: 1.6;
}

.reference-figure {
  margin-top: 0.9rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(30, 36, 48, 0.08);
}

.reference-figure.light {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.18);
}

.reference-figure img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  margin: 0 auto;
}

.slider-label {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  display: block;
  margin: 0.25rem 0 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(216, 95, 63, 0.92), rgba(242, 184, 75, 0.92));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -7px;
  border-radius: 50%;
  border: 3px solid #fffdf9;
  background: var(--secondary);
  box-shadow: 0 6px 16px rgba(21, 97, 109, 0.26);
}

input[type="range"]::-moz-range-track {
  height: 12px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(216, 95, 63, 0.92), rgba(242, 184, 75, 0.92));
}

input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 3px solid #fffdf9;
  border-radius: 50%;
  background: var(--secondary);
  box-shadow: 0 6px 16px rgba(21, 97, 109, 0.26);
}

input[type="range"]:focus-visible {
  outline: 3px solid rgba(21, 97, 109, 0.22);
  outline-offset: 6px;
  border-radius: 999px;
}

.sort-grid {
  margin-bottom: 0.75rem;
}

.sort-chip.selected {
  background: rgba(216, 95, 63, 0.2);
  color: var(--accent-dark);
}

.sort-target.correct {
  background: var(--success);
  color: #fff;
}

.sort-target.incorrect {
  background: rgba(216, 95, 63, 0.2);
  color: var(--accent-dark);
}

.study-tip {
  margin-top: 1.2rem;
  padding: 1.5rem;
  background:
    linear-gradient(135deg, rgba(21, 97, 109, 0.92), rgba(14, 61, 69, 0.95)),
    var(--secondary);
  color: #effcff;
}

.summary-pane {
  display: grid;
  grid-template-columns: 1fr 0.9fr;
  gap: 1rem;
  align-items: center;
}

.study-tip p {
  max-width: 72ch;
  color: rgba(239, 252, 255, 0.88);
}

.summary-points {
  display: grid;
  gap: 0.15rem;
  margin-top: 1rem;
}

.summary-points p {
  margin: 0;
  padding: 0.8rem 0;
  border-top: 1px solid rgba(239, 252, 255, 0.18);
}

.summary-points .summary-final {
  margin-top: 0.5rem;
  padding: 1rem;
  border: 0;
  border-radius: var(--radius-md);
  background: rgba(242, 184, 75, 0.16);
  color: #fff9e8;
}

.quiz-section {
  margin-top: 1.2rem;
  padding: 1.5rem;
}

.lesson-pane {
  display: none;
}

.lesson-pane.active {
  display: block;
}

.hero.lesson-pane.active {
  display: grid;
}

.summary-pane.active {
  display: grid;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.quiz-score {
  min-width: 164px;
  text-align: center;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(242, 184, 75, 0.2);
  font-weight: 800;
}

.quiz-form {
  display: grid;
  gap: 1rem;
}

.question-card {
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.question-card legend {
  padding: 0 0.35rem;
  font-weight: 800;
}

.question-card label,
.question-card select,
.question-card input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 0.7rem;
  color: var(--text);
}

.question-card input[type="text"],
.question-card select {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(30, 36, 48, 0.16);
  background: #fffefb;
  font: inherit;
}

.quiz-feedback {
  margin-top: 1rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-lg);
  background: rgba(21, 97, 109, 0.08);
  border: 1px solid rgba(21, 97, 109, 0.12);
  min-height: 76px;
}

.quiz-breakdown {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.result-item {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
}

.result-item.correct {
  border-color: rgba(47, 143, 109, 0.36);
  background: rgba(47, 143, 109, 0.1);
}

.result-item.incorrect {
  border-color: rgba(216, 95, 63, 0.3);
  background: rgba(216, 95, 63, 0.08);
}

.result-title {
  margin: 0 0 0.35rem;
  font-weight: 800;
}

.result-detail {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms ease, transform 500ms ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@media (max-width: 980px) {
  .hero,
  .interactive-panel.dual,
  .quiz-header {
    grid-template-columns: 1fr;
    display: grid;
  }

  .summary-pane {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 1rem, 1180px);
  }

  .hero,
  .unit-card,
  .study-tip,
  .quiz-section {
    padding: 1rem;
  }

  .top-nav {
    top: 0;
    border-radius: 24px;
  }

  .lesson-meta {
    grid-template-columns: 1fr;
  }

  .unit-header {
    flex-direction: column;
  }

  .unit-header img {
    width: 100%;
    max-width: 180px;
  }

  .large-unit-figure {
    padding: 0.7rem;
  }
}
