/* MGA 1600 configurator: UI styles.
   Look: a late-1950s British sales brochure and driver's handbook. Cream paper with a fine
   grain, deep racing green for active states, brass for selection and focus, chrome
   hairlines; Baskerville for headings and Gill Sans small caps for labels (system fonts,
   with fallbacks). Desktop: a right-hand specification column over a full-bleed view.
   Phones (<= 760 px, .is-sheet): top bar, scrolling view chips and a bottom sheet.
   Phones on their side (.is-landscape, layout.js): a narrow column, one row of bars at the
   top and one at the bottom, inside the safe area. Touch screens get 44 px targets. */

:root {
  --paper: #f3eee3;
  --paper-hi: #fbf8f1;
  --paper-lo: #e9e1d0;
  --paper-edge: #d8cdb6;
  --ink: #1c2420;
  --ink-2: #35403a;
  --muted: #5b6159;
  --rule: rgba(28, 36, 32, 0.15);
  --rule-strong: rgba(28, 36, 32, 0.32);
  --green: #1e3b2c;
  --green-2: #2b5440;
  --on-green: #f6f1e6;
  --brass: #7a5d26; /* text-safe on paper (5.3:1) */
  --brass-hi: #c9a25a; /* decorative only */
  --error: #8c2a22;
  --chrome: linear-gradient(180deg, #fdfdfc 0%, #dfe2e3 42%, #a9aeb1 52%, #eceeef 100%);
  --glass: color-mix(in srgb, var(--paper) 90%, transparent);
  --shadow-1: 0 1px 2px rgba(22, 26, 22, 0.1), 0 6px 20px rgba(22, 26, 22, 0.12);
  --shadow-2: 0 2px 6px rgba(22, 26, 22, 0.1), 0 22px 60px rgba(22, 26, 22, 0.22);
  --serif: Baskerville, 'Baskerville Old Face', 'Libre Baskerville', 'Hoefler Text', Garamond, 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Gill Sans', 'Gill Sans MT', 'Gill Sans Nova', Seravek, Optima, 'Segoe UI', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --gap: 16px;
  --panel-w: clamp(330px, 27vw, 408px);
  --radius: 12px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --sheet-min: 118px;
  --sheet-peek: 46svh;
  --sheet-full: 84svh;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .32 0 0 0 0 .27 0 0 0 0 .18 0 0 0 .07 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------- base ---------- */
html,
body {
  margin: 0;
  height: 100%;
  background: #dcdad3;
  color: var(--ink);
  font: 400 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}
#app {
  position: fixed;
  inset: 0;
  overflow: clip; /* never scrollable, not even programmatically */
}
#viewport {
  position: absolute;
  inset: 0;
}
#viewport canvas {
  display: block;
  touch-action: none;
}
#viewport canvas:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: -4px;
}
.ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  --vis-r: 0px;
  --vis-b: 0px;
  --vis-t: 0px;
  --vis-l: 0px;
  --vis-cx: calc(var(--vis-l) + (100% - var(--vis-l) - var(--vis-r)) / 2);
}
.ui > * {
  pointer-events: auto;
}
.ui .topbar {
  pointer-events: none;
}
.ui .topbar > * {
  pointer-events: auto;
}
/* resets carry no specificity (:where) so component classes always win */
:where(.ui) :where(h1, h2, h3, p, dl, dd, ul, fieldset) {
  margin: 0;
  padding: 0;
}
:where(.ui) ul {
  list-style: none;
}
:where(.ui) fieldset {
  border: 0;
  min-width: 0;
}
:where(.ui) :where(button, select, input) {
  font: inherit;
  color: inherit;
}
:where(.ui) button {
  cursor: pointer;
}
.ui [hidden] {
  display: none !important;
}
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  display: block;
}
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.muted {
  color: var(--muted);
}
.skip-link {
  position: absolute;
  left: var(--gap);
  top: -60px;
  z-index: 60;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--green);
  color: var(--on-green);
  text-decoration: none;
}
.skip-link:focus {
  top: var(--gap);
}
.ui :focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
kbd {
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.06em;
  padding: 2px 5px;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  margin-left: 4px;
}

/* small caps label style used across the UI */
.brand-kicker,
.brand-sub,
.panel-kicker,
.panel-nav,
.opt-label,
.group-title,
.swatch-code,
.hint-kicker,
.card-kicker,
.meta-label,
.pop-title,
.tag,
.confidence,
.loading-kicker,
.loading-sub {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10.5px;
  font-weight: 500;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--green);
  background: var(--green);
  color: var(--on-green);
  font-size: 13px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.btn:hover {
  background: var(--green-2);
}
.btn .icon {
  width: 16px;
  height: 16px;
}
.btn-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-strong);
}
.btn-quiet:hover {
  background: var(--paper-lo);
}
.btn-small {
  height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
}
.btn[aria-pressed='true'] {
  background: var(--brass);
  border-color: var(--brass);
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
}
.icon-btn:hover {
  background: var(--paper-lo);
}

/* ---------- top bar: title + actions ---------- */
.topbar {
  position: absolute;
  z-index: 16; /* above the view chips and bars, so the actions menu can drop over them */
  top: var(--gap);
  left: var(--gap);
  right: calc(var(--vis-r) + var(--gap));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  transition: right 0.05s linear;
}
.brand {
  padding: 11px 18px 12px;
  border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: var(--shadow-1);
  border: 1px solid rgba(255, 255, 255, 0.55);
}
.brand-kicker {
  color: var(--muted);
  font-size: 10px;
}
.brand-title {
  position: relative;
  font: 400 30px/1.05 var(--serif);
  letter-spacing: 0.08em;
  margin: 3px 0 5px;
  padding-bottom: 7px;
}
.brand-title::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, #9da2a5, #f7f8f8 45%, #9da2a5 70%, rgba(157, 162, 165, 0));
}
.brand-title span {
  color: var(--brass);
}
.brand-sub {
  color: var(--ink-2);
  font-size: 10px;
}
.actions {
  position: relative;
}
.actions-list {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: var(--shadow-1);
  border: 1px solid rgba(255, 255, 255, 0.55);
}
.act {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  min-width: 36px;
  padding: 0 9px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.act:hover {
  background: var(--paper-lo);
  color: var(--ink);
}
.act[aria-pressed='true'] {
  background: var(--green);
  color: var(--on-green);
}
.act[aria-busy='true'] {
  opacity: 0.6;
  cursor: progress;
}
.act .act-text {
  display: none;
}
.act-labelled .act-text {
  display: inline;
}
.menu-btn {
  display: none;
}
.env-pill {
  padding-right: 6px;
  cursor: pointer;
}
.env-select {
  appearance: none;
  field-sizing: content;
  border: 0;
  background: transparent;
  font-size: 13px;
  padding: 0 18px 0 0;
  margin-right: -20px;
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.env-pill .chev .icon,
.tool-btn .chev .icon {
  width: 14px;
  height: 14px;
}
.bar-sep {
  width: 1px;
  height: 22px;
  background: var(--rule-strong);
  margin: 0 2px;
}
.ui.is-busy .env-pill {
  cursor: progress;
  opacity: 0.7;
}

/* ---------- views bar and tools bar (centred on the uncovered area) ---------- */
.views-bar,
.tools-bar {
  position: absolute;
  left: var(--vis-cx);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: var(--shadow-1);
  border: 1px solid rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}
.views-bar {
  bottom: 18px;
  gap: 2px;
  padding: 4px;
}
.view-btn {
  height: 32px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: 0.05em;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.view-btn:hover {
  background: var(--paper-lo);
  color: var(--ink);
}
.view-btn[aria-pressed='true'] {
  background: var(--green);
  color: var(--on-green);
}
.tools-bar {
  bottom: 70px;
  gap: 8px;
  padding: 5px 8px 5px 5px;
}
.btn-explode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  min-width: 112px;
  padding: 0 15px 0 11px;
  border-radius: 999px;
  border: 1px solid var(--green);
  background: var(--green);
  color: var(--on-green);
  font-size: 13.5px;
  letter-spacing: 0.04em;
}
.btn-explode:hover {
  background: var(--green-2);
}
.btn-explode[aria-pressed='true'] {
  background: var(--paper-hi);
  color: var(--green);
}
.range-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.range {
  --fill: 0%;
  appearance: none;
  width: 150px;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--green) var(--fill), var(--rule-strong) var(--fill));
}
.range::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: var(--rule-strong);
}
.range::-moz-range-progress {
  height: 3px;
  background: var(--green);
}
.range::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7.5px;
  border-radius: 50%;
  background: var(--chrome);
  border: 1px solid #7f8487;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--chrome);
  border: 1px solid #7f8487;
}
.readout {
  width: 34px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-align: right;
}
.chip-toggle,
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  letter-spacing: 0.04em;
}
.chip-toggle .icon,
.tool-btn .icon {
  width: 16px;
  height: 16px;
}
.chip-toggle:hover,
.tool-btn:hover {
  background: var(--paper-lo);
}
.chip-toggle[aria-pressed='true'] {
  border-color: var(--green);
  color: var(--green);
  background: color-mix(in srgb, var(--green) 9%, transparent);
}
.tool-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* popovers */
.pop {
  position: relative;
}
.pop-panel {
  position: absolute;
  z-index: 20;
  min-width: 250px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--paper);
  background-image: var(--grain);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--paper-edge);
  white-space: normal;
}
.pop-up {
  bottom: calc(100% + 12px);
  right: -8px;
  max-height: var(--pop-room, none);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.pop-title {
  color: var(--muted);
  margin-bottom: 6px;
}
.pop-foot {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
}
.open-list .switch-row {
  padding: 6px 0;
}

/* ---------- switches ---------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}
.switch-label {
  font-size: 14px;
}
.switch {
  appearance: none;
  position: relative;
  flex: none;
  width: 40px;
  height: 23px;
  margin: 0;
  border-radius: 999px;
  background: var(--paper-lo);
  border: 1px solid var(--rule-strong);
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--chrome);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s var(--ease);
}
.switch:checked {
  background: var(--green);
  border-color: var(--green);
}
.switch:checked::after {
  transform: translateX(17px);
}

/* ---------- configuration panel ---------- */
.panel {
  position: absolute;
  top: var(--gap);
  right: var(--gap);
  bottom: var(--gap);
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background-color: var(--paper);
  background-image: var(--grain);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--paper-edge);
  transition: transform 0.42s var(--ease);
  z-index: 10;
}
.panel:focus {
  outline: none;
}
.ui.panel-collapsed .panel {
  transform: translateX(calc(100% + var(--gap) + 6px));
  visibility: hidden;
  transition: transform 0.42s var(--ease), visibility 0s 0.42s;
}
.sheet-handle {
  display: none;
}
.panel-head {
  padding: 16px 22px 10px;
  text-align: center;
}
.panel-plate {
  margin: 0 auto 8px;
  width: 78%;
}
.panel-plate .elevation {
  --paint: transparent;
}
.panel-plate .elev-body {
  fill: var(--paint);
  transition: fill 0.5s var(--ease);
}
.panel-plate .elev-line {
  stroke: #fff;
  stroke-opacity: 0.32;
}
.panel-kicker {
  color: var(--brass);
}
.panel-title {
  font: 400 23px/1.2 var(--serif);
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.panel-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 4px;
  padding: 8px 14px 10px;
  border-bottom: 3px double var(--rule-strong);
  font-size: 10.5px;
}
.nav-item {
  border: 0;
  background: transparent;
  padding: 4px 6px;
  color: var(--muted);
  letter-spacing: inherit;
  text-transform: inherit;
  border-bottom: 1px solid transparent;
}
.nav-item:hover {
  color: var(--ink);
}
.nav-item[aria-current='true'] {
  color: var(--ink);
  border-bottom-color: var(--brass);
}
.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 22px 26px;
  scroll-padding-top: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--paper-edge) transparent;
}
.panel-body:focus {
  outline: none;
}
.cfg-section {
  padding: 20px 0 6px;
}
.cfg-section + .cfg-section {
  border-top: 1px solid var(--rule);
}
.sec-head {
  margin-bottom: 10px;
}
.sec-head h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font: 400 22px/1.2 var(--serif);
  letter-spacing: 0.01em;
}
.sec-num {
  font: 400 17px/1 var(--serif);
  color: var(--brass);
}
.sec-num:not(:has(svg))::after {
  content: '.';
}
.sec-num .icon {
  width: 17px;
  height: 17px;
  transform: translateY(2px);
}
.sec-summary {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}
.opt + .opt {
  margin-top: 16px;
}
.opt-label {
  display: block;
  color: var(--ink-2);
  margin-bottom: 8px;
  padding: 0;
}
.group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 9px;
  color: var(--muted);
  font-size: 10px;
}
.group-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
}
.swatch-group:first-of-type .group-title {
  margin-top: 4px;
}
.note {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-left: 2px solid var(--brass);
  background: color-mix(in srgb, var(--paper-lo) 75%, transparent);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.note strong {
  font: italic 400 13.5px/1.4 var(--serif);
  color: var(--ink);
}

/* paint-chip swatches */
.swatches {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 9px;
}
.swatch {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  min-width: 0;
}
.chip {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 5px;
  background-color: var(--c);
  background-image: linear-gradient(158deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.06) 34%, rgba(255, 255, 255, 0) 36%), linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0%, rgba(0, 0, 0, 0) 48%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14), 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
}
.chip.is-metallic {
  background-image: linear-gradient(158deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.06) 34%, rgba(255, 255, 255, 0) 36%), radial-gradient(rgba(255, 255, 255, 0.14) 0.5px, transparent 0.7px), linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0%, rgba(0, 0, 0, 0) 48%);
  background-size: auto, 3px 3px, auto;
}
.swatch:hover .chip {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14), 0 4px 10px rgba(0, 0, 0, 0.16);
}
.swatch input:checked + .chip {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14), 0 0 0 2px var(--paper), 0 0 0 4px var(--green);
}
.swatch input:checked + .chip::after {
  content: '';
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--paper-hi) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 8.4l2.6 2.5L12 5.5' fill='none' stroke='%231e3b2c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / 11px no-repeat;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.swatch input:focus-visible + .chip {
  outline: 2px solid var(--brass);
  outline-offset: 5px;
}
.swatch-name {
  font-size: 11.5px;
  line-height: 1.22;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.swatch-code {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: -2px;
}
.swatch-caption {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dotted var(--rule-strong);
}
.swatch-caption:empty {
  display: none;
}
.caption-name {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  font: 400 16px/1.3 var(--serif);
}
.confidence {
  font-size: 9.5px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  color: var(--muted);
}
.confidence.c-high {
  color: var(--green-2);
}
.confidence.c-low {
  color: var(--brass);
}
.caption-facts {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.caption-note {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.caption-note summary {
  cursor: pointer;
  color: var(--brass);
  font-size: 12px;
  width: max-content;
}
.caption-note p {
  margin-top: 5px;
  line-height: 1.5;
}
.combo-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--rule-strong);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.combo-hint:empty {
  display: none;
}
.combo-hint p {
  flex: 1;
}
.hint-kicker {
  display: block;
  color: var(--brass);
  font-size: 9.5px;
  margin-bottom: 2px;
}

/* choices: segmented controls and option lists */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--paper-lo);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}
.choice {
  display: block;
  cursor: pointer;
  min-width: 0;
}
.segmented .choice-face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  color: var(--ink-2);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.segmented .choice:hover .choice-face {
  color: var(--ink);
}
.segmented input:checked + .choice-face {
  background: var(--green);
  color: var(--on-green);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.choice-list {
  display: grid;
  gap: 6px;
}
.choice-list .choice-face {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 7px 12px 7px 36px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper-hi) 70%, transparent);
  font-size: 13.5px;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.choice-list .choice-face::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -8px;
  border-radius: 50%;
  border: 1px solid var(--rule-strong);
  background: var(--paper-hi);
}
.choice-list .choice:hover .choice-face {
  border-color: var(--rule-strong);
}
.choice-list input:checked + .choice-face {
  border-color: var(--green);
  background: var(--paper-hi);
  box-shadow: inset 0 0 0 1px var(--green);
}
.choice-list input:checked + .choice-face::before {
  border-color: var(--green);
  background: radial-gradient(circle, var(--paper-hi) 0 2.5px, var(--green) 3px);
}
.choice input:focus-visible + .choice-face {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* Studio build / Stock 1960 compare at the top of the panel (compare.js): a segmented
   control of two buttons, pressed while the config matches that build */
.compare {
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--rule);
}
.compare .choice-face {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.compare .choice-face:hover {
  color: var(--ink);
}
.compare .choice-face[aria-pressed='true'] {
  background: var(--green);
  color: var(--on-green);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.compare .choice-face:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
.compare-note {
  margin-top: 6px;
  font: italic 400 12.5px/1.35 var(--serif);
  color: var(--muted);
}
.choice-name {
  flex: 1;
  min-width: 0;
}
.segmented .choice-name {
  flex: none;
}
.segmented .choice-face {
  flex-direction: column;
  gap: 0;
}
.segmented .tag {
  border: 0;
  padding: 0;
  font-size: 8.5px;
  color: inherit;
  opacity: 0.75;
}
.dot {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.tag {
  flex: none;
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  color: var(--muted);
}
.opt-toggle {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper-hi) 70%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.opt-toggle .switch-row {
  flex: 1;
}
/* geometry option whose system isn't modelled yet, or whose parts another choice hides
   (config-panel.js); the hidden one's controls are disabled meanwhile */
.opt-pending,
.opt-masked {
  display: block;
  margin: -3px 0 8px;
  font: italic 400 12.5px/1.35 var(--serif);
  color: var(--muted);
}
.opt-toggle .opt-pending,
.opt-toggle .opt-masked {
  margin: 2px 0 0;
}
.switch:disabled,
.choice input:disabled + .choice-face {
  opacity: 0.45;
}
.switch-row:has(.switch:disabled),
.choice:has(input:disabled),
.switch:disabled {
  cursor: default;
}
.opt-toggle + .opt-toggle {
  margin-top: 8px;
}

/* build sheet, after the handbook's "General Data" page */
.build-sheet .sheet-list {
  font: 400 14px/1.4 var(--serif);
  border-top: 1px solid var(--rule);
  padding-top: 8px;
}
.sheet-row {
  display: flex;
  align-items: baseline;
  gap: 0;
  padding: 3px 0;
}
.sheet-row dt {
  flex: 1 1 auto;
  display: flex;
  align-items: baseline;
  min-width: 90px;
  color: var(--ink-2);
}
.sheet-row dt::after {
  content: '';
  flex: 1;
  min-width: 14px;
  margin: 0 6px;
  border-bottom: 1.5px dotted var(--rule-strong);
  transform: translateY(-4px);
}
.sheet-row dd {
  flex: 0 1 auto;
  max-width: 62%;
  text-align: right;
}
.sheet-code {
  display: inline-block;
  margin-left: 6px;
  font: 400 10.5px/1 var(--mono);
  color: var(--muted);
}
.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- info card ---------- */
.info-card {
  position: absolute;
  left: var(--gap);
  top: 132px;
  width: 320px;
  padding: 14px 16px 14px;
  border-radius: var(--radius);
  background: var(--paper);
  background-image: var(--grain);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--paper-edge);
  z-index: 12;
  animation: card-in 0.25s var(--ease);
}
@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.ui.tree-open .info-card {
  left: calc(var(--gap) + 330px + 12px);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.card-kicker {
  color: var(--brass);
  font-size: 10px;
}
.card-title {
  font: 400 22px/1.15 var(--serif);
  margin-top: 2px;
}
.card-title:focus {
  outline: none;
}
.card-close {
  flex: none;
  margin: -4px -6px 0 0;
}
.card-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  margin-top: 6px;
  font-size: 12px;
}
.crumb {
  border: 0;
  background: none;
  padding: 0;
  color: var(--green-2);
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 2px;
}
.crumb-sep {
  color: var(--muted);
}
.card-desc {
  margin-top: 8px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.meta-label {
  font-size: 9.5px;
  color: var(--muted);
}
.card-id {
  font: 400 12px/1 var(--mono);
  padding: 4px 6px;
  border-radius: 4px;
  background: var(--paper-lo);
  color: var(--ink-2);
}
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 14px;
}
.card-actions .btn-small {
  gap: 5px;
  padding: 0 9px;
  font-size: 12px;
}
.card-actions .icon {
  width: 15px;
  height: 15px;
}

/* ---------- parts drawer ---------- */
.drawer {
  position: absolute;
  top: var(--gap);
  left: var(--gap);
  bottom: var(--gap);
  width: 330px;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: var(--paper);
  background-image: var(--grain);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--paper-edge);
  z-index: 20; /* over the title card */
  animation: drawer-in 0.3s var(--ease);
}
@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 16px 8px 18px;
}
.drawer-title {
  font: 400 24px/1.2 var(--serif);
}
.drawer-count {
  font: 500 12px/1 var(--sans);
  color: var(--muted);
  letter-spacing: 0.08em;
}
.drawer-tools {
  display: flex;
  gap: 6px;
  padding: 0 16px 10px 18px;
  border-bottom: 3px double var(--rule-strong);
}
.tree {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 8px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--paper-edge) transparent;
}
.tree-list .tree-list {
  margin-left: 15px;
  padding-left: 6px;
  border-left: 1px solid var(--rule);
}
.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 0 6px 0 2px;
  border-radius: 6px;
}
.tree-row:hover {
  background: color-mix(in srgb, var(--paper-lo) 80%, transparent);
}
.tree-row.is-selected {
  background: color-mix(in srgb, var(--brass-hi) 24%, transparent);
  box-shadow: inset 2px 0 0 var(--brass);
}
.tree-row.is-system .tree-name {
  font: 400 15.5px/1.2 var(--serif);
}
.tree-twisty {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}
.tree-twisty .icon {
  width: 14px;
  height: 14px;
  transform: rotate(-90deg);
  transition: transform 0.18s var(--ease);
}
.tree-twisty[aria-expanded='true'] .icon {
  transform: none;
}
.tree-check-hit {
  display: flex;
  align-items: center;
  flex: none;
  align-self: stretch;
  cursor: pointer;
}
.tree-check {
  flex: none;
  width: 15px;
  height: 15px;
  margin: 0 4px 0 0;
  accent-color: var(--green);
  cursor: pointer;
}
/* hidden with a parent row: shown again by ticking that row */
.tree-check:disabled {
  cursor: default;
}
.tree-row:has(.tree-check:disabled) .tree-name {
  color: var(--muted);
}
.tree-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  border: 0;
  background: none;
  padding: 4px 2px;
  font-size: 13px;
}
.tree-count {
  flex: none;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- isolate chip, toasts ---------- */
.isolate-chip {
  position: absolute;
  top: calc(var(--vis-t) + var(--gap));
  left: var(--vis-cx);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--paper-edge);
  font-size: 13px;
  white-space: nowrap;
  z-index: 13;
}
.isolate-chip strong {
  font: italic 400 15px/1 var(--serif);
}
.toasts {
  position: absolute;
  left: var(--vis-cx);
  bottom: calc(var(--vis-b) + 128px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 30;
}
.toast {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--green);
  color: var(--on-green);
  font-size: 13px;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-1);
  white-space: nowrap;
  animation: toast-in 0.25s var(--ease);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.toast.is-error {
  background: var(--error);
}
.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- exploded-view labels (CSS2DRenderer layer) ---------- */
.xlabels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  z-index: 1;
}
.xlabels.is-on {
  opacity: 1;
}
.xl {
  position: absolute;
  width: 0;
  height: 0;
}
.xl-dot {
  position: absolute;
  left: -3.5px;
  top: -3.5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1.5px rgba(251, 248, 241, 0.9);
}
.xl-lead {
  position: absolute;
  left: 0;
  top: -0.5px;
  height: 1px;
  background: rgba(28, 36, 32, 0.78);
  box-shadow: 0 0 0 0.5px rgba(251, 248, 241, 0.6);
  transform-origin: 0 50%;
}
.xl-tag {
  position: absolute;
  left: 0;
  top: 0;
  height: 24px;
  padding: 0 9px;
  white-space: nowrap;
  border-radius: 4px;
  border: 1px solid rgba(28, 36, 32, 0.28);
  background: color-mix(in srgb, var(--paper-hi) 94%, transparent);
  color: var(--ink);
  font: italic 400 13.5px/22px var(--serif);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
  cursor: pointer;
}
.xlabels:not(.is-on) .xl-tag {
  pointer-events: none;
}
.xl-tag:hover {
  border-color: var(--brass);
  color: var(--green);
}

/* ---------- side elevation drawing (loading screen, panel plate) ---------- */
.elevation {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.elev-body {
  stroke: var(--ink);
  stroke-width: 1.2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.elev-line {
  stroke: var(--ink);
  stroke-opacity: 0.5;
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
}
.elev-screen {
  fill: rgba(196, 214, 222, 0.35);
  stroke: var(--ink);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.elev-ground {
  stroke: var(--ink);
  stroke-opacity: 0.28;
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
}
.elev-tyre {
  fill: #2a2d2b;
  stroke: var(--ink);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.elev-rim {
  fill: #c9ccce;
  stroke: var(--ink);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
}
.elev-hub {
  fill: #eef0f1;
  stroke: var(--ink);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
}

/* ---------- loading screen ---------- */
.loading {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 40%, var(--paper-hi) 0%, var(--paper) 55%, var(--paper-lo) 100%);
  background-color: var(--paper);
  transition: opacity 0.6s var(--ease), visibility 0.6s;
  --p: 0;
}
.loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  pointer-events: none;
}
/* Exit in two beats, so the title and drawing never ghost over the live car: the content
   lifts away first, then the bare paper dissolves (loader.js hides it afterwards). */
.loading.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.45s var(--ease) 0.18s, visibility 0s linear 0.63s;
}
.loading-inner {
  position: relative;
  width: min(580px, 86vw);
  text-align: center;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}
.loading.done .loading-inner {
  opacity: 0;
  transform: translateY(-6px);
}
.loading-kicker {
  color: var(--muted);
}
.loading-title {
  margin: 6px 0 4px;
  font: 400 clamp(40px, 9vw, 60px) / 1 var(--serif);
  letter-spacing: 0.1em;
}
.loading-title span {
  color: var(--brass);
}
.loading-sub {
  color: var(--ink-2);
}
.loading-art {
  margin: 26px auto 18px;
  width: 92%;
  min-height: 40px;
}
.loading-art .elev-body {
  fill: none;
  /* pathLength dashes are measured in user units: a non-scaling stroke would be dashed in
     screen pixels and never reach the end of the outline */
  vector-effect: none;
  stroke-width: 1.05;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--p));
  transition: stroke-dashoffset 0.5s var(--ease);
}
.loading-art .elev-line,
.loading-art .elev-tyre,
.loading-art .elev-rim,
.loading-art .elev-hub {
  opacity: calc(var(--p) * 1.4 - 0.3);
  transition: opacity 0.5s var(--ease);
}
.loading-art .elev-tyre {
  fill: none;
}
.loading-art .elev-rim,
.loading-art .elev-hub {
  fill: none;
}
.loading-bar {
  position: relative;
  height: 2px;
  width: 62%;
  margin: 0 auto;
  background: var(--rule);
  overflow: hidden;
}
.loading-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 30%;
  background: var(--brass);
  animation: loading-sweep 1.4s var(--ease) infinite;
}
.loading.has-progress .loading-bar span {
  width: calc(var(--p) * 100%);
  animation: none;
  transition: width 0.4s var(--ease);
}
@keyframes loading-sweep {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}
.loading-status {
  margin-top: 14px;
  font: italic 400 15px/1.5 var(--serif);
  color: var(--ink-2);
  min-height: 1.5em;
}
.loading.failed .loading-bar span {
  width: 100%;
  background: var(--error);
}
.loading.failed .loading-status {
  font-style: normal;
  color: var(--ink);
}
.loading.failed .loading-status strong {
  color: var(--error);
}
.loading-actions {
  margin-top: 16px;
}
.loading-detail {
  margin: 14px auto 0;
  max-width: 100%;
  text-align: left;
  font-size: 12.5px;
}
.loading-detail summary {
  cursor: pointer;
  color: var(--muted);
  text-align: center;
}
.loading-detail pre {
  margin-top: 8px;
  max-height: 28vh;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--paper-lo);
  font: 11.5px/1.45 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- compact desktop (narrow windows, portrait tablets) ---------- */
@media (min-width: 761px) and (max-width: 1100px) {
  :root {
    --panel-w: 300px;
    --gap: 12px;
  }
  /* the panel masthead carries the title here; the floating card would crowd the actions */
  .brand {
    display: none;
  }
  .topbar {
    justify-content: flex-end;
  }
  .act-labelled .act-text,
  .actions-list .bar-sep {
    display: none;
  }
  .actions-list {
    gap: 2px;
  }
  .view-btn {
    padding: 0 9px;
    font-size: 12.5px;
  }
  .readout,
  .chip-toggle .btn-text,
  .tool-btn .btn-text {
    display: none;
  }
  .range {
    width: 110px;
  }
  .btn-explode {
    min-width: 0;
  }
  .info-card {
    top: 70px;
    width: 290px;
  }
  .drawer {
    width: 290px;
  }
  .ui.tree-open .info-card {
    left: calc(var(--gap) + 290px + 10px);
  }
  .panel-head {
    padding: 12px 16px 6px;
  }
  .panel-body {
    padding: 0 16px 22px;
  }
  /* three chips a row keep two-word colour names whole in the narrower column */
  .swatches {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 8px;
  }
}

/* ---------- short windows (landscape phones, small laptops): give the panel to options ---------- */
@media (min-width: 761px) and (max-height: 560px) {
  .panel-plate,
  .panel-kicker {
    display: none;
  }
  .panel-head {
    padding: 8px 14px 2px;
  }
  .panel-title {
    font-size: 18px;
  }
  .panel-nav {
    padding: 4px 10px 6px;
  }
  .nav-item {
    padding: 3px 5px;
  }
  .cfg-section {
    padding-top: 12px;
  }
  .views-bar {
    bottom: 10px;
  }
  .tools-bar {
    bottom: 58px;
  }
  .info-card {
    top: 64px;
  }
}

/* ---------- phones: top bar, view chips, bottom sheet ---------- */
.ui.is-sheet .topbar {
  top: 0;
  left: 0;
  right: 0;
  padding: max(8px, env(safe-area-inset-top)) 10px 6px 12px;
  align-items: center;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  backdrop-filter: blur(12px) saturate(1.1);
  border-bottom: 1px solid var(--rule);
  pointer-events: auto;
}
.ui.is-sheet .brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0;
  background: none;
  box-shadow: none;
  border: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.ui.is-sheet .brand-title {
  font-size: 22px;
  margin: 0;
  padding: 0;
  border: 0;
}
.ui.is-sheet .brand-kicker {
  display: none;
}
.ui.is-sheet .brand-sub {
  font-size: 9.5px;
}
.ui.is-sheet .menu-btn {
  display: inline-flex;
  justify-content: center;
}
.ui.is-sheet .actions-list {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 230px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--paper);
  background-image: var(--grain);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--paper-edge);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.ui.is-sheet .actions.is-open .actions-list {
  display: flex;
}
.ui.is-sheet .actions-list .act {
  justify-content: flex-start;
  height: 42px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 14px;
}
.ui.is-sheet .actions-list .act-text {
  display: inline;
}
.ui.is-sheet .actions-list .bar-sep {
  width: auto;
  height: 1px;
  margin: 4px 6px;
}
.ui.is-sheet .env-select {
  font-size: 14px;
  flex: 1;
}
.ui.is-sheet .views-bar {
  top: var(--topbar-h, 52px);
  bottom: auto;
  left: 0;
  right: 0;
  transform: none;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 0;
  background: none;
  box-shadow: none;
  border: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.ui.is-sheet .views-bar::-webkit-scrollbar {
  display: none;
}
.ui.is-sheet .view-btn {
  flex: none;
  height: 32px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.ui.is-sheet .view-btn[aria-pressed='true'] {
  background: var(--green);
}
.ui.is-sheet .tools-bar {
  left: 50%;
  bottom: calc(var(--vis-b) + 10px);
  gap: 6px;
  padding: 4px 6px 4px 4px;
  max-width: calc(100% - 16px);
}
.ui.is-sheet .tools-bar.is-tucked {
  visibility: hidden;
}
.ui.is-sheet .btn-explode {
  min-width: 0;
  padding: 0 11px 0 9px;
  font-size: 12px;
}
.ui.is-sheet .range {
  width: 92px;
}
.ui.is-sheet .readout,
.ui.is-sheet .chip-toggle .btn-text,
.ui.is-sheet .tool-btn .btn-text,
.ui.is-sheet .tools-bar .bar-sep {
  display: none;
}
.ui.is-sheet .chip-toggle,
.ui.is-sheet .tool-btn {
  padding: 0 9px;
}
.ui.is-sheet .pop-up {
  right: -4px;
}
.ui.is-sheet .panel {
  top: auto;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: var(--sheet-peek);
  border-radius: 18px 18px 0 0;
  border-width: 1px 0 0;
  transition: height 0.38s var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
.ui.is-sheet .panel[data-sheet='min'] {
  height: var(--sheet-min);
}
.ui.is-sheet .panel[data-sheet='full'] {
  /* never up over the view chips (a short screen: an SE, or Safari's bars showing) */
  height: min(var(--sheet-full), calc(100% - var(--vis-t) - env(safe-area-inset-bottom) - 4px));
}
.ui.is-sheet .panel.is-dragging {
  transition: none;
}
.ui.is-sheet .sheet-handle {
  display: grid;
  place-items: center;
  flex: none;
  height: 24px;
  border: 0;
  background: transparent;
  touch-action: none;
  cursor: grab;
}
.ui.is-sheet .sheet-handle .grip {
  width: 42px;
  height: 4px;
  border-radius: 4px;
  background: var(--rule-strong);
}
.ui.is-sheet .panel-head,
.ui.is-sheet .panel-toggle {
  display: none;
}
.ui.is-sheet .panel-nav {
  flex-wrap: nowrap;
  justify-content: flex-start;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 12px 8px;
  gap: 4px;
  border-bottom-width: 3px;
}
.ui.is-sheet .panel-nav::-webkit-scrollbar {
  display: none;
}
.ui.is-sheet .nav-item {
  flex: none;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--rule);
}
.ui.is-sheet .nav-item[aria-current='true'] {
  background: var(--green);
  color: var(--on-green);
  border-color: var(--green);
}
.ui.is-sheet .panel-body {
  padding: 0 16px 22px;
}
.ui.is-sheet .cfg-section {
  padding-top: 14px;
  border-top: 0;
}
.ui.is-sheet .swatches {
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px 8px;
}
/* phones: a compact card above the explode bar (the part id is left to the parts list);
   layout.js tucks it away while the sheet is too tall for it to clear the view chips */
.ui.is-sheet .info-card {
  top: auto;
  left: 8px;
  right: 8px;
  width: auto;
  bottom: calc(var(--vis-b) + 58px);
  padding: 10px 12px 10px 14px;
}
.ui.is-sheet .info-card.is-tucked {
  visibility: hidden;
}
/* at the bottom over the sheet (layout.js): it covers options, not the car */
.ui.is-sheet .info-card.is-over-sheet {
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 16px calc(12px + env(safe-area-inset-bottom)) 18px;
  border-radius: 18px 18px 0 0;
  border-width: 1px 0 0;
  box-shadow: 0 -10px 30px rgba(22, 26, 22, 0.16), 0 -1px 3px rgba(22, 26, 22, 0.08);
  box-sizing: border-box;
  height: var(--sheet-nav-b, auto);
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* on a sheet too low to hold it: on top of the sheet, in the explode bar's place (layout.js) */
.ui.is-sheet .info-card.is-on-sheet {
  bottom: calc(var(--vis-b) + 8px);
  max-height: calc(100% - var(--vis-b) - var(--vis-t) - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ui.is-sheet:has(.info-card.is-on-sheet:not([hidden])) .toasts {
  bottom: auto;
  top: calc(var(--vis-t) + 8px);
}
.ui.is-sheet:has(.info-card.is-on-sheet:not([hidden])):has(.isolate-chip:not([hidden])) .toasts {
  top: calc(var(--vis-t) + 64px);
}
.ui.is-sheet .info-card.is-over-sheet .card-desc {
  -webkit-line-clamp: unset;
  display: block;
}
.ui.is-sheet .card-title {
  font-size: 18px;
}
.ui.is-sheet .card-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
  font-size: 12.5px;
}
.ui.is-sheet .card-meta {
  display: none;
}
.ui.is-sheet .card-path {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.ui.is-sheet .card-path::-webkit-scrollbar {
  display: none;
}
.ui.is-sheet .card-actions {
  margin-top: 8px;
}
.ui.is-sheet .card-actions .btn-small {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}
.ui.is-sheet .drawer {
  inset: 0;
  width: auto;
  border-radius: 0;
  z-index: 45;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.ui.is-sheet .toasts {
  left: 50%;
  bottom: calc(var(--vis-b) + 64px);
}

/* ---------- phones on their side (layout.js .is-landscape) ----------
   The desktop column, narrower; the actions behind a menu button with the view chips beside
   it in one row at the top; the explode bar alone at the bottom; the info card over the
   column; everything inside the safe area (the notch side, the rounded corners, the home bar). */
.ui.is-landscape {
  --gap: 8px;
  --safe-l: max(var(--gap), env(safe-area-inset-left));
  --safe-r: max(var(--gap), env(safe-area-inset-right));
  --safe-b: max(var(--gap), env(safe-area-inset-bottom));
  --panel-w: clamp(260px, 36vw, 320px);
}
.ui.is-landscape .brand,
.ui.is-landscape .panel-head {
  display: none;
}
.ui.is-landscape .topbar {
  top: var(--gap);
  left: var(--safe-l);
  right: auto;
}
.ui.is-landscape .menu-btn {
  display: inline-flex;
  justify-content: center;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: var(--shadow-1);
  border: 1px solid rgba(255, 255, 255, 0.55);
}
.ui.is-landscape .menu-btn[aria-expanded='true'] {
  background: var(--paper);
}
.ui.is-landscape .actions-list {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 4px;
  width: 400px;
  max-width: calc(100vw - var(--safe-l) - var(--vis-r) - var(--gap));
  box-sizing: border-box;
  max-height: calc(100vh - 70px);
  max-height: calc(100svh - 70px);
  overflow-y: auto;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--paper);
  background-image: var(--grain);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--paper-edge);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.ui.is-landscape .actions.is-open .actions-list {
  display: grid;
}
.ui.is-landscape .actions-list .act {
  justify-content: flex-start;
  height: 44px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 14px;
}
.ui.is-landscape .actions-list .act-text {
  display: inline;
}
/* two columns read as pairs without it, and the menu stays short enough for a 340 px screen */
.ui.is-landscape .actions-list .bar-sep {
  display: none;
}
.ui.is-landscape .env-select {
  font-size: 14px;
  flex: 1;
}
.ui.is-landscape .views-bar {
  top: calc(var(--gap) - 4px);
  bottom: auto;
  left: calc(var(--safe-l) + 52px);
  right: calc(var(--vis-r) + var(--gap));
  transform: none;
  gap: 6px;
  padding: 4px 2px;
  border-radius: 0;
  background: none;
  box-shadow: none;
  border: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.ui.is-landscape .views-bar::-webkit-scrollbar {
  display: none;
}
.ui.is-landscape .view-btn {
  flex: none;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.ui.is-landscape .view-btn[aria-pressed='true'] {
  background: var(--green);
}
.ui.is-landscape .tools-bar {
  bottom: var(--safe-b);
  gap: 6px;
  padding: 4px 6px 4px 4px;
}
.ui.is-landscape .tools-bar.is-tucked {
  visibility: hidden;
}
.ui.is-landscape.tree-open .topbar {
  left: calc(var(--vis-l) + var(--gap));
}
.ui.is-landscape.tree-open .actions-list {
  max-width: calc(100vw - var(--vis-l) - var(--vis-r) - 2 * var(--gap));
}
.ui.is-landscape.tree-open .views-bar {
  left: calc(var(--vis-l) + var(--gap) + 52px);
}
.ui.is-landscape .btn-explode {
  min-width: 0;
  padding: 0 12px 0 10px;
  font-size: 12.5px;
}
.ui.is-landscape .range {
  width: 100px;
}
.ui.is-landscape .readout,
.ui.is-landscape .chip-toggle .btn-text,
.ui.is-landscape .tool-btn .btn-text,
.ui.is-landscape .tools-bar .bar-sep {
  display: none;
}
.ui.is-landscape .chip-toggle,
.ui.is-landscape .tool-btn {
  padding: 0 9px;
}
.ui.is-landscape .panel {
  top: var(--gap);
  right: var(--safe-r);
  bottom: var(--gap);
}
.ui.is-landscape.panel-collapsed .panel {
  transform: translateX(calc(100% + var(--safe-r) + 6px));
}
.ui.is-landscape .panel-nav {
  flex-wrap: nowrap;
  justify-content: flex-start;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 10px;
  gap: 4px;
}
.ui.is-landscape .panel-nav::-webkit-scrollbar {
  display: none;
}
.ui.is-landscape .nav-item {
  flex: none;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--rule);
}
.ui.is-landscape .nav-item[aria-current='true'] {
  background: var(--green);
  color: var(--on-green);
  border-color: var(--green);
}
.ui.is-landscape .panel-body {
  padding: 0 14px calc(16px + env(safe-area-inset-bottom));
}
.ui.is-landscape .cfg-section {
  padding-top: 12px;
}
.ui.is-landscape .swatches {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 8px;
}
/* the info card over the column, where it hides options rather than the car */
.ui.is-landscape .info-card,
.ui.is-landscape.tree-open .info-card {
  top: var(--gap);
  right: var(--safe-r);
  left: auto;
  width: calc(var(--panel-w) + 2px); /* the column's border box (content-box + 1 px borders) */
  max-height: calc(100% - 2 * var(--gap));
  overflow-y: auto;
  box-sizing: border-box;
  padding: 10px 12px 10px 14px;
}
.ui.is-landscape .card-title {
  font-size: 18px;
}
.ui.is-landscape .card-desc {
  margin-top: 4px;
  font-size: 12.5px;
}
.ui.is-landscape .card-meta {
  display: none;
}
.ui.is-landscape .card-actions {
  margin-top: 8px;
}
.ui.is-landscape .card-actions .btn-small {
  padding: 0 9px;
}
.ui.is-landscape .drawer {
  top: var(--gap);
  left: var(--safe-l);
  bottom: var(--gap);
  width: min(330px, 44vw);
}
.ui.is-landscape .isolate-chip {
  top: calc(var(--vis-t) + var(--gap));
}
.ui.is-landscape .toasts {
  bottom: calc(var(--safe-b) + 64px);
}

/* QA screenshots (?qa&ui) must not catch transitions half-way: the UI and the
   exploded-view labels (a layer in #viewport, outside #ui-root) */
.is-qa *,
.is-qa *::before,
.is-qa *::after {
  transition: none !important;
  animation: none !important;
}

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

/* ---------- touch screens (iPhone) ---------- */
/* No grey flash on tap and no double-tap zoom on the controls; pinch zoom stays available. */
.ui {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* iOS Safari zooms the page into any form control under 16 px and stays zoomed.
   Every control a finger uses is at least 44 px each way (Apple's minimum): bigger where
   there is room, else 40 px with a hit area reaching past it (::before, vertical only, so
   neighbours in a row never steal each other's taps). */
@media (pointer: coarse) {
  .ui .env-select,
  .ui.is-sheet .env-select,
  .ui.is-landscape .env-select {
    font-size: 16px;
  }
  .ui .env-select {
    align-self: stretch;
  }
  /* bars over the 3D view keep their live sizes; the hit areas reach past them */
  .ui .act {
    min-width: 38px;
  }
  .ui .view-btn,
  .ui .chip-toggle,
  .ui .tool-btn {
    min-width: 44px;
  }
  .ui .chip-toggle,
  .ui .tool-btn {
    justify-content: center;
  }
  .ui .view-btn,
  .ui .btn-explode,
  .ui .chip-toggle,
  .ui .tool-btn,
  .ui .btn-small,
  .ui .nav-item,
  .ui .crumb,
  .ui .sheet-handle,
  .ui .tree-twisty {
    position: relative;
  }
  .ui .act::before,
  .ui .view-btn::before,
  .ui .btn-explode::before,
  .ui .chip-toggle::before,
  .ui .tool-btn::before,
  .ui .btn-small::before,
  .ui .nav-item::before,
  .ui .crumb::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 0;
    bottom: -6px;
    left: 0;
  }
  .ui .act::before {
    top: -4px;
    right: -3px;
    bottom: -4px;
    left: -3px;
  }
  .ui .btn-explode::before {
    top: -5px;
    bottom: -5px;
  }
  .ui .btn-small::before,
  .ui .nav-item::before {
    top: -4px;
    bottom: -4px;
  }
  .ui .crumb::before {
    right: -3px;
    left: -3px;
  }
  /* the iPad's section index wraps into rows 2 px apart: real 44 px items, no spill */
  .ui .nav-item::before {
    content: none;
  }
  .ui.is-sheet .nav-item::before,
  .ui.is-landscape .nav-item::before {
    content: '';
  }
  /* the slider's own box is the hit area: 44 px tall, laid out as the live 22 px */
  .ui .range {
    height: 44px;
    margin: -11px 0;
  }
  /* menus that drop down: real 44 px rows, no hit areas spilling into the next row */
  .ui.is-sheet .actions-list .act,
  .ui.is-landscape .actions-list .act {
    height: 44px;
  }
  .ui.is-sheet .actions-list .act::before,
  .ui.is-landscape .actions-list .act::before {
    content: none;
  }
  .ui.is-landscape .menu-btn {
    width: 44px;
    height: 44px;
  }
  .ui.is-landscape .menu-btn::before {
    content: none;
  }
  /* the Lighting pill in a top toolbar (iPad): the select itself is the target, so it is 44 px
     tall, laid out as the 36 px bar */
  .ui:not(.is-sheet):not(.is-landscape) .topbar .env-pill {
    height: 44px;
    margin: -4px 0;
  }
  .ui .env-pill::before {
    content: none;
  }
  /* inside cards and the column there is room for the real size */
  .ui .btn {
    height: 44px;
  }
  .ui .btn-small,
  .ui.is-sheet .card-actions .btn-small {
    height: 40px;
  }
  .ui .icon-btn {
    width: 44px;
    height: 44px;
  }
  .ui .card-close {
    margin: -8px -10px 0 0;
  }
  .ui .nav-item {
    min-height: 44px;
  }
  .ui.is-sheet .nav-item,
  .ui.is-landscape .nav-item {
    min-height: 40px;
  }
  .ui .crumb {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
  }
  /* the sheet's grab handle: a taller strip that reaches a little above the sheet's edge */
  .ui.is-sheet .sheet-handle {
    height: 34px;
  }
  .ui .sheet-handle::before {
    content: '';
    position: absolute;
    top: -10px;
    right: 0;
    bottom: 0;
    left: 0;
  }
  .ui.is-sheet .panel[data-sheet='full'] .sheet-handle::before {
    top: 0;
  }
  /* the Open & close rows: 44 px, not 44 plus the old padding */
  .ui .open-list .switch-row {
    padding: 0;
  }
  .ui .segmented .choice-face,
  .ui .choice-list .choice-face {
    min-height: 44px;
  }
  /* a switch row's label fills its box, so the whole row toggles */
  .ui .opt-toggle {
    padding-top: 0;
    padding-bottom: 0;
  }
  .ui .switch-row {
    min-height: 44px;
  }
  .ui .caption-note summary {
    display: flex;
    align-items: center;
    min-height: 44px;
  }
  /* parts list: 44 px rows; the arrow's hit area reaches into the indent */
  .ui .tree-row {
    min-height: 44px;
  }
  .ui .tree-twisty {
    width: 34px;
    height: 44px;
  }
  .ui button.tree-twisty::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: -10px;
  }
  .ui .tree-check-hit {
    justify-content: center;
    width: 44px;
  }
  .ui .tree-check {
    width: 18px;
    height: 18px;
    margin: 0;
  }
  .ui .tree-name {
    align-self: stretch;
  }
  .ui .card-actions,
  .ui .pop-foot,
  .ui .drawer-tools,
  .ui .sheet-actions {
    gap: 8px;
  }
  /* rows that scroll sideways clip what spills past their padding: room for the hit areas */
  .ui.is-landscape .views-bar {
    top: calc(var(--gap) - 6px);
    padding: 6px 2px;
  }
  .ui.is-sheet .card-path {
    margin-top: 0;
    padding: 6px 0;
  }
}


/* ---------- ThoughtLeap Studios: in-house label, call to action, copyright ---------- */
.brand-inhouse {
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.brand-inhouse strong {
  color: var(--ink-2);
  font-weight: 600;
}
.studio-cta {
  margin: 16px 0 4px;
  padding: 16px 16px 18px;
  border-radius: 12px;
  background: var(--green);
  color: var(--on-green);
}
.studio-cta-title {
  font: 400 19px/1.2 var(--serif);
  margin: 0 0 6px;
}
.studio-cta-text {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.45;
  color: color-mix(in srgb, var(--on-green) 86%, transparent);
}
.studio-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--paper-hi);
  color: var(--green);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.studio-cta-btn:hover {
  background: #fff;
}
.studio-cta-btn:focus-visible {
  outline: 2px solid var(--brass-hi);
  outline-offset: 3px;
}
.studio-foot {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.studio-foot p {
  margin: 0 0 4px;
}
