:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #181817;
  --muted: #797976;
  --soft: #a6a6a1;
  --line: #e5e4e0;
  --line-strong: #d4d3cf;
  --paper: #ffffff;
  --scene: #f1f0ed;
  --accent: #171716;
  --focus: #707c8d;
  --mono: 'DM Mono', 'SFMono-Regular', Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] { display: none !important; }

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  background: var(--scene);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.app-shell {
  display: grid;
  width: 100%;
  height: 100%;
  height: 100dvh;
  grid-template-columns: 310px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  z-index: 5;
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--paper);
  border-right: 1px solid var(--line);
  transition: transform 220ms ease;
}

.sidebar-header {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 19px 15px 21px;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  color: #252523;
  background: #f4f3f0;
  border: 1px solid #e9e8e4;
  border-radius: 10px;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.075em;
  line-height: 1.2;
  text-transform: uppercase;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.model-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: #686863;
  background: #f5f4f1;
  border: 1px solid #ecebe7;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.sidebar-content {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #d6d5d1 transparent;
  scrollbar-width: thin;
}

.control-section {
  padding: 15px 19px 16px 21px;
  border-bottom: 1px solid var(--line);
}

.section-heading-row {
  display: flex;
  min-height: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}

.section-heading {
  margin: 0;
  color: #363633;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-index {
  color: #b2b1ac;
  font-family: var(--mono);
  font-size: 9px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.choice-button,
.segment-button,
.tool-button,
.icon-button {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.choice-button {
  min-height: 34px;
  padding: 0 9px;
  color: #464642;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 500;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.choice-button:hover,
.tool-button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
}

.choice-button.is-active,
.choice-button[aria-pressed="true"] {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.choice-button svg,
.segment-button svg,
.tool-button svg,
.icon-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.35;
}

.choice-button-wide {
  grid-column: 1 / -1;
  justify-content: flex-start;
  padding-left: 12px;
}

.segmented-control {
  display: grid;
  min-height: 35px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 3px;
  background: #f5f4f1;
  border: 1px solid #ecebe7;
  border-radius: 8px;
}

.segment-button {
  min-height: 27px;
  padding: 0 5px;
  color: #777772;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  transition: color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.segment-button:hover {
  color: var(--ink);
}

.segment-button.is-active,
.segment-button[aria-pressed="true"] {
  color: #252523;
  background: #fff;
  box-shadow: 0 1px 3px rgb(30 30 25 / 10%);
}

.layer-list {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 9px;
  margin: 0;
  padding: 0;
  border: 0;
}

.check-row {
  position: relative;
  display: flex;
  min-height: 28px;
  align-items: center;
  gap: 8px;
  color: #585853;
  cursor: pointer;
  font-size: 11px;
  user-select: none;
}

.check-row input,
.section-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.check-box {
  position: relative;
  display: inline-grid;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  place-items: center;
  background: #fff;
  border: 1px solid #cfcec9;
  border-radius: 4px;
  transition: background 130ms ease, border-color 130ms ease;
}

.check-row input:checked + .check-box,
.section-toggle input:checked + .check-box {
  background: #20201f;
  border-color: #20201f;
}

.check-row input:checked + .check-box::after,
.section-toggle input:checked + .check-box::after {
  width: 7px;
  height: 4px;
  border-bottom: 1.5px solid white;
  border-left: 1.5px solid white;
  content: '';
  transform: translateY(-1px) rotate(-45deg);
}

.check-row input:focus-visible + .check-box,
.section-toggle input:focus-visible + .check-box {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.dimensions-row {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed #e7e6e2;
}

.display-modes {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.display-modes .segment-button {
  gap: 4px;
  font-size: 9px;
}

.display-modes .segment-button svg {
  width: 14px;
  height: 14px;
}

.range-control {
  margin-bottom: 15px;
}

.range-control-last {
  margin-bottom: 0;
}

.range-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #4d4d49;
  font-size: 11px;
}

.range-label-row label {
  cursor: pointer;
}

.range-label-row output {
  color: #696963;
  font-family: var(--mono);
  font-size: 10px;
}

input[type="range"] {
  display: block;
  width: 100%;
  height: 15px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  accent-color: #20201f;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: #e3e2de;
  border-radius: 99px;
}

input[type="range"]::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -5px;
  appearance: none;
  background: #222220;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #222220;
}

input[type="range"]::-moz-range-track {
  height: 3px;
  background: #e3e2de;
  border: 0;
  border-radius: 99px;
}

input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  background: #222220;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #222220;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  color: #9a9993;
  font-size: 9px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tool-button {
  min-height: 34px;
  padding: 0 8px;
  color: #43433f;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.tool-button svg {
  width: 15px;
  height: 15px;
  color: #555550;
}

.parts-section {
  padding-bottom: 17px;
}

.parts-section .section-heading-row {
  margin-bottom: 10px;
}

.count-pill {
  min-width: 21px;
  padding: 3px 6px;
  color: #777772;
  background: #f5f4f1;
  border-radius: 99px;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1;
  text-align: center;
}

.search-field {
  display: flex;
  height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.search-field:focus-within {
  border-color: #aaa9a4;
  box-shadow: 0 0 0 2px rgb(112 124 141 / 12%);
}

.search-field svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: #8c8b85;
  stroke-linecap: round;
  stroke-width: 1.5;
}

.search-field input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 11px;
}

.search-field input::placeholder {
  color: #9b9a94;
}

.search-shortcut {
  flex: 0 0 auto;
  padding: 3px 4px;
  color: #a2a19b;
  background: #f6f5f2;
  border: 1px solid #efeeea;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 8px;
}

.part-list {
  display: grid;
  max-height: 240px;
  overflow-y: auto;
  gap: 4px;
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
}

.part-list:empty {
  display: none;
}

.part-list button,
.part-list [role="button"] {
  display: flex;
  width: 100%;
  min-height: 31px;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  color: #484843;
  background: #fff;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 10px;
  text-align: left;
}

.part-list button:hover,
.part-list button[aria-selected="true"],
.part-list [role="button"]:hover {
  background: #f6f5f2;
  border-color: #e9e8e4;
}

.selected-panel {
  margin-top: 9px;
  padding: 10px;
  background: #f7f6f3;
  border: 1px solid #eeede9;
  border-radius: 8px;
}

.part-empty {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: #7b7a74;
}

.empty-icon {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  place-items: center;
  color: #898881;
  background: #eeede9;
  border-radius: 6px;
}

.empty-icon svg {
  width: 17px;
  height: 17px;
}

.part-empty p {
  margin: 1px 0 0;
  font-size: 10px;
  line-height: 1.5;
}

.part-detail:empty,
.part-detail h3:empty,
#part-details:empty {
  display: none;
}

#part-name:empty {
  display: none;
}

.part-detail h3 {
  margin: 0 0 7px;
  color: #272725;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

#part-details {
  color: #65645f;
  font-size: 10px;
  line-height: 1.55;
}

#part-details p {
  margin: 0 0 5px;
}

#part-details p:last-child {
  margin-bottom: 0;
}

#selected-panel.has-selection #part-empty,
#selected-panel:has(#part-name:not(:empty), #part-details:not(:empty)) #part-empty {
  display: none;
}

.source-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 20px 15px 21px;
  color: #797872;
  background: #fbfaf8;
  border-bottom: 1px solid var(--line);
}

.source-note svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 1px;
  fill: none;
  stroke: #8b8a84;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.25;
}

.source-note p {
  margin: 0;
  font-size: 9px;
  line-height: 1.5;
}

.sidebar-footer {
  display: flex;
  min-height: 39px;
  align-items: center;
  gap: 7px;
  padding: 0 21px;
  color: #96958f;
  font-family: var(--mono);
  font-size: 9px;
}

.footer-dot,
.footer-source-mark {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  background: #a6a59e;
  border-radius: 50%;
}

.stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--scene);
}

.stage-header {
  z-index: auto;
  display: flex;
  min-height: 76px;
  align-items: center;
  gap: 13px;
  padding: 13px 22px 12px 25px;
}

.stage-heading {
  min-width: 0;
}

.stage-heading .eyebrow {
  margin-bottom: 2px;
  color: #8c8b85;
  font-size: 9px;
}

.stage-heading h2 {
  margin: 0;
  overflow: hidden;
  color: #232321;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-heading #scene-subtitle {
  margin: 3px 0 0;
  color: #8a8983;
  font-size: 10px;
  line-height: 1.2;
}

.stage-tools {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
}

.status-pill {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  color: #6d6c67;
  background: rgb(255 255 255 / 66%);
  border: 1px solid #e4e3de;
  border-radius: 99px;
  font-size: 9px;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: #c8a35d;
  border-radius: 50%;
}

.status-pill[data-state="ready"] .status-dot {
  background: #69866e;
}

.status-pill[data-state="error"] .status-dot {
  background: #bd6258;
}

.icon-button {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  color: #4a4a45;
  background: rgb(255 255 255 / 76%);
  border: 1px solid #e0dfda;
  border-radius: 8px;
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.panel-toggle {
  display: none;
}

.scene-frame {
  position: relative;
  min-width: 0;
  min-height: 0;
  margin: 0 16px 11px;
  overflow: hidden;
  background: #e9e8e4;
  border: 1px solid #deddd8;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgb(33 33 29 / 3%);
}

.viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 46%, rgb(255 255 255 / 46%), transparent 57%),
    #e9e8e4;
  touch-action: none;
}

.viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: 0;
}

.touch-hint { display: none; }

@media (max-width: 900px) {
  .desktop-hint { display: none; }
  .touch-hint { display: inline; }
}

.loading-state {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #74736d;
  background: rgb(233 232 228 / 76%);
  font-size: 11px;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.loading-state[hidden] {
  display: none;
}

.loading-state.is-hidden {
  opacity: 0;
}

.loading-spinner {
  width: 15px;
  height: 15px;
  border: 1.5px solid #cbc9c2;
  border-top-color: #4a4a45;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.scene-controls-hint {
  position: absolute;
  z-index: 2;
  bottom: 13px;
  left: 50%;
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  color: #777670;
  background: rgb(255 255 255 / 87%);
  border: 1px solid rgb(218 217 212 / 90%);
  border-radius: 99px;
  box-shadow: 0 2px 8px rgb(31 31 28 / 5%);
  font-size: 9px;
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
}

kbd {
  padding: 2px 4px;
  color: #696862;
  background: #f1f0ec;
  border: 1px solid #e6e5e0;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 8px;
}

.hint-divider {
  width: 1px;
  height: 12px;
  background: #deddd8;
}

.section-toggle {
  position: absolute;
  z-index: 2;
  top: 13px;
  right: 13px;
  display: inline-flex;
  min-height: 31px;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  color: #676660;
  background: rgb(255 255 255 / 87%);
  border: 1px solid #deddd8;
  border-radius: 7px;
  cursor: pointer;
  font-size: 10px;
  box-shadow: 0 2px 8px rgb(31 31 28 / 4%);
}

.section-toggle .check-box {
  width: 14px;
  height: 14px;
}

.stage-footer {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 14px;
  padding: 0 21px 2px;
  color: #8d8c86;
  font-size: 9px;
}

.footer-source {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
}

.footer-source-mark {
  background: #9b9a94;
}

.footer-legend {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-left: auto;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
}

.legend-selected {
  background: #d1a654;
}

.legend-dim {
  background: #828178;
}

.footer-model-label {
  color: #999892;
  font-family: var(--mono);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
  border: 0;
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(310px, calc(100vw - 44px));
    max-width: 100%;
    box-shadow: 14px 0 40px rgb(28 28 24 / 10%);
    transform: translateX(-105%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .stage {
    width: 100%;
    height: 100%;
    height: 100dvh;
  }

  .stage-header {
    min-height: 70px;
    gap: 10px;
    padding: 11px 13px;
  }

  .panel-toggle {
    display: inline-flex;
  }

  .panel-toggle .icon-close {
    display: none;
  }

  body.sidebar-open .panel-toggle {
    position: fixed;
    top: 24px;
    left: min(263px, calc(100vw - 82px));
    z-index: 8;
    background: #fff;
    border-color: #e5e4e0;
  }

  body.sidebar-open .panel-toggle .icon-menu {
    display: none;
  }

  body.sidebar-open .panel-toggle .icon-close {
    display: block;
  }

  .stage-heading h2 {
    font-size: 14px;
  }

  .stage-heading #scene-subtitle {
    max-width: 44vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stage-tools {
    gap: 6px;
  }

  .status-pill {
    min-height: 25px;
    gap: 5px;
    padding: 0 7px;
    font-size: 8px;
  }

  .fit-button {
    display: none;
  }

  .scene-frame {
    margin: 0 8px 7px;
    border-radius: 8px;
  }

  .scene-controls-hint {
    bottom: 10px;
    gap: 7px;
    min-height: 30px;
    padding: 0 9px;
    font-size: 8px;
  }

  .stage-footer {
    min-height: 34px;
    gap: 8px;
    padding: 0 13px 1px;
    font-size: 8px;
  }

  .footer-legend {
    gap: 8px;
  }
}

@media (max-width: 420px) {
  .status-pill {
    max-width: 118px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stage-heading .eyebrow {
    font-size: 8px;
  }

  .scene-controls-hint {
    gap: 5px;
    font-size: 7px;
  }

  kbd {
    font-size: 7px;
  }

  .footer-model-label {
    display: none;
  }
}

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