:root {
  --header-height: 302px;
  --frame-margin: 18px;
  --ink: #160907;
  --muted: #3f2719;
  --line: #9b6a1f;
  --surface: #ffffff;
  --surface-soft: #fff8e6;
  --blue: #700b06;
  --blue-soft: #fff0c7;
  --teal: #8b1209;
  --green: #7b5b37;
  --rose: #9f1d0f;
  --amber: #c58b19;
  --burgundy: #700b06;
  --burgundy-dark: #5a0805;
  --accent-soft: rgba(112, 11, 6, 0.24);
  --shadow: 0 12px 28px rgba(89, 43, 8, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f7ecd0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

button {
  font: inherit;
}

a {
  color: var(--blue);
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  max-width: 1500px;
  margin: 18px var(--frame-margin) 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(89, 43, 8, 0.12);
  overflow: hidden;
}

.sidebar {
  grid-column: 1;
  grid-row: 1;
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100%;
  padding: 24px;
  border-radius: 13px 0 0 13px;
  background: linear-gradient(180deg, var(--burgundy), var(--burgundy-dark));
  color: #ffffff;
  box-shadow: inset -1px 0 0 rgba(255, 231, 163, 0.16);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 241, 184, 0.28);
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #f4c542;
  color: #3a0905;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.brand p {
  margin: 5px 0 0;
  color: #f5d9a0;
  font-size: 0.86rem;
}

.menu-label {
  display: block;
  margin: 24px 0 8px;
  color: #ffe7a3;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #ffffff;
  text-decoration: none;
}

.side-nav a:hover,
.side-nav a:focus-visible {
  border-color: rgba(255, 241, 184, 0.42);
  background: rgba(255, 241, 184, 0.14);
  color: #ffffff;
  outline: 0;
}

.side-nav span {
  display: block;
  margin-top: 2px;
  color: #ffe7a3;
  font-size: 0.78rem;
}

.mobile-section-select {
  display: none;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 241, 184, 0.62);
  border-radius: 8px;
  background: #fff7dc;
  color: var(--burgundy);
  font: inherit;
  font-weight: 800;
}

.content {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  padding: 28px;
  background: #fff8e6;
}

.page-header {
  margin: 8px var(--frame-margin) 0;
  min-height: var(--header-height);
  padding: 8px;
  border-radius: 14px;
  background: var(--burgundy);
  overflow: hidden;
}

.image-banner {
  display: grid;
  min-height: 286px;
  place-items: center start;
  border-radius: 14px;
  background: var(--burgundy);
  overflow: hidden;
  text-decoration: none;
}

.image-banner img {
  display: block;
  width: min(1120px, 100%);
  height: auto;
  max-width: 1120px;
}

.hero {
  min-height: 0;
  padding: 20px;
  border: 1px solid #d99a1a;
  border-radius: 14px;
  background: #fff3cf;
  color: var(--ink);
  box-shadow: none;
}

.hero-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.hero h1 {
  margin: 8px 0 0;
  max-width: none;
  color: #1f0805;
  font-size: clamp(34px, 3.2vw, 46px);
  line-height: 1.12;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--burgundy);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: var(--burgundy);
}

.hero-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
}

.hero-action {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border: 1px solid #d99a1a;
  border-radius: 7px;
  color: #260803;
  font-weight: 800;
  text-decoration: none;
}

.hero-action.primary {
  border-color: var(--burgundy);
  background: var(--burgundy);
  color: #ffffff;
}

.hero-action.secondary {
  background: #f4c542;
}

.hero-note {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid #d99a1a;
  border-radius: 7px;
  background: #fff7dc;
}

.subtitle {
  max-width: none;
  margin: 0;
  line-height: 1.55;
  color: #2e1b10;
  font-size: 15px;
}

.section {
  margin-top: 26px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  color: var(--burgundy);
  font-size: 28px;
}

.section-copy {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-weight: 600;
}

.puzzle-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1fr);
  gap: 18px;
}

.puzzle-pool,
.puzzle-target {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.puzzle-pool h3,
.puzzle-target h3 {
  margin: 0 0 12px;
  color: var(--burgundy);
}

.puzzle-options,
.sequence-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.sequence-list {
  list-style: none;
}

.puzzle-option,
.sequence-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: left;
}

.puzzle-option {
  color: var(--ink);
  cursor: pointer;
}

.puzzle-option:hover,
.puzzle-option:focus-visible {
  border-color: var(--blue);
  background: var(--blue-soft);
  outline: none;
}

.puzzle-option.used {
  display: none;
}

.sequence-item.correct {
  border-color: var(--green);
  background: #fff5dd;
}

.sequence-item.wrong {
  border-color: var(--rose);
  background: #ffe6dc;
}

.step-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #f0c95f;
  color: #4f0704;
  font-weight: 800;
}

.puzzle-text strong,
.puzzle-text span {
  display: block;
}

.puzzle-text strong {
  color: var(--burgundy);
  margin-bottom: 3px;
}

.puzzle-text span {
  color: var(--muted);
  line-height: 1.55;
  font-weight: 600;
}

.remove-step {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--rose);
  cursor: pointer;
  font-weight: 800;
}

.puzzle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.map {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.node {
  flex: 1 1 0;
  min-width: 0;
  max-width: 190px;
  min-height: 98px;
  padding: 14px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  box-shadow: 0 8px 20px rgba(89, 43, 8, 0.08);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.node:hover,
.node.active,
.node:focus-visible {
  background: var(--blue-soft);
  border-color: var(--blue);
  outline: none;
  transform: translateY(-3px);
}

.node strong {
  display: block;
  color: var(--burgundy);
  font-size: clamp(14px, 1.05vw, 16px);
  margin-bottom: 6px;
}

.node span {
  display: block;
  color: var(--muted);
  font-size: clamp(12px, 0.9vw, 13px);
  line-height: 1.35;
  font-weight: 600;
}

.arrow {
  color: var(--blue);
  flex: 0 0 auto;
  font-size: 22px;
  font-weight: 800;
}

.hpa-mobile-carousel {
  display: none;
}

.hpa-carousel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.hpa-carousel-control {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--burgundy);
  cursor: pointer;
  font: inherit;
  font-size: 23px;
  font-weight: 800;
}

.hpa-carousel-status {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.hpa-carousel-card {
  min-height: 240px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--burgundy);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.hpa-carousel-card h3 {
  margin: 10px 0 8px;
  color: var(--burgundy);
}

.hpa-carousel-card p {
  margin: 10px 0;
  color: var(--ink);
  line-height: 1.55;
}

.hpa-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
}

.hpa-carousel-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #d8bc74;
  cursor: pointer;
}

.hpa-carousel-dot.active {
  background: var(--burgundy);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 18px;
  align-items: stretch;
}

.info-card,
.summary-card,
.mode-card,
.box,
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.info-card {
  min-height: 250px;
  padding: 24px;
  border-left: 6px solid var(--blue);
}

.info-card.compact {
  min-height: 190px;
  margin-top: 16px;
}

.info-card h3,
.mode-card h3,
.box h3 {
  margin: 10px 0 8px;
  color: var(--burgundy);
}

.info-card p,
.mode-card p,
.box p,
.source-note p {
  margin: 10px 0;
  line-height: 1.6;
  color: var(--ink);
}

.tag {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff5dd;
  color: var(--burgundy);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid #e0c175;
}

.summary-card {
  padding: 22px;
}

.summary-card h3 {
  margin-top: 0;
  color: var(--burgundy);
}

.mini-list {
  margin-bottom: 0;
  padding-left: 20px;
  line-height: 1.7;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.toggle,
.answer,
.primary-action,
.secondary-action {
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.toggle.active,
.answer.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--burgundy);
}

.toggle:focus-visible,
.answer:focus-visible,
.primary-action:focus-visible,
.secondary-action:focus-visible,
.remove-step:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

.mode-card {
  min-height: 210px;
  padding: 24px;
  border-top: 6px solid var(--green);
}

.mode-card:not([data-mode]) {
  display: none;
}

.mode-card[data-mode="chronic"] {
  border-top-color: var(--rose);
}

.pathway {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 14px;
  margin: 18px 0 4px;
}

.pathway span {
  position: relative;
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff5dd;
  color: #5a2e14;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.mode-card[data-mode="chronic"] .pathway span {
  background: #ffe6dc;
  color: var(--burgundy);
}

.pathway span:not(:last-child)::after {
  content: ">";
  position: absolute;
  top: 50%;
  right: -11px;
  transform: translateY(-50%);
  color: var(--muted);
}

.brain-map-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(280px, 0.72fr);
  gap: 18px;
  align-items: stretch;
}

.brain-map-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.brain-map-layout .info-card.compact {
  height: 100%;
  margin-top: 0;
}

.brain-region-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.brain-region-control {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.brain-region-control.active,
.brain-region-control:hover,
.brain-region-control:focus-visible {
  border-color: var(--burgundy);
  background: var(--blue-soft);
  color: var(--burgundy);
  outline: none;
}

.brain-map {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 320px;
  border: 1px solid #e5c574;
  border-radius: 8px;
  background: #ffffff;
}

.brain-map img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: contain;
}

.brain-pointer {
  position: absolute;
  left: 56%;
  top: 58%;
  width: 0;
  height: 0;
  pointer-events: none;
  transition: left 0.25s ease, top 0.25s ease;
}

.pointer-label {
  position: absolute;
  left: var(--label-x, 34px);
  top: var(--label-y, -68px);
  padding: 7px 10px;
  border: 2px solid var(--burgundy);
  border-radius: 999px;
  background: #fff7dc;
  color: var(--burgundy);
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(89, 43, 8, 0.16);
}

.brain-pointer::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: var(--arrow-length, 72px);
  height: 2px;
  background: var(--burgundy);
  transform: rotate(var(--arrow-angle, -48deg));
  transform-origin: left center;
}

.brain-pointer::after {
  content: "";
  position: absolute;
  left: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  border: 3px solid var(--burgundy);
  border-radius: 50%;
  background: rgba(255, 247, 220, 0.72);
}

.brain-map[data-active="hippocampus"] .brain-pointer {
  left: 56%;
  top: 50%;
  --label-x: 34px;
  --label-y: -68px;
  --arrow-length: 76px;
  --arrow-angle: -52deg;
}

.brain-map[data-active="amygdala"] .brain-pointer {
  left: 50%;
  top: 60%;
  --label-x: -118px;
  --label-y: -34px;
  --arrow-length: 94px;
  --arrow-angle: -168deg;
}

.brain-map[data-active="prefrontal"] .brain-pointer {
  left: 40%;
  top: 32%;
  --label-x: 28px;
  --label-y: -92px;
  --arrow-length: 92px;
  --arrow-angle: -46deg;
}

.stress-types,
.effects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 16px;
}

.stress-card {
  min-height: 190px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--amber);
  border-radius: 8px;
  background: var(--surface);
}

.stress-card h3 {
  margin: 0 0 8px;
  color: var(--burgundy);
}

.stress-card p {
  margin: 8px 0;
  line-height: 1.52;
  color: var(--ink);
}

.stress-card strong {
  color: var(--ink);
}

.box {
  padding: 20px;
  border-top: 5px solid var(--teal);
}

.effects .box:nth-child(2) {
  border-top-color: var(--blue);
}

.effects .box:nth-child(3) {
  border-top-color: var(--rose);
}

.quiz-card {
  padding: 24px;
}

.quiz-progress {
  display: inline-block;
  margin-bottom: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff5dd;
  color: var(--burgundy);
  font-size: 13px;
  font-weight: 800;
  border: 1px solid #e0c175;
}

#questionText {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.45;
}

#questionText[hidden] {
  display: none;
  margin: 0;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.answer.correct {
  border-color: var(--green);
  background: #fff5dd;
}

.answer.incorrect {
  border-color: var(--rose);
  background: #ffe6dc;
}

.quiz-feedback {
  min-height: 28px;
  color: var(--ink);
  font-weight: 700;
}

.quiz-feedback[hidden] {
  display: none;
  min-height: 0;
}

.quiz-result {
  margin-top: 0;
  margin-bottom: 18px;
}

.quiz-result h3 {
  margin: 0 0 8px;
  color: var(--burgundy);
}

.quiz-result p {
  margin: 8px 0;
  line-height: 1.55;
}

.primary-action {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-action {
  background: var(--surface);
  color: var(--blue);
  border-color: var(--line);
}

.source-note {
  margin-top: 24px;
  padding: 18px;
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}

.site-footer {
  margin: 0 var(--frame-margin) 18px;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--burgundy), var(--burgundy-dark));
  color: #ffffff;
}

.site-footer p {
  margin: 0;
  padding: 14px 18px;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 900px) {
  :root {
    --header-height: auto;
    --frame-margin: 12px;
  }

  .page-header {
    margin: 12px;
    min-height: 0;
    padding: 0;
    border-radius: 12px;
    background: transparent;
  }

  .image-banner {
    min-height: 0;
    border-radius: 12px;
    background: transparent;
  }

  .image-banner img {
    width: 100%;
    max-width: 100%;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    margin: 12px;
    border-radius: 12px;
  }

  .sidebar {
    grid-column: 1;
    grid-row: 1;
    position: static;
    min-height: 0;
    padding: 14px;
    border-radius: 12px 12px 0 0;
  }

  .brand {
    display: none;
  }

  .menu-label {
    margin: 0 0 8px;
  }

  .mobile-section-select {
    display: block;
  }

  .side-nav {
    display: none;
  }

  .content {
    grid-column: 1;
    grid-row: 2;
    padding: 18px;
  }

  .hero-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-actions {
    display: none;
  }

  .hero h1 {
    white-space: normal;
  }

  .hero-note {
    margin-top: 16px;
    padding: 12px;
  }

  .hero-note .subtitle {
    font-size: 15px;
    line-height: 1.45;
  }

  .puzzle-workspace,
  .brain-map-layout {
    grid-template-columns: 1fr;
  }

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

  .site-footer {
    margin: 0 12px 12px;
    border-radius: 12px;
  }
}

@media (max-width: 700px) {
  .app {
    padding: 16px 12px 30px;
  }

  .hero,
  .section {
    padding: 20px;
  }

  #hpa .map,
  #hpa .content-grid {
    display: none;
  }

  .hpa-mobile-carousel {
    display: block;
  }

  .arrow {
    transform: rotate(90deg);
  }

  .node {
    flex: 0 1 auto;
    width: 100%;
    max-width: 340px;
  }

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

  .pathway span:not(:last-child)::after {
    content: "v";
    top: auto;
    right: 50%;
    bottom: -14px;
    transform: translateX(50%);
  }

  .brain-map {
    min-height: 260px;
  }

  .brain-map img {
    min-height: 260px;
  }

  .brain-pointer {
    width: 130px;
    transform: scale(0.86);
    transform-origin: left top;
  }

  .sequence-item,
  .puzzle-option {
    grid-template-columns: 1fr;
  }
}
