/* Builder page. Desktop: parts list on the left, the big 3D view (or the parts browser) in
   the middle, the summary column only when "More info" is on, and a summary bar at the
   bottom. Narrow screens: tabs (3D first) plus the same bar. Tokens from style.css only. */

.builder {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--gutter) var(--s-5);
}

/* ---------- Top bar of the page ---------- */
.builder__bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  padding: var(--s-5) 0 var(--s-4);
}
.builder__heading .eyebrow { margin: 0 0 2px; }
.builder__title {
  font-size: clamp(26px, 3vw, 34px);
  margin: 0;
  overflow-wrap: anywhere;
}
.builder__state {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--muted);
  vertical-align: middle;
}
.builder__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
@media (max-width: 640px) {
  /* One scrolling row of actions instead of two wrapped rows. */
  .builder__actions { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(var(--gutter) * -1); padding: 4px var(--gutter) 8px; scrollbar-width: none; }
  .builder__actions > * { flex: none; }
  .builder__actions .menu__list { position: fixed; top: auto; right: var(--gutter); }
}
.btn.is-blocked { --btn-text: var(--muted); --btn-border: var(--line); --btn-bg: transparent; cursor: not-allowed; }
.btn.is-blocked:active { transform: none; }

/* ---------- Grid ---------- */
.builder__grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: var(--s-5);
  align-items: start;
}
.builder__grid[data-info="on"] { grid-template-columns: 280px minmax(0, 1fr) 340px; }
@media (min-width: 1024px) {
  .builder__grid[data-info="off"] > .col--summary { display: none; }
}
.col { min-width: 0; }
.col--build,
.col--summary {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s-4));
  max-height: calc(100vh - var(--topbar-h) - var(--s-5));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.col__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-4) var(--s-2);
}
.col__head h2 { margin: 0; font-size: 18px; }
.col__hint { font-size: 12px; }

@media (max-width: 1279px) {
  .builder__grid { grid-template-columns: 270px minmax(0, 1fr); }
  .builder__grid[data-info="on"] { grid-template-columns: 250px minmax(0, 1fr) 300px; }
}

/* ---------- Category list ---------- */
.cats { list-style: none; margin: 0; padding: 0 var(--s-2) var(--s-2); }
.cat { position: relative; border-radius: 12px; transition: background var(--dur) var(--ease); }
.cat:hover { background: var(--panel-2); }
.cat[data-current="true"] { background: var(--accent-soft); }
.cat__btn {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 0 var(--s-3);
  width: 100%;
  padding: 10px var(--s-2);
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cat__btn:hover .cat__label { color: var(--text); }
.cat__thumb {
  grid-row: 1 / span 2;
  width: 52px; height: 52px;
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 30%, #DEE0E3, #CACDD2);
  display: grid;
  place-items: center;
}
.cat__thumb img { width: 100%; height: 100%; object-fit: cover; }
.cat__glyph { font-weight: 700; font-size: 18px; color: #A3ACBA; }
.cat__head { grid-column: 2 / -1; display: flex; align-items: center; gap: var(--s-2); }
.cat__label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0;
  color: var(--muted);
}
.cat[data-current="true"] .cat__label { color: var(--text); }
.cat__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  margin-left: auto;
}
.cat[data-status="ok"] .cat__dot { background: var(--ok); border-color: var(--ok); }
.cat[data-status="warn"] .cat__dot { background: var(--warn); border-color: var(--warn); }
.cat[data-status="error"] .cat__dot { background: var(--error); border-color: var(--error); }
.cat__name { font-size: 14px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.cat__price { font-size: 12.5px; color: var(--muted); align-self: end; white-space: nowrap; }
.cat__empty { grid-column: 2 / -1; font-size: 13px; color: var(--muted); }
.cat__items { list-style: none; margin: 0; padding: 0 var(--s-2) 10px calc(52px + var(--s-2) + var(--s-3)); display: grid; gap: 4px; }
/* Details / Swap / Remove: shown for the open category, on hover and on keyboard focus. */
@media (hover: hover) and (min-width: 1024px) {
  .cat:not([data-current="true"]):not(:hover):not(:focus-within) .cat__items { display: none; }
}
.cat__item-name { display: block; font-size: 12.5px; color: var(--muted); }
.cat__actions { display: flex; gap: var(--s-3); flex-wrap: wrap; }

/* ---------- Centre: view switch ---------- */
.centrebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
}
.centrebar__preview::after {
  content: ' · Off';
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.centrebar__preview[aria-pressed="true"]::after { content: ' · On'; }
.col--parts[data-view="3d"] .centrebar__preview { display: none; }
.viewswitch {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  background: var(--panel-2);
  border-radius: var(--r-pill);
}
.viewswitch__btn {
  position: relative;
  height: 34px;
  padding: 0 var(--s-5);
  background: transparent;
  border: 0;
  border-radius: var(--r-pill);
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0;
  cursor: pointer;
}
.viewswitch__btn[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Parts browser ---------- */
.browser__tools {
  padding: var(--s-5);
  background: var(--panel);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.browser__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.browser__title { font-size: 30px; margin: 0 0 var(--s-3); }
.browser__title:focus { outline: none; }
.browser__count { margin: 0; font-size: 12px; color: var(--muted); }
.browser__swap {
  display: flex;
  gap: var(--s-3);
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--r-sm);
  font-size: 14px;
}
.browser__row { display: flex; gap: var(--s-2); align-items: center; }
.browser__note { margin: var(--s-3) 0 0; font-size: 12px; color: var(--muted); }
.browser__note .mono { color: var(--text); }
.filters-toggle { display: none; }

.browser__row .field:not(.field--grow) .input { width: auto; max-width: 220px; }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px var(--s-3);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}
.field--price { grid-column: span 2; }
.price-range { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.filters__end {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.parts { list-style: none; margin: var(--s-3) 0 0; padding: 0; display: grid; gap: var(--s-2); }
.part {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 176px;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--panel);
  border: 1px solid transparent;
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.part:hover { box-shadow: var(--shadow); }
.part[data-state="selected"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.part[data-state="incompatible"] .part__main,
.part[data-state="incompatible"] .part__price { opacity: .48; }
.part__name { margin: 0; font-family: var(--font-body); font-size: 16px; font-weight: 600; line-height: 1.3; letter-spacing: 0; }
.part__title {
  padding: 0;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
}
.part__title:hover { text-decoration-color: var(--accent); }
.part__tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.part__specs { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; }
.part__specs div { display: flex; gap: 6px; align-items: baseline; }
.part__specs dt {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0;
  color: var(--muted);
}
.part__specs dd { margin: 0; font-family: var(--font-mono); font-size: 13px; }
.part__specs dd.null { color: var(--muted); }
.part__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-2);
  text-align: right;
}
.part__price { margin: 0; display: grid; gap: 1px; }
.part__price .mono { font-size: 17px; }
.part__price-note { font-size: 11px; color: var(--muted); }
.empty { padding: var(--s-6) var(--s-4); text-align: center; color: var(--muted); }

/* ---------- 3D viewer ---------- */
/* Desktop: preview above the parts list (parts view) or large on its own (3D view).
   Narrow screens: only on the 3D tab. */
.col--parts[data-view="parts"][data-preview="off"] > .viewer,
.col--parts[data-view="3d"] > .browser { display: none; }
.viewer {
  --viewer-h: clamp(260px, 40vh, 440px);
  margin-bottom: var(--s-4);
  background: var(--panel);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.col--parts[data-view="3d"] > .viewer { --viewer-h: max(460px, calc(100vh - var(--topbar-h) - 420px)); }
/* Advanced viewer controls and notes stay behind "More options". */
.viewer:not([data-more="on"]) .viewer__adv { display: none; }
.vbtn--more[aria-expanded="true"] { color: var(--accent-text); }
/* Build by hand: the case and the tray must both be on screen to drag between them. */
.viewer { scroll-margin-top: calc(var(--topbar-h) + 8px); }
.col--parts > .viewer[data-mode="hand"] { --viewer-h: max(300px, calc(100vh - var(--topbar-h) - 400px)); }
.viewer__stage {
  position: relative;
  height: var(--viewer-h);
  background: radial-gradient(120% 90% at 50% 35%, #D5D7DB, #BDC0C6);
}
.viewer__canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.viewer__frame { --bracket: 18px; position: absolute; inset: 8px; pointer-events: none; }
.viewer__hud {
  position: absolute;
  inset: 12px 16px auto 16px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-3);
  pointer-events: none;
}
.viewer__title { margin: 0; display: flex; align-items: baseline; gap: var(--s-2); min-width: 0; }
.viewer__title .label { margin: 0; font-size: 12px; color: var(--text); white-space: nowrap; }
.viewer__case { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer__fps { margin: 0; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.viewer__readout { display: grid; justify-items: end; gap: 2px; }
.viewer__power { margin: 0; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.viewer__power[data-power="on"],
.viewer__power[data-power="booting"] { color: var(--text); }
.viewer__power[data-power="on"]::before,
.viewer__power[data-power="booting"]::before { content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 6px 1px 0; border-radius: 50%; background: var(--accent); }
/* Tooltip: follows the pointer for 3D hover, docked bottom-left for hover from the list. */
.viewer__hover {
  position: absolute;
  max-width: min(340px, calc(100% - 32px));
  padding: 6px 10px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--r-sm);
  pointer-events: none;
}
.viewer__hover.is-docked { left: 16px; bottom: 10px; }
.viewer__hover p { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--text); }
.viewer__hover .mono { color: var(--muted); font-size: 11.5px; margin-right: 4px; }
.viewer__hover .viewer__hover-approx { margin-top: 2px; font-size: 11.5px; color: var(--warn); }
.viewer__loading,
.viewer__msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--s-2);
  padding: var(--s-5);
  text-align: center;
}
.viewer__loading { background: var(--bg); }
.viewer__loading .label { margin: 0; color: var(--text); }
.viewer__loading .loader__bar { width: min(240px, 60vw); }
.viewer__loading-step { margin: 0; font-size: 11.5px; color: var(--muted); }
.viewer__msg { pointer-events: none; }
.viewer__msg-card {
  display: grid;
  justify-items: center;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r);
  pointer-events: auto;
}
.viewer__msg p { margin: 0; max-width: 40ch; color: var(--muted); font-size: 14px; }
.viewer__msg .label { color: var(--text); }
.viewer[data-state="error"] .viewer__msg { background: var(--bg); }
.viewer__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: var(--s-2) 10px;
}
.viewer__spacer { flex: 1; }
.vgroup { display: inline-flex; padding: 3px; gap: 2px; background: var(--panel-2); border-radius: var(--r-pill); }
.vbtn {
  height: 32px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0;
  cursor: pointer;
}
.vgroup .vbtn { border: 0; height: 28px; }
.vbtn:hover { color: var(--text); border-color: var(--line-strong); }
.vgroup .vbtn:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.vbtn[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.vgroup .vbtn[aria-pressed="true"] { color: var(--text); background: var(--panel); box-shadow: var(--shadow-sm); }
.vbtn:disabled { opacity: .45; cursor: not-allowed; }
.vbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.viewer__tools--fx,
.viewer__tools--view { padding-top: 0; }
.viewer__tools--mode { border-bottom: 1px solid var(--line); margin-bottom: var(--s-2); }
.vbtn--power[aria-pressed="true"] { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 4px 12px -4px rgb(47 107 255 / .6); }
.viewer__range { display: inline-flex; align-items: center; gap: 8px; }
.viewer__range .label { margin: 0; font-size: 12px; }
.viewer__range input { width: 132px; accent-color: var(--accent); }
.viewer__range output { min-width: 4ch; font-size: 12px; color: var(--muted); text-align: right; }
.viewer__lighting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 10px var(--s-2);
  padding: var(--s-2) 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.viewer__lighting[hidden] { display: none; }
.viewer__field { display: inline-flex; align-items: center; gap: 8px; }
.viewer__field .label { margin: 0; font-size: 12px; }
.viewer__field select { max-width: 240px; height: 30px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; font-size: 13px; padding: 0 6px; }
.viewer__field input[type="color"] { width: 40px; height: 30px; padding: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; }
.viewer__field select:focus-visible,
.viewer__field input:focus-visible,
.viewer__range input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.viewer__lighting-note { flex-basis: 100%; margin: 0; font-size: 12px; }
.viewer__notes { padding: 0 var(--s-3) var(--s-3); font-size: 12px; line-height: 1.45; }
.viewer__notes p { margin: 0; }
.viewer__notes p + p { margin-top: 4px; }
.viewer__notes p:first-child:not(:empty) { color: var(--warn); }

/* ---------- Auto-build cinematic ---------- */
.viewer[data-mode="auto"] .viewer__tools--view,
.viewer[data-mode="auto"] .viewer__tools--fx,
.viewer[data-mode="auto"] .viewer__lighting,
.viewer[data-mode="auto"] .viewer__hover { display: none; }
.col--parts > .viewer[data-mode="auto"] { --viewer-h: max(320px, calc(100vh - var(--topbar-h) - 260px)); }
.auto { padding: 0 10px var(--s-3); }
.auto[hidden] { display: none; }
.auto__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.auto__ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.auto__play { min-width: 72px; }
/* Timeline: one segment per step, filled as it plays; click to jump. */
/* Desktop: wraps to a second row rather than cutting every label short. */
.tl { display: flex; flex-wrap: wrap; gap: 3px; margin: 10px 0 0; padding: 0; list-style: none; min-width: 0; }
.tl__item { flex: 1 1 64px; min-width: 0; }
.tl__seg {
  position: relative; display: block; width: 100%; height: 26px; padding: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px;
  overflow: hidden; cursor: pointer; color: var(--muted);
}
.tl__seg:hover:not(:disabled) { border-color: var(--line-strong); color: var(--text); }
.tl__seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tl__seg:disabled { cursor: not-allowed; }
.tl__fill { position: absolute; inset: 0 auto 0 0; width: 0; background: color-mix(in srgb, var(--ok) 22%, var(--panel-2)); }
.tl__seg[data-state="done"] { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); color: var(--text); }
.tl__seg[data-state="current"] { border-color: var(--accent); color: var(--text); }
.tl__label {
  position: relative; display: block; padding: 0 3px;
  font-family: var(--font-head); font-weight: 600; font-size: 11.5px; line-height: 24px;
  letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auto__rec { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.auto__rec[hidden] { display: none; }
.auto__recbar { flex: 1 1 160px; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.auto__recbar span { display: block; height: 100%; background: var(--accent); }
.auto__rectext { margin: 0; font-size: 12px; color: var(--text); }
.auto__done { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-left: 2px solid var(--ok); border-radius: var(--r-sm); }
.auto__done[hidden] { display: none; }
.auto__done-text { flex: 1 1 260px; margin: 0; font-size: 13.5px; line-height: 1.45; }
.auto__done-text .label { margin-right: 6px; color: var(--ok); }
.auto__done-text .mono { margin: 0 4px; }
.auto__done-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.auto__note { margin: 8px 0 0; font-size: 12px; line-height: 1.45; }
.auto__note:empty { display: none; }
/* Over the canvas: crossfade layer, step caption, recording mark. Never takes the pointer. */
.auto-ov { position: absolute; inset: 0; pointer-events: none; }
.auto-ov[hidden] { display: none; }
.auto-ov__fade { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; --bg: #0b0d10; }
.auto-ov__cap {
  position: absolute; left: 16px; right: 16px; bottom: 14px;
  display: grid; justify-items: start; gap: 2px;
}
.auto-ov__step { margin: 0; padding: 2px 8px; font-size: 11.5px; color: var(--muted); background: color-mix(in srgb, var(--bg) 82%, transparent); border-radius: 3px; }
.auto-ov__label {
  margin: 0; max-width: 100%; padding: 4px 10px;
  font-size: 15px; font-weight: 500; line-height: 1.35; color: var(--text);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line); border-left: 2px solid var(--accent); border-radius: var(--r-sm);
}
.auto-ov__label:empty { display: none; }
.auto-ov__rec { position: absolute; top: 34px; right: 16px; margin: 0; font-size: 11.5px; color: var(--text); }
.auto-ov__rec::before { content: ''; display: inline-block; width: 7px; height: 7px; margin: 0 6px 1px 0; border-radius: 50%; background: var(--error); }
@media (max-width: 640px) {
  .tl__label { display: none; }
  .tl { flex-wrap: nowrap; gap: 2px; }
  .tl__item { flex: 1 1 0; }
  .auto-ov__label { font-size: 13px; }
  .auto__done-actions .btn { flex: 1 1 auto; }
}

/* ---------- Build by hand ---------- */
.viewer[data-mode="hand"] [data-v="panel"],
.viewer[data-mode="hand"] .viewer__tools--fx,
.viewer[data-mode="hand"] .viewer__lighting { display: none; }
.vgroup--mode .vbtn { padding: 0 10px; }
.hand { padding: 0 10px var(--s-2); }
.hand[hidden] { display: none; }
.hand__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.hand__progress { flex: 1 1 320px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.hand__tools { display: flex; flex-wrap: wrap; gap: 6px; }
.hsteps { flex: 1; display: flex; gap: 3px; min-width: 0; }
.hsteps__seg { position: relative; flex: 1 1 0; min-width: 0; height: 26px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.hsteps__fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--ok) 22%, var(--panel-2)); transition: width var(--dur) var(--ease); }
.hsteps__seg[data-state="done"] { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.hsteps__seg[data-state="current"] { border-color: var(--accent); }
.hsteps__label { position: relative; display: block; padding: 0 4px; font-family: var(--font-head); font-weight: 600; font-size: 11.5px; line-height: 24px; letter-spacing: 0; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hsteps__seg[data-state="current"] .hsteps__label,
.hsteps__seg[data-state="done"] .hsteps__label { color: var(--text); }
.hsteps__count { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
.hand__msg { min-height: 1.45em; margin: 8px 0 0; padding-left: 10px; border-left: 2px solid var(--line-strong); font-size: 13px; line-height: 1.45; color: var(--muted); }
.hand__msg:empty { border-left-color: transparent; }
.hand__msg[data-level="warn"] { border-left-color: var(--warn); color: var(--text); }
.hand__msg[data-level="ok"] { border-left-color: var(--ok); color: var(--text); }
.hand__done { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; padding: var(--s-2) 10px; background: var(--panel-2); border: 1px solid var(--line); border-left: 2px solid var(--ok); border-radius: var(--r-sm); }
.hand__done[hidden] { display: none; }
.hand__done p { flex: 1 1 260px; margin: 0; font-size: 13px; color: var(--muted); }
.hand__done .label { margin-right: 6px; color: var(--text); }
.hand__why { font-size: 12px; color: var(--muted); }

.tray { margin-top: 10px; }
.tray__title { margin: 0 0 6px; font-size: 12px; }
.tray__list { display: flex; gap: 8px; margin: 0; padding: 0 0 6px; list-style: none; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.tray__item { flex: 0 0 176px; display: flex; flex-direction: column; gap: 4px; padding: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.tray__item[data-selected="true"] { border-color: var(--accent); }
.tray__item--empty { flex-basis: min(420px, 100%); justify-content: center; align-items: flex-start; padding: var(--s-3); }
.tray__item--empty p { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.tray__part { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px; align-items: start; width: 100%; padding: 0; background: none; border: 0; border-radius: 4px; color: inherit; font: inherit; text-align: left; cursor: grab; touch-action: pan-x; user-select: none; -webkit-user-select: none; }
.tray__part[aria-disabled="true"] { cursor: not-allowed; }
.tray__part:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tray__thumb { display: block; width: 64px; height: 48px; background: var(--bg); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.tray__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; pointer-events: none; }
.tray__text { display: grid; gap: 1px; min-width: 0; }
.tray__cat { font-size: 11px; color: var(--muted); }
.tray__name { font-size: 12.5px; line-height: 1.3; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tray__detail { font-size: 11.5px; color: var(--muted); }
.tray__item[data-state="locked"] .tray__part,
.tray__item[data-state="skipped"] .tray__part { opacity: .55; }
.tray__item[data-state="done"] .tray__thumb { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.tray__why { margin: 0; font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.tray__why[data-state="ready"] { color: var(--text); }
.tray__why[data-state="done"] { color: var(--ok); }
.tray__why[data-state="locked"]::before { content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 6px 1px 0; border: 1px solid var(--muted); border-radius: 1px; }
.tray__actions { display: flex; gap: 12px; margin-top: auto; }
.tray__actions .linkbtn { font-size: 12px; }
.hand[data-dragging="true"] .tray__part { cursor: grabbing; }
.viewer[data-mode="hand"] .viewer__hover { display: none; }

/* ---------- Build by hand: cables ---------- */
.vbtn--accent { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.vbtn--accent:hover { color: var(--accent-ink); border-color: var(--accent); filter: brightness(1.08); }
.vbtn--accent:focus-visible { outline-color: var(--text); }
.hand[data-complete="true"] .tray { display: none; }
.cab { margin-top: 10px; padding: var(--s-2) 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); container-type: inline-size; }
.cab[hidden] { display: none; }
.cab__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cab__head .label { margin: 0; color: var(--text); }
.cab__count { margin: 0; font-size: 12px; color: var(--muted); }
.cab__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.cab__field { display: inline-flex; align-items: center; gap: 6px; }
.cab__field[hidden] { display: none; }
.cab__field .label { font-size: 12px; }
.cab__field select { height: 30px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; font-size: 13px; padding: 0 6px; }
.cab__field input[type="color"] { width: 34px; height: 30px; padding: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; }
.cab__field select:focus-visible,
.cab__field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cab__sel { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12.5px; color: var(--text); }
.cab__sel:empty { display: none; }
.cab__sel .linkbtn { font-size: 12px; }
/* One column (score and Power on first) until the panel has room for the list beside them. */
.cab__body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); align-items: start; }
.cab__side { order: -1; }
@container (min-width: 760px) {
  .cab__body { grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); }
  .cab__side { order: 0; position: sticky; top: calc(var(--topbar-h, 56px) + 8px); }
}
@container (max-width: 420px) {
  .cab__item { grid-template-columns: 8px minmax(0, 1fr); }
  .cab__act { grid-column: 2; }
}
.cab__list { display: grid; gap: 10px; min-width: 0; }
.cab__group .label { margin: 0 0 4px; font-size: 12px; }
.cab__items { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--r-sm); }
.cab__item { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 7px 8px; }
.cab__item + .cab__item { border-top: 1px solid var(--line); }
.cab__item[data-selected="true"] { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.cab__dot { width: 8px; height: 8px; margin-top: 5px; border: 1px solid var(--muted); border-radius: 50%; }
.cab__item[data-state="need"] .cab__dot { border-color: var(--text); }
.cab__item[data-state="on"] .cab__dot { background: var(--ok); border-color: var(--ok); }
.cab__item[data-state="warn"] .cab__dot { background: var(--warn); border-color: var(--warn); }
.cab__item[data-state="off"] .cab__dot { border-color: var(--error); }
.cab__text { min-width: 0; }
.cab__text p { margin: 0; }
.cab__name { font-size: 13px; line-height: 1.4; color: var(--text); overflow-wrap: anywhere; }
.cab__to { color: var(--muted); }
.cab__meta { font-size: 11.5px; line-height: 1.4; color: var(--muted); }
.cab__tag { font-family: var(--font-head); font-weight: 600; letter-spacing: 0; }
.cab__item[data-state="need"] .cab__tag { color: var(--text); }
.cab__item[data-state="off"] .cab__tag { color: var(--error); }
.cab__warn { margin-top: 2px !important; font-size: 12px; color: var(--warn); }
.cab__act { display: flex; gap: 10px; white-space: nowrap; }
.cab__act .linkbtn { font-size: 12px; }
.cab__notes { margin: 0; font-size: 12px; line-height: 1.45; }
.cab__side { display: grid; gap: 10px; min-width: 0; }
.cab__score { padding: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.cab__gauge { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cab__gauge .label { margin: 0; font-size: 12px; }
.cab__num { margin: 0; font-size: 13px; color: var(--muted); }
.cab__num span { font-size: 26px; color: var(--text); }
.cab__bar { position: relative; height: 4px; margin: 6px 0 8px; background: var(--line); border-radius: 2px; overflow: hidden;
  background-image: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--bg) calc(10% - 1px) 10%); }
.cab__bar span { position: absolute; inset: 0 auto 0 0; background: var(--ok); transition: width var(--dur) var(--ease); }
.cab__reasons { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 12px; line-height: 1.4; color: var(--muted); }
.cab__reasons li { padding-left: 8px; border-left: 2px solid var(--line-strong); }
.cab__reasons li[data-level="ok"] { border-left-color: var(--ok); }
.cab__reasons li[data-level="warn"] { border-left-color: var(--warn); color: var(--text); }
.cab__reasons li[data-level="error"] { border-left-color: var(--error); color: var(--text); }
.cab__reasons .mono { color: var(--text); }
.cab__empty { margin: 0; font-size: 12.5px; line-height: 1.45; }
.cab__finish { display: grid; gap: 8px; }
.cab__power { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.cab__power .hand__why { flex: 1 1 140px; margin: 0; line-height: 1.4; }
.cab__close { display: flex; flex-wrap: wrap; gap: 6px; }

/* Part under the pointer in 3D, outlined in the list and the browser. */
.cat.is-3d-hover { box-shadow: inset 2px 0 0 var(--accent); }
.cat__item.is-3d-hover .cat__actions { color: var(--text); }
.part.is-3d-hover { border-color: var(--accent); }

/* ---------- Summary ---------- */
.sum { padding: var(--s-4); border-bottom: 1px solid var(--line); }
.sum:last-child { border-bottom: 0; }
.sum > h2.label { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-3); font-size: 13px; line-height: 1.2; }
.sum__total { margin: 0; font-size: 34px; font-weight: 500; line-height: 1.1; }
.sum__note { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.sum__small { margin: var(--s-2) 0 0; font-size: 12px; color: var(--muted); }
.sum__details { margin-top: var(--s-3); }
.sum__details summary,
.issues-group > summary {
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--muted);
}
.sum__details summary:hover,
.issues-group > summary:hover { color: var(--text); }
.sum__details .spec-table { margin-top: var(--s-2); }
.sum__counts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0 0 var(--s-3); }
.sum__ver { margin: 0; font-size: 14px; }
.sum__list { list-style: none; margin: var(--s-2) 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.sum__list li { display: grid; }
.sum__list .mono { font-size: 11.5px; overflow-wrap: anywhere; }
.sum__hints { margin: var(--s-3) 0 0; padding-left: 18px; font-size: 13px; display: grid; gap: 4px; }

.issues-group { margin-top: var(--s-3); }
.issues-group__h { margin: 0 0 var(--s-2); font-family: var(--font-head); font-size: 13px; letter-spacing: 0; }
.issues-group__h--error { color: var(--error); }
.issues-group__h--warn { color: var(--warn); }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
details.issues-group .issues { margin-top: var(--s-2); }
.issue { padding: 2px 0 2px var(--s-3); border-left: 2px solid var(--line-strong); }
.issue--error { border-left-color: var(--error); }
.issue--warn { border-left-color: var(--warn); }
.issue__msg { margin: 0; font-size: 13.5px; line-height: 1.45; }
.issue__fix { margin: 2px 0 2px; font-size: 12.5px; color: var(--muted); }

/* ---------- Drawer (part details) ---------- */
.drawer::backdrop { background: rgb(5 6 8 / .66); }
.drawer {
  padding: 0;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line-strong);
  position: fixed;
  inset: 0 0 0 auto;
  width: min(520px, 100vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border-width: 0 0 0 1px;
  overflow-y: auto;
  animation: drawer-in 220ms var(--ease);
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
.drawer__inner { padding: var(--s-5); }
.drawer__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-3); }
.drawer__head .label { margin: 0 0 4px; }
.drawer__title { font-size: 30px; margin: 0; }
.drawer__price { display: grid; gap: 2px; margin-top: var(--s-4); font-size: 12.5px; }
.drawer__amount { font-size: 24px; color: var(--text); }
.drawer__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; margin: var(--s-4) 0; }
.drawer__h { margin: var(--s-5) 0 var(--s-2); font-family: var(--font-head); font-size: 14px; letter-spacing: 0; color: var(--muted); }
.drawer .spec-table td { overflow-wrap: anywhere; }
.fit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fit { margin: 0; padding: 2px 0 2px 10px; border-left: 2px solid var(--line-strong); font-size: 14px; }
.fit .label { font-size: 11px; margin-right: 4px; }
.fit--error { border-left-color: var(--error); }
.fit--warn { border-left-color: var(--warn); }
.fit--ok { border-left-color: var(--ok); }

/* ---------- Modal contents ---------- */
.shortcuts td { white-space: nowrap; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--s-2); }
.chip {
  height: 28px;
  padding: 0 10px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: var(--muted); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.option { position: relative; display: block; cursor: pointer; }
.option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.option__body {
  display: grid;
  gap: 2px;
  height: 100%;
  padding: 10px var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.option:hover .option__body { border-color: var(--muted); }
.option input:checked + .option__body { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.option input:focus-visible + .option__body { outline: 2px solid var(--accent); outline-offset: 2px; }
.option__title { font-family: var(--font-head); font-weight: 600; font-size: 16px; letter-spacing: 0; }
.option__note { font-size: 12.5px; color: var(--muted); }

.af-score { font-family: var(--font-body); font-size: 16px; font-weight: 400; letter-spacing: 0; }
.af-meta { font-size: 11.5px; }
.af-list { list-style: none; margin: 0; padding: 0; }
.af-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 2px var(--s-3);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.af-row .label { font-size: 12px; padding-top: 2px; }
.af-row__name { font-size: 14px; font-weight: 500; }
.af-row__price { font-size: 13px; }
.af-row__why { grid-column: 2 / -1; font-size: 12.5px; color: var(--muted); }

.save-form { display: flex; gap: var(--s-2); align-items: flex-end; flex-wrap: wrap; }
.save-form .field { margin: 0; flex: 1 1 220px; }
.saved { list-style: none; margin: var(--s-4) 0 0; padding: 0; border-top: 1px solid var(--line); }
.saved__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  flex-wrap: wrap;
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line);
}
.saved__info { display: grid; gap: 2px; min-width: 0; }
.saved__name { font-weight: 600; overflow-wrap: anywhere; }
.saved__meta { font-size: 11.5px; }
.saved__actions { display: flex; gap: 2px; flex-wrap: wrap; }
.saved__rename { display: flex; gap: var(--s-2); width: 100%; }
.saved__rename .input { flex: 1; }

/* ---------- Narrow screens: tabs + status bar ---------- */
.builder__tabs { display: none; }

/* ---------- Summary bar (all sizes) ---------- */
.mbar {
  position: sticky;
  bottom: var(--s-4);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: var(--s-6);
  margin-top: var(--s-5);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.mbar__item { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 0 var(--s-2); }
.mbar__label { grid-column: 1 / -1; font-size: 12px; font-weight: 500; color: var(--muted); line-height: 1.2; }
.mbar__total { font-size: 22px; font-weight: 500; line-height: 1.25; }
.mbar__note { font-size: 11.5px; color: var(--muted); }
.mbar__value { font-size: 18px; line-height: 1.3; }
.mbar__item--status { display: flex; align-items: center; gap: var(--s-2); }
.mbar__status { font-weight: 600; font-size: 15px; }
.mbar__status[data-level="ok"] { color: var(--ok); }
.mbar__status[data-level="warn"] { color: var(--warn); }
.mbar__status[data-level="error"] { color: var(--error); }
.mbar__status[data-level="empty"] { color: var(--muted); }
.mbar__check {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--panel-2) no-repeat center / 14px;
}
.mbar__check[data-level="ok"] { background-color: var(--ok); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E"); }
.mbar__check[data-level="warn"],
.mbar__check[data-level="error"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M8 3.5v5.5M8 12.2v.3'/%3E%3C/svg%3E"); }
.mbar__check[data-level="warn"] { background-color: var(--warn); }
.mbar__check[data-level="error"] { background-color: var(--error); }
.mbar__more { margin-left: auto; }
/* Keep anything scrolled into view (keyboard focus, tray items) clear of the sticky bar. */
html:has(.mbar) { scroll-padding-top: calc(var(--topbar-h) + 12px); scroll-padding-bottom: 104px; }
@media (max-width: 1023px) { html:has(.mbar) { scroll-padding-bottom: calc(170px + env(safe-area-inset-bottom)); } }
.mbar__more[aria-expanded="true"] { --btn-text: var(--accent-text); --btn-border: var(--accent); }

@media (max-width: 1023px) {
  .builder { padding-bottom: var(--s-4); }
  .builder__tabs {
    position: sticky;
    top: var(--topbar-h);
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 0 calc(var(--gutter) * -1) var(--s-3);
    padding: 0 var(--gutter);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .tabbtn {
    position: relative;
    height: 44px;
    background: none;
    border: 0;
    color: var(--muted);
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0;
    cursor: pointer;
  }
  .tabbtn[aria-pressed="true"] { color: var(--text); }
  .tabbtn[aria-pressed="true"]::after {
    content: '';
    position: absolute;
    left: 16%; right: 16%; bottom: -1px;
    height: 2px;
    background: var(--accent);
  }
  .builder__grid { grid-template-columns: minmax(0, 1fr); }
  .builder__grid > .col { display: none; }
  .builder__grid[data-tab="build"] > .col--build,
  .builder__grid[data-tab="parts"] > .col--parts,
  .builder__grid[data-tab="3d"] > .col--parts,
  .builder__grid[data-tab="summary"] > .col--summary { display: block; }
  .centrebar { display: none; }
  .builder__grid > .col--parts > .viewer { display: none; }
  .builder__grid[data-tab="3d"] > .col--parts > .viewer { display: block; --viewer-h: max(300px, calc(100dvh - var(--topbar-h) - 380px)); }
  .builder__grid[data-tab="3d"] > .col--parts > .viewer[data-mode="hand"] { --viewer-h: max(220px, calc(100dvh - var(--topbar-h) - 450px)); }
  .viewer { scroll-margin-top: calc(var(--topbar-h) + 52px); }
  .builder__grid[data-tab="3d"] > .col--parts > .browser { display: none; }
  .col--build, .col--summary { position: static; max-height: none; overflow: visible; }

  .mbar {
    bottom: var(--s-3);
    gap: var(--s-4);
    padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
    border-radius: 18px;
  }
  .mbar__total { font-size: 18px; }
  .mbar__note, .mbar__item--power { display: none; }
  .mbar__status { font-size: 13px; }
  .mbar__check { width: 22px; height: 22px; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

/* Tablets (no bottom navigation): size the 3D view so its controls and the bar both fit on
   the first screen. */
@media (min-width: 721px) and (max-width: 1023px) {
  .builder__grid[data-tab="3d"] > .col--parts > .viewer { --viewer-h: max(300px, calc(100dvh - var(--topbar-h) - 450px)); }
}
/* Phones: the bottom navigation is shown, so the bar floats above it. */
@media (max-width: 720px) {
  .mbar { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
}

@media (max-width: 640px) {
  .builder__bar { padding-top: var(--s-4); }
  .hand__progress { flex-basis: 100%; }
  /* Build by hand on a phone: the camera follows the work, so keep the stage and tray close. */
  .viewer[data-mode="hand"] .viewer__tools--view,
  .viewer[data-mode="hand"] .viewer__opt { display: none; }
  .hsteps__label { font-size: 10.5px; padding: 0 1px; letter-spacing: .02em; }
  .hand__tools { gap: 4px; }
  .hand__tools .vbtn { padding: 0 6px; letter-spacing: .05em; }
  .tray__item { flex-basis: 156px; }
  .cab__tools .vbtn { padding: 0 6px; letter-spacing: .05em; }
  .viewer__range { flex-basis: 100%; }
  .viewer__range input { flex: 1; width: auto; }
  .viewer__field { flex-basis: 100%; }
  .viewer__field select { flex: 1; max-width: none; min-width: 0; }
  .browser__tools { padding: var(--s-3); }
  .browser__title { font-size: 26px; }
  .browser__row { flex-wrap: wrap; }
  .browser__row .field--grow { flex-basis: 100%; }
  .browser__row .field:not(.field--grow) { flex: 1; }
  .browser__row .field:not(.field--grow) .input { width: 100%; max-width: none; }
  .filters-toggle { display: inline-flex; }
  .filters { display: none; grid-template-columns: 1fr 1fr; }
  .filters[data-open="true"] { display: grid; }
  .field--price { grid-column: 1 / -1; }

  .part { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); padding: var(--s-3); }
  .part__side { flex-direction: row; align-items: center; flex-wrap: wrap; text-align: left; justify-content: flex-start; }
  .part__price { margin-right: auto; }
  .part__side > .tag { order: -1; flex-basis: 100%; width: max-content; }

  .drawer {
    inset: auto 0 0 0;
    width: 100vw;
    height: auto;
    max-height: 90dvh;
    border-width: 1px 0 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    animation-name: sheet-in;
  }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
  .drawer__inner { padding: var(--s-4); }
  .options { grid-template-columns: 1fr; }
  .af-row { grid-template-columns: minmax(0, 1fr) auto; }
  .af-row .label { grid-column: 1 / -1; }
  .af-row__why { grid-column: 1 / -1; }
}

/* ---------- Photo mode: the 3D stage fills the window, page UI hidden ---------- */
html.is-photo { overflow: hidden; }
.viewer[data-photo="true"] .viewer__stage { position: fixed; inset: 0; z-index: 250; height: auto; border: 0; }
.viewer[data-photo="true"] :is(.viewer__hud, .viewer__frame, .viewer__hover, .viewer__msg) { display: none; }
.photo { position: absolute; inset: auto 0 0 0; padding: var(--s-3); pointer-events: none; }
.photo__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--s-2) var(--s-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  pointer-events: auto;
}
.photo[data-bar="off"] .photo__bar { display: none; }
.photo__group { display: flex; align-items: center; gap: var(--s-2); margin: 0; }
.photo__group .label { margin: 0; font-size: 11.5px; }
.photo__group select { height: 30px; padding: 0 8px; font-size: 13px; width: auto; }
.photo__group .check { font-size: 13px; white-space: nowrap; }
.photo__range input { width: 96px; accent-color: var(--accent); }
.photo__spacer { flex: 1; }
.photo__note { max-width: 1100px; margin: 6px auto 0; font-size: 11.5px; color: var(--muted); text-align: left; min-height: 1.4em; text-shadow: 0 1px 2px #000; }
@media (max-width: 640px) {
  .photo { padding: var(--s-2); }
  .photo__bar { gap: var(--s-2); }
  .photo__spacer { display: none; }
  .photo__group .vbtn { padding-inline: 8px; }
}

/* Gentle studio vignette: edges a little darker so the white case stands out. At Ultra the
   render pass draws its own on top. */
.viewer[data-quality="high"] .viewer__stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 48%, rgb(26 28 32 / .26) 100%);
}
.viewer[data-quality="high"] .viewer__stage > :not(canvas) { z-index: 1; }
