:root {
  color-scheme: dark;
  --bg: #061a26;
  --surface: #0b2634;
  --line: rgba(216, 238, 244, 0.2);
  --ink: #edf7f8;
  --muted: #9fb4bc;
  --blue: #2aaee2;
  --blue-pale: #8bdcff;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); }
button, a { font: inherit; }

.study-shell { min-height: 100vh; padding: 16px; }
.study-stage {
  position: relative;
  min-height: calc(100vh - 32px);
  overflow: hidden;
  background: radial-gradient(circle at 58% 42%, #113b4d 0, #061a26 48%, #04131d 100%);
  border: 1px solid var(--line);
}

.study-header {
  position: absolute;
  z-index: 5;
  inset: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 64px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
}

.study-header p, .eyebrow, .scene-hint, .feature-index {
  margin: 0;
  color: var(--blue-pale);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.study-brand { color: var(--ink); font-family: var(--mono); font-weight: 700; letter-spacing: 0.1em; text-decoration: none; }
.study-brand::before { display: inline-block; width: 10px; height: 10px; margin-right: 9px; border: 2px solid var(--blue); content: ""; transform: rotate(45deg); }
#sanitary-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

.part-labels { position: absolute; z-index: 3; inset: 0; pointer-events: none; }
.part-labels button {
  position: absolute;
  display: grid;
  grid-template-columns: 24px auto;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  max-width: 190px;
  padding: 7px 10px;
  border: 1px solid rgba(139, 220, 255, 0.45);
  background: rgba(4, 20, 30, 0.9);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.94);
  transition: border-color 160ms ease, background 160ms ease, opacity 180ms ease, transform 180ms ease;
  cursor: pointer;
}
.part-labels button::before { position: absolute; top: 50%; width: 20px; height: 1px; background: rgba(139, 220, 255, 0.58); content: ""; }
.part-labels button::after { position: absolute; top: calc(50% - 3px); width: 7px; height: 7px; border: 1px solid var(--blue-pale); border-radius: 50%; background: var(--bg); content: ""; }
.part-labels button[data-side="left"]::before { right: -20px; }
.part-labels button[data-side="left"]::after { right: -26px; }
.part-labels button[data-side="right"]::before { left: -20px; }
.part-labels button[data-side="right"]::after { left: -26px; }
.part-labels span { color: var(--blue-pale); font-family: var(--mono); font-size: 9px; }
.part-labels strong { overflow: hidden; font-size: 11px; font-weight: 650; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.study-stage.is-exploded .part-labels button { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.study-stage.is-exploded .part-labels button.is-hidden { opacity: 0; pointer-events: none; }
.part-labels button:hover, .part-labels button.is-active { border-color: var(--blue-pale); background: rgba(12, 53, 70, 0.96); }
.part-labels button:focus-visible { outline: 2px solid var(--blue-pale); outline-offset: 3px; }

.scene-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(164, 220, 236, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(164, 220, 236, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent 78%);
}

.scene-loader { position: absolute; z-index: 6; inset: 0; display: grid; place-content: center; gap: 12px; background: #061a26; color: var(--blue-pale); transition: opacity 360ms ease, visibility 360ms ease; }
.scene-loader.is-complete { visibility: hidden; opacity: 0; }
.scene-loader__mark { width: 32px; height: 32px; margin: 0 auto; border: 2px solid rgba(139, 220, 255, 0.22); border-top-color: var(--blue-pale); border-radius: 50%; animation: scene-spin 900ms linear infinite; }
.scene-loader__text { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
@keyframes scene-spin { to { transform: rotate(360deg); } }

.study-copy { position: absolute; z-index: 2; top: 116px; left: clamp(24px, 4vw, 64px); max-width: 350px; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.study-stage.is-exploded .study-copy { opacity: 0; transform: translateY(-8px); }
.study-copy h1 { max-width: 320px; margin: 12px 0 14px; font-size: clamp(30px, 3.2vw, 54px); line-height: 0.98; letter-spacing: 0; }
.study-copy > p:last-child { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }

.study-controls { position: absolute; z-index: 3; bottom: 32px; left: clamp(24px, 4vw, 64px); display: inline-flex; border: 1px solid var(--line); background: rgba(5, 24, 35, 0.78); backdrop-filter: blur(12px); }
.study-controls button { min-width: 110px; min-height: 42px; padding: 0 14px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.study-controls button:last-child { border-right: 0; }
.study-controls button:hover, .study-controls button.is-active { background: var(--blue); color: #00131d; }
.study-controls button:focus-visible, .part-list button:focus-visible, .study-brand:focus-visible { outline: 2px solid var(--blue-pale); outline-offset: 4px; }

.assembly-panel { position: absolute; z-index: 4; right: clamp(24px, 4vw, 64px); bottom: 94px; width: min(330px, calc(100vw - 48px)); padding: 18px 20px 20px; border: 1px solid var(--line); background: rgba(6, 26, 38, 0.82); box-shadow: 0 16px 45px rgba(0, 0, 0, 0.2); backdrop-filter: blur(12px); }
.assembly-panel h2 { margin: 9px 0; font-size: 18px; }
.assembly-panel > p:not(.feature-index) { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.part-list { display: grid; gap: 6px; }
.part-list button { display: grid; grid-template-columns: 26px 1fr; gap: 9px; width: 100%; min-height: 36px; padding: 8px 0; border: 0; border-top: 1px solid rgba(216, 238, 244, 0.15); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.part-list button span { color: var(--blue-pale); font-family: var(--mono); font-size: 10px; }
.part-list button strong { font-size: 13px; font-weight: 600; }
.part-list button:hover strong, .part-list button.is-active strong { color: var(--blue-pale); }
.scene-hint { position: absolute; z-index: 2; right: 32px; bottom: 46px; color: var(--muted); }
.scene-hint span { color: var(--blue); padding: 0 9px; }

@media (max-width: 760px) {
  .study-shell { padding: 0; }
  .study-stage { min-height: 100svh; border: 0; }
  .study-header { min-height: 56px; padding: 0 18px; }
  .study-header p { font-size: 9px; }
  .study-copy { top: 74px; left: 14px; max-width: 280px; padding: 12px 14px 13px; border-left: 2px solid var(--blue); background: rgba(4, 18, 27, 0.86); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); }
  .study-copy h1 { max-width: 245px; margin: 8px 0 0; font-size: 30px; }
  .study-copy > p:last-child { display: none; }
  .study-controls { right: 18px; bottom: 18px; left: 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .study-controls button { min-width: 0; padding: 0 5px; font-size: 11px; }
  .scene-hint { display: none; }
  .assembly-panel { top: auto; right: 18px; bottom: 82px; left: 18px; width: auto; max-height: 34svh; overflow: auto; padding: 14px 16px; }
  .assembly-panel h2 { margin: 6px 0; font-size: 16px; }
  .study-stage.is-exploded .assembly-panel { bottom: 82px; max-height: none; padding: 10px 14px 11px; }
  .study-stage.is-exploded .assembly-panel > p:not(.feature-index) { margin-bottom: 0; font-size: 11px; line-height: 1.4; }
  .study-stage.is-exploded .assembly-panel .part-list { display: none; }
  .part-labels button { grid-template-columns: 20px minmax(0, 1fr); gap: 4px; min-width: 112px; max-width: 128px; min-height: 28px; padding: 5px 7px; }
  .part-labels strong { font-size: 9px; }
  .part-labels button::before { width: 12px; }
  .part-labels button[data-side="left"]::before { right: -12px; }
  .part-labels button[data-side="left"]::after { right: -18px; }
  .part-labels button[data-side="right"]::before { left: -12px; }
  .part-labels button[data-side="right"]::after { left: -18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
