* {
  box-sizing: border-box;
}

/* Match meninges / other atlas structure viewers: full-bleed under fixed 60px nav. */
body.neuron-structure-page {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #020810;
  color: #c8f0e0;
}

body.neuron-structure-page #page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  position: relative;
  z-index: 1;
}

.neuron-structure-main {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
  padding-top: calc(60px + env(safe-area-inset-top, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  background: #020810;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

#root {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #020810;
  color: #c8f0e0;
}

html[data-theme="day"] body.neuron-structure-page,
html.atlas-day body.neuron-structure-page,
html[data-theme="day"] .neuron-structure-main,
html.atlas-day .neuron-structure-main,
html[data-theme="day"] #root,
html.atlas-day #root {
  background: #faf8f4;
  color: #2a1a08;
}

html[data-theme="day"],
html.atlas-day,
html[data-theme="day"] body,
html.atlas-day body {
  background: #faf8f4;
  color: #2a1a08;
}

html[data-theme="day"] #creator-credit,
html.atlas-day #creator-credit {
  color: rgba(42, 26, 8, 0.55) !important;
}

@media (max-width: 640px) {
  #creator-credit {
    right: max(0.65rem, env(safe-area-inset-right, 0px)) !important;
    bottom: max(0.5rem, env(safe-area-inset-bottom, 0px)) !important;
    left: auto !important;
    font-size: 0.5rem !important;
    letter-spacing: 0.08em !important;
    z-index: 15 !important;
  }

  #info-panel {
    top: auto !important;
    bottom: 2.35rem !important;
    left: 0.75rem !important;
    right: 0.75rem !important;
    width: auto !important;
    max-width: none !important;
    max-height: min(36vh, 320px) !important;
    transform: translateY(110%) !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition:
      transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
      visibility 0s linear 0.45s !important;
  }

  #info-panel.is-open {
    transform: none !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition:
      transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
      visibility 0s !important;
  }
}

/* Part info panel — keep inside iframe; long English/AZ text wraps and scrolls */
#info-panel {
  box-sizing: border-box !important;
  width: min(280px, calc(100vw - 24px)) !important;
  max-height: min(86vh, 680px) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
}

#panel-name,
#panel-overview,
#panel-detail {
  overflow-wrap: break-word;
  word-wrap: break-word;
  max-width: 100%;
  white-space: pre-line;
}

#panel-name {
  padding-right: 28px;
}

#panel-overview,
#panel-detail {
  padding-right: 4px;
  font-family: monospace;
  font-size: 0.68rem;
  font-weight: 300;
  line-height: 1.75;
  letter-spacing: 0.02em;
  color: rgba(200, 200, 200, 0.88);
}

.panel-more {
  display: inline-block;
  margin: 0.75rem 0 0;
  padding: 0;
  border: none;
  background: transparent;
  color: #7af0e0;
  font-family: monospace;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.panel-more:hover {
  text-decoration: underline;
}

.panel-detail-wrap {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(126, 207, 179, 0.22);
}

html.atlas-day .panel-detail-wrap {
  border-top-color: rgba(10, 10, 10, 0.15);
}

html.atlas-day .panel-more {
  color: #e05a10 !important;
}

/* Night — description card: clear edges, mint/teal frame (matches AXON night accents) */
html:not(.atlas-day) #info-panel {
  background: rgba(6, 14, 26, 0.78) !important;
  border: 1px solid rgba(126, 207, 179, 0.42) !important;
  border-radius: 6px !important;
  box-shadow:
    0 0 0 1px rgba(0, 255, 204, 0.1),
    0 10px 36px rgba(0, 0, 0, 0.55) !important;
  backdrop-filter: blur(10px);
}

html:not(.atlas-day) #panel-close {
  color: rgba(160, 220, 195, 0.75) !important;
}

html:not(.atlas-day) #panel-close:hover {
  color: rgba(200, 245, 225, 0.95) !important;
}

/* Part info panel — day: solid card, black frame, high-contrast “marker” text */
html.atlas-day #info-panel {
  background: #fffef4 !important;
  border-left: none !important;
  border: 3px solid #0a0a0a !important;
  border-radius: 4px !important;
  box-shadow: 6px 6px 0 rgba(10, 10, 10, 0.12) !important;
}

html.atlas-day #panel-close {
  color: #0a0a0a !important;
  font-weight: 700 !important;
  -webkit-text-stroke: 0.4px #fffef4;
  paint-order: stroke fill;
}

html.atlas-day #panel-name {
  color: #0a0a0a !important;
  font-weight: 800 !important;
  -webkit-text-stroke: 0.65px #fffef4;
  paint-order: stroke fill;
  text-shadow: 0.04em 0.04em 0 rgba(10, 10, 10, 0.18);
}

html.atlas-day #panel-overview,
html.atlas-day #panel-detail {
  color: #0a0a0a !important;
  font-weight: 600 !important;
  -webkit-text-stroke: 0.45px #fffef4;
  paint-order: stroke fill;
  text-shadow: 0.03em 0.03em 0 rgba(10, 10, 10, 0.12);
}

/* Floating structure name — same pattern as meninges / white-matter */
.structure-label {
  position: absolute;
  z-index: 22;
  left: 0;
  top: 0;
  max-width: min(16rem, 70vw);
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-family: monospace;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  line-height: 1.35;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-theme="day"] .structure-label,
html.atlas-day .structure-label {
  background: #fffef4;
  border: 3px solid #0a0a0a;
  color: #0a0a0a;
  font-weight: 600;
}

/* Hover part name — day: same cream + black marker frame as #info-panel */
html.atlas-day .neyron-hover-tooltip {
  background: #fffef4 !important;
  border: 3px solid #0a0a0a !important;
  border-radius: 4px !important;
  box-shadow: 6px 6px 0 rgba(10, 10, 10, 0.12) !important;
  color: #0a0a0a !important;
  font-weight: 600 !important;
  -webkit-text-stroke: 0.45px #fffef4;
  paint-order: stroke fill;
  text-shadow: 0.03em 0.03em 0 rgba(10, 10, 10, 0.12);
}

.r3f-root {
  width: 100%;
  height: 100%;
}

.neuron-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.neuron-scene canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.neuron-description-panel {
  position: fixed;
  top: 16px;
  right: 16px;
  width: min(420px, calc(100vw - 32px));
  max-height: min(72vh, 640px);
  overflow: auto;
  padding: 1rem 2.5rem 1rem 1.1rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.neuron-description-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.25;
  padding-right: 0.25rem;
  color: #7dd3fc;
}

.neuron-description-panel p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #cbd5e1;
}

.neuron-description-panel__empty {
  color: #94a3b8;
  font-style: italic;
}

.neuron-description-panel__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(51, 65, 85, 0.65);
  color: #e2e8f0;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.neuron-description-panel__close:hover {
  background: rgba(71, 85, 105, 0.9);
}

/* Readable sans for the description text; labels keep the mono face. */
#panel-overview,
#panel-detail {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
