:root {
  color: #17212b;
  background: #f3f5f6;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; background: #f3f5f6; }
button, summary { font: inherit; }
button { cursor: pointer; }
button:focus { outline: none; }
button:focus-visible, summary:focus-visible, .wordmark:focus-visible { outline: 3px solid #0b6f76; outline-offset: 3px; }

.site-header {
  width: min(1440px, calc(100% - 48px));
  height: 72px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #d7dde0;
}

.wordmark { color: #17212b; font-weight: 720; letter-spacing: -0.04em; text-decoration: none; font-size: 1.15rem; }
.wordmark span { color: #0b6f76; }
.site-header p { margin: 0; color: #61707a; font-size: 0.825rem; }

.app-shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 22px; }
.intro { max-width: 650px; margin-bottom: 24px; }
.eyebrow, .section-label, .summary-kicker { margin: 0 0 9px; color: #0b6f76; font-size: 0.72rem; font-weight: 760; letter-spacing: 0.11em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.03; letter-spacing: -0.055em; }
.intro > p:last-child { max-width: 590px; margin-bottom: 0; color: #50606b; font-size: 1rem; line-height: 1.55; }

.viewer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: stretch; }
.stage-frame { position: relative; min-height: 590px; overflow: hidden; border: 1px solid #d1d9dc; border-radius: 18px; background: #e6eaeb; box-shadow: 0 22px 45px rgb(42 57 65 / 0.1); }
model-viewer { display: block; width: 100%; height: 100%; min-height: 590px; background: radial-gradient(circle at 50% 42%, #fcfdfd 0%, #e4e9ea 74%); }
.model-fallback { display: grid; place-content: center; gap: 7px; width: 100%; height: 100%; min-height: 590px; color: #52616a; text-align: center; background: #e6eaeb; }
.model-fallback strong { color: #27333b; }

.load-state { position: absolute; top: 18px; left: 18px; right: 18px; display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 8px 11px; border: 1px solid #d4dbdd; border-radius: 10px; background: rgb(252 253 253 / 0.92); color: #40505a; font-size: 0.83rem; box-shadow: 0 4px 12px rgb(40 54 59 / 0.08); }
.load-state.is-ready { opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
.load-state.is-error { border-color: #d89b9b; color: #8d2929; }
.load-indicator { width: 9px; height: 9px; flex: none; border-radius: 999px; background: #0b6f76; }
.load-state.is-error .load-indicator { background: #b33b3b; }
.text-button { margin-left: auto; padding: 4px 0; border: 0; color: #0a6269; background: transparent; font-size: inherit; font-weight: 700; text-decoration: underline; }
.is-hidden { display: none; }

.stage-actions { position: absolute; right: 16px; bottom: 16px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; max-width: calc(100% - 32px); }
.control-button, .secondary-button, .segmented-control button { border: 1px solid #ccd5d8; border-radius: 10px; color: #26333b; background: #fdfefe; font-size: 0.82rem; font-weight: 680; line-height: 1; transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease; }
.control-button { min-height: 36px; padding: 0 11px; box-shadow: 0 4px 10px rgb(40 54 59 / 0.08); }
.control-button:hover, .secondary-button:hover { border-color: #80a4a7; background: #f3f9f8; }
.control-button:active, .secondary-button:active, .segmented-control button:active { transform: translateY(1px); }

.control-panel { padding: 24px; border: 1px solid #d1d9dc; border-radius: 18px; background: #fbfcfc; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 10px; color: #4f5d66; font-size: 0.79rem; font-weight: 700; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid #d5dcdf; border-radius: 12px; background: #edf0f1; }
.segmented-control button { min-height: 38px; border-color: transparent; background: transparent; }
.segmented-control button[aria-selected="true"] { border-color: #0b6f76; color: #064f54; background: #e0f0ee; }

.model-summary { margin: 28px 0; padding: 20px 0; border-top: 1px solid #dce2e4; border-bottom: 1px solid #dce2e4; }
.model-summary h2 { margin-bottom: 8px; font-size: 1.25rem; letter-spacing: -0.025em; }
.model-summary p:last-child { margin-bottom: 0; color: #586771; font-size: 0.9rem; line-height: 1.45; }
.summary-kicker { color: #697a83; }
.view-presets { margin-bottom: 28px; }
.preset-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
.secondary-button { min-height: 36px; padding: 0 6px; }

.legend { margin-bottom: 20px; }
.legend dl { margin: 0; display: grid; gap: 10px; }
.legend dl > div { display: flex; justify-content: space-between; gap: 12px; color: #40505a; font-size: 0.82rem; }
.legend dt { display: flex; align-items: center; gap: 7px; }
.legend dd { margin: 0; color: #64737c; font-variant-numeric: tabular-nums; }
.swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid #aeb9bc; }
.swatch-white { background: #fff; }
.swatch-red { border-color: #b84444; background: #be3d3d; }
.swatch-black { border-color: #26343a; background: #26343a; }
.swatch-yellow { border-color: #caa11e; background: #e0bc30; }
.band-key { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 15px 0 0; color: #5c6b74; font-size: 0.77rem; line-height: 1.5; }
.one-band, .two-bands { display: inline-block; width: 16px; height: 10px; border-top: 2px solid #0b6f76; }
.two-bands { margin-left: 5px; border-bottom: 2px solid #0b6f76; }

.help-panel { padding-top: 17px; border-top: 1px solid #dce2e4; color: #586771; font-size: 0.84rem; line-height: 1.5; }
.help-panel summary { color: #2f4049; font-weight: 720; cursor: pointer; }
.help-panel p { margin: 10px 0 0; }
.detail-panel { display: contents; }
.site-footer { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 0 0 26px; color: #697880; font-size: 0.78rem; }

@media (max-width: 980px) {
  .viewer-layout { grid-template-columns: 1fr; }
  .control-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 24px; align-items: start; }
  .model-summary { margin: 0; }
  .view-presets, .legend, .help-panel { margin: 0; }
  .view-presets { grid-column: 1; }
  .legend, .help-panel { grid-column: 2; }
  .help-panel { padding-top: 0; border-top: 0; }
}

@media (max-width: 640px) {
  .site-header, .app-shell, .site-footer { width: min(100% - 28px, 1440px); }
  .site-header { height: 64px; }
  .site-header p { display: none; }
  .app-shell { padding-top: 20px; }
  .intro { margin-bottom: 16px; }
  .intro .eyebrow { margin-bottom: 6px; }
  .intro h1 { margin-bottom: 7px; font-size: 1.85rem; }
  .intro > p:last-child { font-size: 0.9rem; line-height: 1.42; }
  .viewer-layout { display: flex; flex-direction: column; gap: 16px; }
  .control-panel { display: contents; }
  .model-picker { order: -1; padding: 16px; border: 1px solid #d1d9dc; border-radius: 14px; background: #fbfcfc; }
  .detail-panel { display: block; padding: 19px; border: 1px solid #d1d9dc; border-radius: 14px; background: #fbfcfc; }
  .stage-frame, model-viewer, .model-fallback { min-height: min(68dvh, 520px); }
  .stage-frame { border-radius: 14px; }
  .model-summary { margin: 22px 0; padding: 17px 0; }
  .view-presets { margin-bottom: 22px; }
  .legend { margin-bottom: 20px; }
  .help-panel { padding-top: 17px; border-top: 1px solid #dce2e4; }
  .stage-actions { left: 12px; right: 12px; bottom: 12px; gap: 5px; }
  .control-button { flex: 1 1 auto; padding: 0 8px; }
  .load-state { top: 12px; left: 12px; right: 12px; }
}

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