:root {
  --ink: #e8ecf4;
  --ink-dim: #9aa7bd;
  --panel: rgba(13, 19, 32, 0.82);
  --line: rgba(140, 165, 200, 0.22);
  --accent: #6db3ff;
  --accent-warm: #ffb25e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: #111826;
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#scene { position: fixed; inset: 0; touch-action: none; }
#scene canvas { display: block; }

.panel {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Title block, top left */
#title {
  top: 18px; left: 18px;
  padding: 14px 18px;
  max-width: 340px;
}
#title h1 { font-size: 17px; font-weight: 650; letter-spacing: 0.2px; }
#title p { margin-top: 4px; font-size: 12.5px; color: var(--ink-dim); }
#title .credit { margin-top: 8px; font-size: 11.5px; color: var(--ink-dim); }
#title .credit a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(109,179,255,0.4); }
#title .credit a:hover { color: #8cc4ff; border-bottom-color: #8cc4ff; }

/* The control buttons, bottom center */
#controls {
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 10px;
  padding: 10px;
  border-radius: 18px;
}
#controls button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(38, 54, 82, 0.65);
  color: var(--ink);
  font: 600 14px/1 system-ui, sans-serif;
  padding: 13px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
#controls button:hover { background: rgba(62, 88, 132, 0.8); }
#controls button:active { transform: scale(0.97); }
#controls button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #08101f;
}
#controls button.primary:hover { background: #8cc4ff; }
#controls button[aria-pressed="true"]:not(.primary) {
  background: rgba(62, 88, 132, 0.9);
  border-color: var(--accent);
  color: #dfeaff;
}
#controls button[aria-pressed="false"]:not(.primary) { opacity: 0.72; }

/* The X-ray slice panel, right edge */
#slice {
  right: 18px; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 14px 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
  z-index: 15;
}
#slice.open { opacity: 1; pointer-events: auto; }
#slice label { font-size: 11.5px; color: var(--ink-dim); letter-spacing: 0.2px; }
#slice-slider {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 22px; height: 180px;
  accent-color: var(--accent);
  cursor: pointer;
}
#slice-axes { display: flex; gap: 6px; }
#slice-axes .axis {
  appearance: none;
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(38, 54, 82, 0.65);
  color: var(--ink-dim);
  font: 650 13px/1 system-ui, sans-serif;
  cursor: pointer;
}
#slice-axes .axis.active {
  background: var(--accent);
  color: #08101f;
  border-color: transparent;
}

/* Hint, bottom right */
#hint {
  bottom: 26px; right: 18px;
  padding: 9px 14px;
  font-size: 12px; color: var(--ink-dim);
}

/* The part card, bottom left */
#part-label {
  left: 18px; bottom: 20px;
  max-width: 350px;
  padding: 14px 16px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: none;
}
#part-label.visible { opacity: 1; transform: none; pointer-events: auto; cursor: pointer; }
#part-label strong { display: block; font-size: 15px; color: var(--accent-warm); margin-bottom: 5px; }
#part-label span { font-size: 13px; color: var(--ink); }

/* Loading veil */
#loading {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #111826;
  z-index: 30;
  color: var(--ink-dim);
  font-size: 14px;
  flex-direction: column; gap: 14px;
  transition: opacity 0.5s;
}
#loading.hidden { opacity: 0; pointer-events: none; }
#loading .ring {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  #title { max-width: 62vw; padding: 10px 14px; }
  #title h1 { font-size: 15px; }
  #title p { font-size: 11.5px; }
  #hint { display: none; }
  #part-label {
    max-width: 76vw; left: 12px; bottom: 96px;
    max-height: 32vh; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #controls {
    bottom: 12px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100vw - 24px);
    gap: 8px;
    padding: 8px;
  }
  #controls button { padding: 12px 13px; font-size: 13px; flex: 1 1 auto; white-space: nowrap; }
  #slice { right: 10px; }
  #slice-slider { height: 130px; }
}

@media (max-width: 420px) {
  #title { max-width: 74vw; }
  #title .desc { display: none; }   /* the one-line header carries the phone view; the credit stays */
  #controls button { padding: 12px 10px; font-size: 12.5px; }
}
