:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #000000;
  color: #f5f5f7;
  font-synthesis: none;
  --panel: #111111;
  --line: #222222;
  --muted: #888888;
  --accent: #ffffff;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: #000000; }

body {
  min-height: 100svh;
  overflow: hidden;
  background: #000000;
}

button, input { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100svh; display: grid; grid-template-rows: auto 1fr; }

.topbar {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 34px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(18px);
  position: relative;
  z-index: 5;
}

.identity { display: flex; align-items: center; gap: 15px; min-width: 0; }

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #000;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.05em;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .16em;
}

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.035em; }
h1 { font-size: clamp(1.12rem, 2.4vw, 1.42rem); }
h2 { font-size: 1.5rem; }

.load-state {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: .88rem;
  white-space: nowrap;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #a5a5a0; }
.load-state.is-ready .status-dot { background: #0a0a0a; }
.load-state.is-error .status-dot { background: #c9342f; }

.workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.viewer { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #f4f4f1; }

.viewer::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 44%, transparent 38%, rgba(0, 0, 0, .055) 100%);
}

#scene { width: 100%; height: 100%; display: block; touch-action: none; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgba(244, 244, 241, .88);
  z-index: 3;
  transition: opacity .45s ease, visibility .45s ease;
}

.loading.is-hidden { opacity: 0; visibility: hidden; }
.loading p { margin: 0; color: #4d4d49; }

.loading-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #d6d6d1;
  border-top-color: #000;
  animation: spin .8s linear infinite;
}

.progress-track { width: 180px; height: 3px; overflow: hidden; border-radius: 4px; background: #deded9; }
.progress-track span { display: block; width: 0; height: 100%; background: #000; transition: width .18s ease; }

.viewer-error {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: min(460px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  padding: 18px 20px;
  border: 1px solid #c9342f;
  border-radius: 10px;
  background: #fff;
  color: #861d19;
  line-height: 1.5;
}

.gesture-hint {
  position: absolute;
  left: 24px;
  bottom: 20px;
  z-index: 2;
  padding: 9px 14px;
  border: 1px solid #d2d2cd;
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  color: #5e5e59;
  font-size: .8rem;
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.control-panel {
  padding: 28px 25px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
}

.panel-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 25px; }
.index { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #cfcfca; border-radius: 50%; color: #5e5e59; font-size: .8rem; }

.primary-action, .secondary-action {
  width: 100%;
  min-height: 50px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}

.primary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #000;
  background: #000;
  color: #fff;
  font-weight: 700;
}

.secondary-action { margin-top: 10px; border: 1px solid #bcbcb6; background: #fff; }
.primary-action:hover, .secondary-action:hover { transform: translateY(-1px); }
.primary-action:hover { background: #272727; }
.secondary-action:hover { background: #f1f1ed; }
.primary-action:focus-visible, .secondary-action:focus-visible, .switch:focus-visible, .range:focus-visible { outline: 2px solid #000; outline-offset: 3px; }
.play-icon { font-size: .78rem; }

.range-label { display: flex; justify-content: space-between; margin: 26px 1px 10px; color: #333330; font-size: .92rem; }
.range-label output { color: #000; font-weight: 650; font-variant-numeric: tabular-nums; }
.range { width: 100%; accent-color: #000; cursor: pointer; }

.sequence-map { display: grid; grid-template-columns: auto 1fr auto 1fr auto; align-items: center; margin: 25px 0; }
.sequence-map div { display: grid; justify-items: center; gap: 7px; color: var(--muted); font-size: .72rem; }
.sequence-map div span { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid #bdbdb8; border-radius: 50%; color: #000; font-weight: 700; }
.sequence-map div b { font-weight: 560; }
.sequence-map i { height: 1px; margin: 0 7px 19px; background: #d4d4cf; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.setting-row strong { display: block; font-size: .9rem; font-weight: 650; }
.setting-row div > span { display: block; margin-top: 4px; color: var(--muted); font-size: .77rem; }

.switch { position: relative; flex: 0 0 auto; width: 44px; height: 25px; padding: 0; border: 1px solid #c5c5bf; border-radius: 999px; background: #e7e7e2; cursor: pointer; }
.switch span { position: absolute; left: 3px; top: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; border: 1px solid #c1c1bb; transition: transform .2s ease, background .2s ease; }
.switch.is-on { border-color: #000; background: #000; }
.switch.is-on span { transform: translateX(19px); background: #fff; border-color: #fff; }

.parts-key { display: grid; gap: 11px; margin-top: 21px; padding-top: 19px; border-top: 1px solid var(--line); color: #4c4c48; font-size: .83rem; }
.parts-key div { display: flex; align-items: center; gap: 9px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; border: 1px solid #888883; }
.swatch.case { background: #111; border-color: #111; }
.swatch.board { background: #74746f; }
.swatch.lid { background: #292929; border-color: #292929; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell { min-height: 100svh; }
  .topbar { height: 74px; padding: 0 16px; }
  .brand-mark { width: 40px; height: 40px; }
  .topbar .eyebrow { display: none; }
  h1 { font-size: 1rem; }
  .load-state { font-size: .76rem; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(430px, 58svh) auto; }
  .control-panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 23px 18px 31px; }
  .gesture-hint { left: 50%; bottom: 14px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 28px); text-align: center; }
  .panel-heading { margin-bottom: 18px; }
  .parts-key { grid-template-columns: 1fr 1fr; }
  .parts-key .eyebrow { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.embedded-viewer .topbar { display: none; }
.embedded-viewer .app-shell { height: 100svh; min-height: 0; grid-template-rows: 1fr; }
html:has(.hero-mode),
body.hero-mode { overflow: hidden; background: #000000 !important; }
.hero-mode .workspace { grid-template-columns: 1fr; height: 100%; }
.hero-mode .control-panel,
.hero-mode .gesture-hint { display: none; }
.hero-mode .viewer { background: #000000 !important; height: 100%; }
.hero-mode .viewer::after { background: radial-gradient(circle at 50% 48%, transparent 42%, rgba(0, 0, 0, .5) 100%); }
.hero-mode .loading { background: #000000; }
.hero-mode .loading p,
.hero-mode .progress-track { display: none; }
.hero-mode .loading-ring { border-color: #282828; border-top-color: #fff; }


/* Direct manipulation inside the hero viewer */
.hero-mode #scene { cursor: grab; }
.hero-mode #scene.is-dragging { cursor: grabbing; }
