:root {
  color-scheme: light;
  --ink: #24302d;
  --muted-ink: #66706c;
  --cream: #f4efe7;
  --paper: #fffdf9;
  --sage: #8da598;
  --sage-dark: #536d61;
  --taupe: #b7a995;
  --line: rgba(52, 67, 62, 0.14);
  --shadow: 0 20px 60px rgba(71, 65, 54, 0.13);
  --focus: #245f91;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--cream);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 7%, rgba(225, 185, 156, 0.28), transparent 25rem),
    radial-gradient(circle at 94% 22%, rgba(141, 165, 152, 0.23), transparent 28rem),
    var(--cream);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
canvas:focus-visible,
summary:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  color: white;
  background: #173e34;
  border-radius: 0.75rem;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(1600px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 2.5vw, 2.5rem) 1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  position: relative;
  flex: 0 0 auto;
  width: 3.1rem;
  height: 3.1rem;
  border: 1px solid rgba(36, 48, 45, 0.14);
  background: var(--paper);
  border-radius: 1rem;
  box-shadow: 0 8px 24px rgba(74, 68, 57, 0.12);
}

.brand-mark span {
  position: absolute;
  border-radius: 50%;
}

.brand-mark span:nth-child(1) {
  inset: 0.7rem 1.55rem 0.7rem 0.55rem;
  background: #d98572;
}

.brand-mark span:nth-child(2) {
  inset: 0.55rem 0.55rem 1.35rem 1.45rem;
  background: #7d9da0;
}

.brand-mark span:nth-child(3) {
  inset: 1.45rem 0.75rem 0.55rem 1.25rem;
  background: #9daf8f;
}

.eyebrow,
.section-label,
.fact-label {
  margin: 0;
  color: var(--sage-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0.08rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.08;
}

h2,
h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.quiet-button,
.view-button,
.control-button,
.icon-button,
.read-button,
.part-button {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.quiet-button:hover,
.view-button:hover,
.control-button:hover,
.icon-button:hover,
.read-button:hover,
.part-button:hover {
  transform: translateY(-1px);
}

.quiet-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.9rem;
  background: rgba(255, 253, 249, 0.78);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 750;
}

.contrast-icon {
  width: 1.05rem;
  height: 1.05rem;
  background: linear-gradient(90deg, var(--ink) 50%, var(--paper) 50%);
  border: 1px solid var(--ink);
  border-radius: 50%;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(20rem, 0.75fr);
  gap: 1rem;
  align-items: stretch;
}

.brain-card,
.info-card {
  overflow: hidden;
  background: rgba(255, 253, 249, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 1.6rem;
  box-shadow: var(--shadow);
}

.brain-card {
  display: flex;
  min-height: 44rem;
  flex-direction: column;
  padding: clamp(1rem, 2vw, 1.4rem);
}

.stage-heading,
.part-heading,
.picker-heading,
.slider-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.stage-heading {
  padding: 0 0.15rem 0.85rem;
}

.stage-heading h2,
.part-heading h2 {
  margin: 0.15rem 0 0;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  line-height: 1.12;
}

.view-switch {
  display: flex;
  flex: 0 0 auto;
  gap: 0.2rem;
  padding: 0.25rem;
  background: #ebe7df;
  border-radius: 999px;
}

.view-button {
  min-height: 2.4rem;
  padding: 0.45rem 0.9rem;
  background: transparent;
  border-color: transparent;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 760;
}

.view-button.is-active {
  background: var(--paper);
  box-shadow: 0 3px 12px rgba(50, 50, 40, 0.12);
}

.brain-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 28rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.96) 0 16%, rgba(239, 234, 225, 0.65) 62%, rgba(224, 218, 207, 0.35) 100%),
    linear-gradient(#faf8f4, #f3efe8);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  isolation: isolate;
}

.brain-stage::before {
  position: absolute;
  z-index: -1;
  right: -8%;
  bottom: -22%;
  left: -8%;
  height: 44%;
  background: linear-gradient(160deg, transparent 34%, rgba(141, 165, 152, 0.1) 35% 53%, transparent 54%);
  content: "";
}

.brain-visual {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 28rem;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.brain-visual.is-dragging {
  cursor: grabbing;
}

.brain-visual.is-hovering-part:not(.is-dragging) {
  cursor: pointer;
}

.brain-visual.has-model-error {
  cursor: default;
  background: url("assets/brain-assembled.png") center 48% / min(82%, 42rem) auto no-repeat;
}

.brain-visual.has-model-error::after {
  opacity: 0.08;
}

.brain-visual::after {
  position: absolute;
  z-index: 0;
  right: 20%;
  bottom: 6%;
  left: 20%;
  height: 7%;
  background: rgba(44, 53, 48, 0.14);
  border-radius: 50%;
  content: "";
  filter: blur(1rem);
  pointer-events: none;
  transform: scaleX(calc(1 + var(--brain-separation, 0) * 0.34));
  transition: opacity 180ms ease, transform 180ms ease;
}

.brain-visual.is-dragging::after {
  opacity: 0.1;
}

#brain-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 320ms ease;
}

#brain-canvas.is-ready {
  opacity: 1;
}

.model-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  gap: 0.8rem;
  width: min(88%, 22rem);
  margin: 0;
  color: var(--sage-dark);
  font-size: 0.84rem;
  font-weight: 780;
  text-align: center;
  transform: translate(-50%, -50%);
}

.model-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.loading-brain {
  position: relative;
  display: block;
  width: 4.1rem;
  height: 3.35rem;
  animation: loading-float 1.65s ease-in-out infinite;
}

.loading-brain i {
  position: absolute;
  display: block;
  background: #d98572;
  border-radius: 52% 48% 44% 56%;
  box-shadow: inset -0.3rem -0.3rem 0 rgba(101, 68, 61, 0.1);
}

.loading-brain i:nth-child(1) {
  inset: 0 48% 18% 0;
}

.loading-brain i:nth-child(2) {
  inset: 0 0 18% 48%;
  background: #80a7c9;
  transform: scaleX(-1);
}

.loading-brain i:nth-child(3) {
  inset: 58% 19% 0 20%;
  background: #91ad8a;
  border-radius: 48%;
}

@keyframes loading-float {
  0%,
  100% {
    transform: translateY(0) rotate(-1.5deg);
  }

  50% {
    transform: translateY(-0.35rem) rotate(1.5deg);
  }
}

.part-tooltip {
  position: absolute;
  z-index: 6;
  max-width: 11rem;
  padding: 0.38rem 0.58rem;
  color: var(--ink);
  background: rgba(255, 253, 249, 0.96);
  border: 1px solid rgba(42, 52, 49, 0.18);
  border-radius: 0.6rem;
  box-shadow: 0 0.4rem 1.1rem rgba(47, 49, 42, 0.16);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(0.65rem, calc(-100% - 0.65rem));
  transition: opacity 100ms ease;
}

.part-tooltip.is-visible {
  opacity: 1;
}

.stage-badge,
.view-state {
  position: absolute;
  z-index: 7;
  pointer-events: none;
  user-select: none;
}

.stage-badge {
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.65rem;
  color: var(--muted-ink);
  background: rgba(255, 253, 249, 0.84);
  border: 1px solid rgba(60, 70, 65, 0.12);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  font-size: 0.79rem;
  font-weight: 740;
}

.drag-symbol {
  color: var(--sage-dark);
  font-size: 1rem;
}

.view-state {
  right: 0.75rem;
  bottom: 0.75rem;
  padding: 0.42rem 0.68rem;
  color: var(--sage-dark);
  background: rgba(255, 253, 249, 0.9);
  border: 1px solid rgba(60, 70, 65, 0.12);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  font-size: 0.78rem;
  font-weight: 800;
}

.model-controls {
  display: grid;
  grid-template-columns: auto minmax(12rem, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 0.1rem 0.25rem;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.control-button,
.icon-button,
.read-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  background: #f5f2ec;
  border-radius: 0.8rem;
  font-size: 0.88rem;
  font-weight: 780;
}

.control-button-primary {
  color: white;
  background: #536d61;
  border-color: #536d61;
}

.control-button-primary:hover {
  background: #425a50;
}

.icon-button {
  min-width: 5rem;
}

.separation-control {
  display: block;
  min-width: 0;
  color: var(--muted-ink);
  font-size: 0.78rem;
  font-weight: 730;
}

.slider-label-row output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  --slider-progress: 0%;
  appearance: none;
  width: 100%;
  height: 2rem;
  margin: 0.1rem 0 0;
  background: transparent;
  cursor: ew-resize;
  touch-action: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 0.55rem;
  background: linear-gradient(90deg, var(--sage-dark) 0 var(--slider-progress), #d9d5cd var(--slider-progress) 100%);
  border: 1px solid rgba(36, 48, 45, 0.16);
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: -0.45rem;
  background: var(--paper);
  border: 0.23rem solid var(--sage-dark);
  border-radius: 50%;
  box-shadow: 0 0.28rem 0.65rem rgba(36, 48, 45, 0.25);
  cursor: grab;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

input[type="range"]::-moz-range-track {
  height: 0.55rem;
  background: #d9d5cd;
  border: 1px solid rgba(36, 48, 45, 0.16);
  border-radius: 999px;
}

input[type="range"]::-moz-range-progress {
  height: 0.55rem;
  background: var(--sage-dark);
  border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  background: var(--paper);
  border: 0.23rem solid var(--sage-dark);
  border-radius: 50%;
  box-shadow: 0 0.28rem 0.65rem rgba(36, 48, 45, 0.25);
  cursor: grab;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.separation-control.is-scrubbing input[type="range"]::-webkit-slider-thumb {
  box-shadow: 0 0 0 0.35rem rgba(83, 109, 97, 0.16), 0 0.38rem 0.8rem rgba(36, 48, 45, 0.28);
  cursor: grabbing;
  transform: scale(1.12);
}

.separation-control.is-scrubbing input[type="range"]::-moz-range-thumb {
  box-shadow: 0 0 0 0.35rem rgba(83, 109, 97, 0.16), 0 0.38rem 0.8rem rgba(36, 48, 45, 0.28);
  cursor: grabbing;
  transform: scale(1.12);
}

.separation-control.is-scrubbing output {
  color: var(--sage-dark);
  font-weight: 850;
}

.interaction-tip {
  margin: 0.65rem 0 0;
  padding: 0.65rem 0.8rem;
  color: #58635f;
  background: rgba(141, 165, 152, 0.11);
  border-radius: 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.interaction-tip strong {
  color: var(--sage-dark);
}

.info-card {
  padding: clamp(1rem, 2vw, 1.4rem);
}

.large-swatch {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border: 4px solid rgba(255, 255, 255, 0.92);
  border-radius: 0.9rem;
  box-shadow: 0 0 0 1px var(--line), 0 8px 16px rgba(54, 54, 46, 0.12);
}

.part-summary {
  margin: 1rem 0;
  color: #45504c;
  font-size: 1.02rem;
  line-height: 1.65;
}

.fact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.fact-card {
  min-height: 7.7rem;
  padding: 0.85rem;
  background: #f5f2ec;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
}

.fact-card p:last-child {
  margin: 0.48rem 0 0;
  color: #3d4945;
  font-size: 0.88rem;
  line-height: 1.5;
}

.detail-actions {
  display: grid;
  gap: 0.65rem;
  margin: 0.8rem 0 1.1rem;
}

.read-button {
  width: 100%;
  background: #eef2ef;
  border-color: rgba(83, 109, 97, 0.2);
}

.grown-up-detail {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

.grown-up-detail summary {
  min-height: 2.75rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 780;
}

.grown-up-detail p {
  margin: 0;
  padding: 0 0.85rem 0.85rem;
  color: #55605c;
  font-size: 0.83rem;
  line-height: 1.55;
}

.part-picker {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.picker-heading h3 {
  margin: 0;
  font-size: 1.05rem;
}

.picker-heading span {
  color: var(--muted-ink);
  font-size: 0.75rem;
  font-weight: 700;
}

.part-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.part-button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.55rem 0.62rem;
  color: #42504b;
  background: transparent;
  border-radius: 0.7rem;
  font-size: 0.78rem;
  font-weight: 730;
  line-height: 1.25;
  text-align: left;
}

.part-button.is-selected {
  color: var(--ink);
  background: #f1eee8;
  border-color: rgba(67, 85, 78, 0.28);
  box-shadow: inset 3px 0 0 var(--part-color);
}

.part-button-swatch {
  flex: 0 0 auto;
  width: 0.72rem;
  height: 0.72rem;
  background: var(--part-color);
  border: 1px solid rgba(36, 48, 45, 0.22);
  border-radius: 50%;
}

footer {
  margin: 0.85rem 0 0;
  padding: 0 0.25rem;
  color: #69736f;
  font-size: 0.75rem;
  text-align: center;
}

footer p {
  margin: 0;
}

.model-credit {
  margin-top: 0.22rem;
  color: #7a827f;
  font-size: 0.75rem;
}

.model-credit a {
  color: inherit;
  text-underline-offset: 0.14em;
}

.model-credit a:hover {
  color: var(--ink);
}

.noscript-message {
  position: fixed;
  inset: 1rem;
  z-index: 20;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 1rem;
  color: white;
  background: #26342f;
  border-radius: 1rem;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body.high-contrast {
  --ink: #0a0a0a;
  --muted-ink: #222;
  --cream: #fff;
  --paper: #fff;
  --sage-dark: #163f2d;
  --line: rgba(0, 0, 0, 0.42);
  --shadow: 0 0 0 2px #111;
  --focus: #005fcc;
  background: white;
}

body.high-contrast .brain-stage,
body.high-contrast .fact-card,
body.high-contrast .interaction-tip,
body.high-contrast .view-switch,
body.high-contrast .control-button,
body.high-contrast .read-button {
  background: white;
}

body.high-contrast .control-button-primary {
  color: white;
  background: #111;
}

body.high-contrast .part-tooltip {
  color: #000;
  background: #fff;
  border-color: #000;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(0, 1.4fr) minmax(18rem, 0.8fr);
  }

  .model-controls {
    grid-template-columns: 1fr auto;
  }

  .action-buttons {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 0.8rem 0.7rem 1rem;
  }

  .topbar {
    align-items: flex-start;
    padding: 0 0.25rem;
  }

  .brand-mark {
    width: 2.7rem;
    height: 2.7rem;
  }

  .quiet-button {
    min-width: 2.75rem;
    padding: 0.65rem;
    font-size: 0;
  }

  .contrast-icon {
    width: 1.15rem;
    height: 1.15rem;
  }

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

  .brain-card {
    min-height: 0;
  }

  .brain-stage,
  .brain-visual {
    min-height: min(58vh, 32rem);
  }

  .info-card {
    overflow: visible;
  }
}

@media (max-width: 540px) {
  body {
    font-size: 16px;
  }

  .topbar {
    margin-bottom: 0.7rem;
  }

  .eyebrow {
    font-size: 0.66rem;
  }

  h1 {
    font-size: 1.35rem;
  }

  .brain-card,
  .info-card {
    border-radius: 1.2rem;
  }

  .stage-heading {
    align-items: flex-end;
  }

  .stage-heading h2 {
    font-size: 1.22rem;
  }

  .view-button {
    padding-inline: 0.7rem;
    font-size: 0.8rem;
  }

  .brain-stage,
  .brain-visual {
    min-height: min(52vh, 27rem);
  }

  .stage-badge {
    top: 0.55rem;
    left: 0.55rem;
  }

  .model-controls {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .action-buttons,
  .separation-control,
  .icon-button {
    grid-column: 1;
  }

  .action-buttons > * {
    flex: 1 1 0;
  }

  .icon-button {
    width: 100%;
  }

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

  .fact-card {
    min-height: 0;
  }
}

@media (max-width: 370px) {
  .brand-mark {
    display: none;
  }

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

  .view-switch {
    align-self: flex-start;
  }

  .part-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
 .host-back-link{position:fixed;top:.65rem;left:.75rem;z-index:1000;display:inline-flex;align-items:center;border:1px solid rgba(41,41,41,.14);border-radius:999px;background:rgba(255,255,255,.92);color:#292929;padding:.5rem .8rem;font-size:.78rem;font-weight:700;text-decoration:none;box-shadow:0 6px 18px rgba(41,41,41,.1);backdrop-filter:blur(10px)}.host-back-link:hover{background:#fff}.host-back-link:focus-visible{outline:3px solid #9e7a26;outline-offset:3px}@media(max-width:720px){.host-back-link{position:relative;top:auto;left:auto;margin:.65rem .75rem 0}}
