:root {
  --ink: #10232f;
  --ink-2: #173646;
  --paper: #f5fbff;
  --paper-2: #e7f4fb;
  --line: rgba(37, 97, 128, 0.18);
  --muted: #5d7c8f;
  --accent: #84cef2;
  --accent-soft: #b9e7fa;
  --white: #fafdff;
  --shadow: 0 30px 70px rgba(7, 9, 8, 0.16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--ink);
  color: var(--ink);
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.app-shell {
  width: 100%;
  height: 100svh;
  min-height: 620px;
  display: grid;
  grid-template-rows: 74px minmax(0, 1fr) 68px;
  background: var(--paper);
}

.display-mode .app-shell { grid-template-rows: 74px minmax(0, 1fr); }
.display-mode .bottom-controls { display: none; }

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  color: var(--white);
  background: #0e2650;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand {
  width: min(184px, 44vw);
  height: 44px;
  display: flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  /* Display the three cropped logo elements in white on the navy bar. */
  filter: grayscale(1) invert(1);
  mix-blend-mode: screen;
}

.guide-picker { min-width: 0; }
.guide-picker-panel { display: flex; gap: 8px; min-width: 0; }
.guide-picker-heading, .guide-picker-trigger, .guide-picker-backdrop { display: none; }
.guide-field { display: flex; align-items: center; gap: 8px; min-width: 0; padding-left: 10px; border: 1px solid #ffffff38; border-radius: 7px; background: var(--ink-2); }
.guide-field > span { color: #bad0dc; font-size: 11px; white-space: nowrap; }
.guide-field select, .guide-model-button { min-height: 38px; border: 0; border-radius: 6px; background: transparent; color: inherit; font-size: 13px; cursor: pointer; }
.guide-field select { padding: 0 8px 0 0; }
.guide-field select option { background: var(--ink-2); }
.guide-model-field { position: relative; }
.guide-model-button { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; width: clamp(125px, 19vw, 240px); padding: 0 11px 0 0; text-align: left; }
.guide-model-button span, .guide-picker-trigger strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guide-model-button::after, .guide-picker-trigger::after { content: ""; flex: none; width: 7px; height: 7px; margin: -4px 2px 0 0; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.guide-picker :disabled { opacity: .55; cursor: default; }
.guide-model-menu { position: absolute; z-index: 1; top: calc(100% + 9px); right: 0; display: grid; gap: 8px; width: min(370px, calc(100vw - 32px)); padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); box-shadow: 0 14px 35px #10232f38; }
.guide-model-menu input { width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-size: 14px; }
.guide-model-results { max-height: min(52dvh, 380px); overflow: auto; overscroll-behavior: contain; }
.guide-model-row { display: flex; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); }
.guide-model-row:first-child { border-top: 0; }
.guide-model-option { display: grid; flex: 1; gap: 3px; min-width: 0; min-height: 44px; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: inherit; text-align: left; font-size: 14px; cursor: pointer; }
.guide-model-option small { color: var(--muted); font-size: 11px; }
.guide-model-option[aria-current="true"] { background: var(--paper-2); font-weight: 650; }
.guide-model-option:hover, .guide-model-versions summary:hover { background: var(--paper-2); }
.guide-model-versions { flex: none; }
.guide-model-versions summary { display: flex; align-items: center; min-height: 44px; padding: 0 8px; border-radius: 6px; color: #385f74; font-size: 11px; cursor: pointer; }
.guide-model-versions summary::after { content: "▾"; margin-left: 4px; }
.guide-model-versions[open] { flex-basis: 100%; }
.guide-model-versions .guide-model-option { width: 100%; padding-left: 20px; }
.guide-model-empty { margin: 6px 0; padding: 6px 10px; color: var(--muted); font-size: 13px; }

.document-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 999px;
  background: rgba(255,255,255,.04);
}

.switcher-label {
  padding: 0 10px 0 13px;
  color: rgba(255,255,255,.42);
  font-size: 10px;
  letter-spacing: .1em;
}

.document-button {
  position: relative;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  color: rgba(255,255,255,.54);
  background: transparent;
  font-size: 10px;
  letter-spacing: .08em;
  cursor: pointer;
  transition: color .25s ease, background .25s ease;
}

.document-button span { color: rgba(255,255,255,.28); margin-right: 6px; }
.document-button:hover { color: var(--white); }
.document-button.is-active { color: var(--ink); background: var(--paper); }
.document-button.is-active span { color: var(--accent); }

.top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 18px;
}

.upload-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--accent); border-radius: 4px; color: var(--ink); background: var(--accent); font-size: 11px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.upload-button:hover { background: var(--accent-soft); }
.upload-button:disabled { opacity: .6; cursor: wait; }
.upload-status { max-width: 230px; color: var(--accent-soft); font-size: 10px; line-height: 1.25; }
.upload-status:empty { display: none; }

.text-action {
  color: rgba(255,255,255,.6);
  font-size: 11px;
  text-decoration: none;
  transition: color .2s ease;
}

.text-action:hover { color: var(--white); }
.text-action span { color: var(--accent); margin-left: 4px; }

.record-button {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 4px;
  color: var(--white);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
  transition: border-color .25s ease, background .25s ease;
}

.record-button:hover { border-color: var(--accent); background: rgba(132,206,242,.14); }
.record-button:disabled { opacity: .55; cursor: wait; }
.record-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(132,206,242,.16); }

.workspace {
  --parts-panel-width: 222px;
  min-height: 0;
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr) var(--parts-panel-width);
  background: var(--paper);
}

.parts-panel-collapsed .workspace { --parts-panel-width: 0px; }

.bottom-controls {
  position: relative;
  z-index: 30;
  width: 100%;
  height: 68px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  color: var(--white);
  background: var(--ink);
  border-top: 1px solid rgba(255,255,255,.1);
}

.bottom-control {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 0;
  border-right: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.72);
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .08em;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}

.bottom-control:last-child { border-right: 0; }
.bottom-control:hover:not(:disabled) { color: var(--white); background: rgba(255,255,255,.055); }
.bottom-control:disabled { opacity: .26; cursor: default; }
.bottom-control-primary { color: var(--ink); background: var(--accent); }
.bottom-control-primary:hover:not(:disabled) { color: var(--ink); background: var(--accent-soft); }
.bottom-control-icon { font: 700 20px/1 ui-monospace, monospace; }
.pause-glyph { letter-spacing: 3px; transform: translateX(2px); }

.step-rail,
.parts-panel { min-height: 0; background: var(--paper); }

.step-rail {
  display: grid;
  grid-template-rows: 66px auto auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
}

.rail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.rail-head span { font-size: 11px; font-weight: 650; }
.rail-head strong { color: var(--muted); font: 600 8px/1 ui-monospace, monospace; letter-spacing: .1em; }

.step-list {
  margin: 0;
  padding: 12px 0;
  list-style: none;
  overflow: auto;
  scrollbar-width: none;
}

.step-list::-webkit-scrollbar { display: none; }


.step-item { position: relative; }

.step-button {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 35px 1fr;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border: 0;
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: color .25s ease, background .25s ease;
}

.step-button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: transparent;
}

.step-button:hover { color: var(--ink); background: rgba(16,35,47,.04); }
.step-button.is-active { color: var(--ink); background: var(--white); }
.step-button.is-active::before { background: var(--accent); }

.step-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  font: 600 9px/1 ui-monospace, monospace;
}

.step-button.is-complete .step-number { color: var(--white); border-color: var(--ink); background: var(--ink); }
.step-button.is-active .step-number { color: var(--white); border-color: var(--accent); background: var(--accent); }
.step-name { display: block; max-width: 93px; font-size: 11px; line-height: 1.35; }
.step-parts { display: block; margin-top: 3px; color: #999b96; font: 500 7px/1 ui-monospace, monospace; letter-spacing: .05em; }

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(rgba(50,126,162,.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(50,126,162,.075) 1px, transparent 1px),
    #c0daf5;
  background-size: 42px 42px;
}

.stage-canvas { position: absolute; inset: 0; z-index: 1; touch-action: none; cursor: grab; }
.stage-canvas:active { cursor: grabbing; }
.stage-canvas canvas { width: 100%; height: 100%; display: block; }
.part-tools { position: absolute; z-index: 4; bottom: 16px; left: 88px; right: 16px; max-width: 480px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(250,253,255,.94); box-shadow: 0 8px 28px #14365318; }
.part-tools[hidden] { display: none; }
.explode-distance-control { display: grid; grid-template-columns: auto minmax(0, 1fr) 4ch; align-items: center; gap: 10px; margin-bottom: 10px; padding-bottom: 9px; border-bottom: 1px solid var(--line); font-size: 12px; }
.explode-distance-control input { width: 100%; min-width: 0; min-height: 28px; margin: 0; accent-color: #1688c5; cursor: pointer; }
.explode-distance-control input:disabled { opacity: .45; cursor: default; }
.explode-distance-control output { text-align: right; font-variant-numeric: tabular-nums; color: #456174; }
.part-tools > strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.part-tools-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.part-tools select { min-width: 74px; flex-shrink: 0; }
.part-tools button, .part-tools select { min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--ink); font: inherit; font-size: 12px; cursor: pointer; }
.part-tools button[aria-pressed="true"] { background: var(--accent-soft); border-color: #64b7df; }
.part-tools button:disabled { opacity: .45; cursor: default; }
.part-tools p { margin: 8px 0 0; color: #456174; font-size: 11px; }
@media (max-width: 780px), (hover: none) and (pointer: coarse) { .camera-keyboard-hint { display: none; } }
@media (max-width: 780px) { .display-mode #inventoryButton { position: fixed; right: 12px; bottom: calc(66px + env(safe-area-inset-bottom)); margin: 0; pointer-events: auto; } .part-tools { left: 76px; right: 12px; bottom: 160px; } .part-tools button, .part-tools select { padding: 6px 8px; } }
.video-canvas { position: fixed; left: -99999px; top: -99999px; pointer-events: none; }

.stage-heading {
  position: absolute;
  z-index: 3;
  left: 32px;
  top: 30px;
  width: min(430px, 46%);
  pointer-events: none;
}

.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--accent); font: 700 9px/1 ui-monospace, monospace; letter-spacing: .12em; }
.eyebrow i { width: 26px; height: 1px; background: var(--accent); }
.eyebrow span:last-child { color: var(--muted); }
.stage-heading h1 { margin: 12px 0 8px; max-width: 480px; font-size: clamp(26px, 2.6vw, 42px); line-height: 1.04; letter-spacing: -.05em; }
.stage-heading p { max-width: 400px; margin: 0; color: #5f645f; font-size: 12px; line-height: 1.7; }

.tool-dock {
  position: absolute;
  z-index: 4;
  left: 0;
  top: 100%;
  margin-top: 10px;
  display: grid;
  padding: 3px;
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(250,253,255,.86);
  box-shadow: 0 14px 40px rgba(8,10,9,.08);
  backdrop-filter: blur(14px);
}

.tool-dock > button,
.view-help summary {
  width: 34px;
  height: 34px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  color: #456174;
  background: transparent;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}

.tool-dock > button:not(:first-child),
.view-help summary { border-top: 1px solid var(--line); }
.tool-dock > button:hover:not(:disabled),
.view-help summary:hover { color: var(--ink); background: var(--paper-2); }
.tool-dock > button.is-active,
.view-help[open] summary { color: var(--ink); background: var(--accent-soft); }
.tool-dock > button:focus-visible,
.view-help summary:focus-visible { outline: 2px solid var(--ink-2); outline-offset: 2px; }
.tool-dock > button:disabled { opacity: .45; cursor: default; }
.tool-dock > button small,
.view-help summary small { font-size: 10px; font-weight: 500; line-height: 1.2; }
.tool-dock svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.view-help summary {
  list-style: none;
}
.view-help summary::-webkit-details-marker { display: none; }
.view-help-panel {
  position: absolute;
  left: calc(100% + 12px);
  bottom: 0;
  width: 224px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 8px 28px rgba(16,35,47,.12);
}
.view-help-title { display: block; padding-bottom: 12px; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.4; }
.view-help-row { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 12px; margin-top: 14px; }
.view-help-row strong { display: block; font-size: 13px; font-weight: 600; line-height: 1.5; }
.view-help-row p { margin: 3px 0 0; color: #456174; font-size: 12px; line-height: 1.6; }

.playback-panel {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 22px;
  width: min(660px, calc(100% - 52px));
  min-height: 62px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 34px 48px 34px minmax(160px, 1fr) 56px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  color: var(--white);
  background: rgba(16,35,47,.95);
  box-shadow: 0 18px 50px rgba(7,9,8,.28);
  backdrop-filter: blur(18px);
}

.round-button,
.play-button,
.sound-button { border: 0; color: inherit; background: transparent; cursor: pointer; }
.round-button { width: 32px; height: 32px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; transition: color .2s ease, border-color .2s ease; }
.round-button:hover { color: var(--accent); border-color: var(--accent); }
.round-button:disabled { opacity: .25; cursor: default; }
.play-button { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); background: var(--accent); box-shadow: 0 0 0 5px rgba(132,206,242,.18); }
.play-button .pause-icon { display: none; font-weight: 800; letter-spacing: 2px; }
.play-button.is-playing .play-icon { display: none; }
.play-button.is-playing .pause-icon { display: inline; }
.play-icon { transform: translateX(1px); }

.sound-button { height: 40px; display: grid; place-items: center; align-content: center; gap: 2px; border-left: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.6); }
.sound-button.is-muted { opacity: .35; }
.sound-button span { font-size: 18px; }
.sound-button small { font-size: 7px; }

.recording-overlay {
  visibility: hidden;
  position: absolute;
  z-index: 9;
  left: 50%;
  top: 22px;
  transform: translate(-50%, -140%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--white);
  background: var(--ink);
  font-size: 10px;
  box-shadow: var(--shadow);
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.recording-overlay.is-visible { visibility: visible; transform: translate(-50%, 0); }
.recording-pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.recording-overlay strong { color: var(--accent); font: 700 9px/1 ui-monospace, monospace; }

.loading-state,
.webgl-fallback {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  background: var(--paper-2);
  transition: opacity .45s ease, visibility .45s ease;
}
.webgl-fallback[hidden] { display: none; }
.webgl-fallback { padding: 28px; text-align: center; }
.webgl-fallback p { max-width: 520px; line-height: 1.7; overflow-wrap: anywhere; }
.loading-state.is-hidden { opacity: 0; visibility: hidden; }
.loading-state p,
.webgl-fallback p { margin: 0; color: var(--muted); font-size: 11px; }
.loader-product { position: relative; width: 62px; height: 62px; animation: float 1.8s ease-in-out infinite; }
.loader-product i { position: absolute; display: block; width: 24px; height: 24px; border: 2px solid var(--ink); background: rgba(132,206,242,.3); transform: rotate(45deg); }
.loader-product i:nth-child(1) { left: 19px; top: 1px; }
.loader-product i:nth-child(2) { left: 5px; top: 27px; }
.loader-product i:nth-child(3) { right: 5px; top: 27px; background: var(--accent); }

.parts-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 24px 18px 18px;
  border-left: 1px solid var(--line);
  overflow: hidden;
}

.panel-number {
  position: absolute;
  right: -8px;
  top: 48px;
  color: rgba(16,35,47,.035);
  font: 800 120px/1 ui-monospace, monospace;
  letter-spacing: -.1em;
  pointer-events: none;
}

.panel-title { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.panel-title span { font-size: 12px; font-weight: 680; }
.panel-title small { color: var(--muted); font: 600 8px/1 ui-monospace, monospace; letter-spacing: .08em; }

.parts-list { position: relative; z-index: 1; display: grid; gap: 8px; margin-top: 14px; overflow: auto; scrollbar-width: none; }
.parts-list::-webkit-scrollbar { display: none; }
.part-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 55px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(250,253,255,.62);
  cursor: pointer;
  transition: border-color .2s ease, transform .2s ease, background .2s ease;
}
.part-item:hover,
.part-item.is-highlighted { transform: translateX(-3px); border-color: var(--accent); background: var(--white); }
.part-swatch { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 3px; color: var(--white); background: var(--ink); font: 700 11px/1 ui-monospace, monospace; }
.part-item strong { display: block; font-size: 10px; }
.part-item small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; }
.part-qty { color: var(--accent); font: 700 9px/1 ui-monospace, monospace; }

.safety-card {
  position: relative;
  z-index: 1;
  margin-top: auto;
  display: grid;
  grid-template-columns: 27px 1fr;
  gap: 10px;
  padding: 12px;
  border-radius: 4px;
  color: var(--white);
  background: var(--ink);
}
.safety-icon { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); background: var(--accent); font-weight: 850; }
.safety-card strong { font-size: 9px; }
.safety-card p { margin: 5px 0 0; color: rgba(255,255,255,.58); font-size: 8px; line-height: 1.5; }
.safety-card { flex-shrink: 0; }
.bottom-control:disabled, .tool-dock button:disabled { opacity: .4; cursor: default; }

.overview-button { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--white); color: var(--ink); cursor: pointer; font-size: 12px; }
.overview-button[hidden], .instruction-context[hidden], .tool-dock button[hidden] { display: none; }
.instruction-context { flex-shrink: 0; margin-bottom: 18px; padding: 14px; border: 1px solid #aad0df; border-radius: 6px; background: #eaf6fb; }
.instruction-label { color: #27627b; font-size: 11px; font-weight: 700; }
.instruction-context p { margin: 7px 0 10px; font-size: 13px; line-height: 1.65; }
.instruction-context a { color: #216786; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.instruction-context small { display: block; margin-top: 9px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.instruction-context small[hidden] { display: none; }
.manual-assembly .parts-panel { overflow-y: auto; }
.manual-assembly .overview-button { margin: 10px 12px; }
.manual-assembly .part-swatch { width: 44px; font-size: 8px; line-height: 1.4; overflow-wrap: anywhere; }
.manual-assembly .part-item { grid-template-columns: 44px minmax(0, 1fr) auto; }
.manual-assembly .parts-list { flex-shrink: 0; }
.manual-assembly .safety-card { margin-top: 18px; }
.manual-assembly .stage-heading { pointer-events: none; }
.step-share { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; margin-top: 7px; width: fit-content; max-width: 100%; pointer-events: auto; }
.step-share button { border: 1px solid #426785; border-radius: 5px; color: #163652; background: #f2f8fd; font: inherit; font-size: 12px; padding: 5px 9px; cursor: pointer; }
.step-share button:focus-visible { outline: 2px solid #174f82; outline-offset: 2px; }
.step-share span, .step-share small { color: #19374e; font-size: 11px; }
.step-share input { width: 100%; min-width: 0; border: 1px solid #426785; border-radius: 4px; padding: 4px; }
.manual-assembly .part-swatch { font-size: 9px; }
.step-detail { flex-shrink: 0; margin-bottom: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.step-detail-title { display: block; font-size: 12px; line-height: 1.6; }
.connection-list { display: grid; gap: 7px; padding: 0; margin: 12px 0; list-style: none; }
.connection-row { display: grid; grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr); align-items: center; gap: 4px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.connection-row > span { overflow-wrap: anywhere; }
.connection-origin, .connection-target { padding: 7px; border: 1px solid var(--line); border-radius: 4px; }
.connection-arrow { text-align: center; }
.connection-row.is-connected { color: #176581; }
.connection-row.is-connected .connection-target { border-color: #4aa5bd; background: #e4f5f8; }
.keypad-diagram { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin: 12px 0; padding: 12px 8px; border-radius: 6px; background: var(--ink); }
.keypad-key { min-width: 25px; display: grid; place-items: center; min-height: 31px; padding: 4px; border: 1px solid #6b899b; border-radius: 4px; color: var(--white); font: 600 12px/1 ui-monospace, monospace; }
.keypad-key[data-selected="true"] { border-color: var(--accent); }
.keypad-key.is-pressing { color: var(--ink); background: var(--accent); box-shadow: 0 0 10px #84cef255; }
.keypad-hold, .step-detail-result { margin: 10px 0 0; font-size: 12px; line-height: 1.65; }
.step-detail-result { padding-left: 9px; border-left: 3px solid var(--line); }
.step-detail.is-complete .step-detail-result { border-color: #4aa5bd; }
.step-detail-note { display: block; margin-top: 9px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.operation-presentation .part-item { border-left: 3px solid #1769e8; }
.operation-presentation .part-item.is-operating { border-color: #ba8b00; background: #fff4c9; }
.operation-presentation .part-item.is-operating .part-swatch { color: #3a2d08; background: #ffd24a; }
.operation-presentation .part-item.is-highlighted { border-color: #e52638; background: #ffebee; }
.operation-presentation .part-item.is-highlighted .part-swatch { color: #fff; background: #e52638; }
.operation-presentation .aa-operation-status { border-left-color: #ba8b00; background: #fff4d8ef; color: #48380f; }

@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(132,206,242,.2); } }
@keyframes float { 50% { transform: translateY(-6px); } }

@media (max-width: 1040px) {
  .workspace { --parts-panel-width: 190px; grid-template-columns: 152px minmax(0, 1fr) var(--parts-panel-width); }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; }
  .guide-picker { justify-self: center; }
  .switcher-label { display: none; }
  .text-action { display: none; }
  .parts-panel { padding-left: 14px; padding-right: 14px; }
  .stage-heading { width: min(390px, 58%); }
}

@media (max-width: 780px) {
  html, body { overflow: auto; background: var(--paper); }
  .app-shell { height: auto; min-height: 100svh; grid-template-rows: auto auto 64px; }
  .topbar { z-index: 21; min-height: 66px; grid-template-columns: auto auto; padding: 10px 14px; }
  .guide-picker { grid-column: 1 / -1; grid-row: 2; width: 100%; justify-self: stretch; }
  .guide-picker-trigger { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid #ffffff38; border-radius: 8px; background: var(--ink-2); color: var(--white); font-size: 13px; cursor: pointer; }
  .guide-picker-trigger > span { flex: none; }
  .guide-picker-trigger strong { flex: 1; color: #cce1ed; text-align: right; font-size: 12px; font-weight: 500; }
  .guide-picker.is-open .guide-picker-backdrop { display: block; position: fixed; inset: 0; background: #10232f65; }
  .guide-picker-panel { display: none; position: fixed; z-index: 1; right: 0; bottom: 0; left: 0; max-height: 90dvh; overflow: auto; padding: 14px 14px max(14px, env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; background: #fff; color: var(--ink); }
  .guide-picker.is-open .guide-picker-panel { display: grid; }
  .guide-picker-heading { display: flex; align-items: center; justify-content: space-between; font-size: 17px; }
  .guide-picker-heading button { width: 44px; height: 44px; border: 0; border-radius: 8px; background: var(--paper); color: var(--ink); font-size: 23px; cursor: pointer; }
  .guide-field { background: var(--paper); border-color: var(--line); }
  .guide-field > span { color: var(--muted); font-size: 12px; }
  .guide-field select, .guide-model-button { flex: 1; width: 100%; min-height: 44px; }
  .guide-field select option { background: var(--paper); }
  .guide-model-field { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .guide-model-menu { position: static; grid-column: 1 / -1; width: auto; margin: 0 8px 8px -2px; box-shadow: none; }
  .guide-model-menu input { font-size: 16px; }
  .guide-model-results { max-height: min(43dvh, 380px); }
  .document-switcher { grid-column: 1 / -1; grid-row: 2; width: 100%; justify-content: center; order: 3; }
  .document-button { flex: 1; }
  .top-actions { gap: 8px; }
  .upload-button { min-height: 34px; padding: 0 9px; font-size: 10px; }
  .upload-status { max-width: 110px; }
  .record-button { padding: 0 11px; }
  .record-label { display: none; }
  .workspace { --stage-height: max(590px, calc(100svh - 170px)); position: relative; grid-template-columns: 1fr; grid-template-rows: var(--stage-height) auto; }
  .display-mode .workspace { --stage-height: max(590px, calc(100svh - 106px)); }
  .step-rail { position: absolute; z-index: 10; left: 10px; right: 10px; top: calc(var(--stage-height) - 60px); bottom: auto; display: block; border: 0; background: transparent; pointer-events: none; }
  .rail-head { display: none; }
  .step-list { display: flex; gap: 5px; padding: 0; overflow-x: auto; pointer-events: auto; }
  #overviewButton { pointer-events: auto; }
  #overviewButton[aria-expanded] { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); margin: 0; }
  .step-item { flex: 0 0 auto; }
  .step-button { width: 44px; min-height: 44px; display: block; padding: 8px; border: 1px solid var(--line); border-radius: 50%; background: rgba(250,253,255,.92); }
  .step-button::before, .step-name, .step-parts { display: none; }
  .step-number { border: 0; }
  .stage { grid-row: 1; }
  .stage-heading { left: 18px; top: 18px; width: calc(100% - 36px); }
  .stage-heading h1 { font-size: 28px; }
  .stage-heading p { font-size: 11px; }
  .bottom-controls { height: 64px; }
  .bottom-control { gap: 9px; font-size: 12px; }
  .parts-panel { grid-row: 2; min-height: 250px; border-left: 0; border-top: 1px solid var(--line); }
  .parts-list { grid-template-columns: repeat(2, 1fr); }
  .safety-card { margin-top: 16px; }
  .manual-assembly .overview-button { position: absolute; bottom: 102px; right: 0; margin: 0; padding: 7px 10px; pointer-events: auto; font-size: 11px; }
  .manual-assembly .stage-heading { width: calc(100% - 36px); }
  .manual-assembly .stage-heading h1 { font-size: 25px; }
  .manual-assembly .instruction-context { margin-bottom: 16px; }
  .manual-assembly .app-shell { grid-template-rows: auto auto; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .display-mode .app-shell { grid-template-rows: auto auto; padding-bottom: 0; }
  .manual-assembly .bottom-controls { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
  .manual-assembly .part-item:hover { transform: none; }
}

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