:root {
  color-scheme: dark;
  --bg: #0d1014;
  --panel: rgba(18, 23, 29, 0.92);
  --panel-strong: #171d24;
  --text: #f4efe8;
  --muted: #abb4bb;
  --line: rgba(255, 255, 255, 0.12);
  --cortex: #d78374;
  --accent: #55c2b7;
  --gold: #d9b66f;
  --blue: #72a7ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #070a0d;
  color: var(--text);
  overflow: hidden;
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  min-height: 38px;
  padding: 0 13px;
  font: inherit;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

button:hover,
button.active {
  border-color: rgba(85, 194, 183, 0.75);
  background: rgba(85, 194, 183, 0.15);
}

button:active {
  transform: translateY(1px);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
  height: 100dvh;
}

.program-tabs {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  max-height: 28vh;
  overflow-y: auto;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 12, 16, 0.96);
  backdrop-filter: blur(18px);
}

.program-tab-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 5px;
  min-width: 0;
}

.program-tab {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  min-height: 35px;
  padding: 5px 7px;
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    rgba(255, 255, 255, 0.035);
}

.program-tab strong {
  overflow: hidden;
  color: inherit;
  font-size: 0.62rem;
  line-height: 1.16;
  text-overflow: ellipsis;
  white-space: normal;
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid rgba(85, 194, 183, 0.32);
  border-radius: 8px;
  background: rgba(85, 194, 183, 0.1);
  color: var(--accent);
  font-size: 0.54rem;
  font-weight: 950;
}

.tab-count {
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 900;
}

.program-tab.active {
  color: var(--text);
  border-color: rgba(85, 194, 183, 0.85);
  background:
    linear-gradient(145deg, rgba(85, 194, 183, 0.22), rgba(85, 194, 183, 0.08)),
    rgba(255, 255, 255, 0.045);
}

.program-tab.active .tab-icon {
  background: rgba(85, 194, 183, 0.22);
  color: var(--text);
}

.program-tab.active .tab-count {
  color: var(--accent);
}

.main-social-tab {
  min-height: 42px;
}

.main-social-tab strong {
  font-size: 0.68rem;
}

.language-switch {
  display: flex;
  gap: 6px;
}

.language-switch button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 900;
}

.theme-handbook {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10, 13, 18, 0.34);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.viewer {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 48% 46%, rgba(85, 194, 183, 0.13) 0%, rgba(85, 194, 183, 0.04) 24%, transparent 46%),
    radial-gradient(circle at 58% 54%, rgba(217, 182, 111, 0.1) 0%, rgba(217, 182, 111, 0.025) 24%, transparent 48%),
    linear-gradient(135deg, #141a21 0%, #0b0f13 48%, #06080b 100%);
}

.viewer::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.72), transparent 72%);
}

.viewer::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 0%, transparent 54%, rgba(0, 0, 0, 0.45) 100%),
    linear-gradient(90deg, rgba(85, 194, 183, 0.12), transparent 14%, transparent 86%, rgba(217, 182, 111, 0.08));
  mix-blend-mode: screen;
  opacity: 0.72;
}

#scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: grab;
  user-select: none;
}

#scene:active {
  cursor: grabbing;
}

.topbar {
  position: absolute;
  z-index: 3;
  top: 22px;
  left: 28px;
  right: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.topbar h1 {
  margin: 2px 0 0;
  max-width: min(760px, 58vw);
  font-size: clamp(1.75rem, 3.2vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0;
  color: var(--text);
  text-shadow: 0 10px 32px rgba(0, 0, 0, 0.34);
}

.brand-title {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.home-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-shadow: inherit;
  transition: opacity 0.15s;
}
.home-btn:hover { opacity: 0.75; }

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  padding: 6px 12px;
  background: rgba(85, 194, 183, 0.08);
  border: 1px solid rgba(85, 194, 183, 0.25);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.14s, background 0.14s, border-color 0.14s;
  width: fit-content;
}
.back-btn:hover {
  color: var(--text);
  background: rgba(85, 194, 183, 0.10);
  border-color: rgba(85, 194, 183, 0.30);
}

.creator-credit {
  margin: 8px 0 0 64px;
  max-width: min(520px, 52vw);
  color: rgba(244, 241, 233, 0.74);
  font-size: clamp(0.72rem, 0.95vw, 0.95rem);
  font-weight: 800;
  letter-spacing: 0;
  text-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
}

.brain-logo {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 38px;
  border: 2px solid rgba(85, 194, 183, 0.9);
  border-radius: 52% 48% 46% 54% / 58% 50% 50% 42%;
  background:
    radial-gradient(circle at 34% 35%, rgba(85, 194, 183, 0.5), transparent 22%),
    radial-gradient(circle at 66% 38%, rgba(217, 182, 111, 0.42), transparent 24%),
    rgba(85, 194, 183, 0.08);
  box-shadow: 0 0 28px rgba(85, 194, 183, 0.28);
}

.brain-logo::before,
.brain-logo::after {
  content: "";
  position: absolute;
  inset: 8px 9px;
  border-top: 2px solid rgba(244, 239, 232, 0.54);
  border-left: 2px solid rgba(244, 239, 232, 0.36);
  border-radius: 50%;
  transform: rotate(-18deg);
}

.brain-logo::after {
  inset: 10px 12px 8px 18px;
  border-left: 0;
  border-right: 2px solid rgba(244, 239, 232, 0.34);
  transform: rotate(20deg);
}

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

.view-actions-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: auto;
  position: relative;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(8, 10, 13, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 5px 6px;
  backdrop-filter: blur(16px);
}

.view-btn {
  min-height: 34px;
  min-width: 44px;
  padding: 0 10px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  border-radius: 7px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 100ms ease;
}

.view-btn:hover {
  background: rgba(85, 194, 183, 0.14);
  border-color: rgba(85, 194, 183, 0.5);
  color: var(--text);
}

.view-btn:active {
  transform: translateY(1px);
}

.view-btn--center {
  min-width: 62px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
}

.view-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.13);
  margin: 0 2px;
}

.view-btn--spin {
  font-size: 1rem;
  min-width: 38px;
  padding: 0;
  color: var(--accent);
  background: rgba(85, 194, 183, 0.08);
  border-color: rgba(85, 194, 183, 0.2);
}

.view-btn--spin:hover {
  background: rgba(85, 194, 183, 0.2);
  border-color: rgba(85, 194, 183, 0.6);
}

.view-btn--spin[data-spin="off"] {
  color: var(--gold);
  background: rgba(217, 182, 111, 0.1);
  border-color: rgba(217, 182, 111, 0.3);
}

.view-btn--spin[data-spin="off"]:hover {
  background: rgba(217, 182, 111, 0.2);
  border-color: rgba(217, 182, 111, 0.6);
}

.model-loader {
  position: absolute;
  z-index: 3;
  right: 28px;
  bottom: 82px;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid rgba(85, 194, 183, 0.45);
  border-radius: 7px;
  background: rgba(8, 10, 13, 0.6);
  backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.model-loader input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}


.legend {
  position: absolute;
  z-index: 3;
  left: 28px;
  right: 28px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(18, 23, 29, 0.78), rgba(8, 10, 13, 0.62));
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
  color: var(--muted);
  font-size: 0.8rem;
}

.layer-btn {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, opacity 140ms ease;
}

.layer-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.layer-btn.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.layer-btn:not(.active) {
  opacity: 0.45;
}

.layer-btn:not(.active):hover {
  opacity: 0.8;
}

#model-status {
  margin-left: auto;
  color: var(--gold);
  font-weight: 800;
}

.visit-counter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity 400ms ease;
}

.visit-counter::before {
  content: "👁";
  font-size: 0.7rem;
}

.visit-counter:empty {
  display: none;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 50%;
}

.dot.cortex {
  background: var(--cortex);
}

.dot.network {
  background: var(--accent);
}

.dot.subcortex {
  background: var(--gold);
}

.panel {
  z-index: 3;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(22px);
  padding: 20px;
}

.panel-section {
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--line);
}

.theme-section {
  order: -1;
  padding-top: 4px;
}

.panel-section:first-child {
  padding-top: 4px;
}

.panel h2,
.panel h3 {
  margin: 8px 0 8px;
  letter-spacing: 0;
}

.panel h2 {
  font-size: 1.55rem;
  line-height: 1.12;
}

.panel h3 {
  font-size: 1.05rem;
}

#region-summary,
#experiment-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.principal-function {
  display: grid;
  gap: 8px;
  padding: 16px 0 18px;
}

.principal-function h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
}

.principal-function p {
  padding: 13px;
  border: 1px solid rgba(85, 194, 183, 0.24);
  border-radius: 8px;
  background: rgba(85, 194, 183, 0.08);
}

#deep-copy {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.58;
}

#deep-purpose {
  margin: 12px 0 0;
  padding-left: 12px;
  border-left: 3px solid rgba(217, 182, 111, 0.64);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.facts {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}

.compact-facts {
  margin-top: 12px;
}

.facts div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
}

/* ── Category grid – initial panel state ──────────────── */
.cat-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 14px;
}
.cat-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, border-color 0.14s;
  width: 100%;
}
.cat-card:hover {
  background: rgba(85, 194, 183, 0.10);
  border-color: rgba(85, 194, 183, 0.32);
}
.cat-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0;
  color: #fff;
}
.cat-text { min-width: 0; }
.cat-name {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-hint {
  display: block;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deep-dive {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(85, 194, 183, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(85, 194, 183, 0.12), rgba(255, 255, 255, 0.035) 42%),
    rgba(255, 255, 255, 0.035);
}

.deep-dive h3 {
  margin-top: 0;
}

dt {
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 5px 0 0;
  color: var(--text);
  line-height: 1.35;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-title span {
  max-width: 58%;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
  text-align: right;
}

.region-list {
  display: grid;
  gap: 10px;
}

.theme-tabs,
.theme-detail {
  display: grid;
  gap: 12px;
}

.theme-intro {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.42;
}

.theme-tab-list {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scrollbar-width: thin;
}

.theme-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 38px;
  max-width: 180px;
  padding: 7px 10px;
  color: var(--muted);
  white-space: nowrap;
}

.theme-tab strong {
  overflow: hidden;
  color: inherit;
  font-size: 0.76rem;
  line-height: 1.1;
  text-overflow: ellipsis;
}

.theme-tab span {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 0.68rem;
  font-weight: 900;
}

.theme-tab.active {
  color: var(--text);
  border-color: rgba(85, 194, 183, 0.85);
  background: rgba(85, 194, 183, 0.18);
}

.theme-tab.active span {
  background: rgba(85, 194, 183, 0.28);
  color: var(--accent);
}

.social-function-list {
  display: grid;
  gap: 8px;
}

.social-function-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px;
  color: var(--muted);
  text-align: left;
}

.social-function-card strong,
.social-function-card small {
  display: block;
}

.social-function-card strong {
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.16;
}

.social-function-card small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.24;
}

.function-icon,
.function-count {
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-weight: 900;
}

.function-icon {
  width: 31px;
  height: 31px;
  border: 1px solid rgba(85, 194, 183, 0.34);
  background: rgba(85, 194, 183, 0.1);
  color: var(--accent);
  font-size: 0.7rem;
}

.function-count {
  min-width: 25px;
  height: 25px;
  background: rgba(217, 182, 111, 0.14);
  color: var(--gold);
  font-size: 0.72rem;
}

.social-function-card.active {
  color: var(--text);
  border-color: rgba(85, 194, 183, 0.85);
  background: rgba(85, 194, 183, 0.15);
}

.social-function-card.active .function-icon {
  background: rgba(85, 194, 183, 0.24);
  color: var(--text);
}

.theme-window-header {
  display: grid;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(85, 194, 183, 0.26);
  border-radius: 8px;
  background: rgba(85, 194, 183, 0.08);
}

.theme-window-header strong,
.theme-window-header span {
  display: block;
}

.theme-window-header strong {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.2;
}

.theme-window-header span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.theme-window-body {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.theme-window-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.theme-area-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
  color: var(--text);
}

.theme-area-title strong {
  font-size: 0.82rem;
}

.theme-area-title span {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(85, 194, 183, 0.14);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
}

.theme-guide {
  display: grid;
  gap: 8px;
  margin: 0;
}

.theme-guide div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(13, 16, 20, 0.32);
}

.theme-region-group {
  padding: 0;
}

.region-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.region-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.region-section summary::-webkit-details-marker {
  display: none;
}

.region-section summary::before {
  content: "+";
  display: grid;
  place-items: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(85, 194, 183, 0.32);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 900;
}

.region-section[open] summary::before {
  content: "-";
}

.region-section summary span {
  display: block;
  margin: 0;
  flex: 1;
}

.region-section summary strong {
  display: block;
  color: var(--text);
  font-size: 0.84rem;
}

.region-section summary small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.region-section summary i {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(85, 194, 183, 0.14);
  color: var(--accent);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
}

.region-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  padding: 0 10px 10px;
}

.theme-region-group button,
.zone-list button {
  min-height: 52px;
  padding: 8px 10px;
  text-align: left;
  color: var(--muted);
}

.theme-region-group button strong,
.zone-list button strong {
  display: block;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.1;
}

.theme-region-group button span,
.zone-list button span {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
}

.theme-region-group button small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.25;
}

.card-cite {
  display: block;
  margin-top: 5px;
  font-style: normal;
  font-size: 0.6rem;
  color: var(--muted);
  opacity: 0.55;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.social-function-card .card-cite {
  margin-top: 4px;
  font-size: 0.62rem;
}

.zone-filter {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.zone-filter input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

.side-tabs,
.zone-groups {
  display: flex;
  gap: 6px;
}

.side-tabs button,
.zone-groups button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.zone-groups {
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.zone-list {
  display: grid;
  gap: 8px;
  max-height: 312px;
  overflow: auto;
  padding-right: 4px;
}

.zone-list button {
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.zone-list button.active {
  color: var(--text);
}

.zone-list .side-pill {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 25px;
  border-radius: 999px;
  background: rgba(217, 182, 111, 0.14);
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 900;
}

.zone-list .zone-meta {
  color: var(--muted);
}

.zones-panel {
  position: absolute;
  z-index: 4;
  top: calc(100% + 6px);
  right: 0;
  width: 360px;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 0;
  border: 1px solid rgba(85, 194, 183, 0.28);
  border-radius: 12px;
  background: rgba(13, 16, 20, 0.92);
  backdrop-filter: blur(22px);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.48);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.zones-panel[aria-hidden="false"] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.zones-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.zones-panel-header small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
}

.zones-panel-header > span:last-child {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.zones-panel .zone-filter {
  margin: 10px 14px 0;
}

.zones-panel .zone-groups {
  margin: 8px 14px 0;
}

.zones-panel .zone-list {
  margin: 8px 14px 12px;
  max-height: 280px;
  padding-right: 2px;
}

.view-btn--zones {
  width: 100%;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: rgba(8, 10, 13, 0.55);
  border-color: rgba(85, 194, 183, 0.28);
  backdrop-filter: blur(16px);
  text-align: left;
  padding: 0 12px;
}

.view-btn--zones:hover,
.view-btn--zones.active {
  background: rgba(85, 194, 183, 0.14);
  border-color: rgba(85, 194, 183, 0.6);
  color: var(--text);
}

.task-stage {
  display: grid;
  place-items: center;
  height: 90px;
  margin: 16px 0 12px;
  border: 1px solid rgba(85, 194, 183, 0.34);
  border-radius: 7px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    rgba(12, 16, 20, 0.78);
  background-size: 26px 26px;
}

#task-stimulus {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(85, 194, 183, 0.14);
  color: var(--text);
  font-size: 2.6rem;
  font-weight: 800;
}

.task-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary {
  background: var(--accent);
  color: #06100f;
  border-color: transparent;
  font-weight: 800;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.metrics span {
  padding: 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.76rem;
}

.metrics strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 0.95rem;
}

/* ── Panel handle (hidden on desktop) ─────────────────── */
.panel-handle {
  display: none;
}

@media (max-width: 940px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    min-height: unset;
    height: 100dvh;
    overflow: hidden;
  }

  .program-tabs {
    position: sticky;
    top: 0;
    z-index: 10;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    max-height: none;
    overflow: hidden;
    padding: calc(6px + env(safe-area-inset-top)) 10px 7px;
  }

  .program-tab-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(148px, 52vw);
    grid-template-columns: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 3px;
    scroll-padding-inline: 10px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }

  .program-tab-list::-webkit-scrollbar {
    display: none;
  }

  .program-tab {
    min-height: 44px;
    scroll-snap-align: start;
  }

  .program-tab strong {
    font-size: 0.67rem;
  }

  .tab-icon {
    width: 25px;
    height: 25px;
  }

  .language-switch {
    justify-self: end;
    align-self: stretch;
    padding-left: 2px;
    background: rgba(9, 12, 16, 0.96);
  }

  .language-switch button {
    min-height: 44px;
    padding: 0 9px;
  }

  .viewer {
    min-height: 0;
    align-self: stretch;
  }

  .panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    height: 80dvh;
    max-height: 80dvh;
    border-radius: 20px 20px 0 0;
    border-left: 0;
    border-top: 1px solid rgba(85, 194, 183, 0.3);
    padding: 0 18px calc(env(safe-area-inset-bottom) + 24px);
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateY(calc(100% - 104px));
    transition: transform 340ms cubic-bezier(0.32, 0.72, 0, 1);
    overscroll-behavior: contain;
  }

  .panel.sheet-open {
    transform: translateY(0);
  }

  .panel-handle {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 36px;
    margin: 0 -18px 4px;
    background: var(--panel);
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .panel-handle span {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.26);
    transition: background 150ms ease;
  }

  .panel-handle:active span {
    background: rgba(85, 194, 183, 0.65);
  }

  .zone-list {
    max-height: none;
  }

  .topbar {
    top: 16px;
    left: 16px;
    right: 16px;
    gap: 12px;
  }

  .topbar h1 {
    max-width: 100%;
    font-size: 1.7rem;
  }

  .creator-credit {
    margin-left: 48px;
    max-width: 360px;
  }

  .view-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .legend {
    left: 16px;
    right: 16px;
    bottom: 90px;
  }

  .model-loader {
    right: 16px;
    bottom: 154px;
  }

  .theme-tab-list,
  .zone-list {
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 560px) {
  .topbar {
    left: 12px;
    right: 12px;
    flex-direction: column;
    gap: 9px;
  }

  .topbar h1 {
    font-size: 1.34rem;
  }

  .brand-title {
    gap: 9px;
  }

  .brain-logo {
    width: 34px;
    height: 27px;
    border-width: 1px;
  }

  .creator-credit {
    display: none;
  }

  .topbar .eyebrow {
    font-size: 0.62rem;
  }

  .view-actions-wrap {
    width: 100%;
  }

  .view-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
    width: 100%;
    gap: 4px;
    padding: 4px 5px;
  }

  .view-divider {
    display: none;
  }

  .view-btn {
    width: auto;
    min-width: 0;
    min-height: 34px;
    padding: 0 4px;
    font-size: 0.6rem;
  }

  .view-btn--spin {
    min-width: 34px;
    font-size: 0.9rem;
  }

  .view-btn--zones {
    font-size: 0.65rem;
    padding: 0 8px;
  }

  .zones-panel {
    width: 100%;
    max-height: 60vh;
  }

  .viewer {
    min-height: 0;
    max-height: none;
    align-self: stretch;
  }

  .legend {
    left: 12px;
    right: 12px;
    bottom: 90px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
    font-size: 0.68rem;
  }

  .model-loader {
    right: 12px;
    bottom: 154px;
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  #model-status {
    grid-column: 1 / -1;
    margin-left: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

  .zone-filter {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 0 16px calc(env(safe-area-inset-bottom) + 24px);
  }

  .panel h2 {
    font-size: 1.32rem;
  }

  .section-title {
    align-items: flex-start;
    gap: 8px;
  }

  .section-title span {
    text-align: right;
  }

  .theme-window-header,
  .theme-window-body,
  .deep-dive,
  .facts div {
    padding: 11px;
  }

  .zone-groups,
  .side-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .zone-groups::-webkit-scrollbar,
  .side-tabs::-webkit-scrollbar {
    display: none;
  }

  .zone-groups button,
  .side-tabs button {
    flex: 0 0 auto;
  }
}

@media (max-width: 940px) and (orientation: landscape) {
  .viewer {
    height: 100%;
    min-height: 0;
  }

  .topbar {
    top: 10px;
  }

  .creator-credit {
    display: none;
  }

  .legend {
    bottom: 90px;
  }

  .model-loader {
    bottom: 154px;
  }
}

/* ── Tooltip hover ─────────────────────────────────── */
.brain-tooltip {
  position: fixed;
  z-index: 900;
  padding: 7px 12px;
  border: 1px solid rgba(85, 194, 183, 0.48);
  border-radius: 8px;
  background: rgba(10, 13, 18, 0.95);
  backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.45;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 100ms ease, transform 100ms ease;
}

.brain-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.brain-tooltip strong {
  display: block;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  margin-bottom: 1px;
}

/* ── Botón Acerca ──────────────────────────────────── */
.about-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.08);
}

.about-btn:hover {
  color: var(--accent);
}

/* ── Modal Acerca ──────────────────────────────────── */
.about-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.about-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.about-modal {
  position: relative;
  max-width: 560px;
  width: 100%;
  padding: 28px 28px 24px;
  border: 1px solid rgba(85, 194, 183, 0.28);
  border-radius: 14px;
  background: rgba(13, 18, 26, 0.98);
  color: var(--text);
  transform: translateY(16px);
  transition: transform 200ms ease;
}

.about-overlay.open .about-modal {
  transform: translateY(0);
}

.about-modal h2 {
  margin: 0 0 2px;
  font-size: 1.42rem;
  color: var(--accent);
  letter-spacing: 0;
}

.about-eyebrow {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.82rem;
}

.about-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
  border-radius: 8px;
}

.about-facts {
  display: grid;
  gap: 9px;
  margin: 0;
}

.about-facts > div {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.about-facts dt {
  margin-bottom: 3px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.about-facts dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

/* ── Mobile category strip (hidden on desktop) ─────────── */
.mobile-cats {
  display: none;
}

@media (max-width: 940px) {
  /* Hide tiny top category tabs — replaced by mobile strip */
  .program-tab-list {
    display: none;
  }

  /* Category strip inside the sheet */
  .mobile-cats {
    position: sticky;
    top: 36px;
    z-index: 1;
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 6px 18px 10px;
    margin: 0 -18px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-cats::-webkit-scrollbar {
    display: none;
  }

  .mobile-cat-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 0 0 auto;
    min-width: 58px;
    min-height: 52px;
    padding: 6px 8px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-size: 0.58rem;
    font-weight: 800;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 140ms, background 140ms;
    line-height: 1.2;
  }

  .mobile-cat-btn .cat-icon {
    display: block;
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    color: var(--accent);
  }

  .mobile-cat-btn.active {
    border-color: rgba(85, 194, 183, 0.85);
    background: rgba(85, 194, 183, 0.18);
    color: var(--text);
  }

  .mobile-cat-btn.active .cat-icon {
    color: var(--text);
  }

  /* Sub-function cards: 2-column grid on mobile */
  .social-function-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .social-function-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 84px;
    padding: 10px 6px;
    text-align: center;
  }

  .social-function-card .function-count {
    display: none;
  }

  .social-function-card strong {
    font-size: 0.76rem;
    line-height: 1.18;
  }

  .social-function-card small,
  .social-function-card .card-cite {
    display: none;
  }

  .social-function-card .function-icon {
    width: 28px;
    height: 28px;
    font-size: 0.64rem;
  }

  /* Hide verbose intro sections on mobile — navigation first */
  .theme-intro,
  .theme-window-header,
  .theme-window-body,
  .theme-area-title {
    display: none;
  }
}

/* ── Anatomical illustration overlay ─────────────────── */
.davinci-overlay {
  position: absolute;
  bottom: 78px;
  left: 14px;
  z-index: 8;
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: #000;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 380ms cubic-bezier(0.16, 1, 0.3, 1), transform 380ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.65);
}

.davinci-overlay.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.davinci-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.20);
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.92rem;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.davinci-close:hover {
  background: rgba(0, 0, 0, 0.80);
  color: rgba(255, 255, 255, 0.92);
}

.davinci-sketch-wrap {
  width: 100%;
  line-height: 0;
  position: relative;
}

/* ── Zone anatomical pin overlay ─────────────────────── */
.zone-pin {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 280ms;
}
.zone-pin.visible { opacity: 1; }

.zone-pin__ring {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  transform: translate(-50%, -50%) scale(1);
  animation: pin-pulse 1.9s ease-out infinite;
}
.zone-pin__ring--b { animation-delay: 0.95s; }

@keyframes pin-pulse {
  0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.85; }
  75%  { transform: translate(-50%, -50%) scale(3.4); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(3.4); opacity: 0; }
}

.zone-pin__dot {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px var(--accent), 0 0 2px var(--accent);
}

.zone-pin__label {
  position: absolute;
  font-family: "Courier New", Courier, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.80);
  padding: 3px 7px;
  border-radius: 3px;
  white-space: nowrap;
  margin: 0;
  transform: translate(0, -50%);
}

.davinci-sketch-img {
  display: block;
  width: 100%;
  height: auto;
}

.davinci-caption {
  min-height: 88px;
  overflow: hidden;
  padding: 10px 36px 10px 12px;
  box-sizing: border-box;
  background: rgba(6, 8, 11, 0.94);
  backdrop-filter: blur(12px);
}

.davinci-eyebrow {
  display: block;
  margin: 0 0 6px;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--accent);
}

.davinci-annotation {
  margin: 0;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 0.80rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.72);
}

.davinci-cursor {
  display: inline-block;
  width: 7px;
  height: 0.88em;
  background: var(--accent);
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: davinci-blink 0.65s step-end infinite;
}

@keyframes davinci-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@media (max-width: 940px) {
  .davinci-overlay { bottom: 122px; }
}

@media (max-width: 560px) {
  .davinci-overlay { bottom: 122px; left: 10px; }
}
