:root {
  color-scheme: dark;
  --bg: #090d0c;
  --bg-panel: #101614;
  --bg-card: #151d1a;
  --bg-elevated: #1b2522;
  --bg-hover: #212e2a;
  --bg-stage: #060908;
  --border: #23312c;
  --border-strong: #334840;
  --ink: #eef4f1;
  --muted: #8fa39b;
  --muted-2: #6b7f77;
  --accent: #1fa36b;
  --accent-hover: #27bb7c;
  --accent-deep: #124633;
  --accent-soft: rgba(31, 163, 107, 0.14);
  --accent-ring: rgba(39, 187, 124, 0.45);
  --danger: #ef6461;
  --danger-soft: rgba(239, 100, 97, 0.14);
  --studio-tile: #e6e9e7;
  --top-h: 56px;
  --credit-h: 36px;
  --gutter: clamp(14px, 2.2vw, 28px);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Subtle dark scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #466056; }

/* TOP HEADER */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--top-h);
  padding: 0 var(--gutter);
  background: rgba(11, 16, 14, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 16px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: contain;
  padding: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
}
.brand em {
  font-style: normal;
  color: var(--accent-hover);
  font-weight: 600;
}

.top nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.top nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: background 150ms, color 150ms;
}
.top nav a svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.top nav a:hover {
  background: var(--bg-elevated);
  color: var(--ink);
}
.top nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: #6ee7b7;
  box-shadow: inset 0 0 0 1px rgba(39, 187, 124, 0.3);
}

.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.account-toggle { display: none; }
.account-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.account-pill {
  padding: 5px 10px;
  border-radius: 99px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--muted);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* MAIN SHELL */
main {
  max-width: 1920px;
  margin: 0 auto;
  padding: 16px var(--gutter) 20px;
}

body.studio-active main {
  padding: 12px var(--gutter) 0;
  height: calc(100dvh - var(--top-h));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.studio-active .page-studio {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page-content {
  max-width: 1520px;
  margin: 0 auto;
  padding-block: 10px 44px;
}
.page-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.page-title h1 {
  font-size: clamp(24px, 2.5vw, 34px);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.page-title p {
  color: var(--muted);
  margin-top: 6px;
  font-size: 14px;
}

/* SHARED BUTTONS & UI ATOMS */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  transition: background 140ms, border-color 140ms, color 140ms, transform 100ms, opacity 140ms;
}
.button:active:not(:disabled) { transform: scale(0.985); }
.button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.button.sm { min-height: 34px; padding: 5px 11px; font-size: 13px; }
.button.xs { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }

.button.primary {
  background: var(--accent);
  color: #04150e;
  border-color: rgba(255, 255, 255, 0.08);
}
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.primary:disabled {
  background: var(--bg-elevated);
  color: var(--muted-2);
  border-color: var(--border);
}

.button.secondary {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--ink);
}
.button.secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: #466358;
}
.button.secondary:disabled { opacity: 0.45; }

.button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.button.ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--ink);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  transition: background 140ms, border-color 140ms, color 140ms;
}
.icon-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.icon-btn:disabled { opacity: 0.4; }
.icon-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.text-link {
  background: none;
  border: 0;
  padding: 4px 6px;
  border-radius: 6px;
  color: #6ee7b7;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 140ms, color 140ms;
}
.text-link:hover { background: var(--accent-soft); }
.text-link.danger-link { color: var(--danger); }
.text-link.danger-link:hover { background: var(--danger-soft); }
.text-link.small-link { font-size: 12px; color: var(--muted); }
.text-link.small-link:hover { color: var(--ink); background: var(--bg-elevated); }

.muted { color: var(--muted); font-size: 13.5px; }
.small-note { font-size: 12.5px; }
.inline-message {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 8px;
}
.inline-message:empty { display: none; }
.inline-message.error { color: var(--danger); }
.global-error { text-align: center; margin-top: 16px; }

/* AUTH GATE */
.account-gate {
  max-width: 960px;
  margin: clamp(24px, 6vh, 64px) auto;
  padding: clamp(22px, 4.5vw, 38px);
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.gate-badge {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: #6ee7b7;
  border: 1px solid rgba(39, 187, 124, 0.28);
}
.account-gate h1 {
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.03em;
  max-width: 540px;
}
.gate-sub {
  max-width: 540px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
.account-gate #gate-message {
  max-width: 540px;
}
#google-sign-in { margin-top: 6px; }

/* PRICING */
.gate-pricing {
  width: 100%;
  margin-top: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: left;
  display: grid;
  gap: 12px;
}
.gate-pricing-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.gate-pricing-head h2 {
  font-size: 15px;
  letter-spacing: -0.01em;
}
.gate-pricing-head .muted {
  font-size: 12.5px;
}
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.pricing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pricing-card.is-featured {
  border-color: rgba(39, 187, 124, 0.55);
  background: linear-gradient(180deg, rgba(31, 163, 107, 0.14), rgba(16, 24, 21, 0.96));
  box-shadow: 0 0 0 1px rgba(39, 187, 124, 0.25);
}
.pricing-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pricing-card-head h2,
.pricing-card-head h3 {
  font-size: 17px;
  letter-spacing: -0.015em;
}
.pricing-card p {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}
.plan-badge {
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent);
  color: #04150e;
  font-size: 11px;
  font-weight: 750;
}
.plan-badge.is-enterprise {
  background: var(--accent-soft);
  color: #6ee7b7;
  border: 1px solid rgba(39, 187, 124, 0.35);
}
.plan-quota {
  display: inline-flex;
  width: fit-content;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: #6ee7b7;
  font-size: 12px;
  font-weight: 650;
}
.plan-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.plan-price strong {
  font-size: clamp(22px, 2.4vw, 28px);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.plan-price span {
  color: var(--muted);
  font-size: 13px;
}
.pricing-features {
  list-style: none;
  margin: auto 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 6px;
  font-size: 13.5px;
  color: var(--ink);
}
.pricing-features li::before {
  content: "✓ ";
  color: #6ee7b7;
  font-weight: 700;
}
.pricing-rule {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.pricing-rule strong,
.pricing-notes strong {
  color: var(--ink);
}
.pricing-notes {
  margin-top: 14px;
  padding: 16px 18px;
  display: grid;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.55;
}
@media (max-width: 960px) {
  .pricing-grid { grid-template-columns: 1fr; }
}

/* DESKTOP STUDIO WORKSPACE (SPLIT APP-SHELL) */
.mobile-stages, .mobile-actions, .mobile-car-context { display: none; }

.studio {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.52fr) minmax(380px, 460px);
  gap: 14px;
  padding-bottom: 6px;
}

/* LEFT: VISUAL STAGE */
.stage-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 36px;
}

.stage-source-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.car-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 280px;
  min-height: 36px;
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 140ms, border-color 140ms;
}
.car-pill:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.car-pill svg {
  width: 16px;
  height: 16px;
  stroke: #6ee7b7;
  fill: none;
  stroke-width: 1.9;
  flex: none;
}
.car-pill svg.chevron {
  stroke: var(--muted);
  width: 15px;
  height: 15px;
}
.car-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: var(--bg-stage);
  border: 1px solid var(--border);
}
.compare button {
  min-height: 28px;
  padding: 4px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  transition: background 140ms, color 140ms;
}
.compare button:hover:not([aria-pressed="true"]) { color: var(--ink); }
.compare button[aria-pressed="true"] {
  background: var(--accent);
  color: #04150e;
}

.stage-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  background: var(--bg-stage);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.zoom-controls .icon-btn {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
}
.zoom-controls .icon-btn:hover:not(:disabled) { background: var(--bg-elevated); }
.zoom-readout {
  min-width: 48px;
  height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.zoom-readout:hover { background: var(--bg-elevated); }

/* VIEWER STAGE */
.viewer-slot {
  flex: 1;
  min-height: 0;
  display: flex;
}

.viewer {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 300px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  container-type: size;
  background: radial-gradient(ellipse at 50% 56%, #18231f 0%, #090d0c 72%, #050706 100%);
  border: 1px solid var(--border);
  user-select: none;
}

.viewer.drag-over {
  border-color: var(--accent-hover);
  box-shadow: inset 0 0 0 2px var(--accent-hover);
}
.viewer.drag-over .drop-overlay { opacity: 1; pointer-events: auto; }

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: rgba(9, 13, 12, 0.86);
  backdrop-filter: blur(6px);
  color: #6ee7b7;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms;
}
.drop-overlay svg {
  width: 40px;
  height: 40px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
}

/* EMPTY STATE GUIDE */
.photo-guide {
  width: min(560px, 92%);
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 12px;
  padding: 20px;
}
.guide-icon {
  width: 68px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(39, 187, 124, 0.25);
}
.guide-icon svg {
  width: 48px;
  height: 36px;
  stroke: #6ee7b7;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.photo-guide strong {
  font-size: 19px;
  letter-spacing: -0.02em;
}
.photo-guide p {
  font-size: 13.5px;
  color: var(--muted);
  max-width: 420px;
}
.guide-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.quick-cars {
  width: 100%;
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: left;
}
.quick-cars-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.quick-cars-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.quick-car-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: left;
  overflow: hidden;
  transition: border-color 140ms, background 140ms, transform 120ms;
}
.quick-car-btn:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-1px);
}
.quick-car-btn img {
  width: 100%;
  aspect-ratio: 1.5;
  object-fit: cover;
  border-radius: 5px;
  display: block;
}
.quick-car-btn span {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px 2px;
}

/* ZOOM STAGE & COMPARE */
.zoom-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  transform-origin: center center;
  transition: transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}
.viewer.panning .zoom-stage { transition: none; }
.viewer.is-zoomed { cursor: grab; }
.viewer.is-zoomed.panning { cursor: grabbing; }

#car-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  display: block;
}

.compare-frame {
  --split: 50%;
  position: relative;
  width: min(100cqw, calc(100cqh * var(--photo-ratio, 1.5)));
  height: min(100cqh, calc(100cqw / var(--photo-ratio, 1.5)));
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  border-radius: 6px;
}
.compare-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.compare-frame .compare-before {
  clip-path: inset(0 calc(100% - var(--split)) 0 0);
}

.split-badge {
  position: absolute;
  top: 10px;
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(9, 13, 12, 0.72);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  pointer-events: none;
  z-index: 3;
}
.split-badge-before { left: 10px; }
.split-badge-after { right: 10px; background: rgba(18, 70, 51, 0.85); border-color: rgba(110, 231, 183, 0.35); color: #a7f3d0; }

.compare-divider, .compare-handle {
  position: absolute;
  pointer-events: none;
  z-index: 4;
}
.compare-divider {
  inset-block: 0;
  left: var(--split);
  width: 2px;
  transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.75);
}
.compare-handle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  left: clamp(20px, var(--split), calc(100% - 20px));
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent);
  border: 2px solid #fff;
  color: #04150e;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
}
.compare-handle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}
.compare-frame input {
  position: absolute;
  inset: 0;
  z-index: 5;
  margin: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  touch-action: pan-y;
  appearance: none;
}
.viewer.is-zoomed .compare-frame input { pointer-events: none; }
.compare-frame:has(input:focus-visible) .compare-handle {
  outline: 3px solid var(--accent-hover);
  outline-offset: 2px;
}

.zoom-compare-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.zoom-compare-bar input {
  flex: 1;
  accent-color: var(--accent);
}

.photo-tag {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 6;
  padding: 5px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 650;
  background: rgba(9, 13, 12, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--ink);
  pointer-events: none;
}

.pan-hint {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 6;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  background: rgba(9, 13, 12, 0.76);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  pointer-events: none;
}

/* RENDER LOADING OVERLAY */
.render-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(6, 10, 9, 0.72);
  backdrop-filter: blur(5px);
  overflow: hidden;
}
.render-scan {
  position: absolute;
  inset-inline: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-hover), transparent);
  box-shadow: 0 0 24px var(--accent-hover);
  animation: scan-line 2.2s ease-in-out infinite;
}
@keyframes scan-line {
  0% { top: 6%; opacity: 0.2; }
  50% { top: 92%; opacity: 1; }
  100% { top: 6%; opacity: 0.2; }
}
.render-card {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
  max-width: 340px;
  padding: 18px 22px;
  border-radius: 14px;
  background: rgba(16, 22, 20, 0.92);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.render-card strong { font-size: 15px; }
.render-card p { font-size: 12.5px; color: var(--muted); }
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent-hover);
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* STAGE BOTTOM DOCK (ANGLES + HISTORY) */
.stage-dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.dock-section { display: flex; flex-direction: column; gap: 6px; }
.dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.dock-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.dock-title h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.angle-list {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.angle-chip {
  flex: 1 0 112px;
  max-width: 170px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 5px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: left;
  transition: border-color 140ms, background 140ms;
}
.angle-chip:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}
.angle-chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.angle-chip[data-state="working"] {
  opacity: 0.85;
  cursor: progress;
}
.angle-chip:disabled:not([data-state="working"]) { opacity: 0.5; }

.angle-thumb {
  width: 44px;
  height: 32px;
  border-radius: 5px;
  background: var(--bg-stage);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.angle-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.angle-thumb .mini-spin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-hover);
  animation: spin 0.75s linear infinite;
}
.angle-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.angle-meta b {
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.angle-meta small {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.angle-chip[aria-pressed="true"] .angle-meta small { color: #6ee7b7; }

/* HISTORY FILMSTRIP */
.history-strip {
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.history-list {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.history-item {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 210px;
  padding: 4px 9px 4px 4px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: left;
  transition: border-color 140ms, background 140ms;
}
.history-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}
.history-item[aria-current="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.history-item img {
  width: 46px;
  height: 34px;
  border-radius: 5px;
  object-fit: cover;
  flex: none;
}
.history-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.history-meta strong {
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta small {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* RIGHT: SMART PARTS PICKER */
.parts-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.parts-header {
  flex: none;
  padding: 13px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
.parts-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.parts-title-row h2 {
  font-size: 16px;
  letter-spacing: -0.015em;
}
.count-badge {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.catalog-controls {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
#full-catalog .catalog-controls { margin-bottom: 16px; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box .search-icon {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  pointer-events: none;
}
.search-box input {
  width: 100%;
  min-height: 38px;
  padding: 7px 34px 7px 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-stage);
  color: var(--ink);
  font-size: 13.5px;
  transition: border-color 140ms;
}
.search-box input::placeholder { color: var(--muted-2); }
.search-box input:focus { border-color: var(--accent); outline: none; }
.search-clear {
  position: absolute;
  right: 6px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}
.search-clear:hover { background: var(--bg-elevated); color: var(--ink); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.filters button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 31px;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 140ms, border-color 140ms, color 140ms;
}
.filters button:hover {
  background: var(--bg-elevated);
  color: var(--ink);
}
.filters button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #04150e;
}
.filters button .tab-count {
  font-size: 11px;
  opacity: 0.78;
  font-variant-numeric: tabular-nums;
}
.filters button[data-group="selected"]:not([aria-pressed="true"]) {
  border-color: rgba(39, 187, 124, 0.35);
  color: #6ee7b7;
}

.parts-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 16px;
}

/* PRODUCT GRID & SMART CARDS */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
#full-catalog .product-grid,
.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.part-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  transition: border-color 140ms, background 140ms, box-shadow 140ms;
}
.part-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}
.part-card.is-selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(31, 163, 107, 0.14), rgba(16, 26, 22, 0.96));
  box-shadow: 0 0 0 1px rgba(39, 187, 124, 0.35);
}

.part-select-btn {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
}
.part-select-btn:disabled { opacity: 0.65; }

.part-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1.32;
  background: var(--studio-tile);
  padding: 6px;
  overflow: hidden;
}
.part-media img,
.part-media .photo-missing {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 220ms ease;
}
.part-card:hover .part-media img { transform: scale(1.04); }
.part-media .photo-missing {
  display: grid;
  place-items: center;
  font-size: 12px;
  color: #4c5d54;
}

.part-check {
  position: absolute;
  top: 7px;
  left: 7px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(11, 16, 14, 0.72);
  color: #e6f2ec;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.part-card.is-selected .part-check {
  background: var(--accent);
  color: #04150e;
}
.part-check svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.6;
}

.part-zoom-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 3;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(12, 18, 16, 0.72);
  color: #fff;
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  opacity: 0.88;
  transition: opacity 140ms, background 140ms, transform 120ms;
}
.part-zoom-btn:hover {
  opacity: 1;
  background: rgba(12, 18, 16, 0.94);
  transform: scale(1.05);
}
.part-zoom-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.part-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 10px 10px;
  flex: 1;
  min-width: 0;
}
.part-copy strong {
  font-size: 13.5px;
  line-height: 1.25;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.part-copy small {
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.part-meta-line {
  font-size: 11.5px;
  color: #6ee7b7;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.part-action-row {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.part-card:hover .part-action-row { color: var(--ink); }
.part-card.is-selected .part-action-row { color: #6ee7b7; }
.part-action-tag.swap { color: #f6c453; }

/* STICKY SELECTION DOCK */
.selection-dock {
  flex: none;
  padding: 11px 14px 12px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, #131b18, #0e1412);
}
.selection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.selection-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
}
.slot-pill {
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: #6ee7b7;
}
.price-sum {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.selected-chips {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.selected-chips:empty { display: none; }
.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 4px 3px 4px;
  border-radius: 99px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 600;
}
.selected-chip img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: contain;
  background: var(--studio-tile);
  flex: none;
}
.selected-chip span {
  max-width: 135px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-remove {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
}
.chip-remove:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.selected-empty {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.dock-cta-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}
.try-button {
  width: 100%;
  min-height: 44px;
  font-size: 14.5px;
}

/* VEHICLE CARDS (CARS PAGE & MODAL) */
.car-type-filters { margin-bottom: 14px; }
.car-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  text-align: left;
  transition: border-color 140ms, transform 140ms, background 140ms;
}
.car-card:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-1px);
}
.car-card[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(39, 187, 124, 0.4);
  background: var(--accent-soft);
}
.car-card img {
  width: 100%;
  aspect-ratio: 1.5;
  object-fit: cover;
  display: block;
  background: var(--bg-stage);
}
.car-card-copy {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.car-card-copy strong { font-size: 14px; }
.car-card-copy small { font-size: 12px; color: var(--muted); }
.car-card-cta {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #6ee7b7;
}

/* CATALOG PAGE ADD PRODUCT & FLOATING BAR */
.product-entry { margin-bottom: 18px; overflow: hidden; }
.product-entry summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  font-weight: 650;
  font-size: 14.5px;
  color: #6ee7b7;
}
.product-entry summary::-webkit-details-marker { display: none; }
.product-entry summary svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  transition: transform 150ms;
}
.product-entry[open] summary svg { transform: rotate(180deg); }
#product-form {
  border-top: 1px solid var(--border);
  padding: 16px;
}
.product-photo img {
  display: block;
  object-fit: contain;
  max-width: 260px;
  max-height: 200px;
  background: var(--studio-tile);
  border-radius: 8px;
  margin-bottom: 10px;
}
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.product-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-block: 14px;
}
.product-fields label {
  display: grid;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.product-fields input,
.product-fields select,
.product-fields textarea,
.account-row select {
  width: 100%;
  min-height: 40px;
  background: var(--bg-stage);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.product-fields input:focus,
.product-fields select:focus,
.product-fields textarea:focus,
.account-row select:focus {
  border-color: var(--accent);
  outline: none;
}
.product-detail { grid-column: 1 / -1; }

.catalog-float-bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 15;
  width: min(640px, calc(100vw - 28px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(16, 24, 21, 0.94);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(39, 187, 124, 0.4);
  box-shadow: var(--shadow);
}
.catalog-float-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.catalog-float-info strong { font-size: 13.5px; color: #6ee7b7; }
.catalog-float-info span {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ACCOUNTS ADMIN */
.account-row {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)) auto;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 10px;
}
.account-identity {
  display: grid;
  gap: 2px;
  overflow-wrap: anywhere;
}
.account-identity small { color: var(--muted); }

/* OPTIONAL CUSTOMER CAPTURE & TABLE */
.customer-entry {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}
.customer-entry summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
}
.customer-entry summary::-webkit-details-marker { display: none; }
.customer-entry summary svg {
  width: 16px;
  height: 16px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  flex: none;
  transition: transform 150ms;
}
.customer-entry[open] summary svg { transform: rotate(180deg); }
.customer-summary-title {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.customer-badge {
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent-soft);
  border: 1px solid rgba(39, 187, 124, 0.35);
  color: #6ee7b7;
  font-size: 11px;
  font-weight: 700;
}
.customer-entry-body {
  padding: 0 14px 12px;
  display: grid;
  gap: 8px;
}
.customer-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.customer-fields label {
  display: grid;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.customer-fields input {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-stage);
  color: var(--ink);
  font-size: 13px;
}
.customer-fields input:focus {
  border-color: var(--accent);
  outline: none;
}
.customer-field-full { grid-column: 1 / -1; }
.customer-entry-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.customer-entry-actions > :last-child { margin-left: auto; }

.customers-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.customer-page-form {
  border-top: 1px solid var(--border);
  padding: 16px;
}
.customer-table-wrap { overflow-x: auto; }
.customer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.customer-table th,
.customer-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.customer-table th {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg-card);
  white-space: nowrap;
}
.customer-table tbody tr:last-child td { border-bottom: 0; }
.customer-table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.customer-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.customer-context-cell {
  min-width: 180px;
  max-width: 340px;
  color: var(--muted);
}
.customer-actions-cell {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}
.customer-empty {
  padding: 28px 16px;
  text-align: center;
}

/* FOOTER CREDIT */
.agency-credit {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 0 8px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted-2);
}
body.studio-active .agency-credit {
  margin-top: 0;
  padding: 6px 0;
  border-top: 0;
  justify-content: flex-end;
  min-height: var(--credit-h);
}
.agency-credit img { object-fit: contain; flex: none; opacity: 0.85; }

/* MODALS / DIALOGS */
.modal {
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--bg-panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
}
.modal::backdrop {
  background: rgba(3, 6, 5, 0.82);
  backdrop-filter: blur(6px);
}
body:has(dialog[open]) { overflow: hidden; }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.dialog-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.dialog-head h2 { font-size: 16px; letter-spacing: -0.015em; }
.dialog-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* FULLSCREEN PHOTO DIALOG */
.photo-dialog {
  width: min(1560px, calc(100vw - 20px));
  height: min(960px, calc(100dvh - 20px));
  background: #080c0b;
}
.photo-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.dialog-picture {
  min-width: 0;
  min-height: 0;
  padding: 10px 14px;
  display: flex;
}
.dialog-picture > .viewer {
  width: 100%;
  height: 100%;
  border-radius: 10px;
}
.dialog-dock {
  padding: 8px 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}
.dialog-dock .stage-dock {
  border-top: 0;
  padding-top: 0;
}

/* PRODUCT QUICK VIEW MODAL */
.part-dialog { width: min(760px, calc(100vw - 24px)); }
.group-pill {
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--accent-soft);
  color: #6ee7b7;
  border: 1px solid rgba(39, 187, 124, 0.3);
}
.part-modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
}
.part-modal-media {
  background: var(--studio-tile);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  place-items: center;
  aspect-ratio: 1.18;
}
.part-modal-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.part-modal-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.part-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
  color: #6ee7b7;
}
.part-modal-detail {
  font-size: 14.5px;
  color: var(--ink);
  line-height: 1.55;
}
.part-modal-note {
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(246, 196, 83, 0.1);
  border: 1px solid rgba(246, 196, 83, 0.3);
  color: #f6c453;
  font-size: 12.5px;
}
.part-modal-actions {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.part-modal-actions .button { flex: 1 1 auto; }

/* VEHICLE PICKER MODAL */
.vehicle-dialog { width: min(860px, calc(100vw - 24px)); }
.vehicle-modal-body {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(100dvh - 120px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.upload-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.upload-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  text-align: left;
  transition: border-color 140ms, background 140ms;
}
.upload-tile:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}
.upload-tile.primary-tile {
  border-color: rgba(39, 187, 124, 0.4);
  background: var(--accent-soft);
}
.upload-tile svg {
  width: 26px;
  height: 26px;
  stroke: #6ee7b7;
  fill: none;
  stroke-width: 1.8;
  flex: none;
}
.upload-tile strong { display: block; font-size: 14px; }
.upload-tile small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.vehicle-modal-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}
.modal-car-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

/* TOAST STACK */
.toast-stack {
  position: fixed;
  left: 50%;
  top: calc(var(--top-h) + 12px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(460px, calc(100vw - 24px));
}
.toast {
  pointer-events: auto;
  padding: 9px 15px;
  border-radius: 99px;
  background: rgba(14, 22, 19, 0.96);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease;
  text-align: center;
}
.toast.toast-error {
  border-color: rgba(239, 100, 97, 0.55);
  color: #ffb4b2;
}
.toast.toast-accent {
  border-color: rgba(39, 187, 124, 0.55);
  color: #a7f3d0;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* TABLET BREAKPOINT */
@media (max-width: 1120px) {
  .studio { grid-template-columns: minmax(0, 1.2fr) minmax(330px, 390px); }
  #full-catalog .product-grid, .vehicle-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quick-cars-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .modal-car-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* MOBILE BREAKPOINT */
@media (max-width: 880px) {
  :root {
    --gutter: 12px;
    --top-h: 52px;
    --nav-height: 60px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  .top {
    flex-wrap: wrap;
    background: #0b100e;
    backdrop-filter: none;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .brand { min-height: var(--top-h); font-size: 15px; }
  .account-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 40px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
  }
  .account-toggle svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.9;
  }
  .account-toggle[aria-expanded="false"] + .account-bar { display: none; }
  .top-right { width: auto; }
  .top:has(.account-toggle[aria-expanded="true"]) .top-right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding-bottom: 10px;
  }
  .account-bar {
    justify-content: space-between;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .account-pill { max-width: none; white-space: normal; }

  .top nav {
    position: fixed;
    z-index: 25;
    inset: auto 0 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 4px max(6px, env(safe-area-inset-right, 0px)) calc(4px + var(--safe-bottom))
      max(6px, env(safe-area-inset-left, 0px));
    height: calc(var(--nav-height) + var(--safe-bottom));
    background: rgba(12, 18, 16, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .top nav a {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    font-size: 11px;
    border-radius: 8px;
  }
  .top nav a svg { width: 20px; height: 20px; }
  .top nav a span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.studio-active main {
    height: auto;
    overflow: visible;
    display: block;
    padding: 10px var(--gutter) 0;
  }
  body:has(#app-nav:not([hidden])) main {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 24px);
  }
  body:has(.mobile-actions:not([hidden])) main {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 126px);
  }

  .mobile-stages {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    position: sticky;
    top: calc(var(--top-h) + 6px);
    z-index: 12;
    padding: 4px;
    margin-bottom: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
  }
  .mobile-stages button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
  }
  .mobile-stages button svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.9;
  }
  .mobile-stages button[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: rgba(39, 187, 124, 0.35);
    color: #6ee7b7;
  }
  #stage-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--accent);
    color: #04150e;
    font-size: 11.5px;
    font-weight: 800;
  }

  .studio { display: block; padding-bottom: 0; }
  .studio[data-stage="parts"] .stage-panel,
  .studio[data-stage="photo"] .parts-panel { display: none; }

  .stage-panel {
    padding: 10px;
    gap: 8px;
  }
  .stage-toolbar { gap: 6px; }
  .car-pill { max-width: 185px; font-size: 12.5px; padding: 4px 9px; }
  .compare button { padding: 4px 8px; font-size: 12px; }
  #download, .stage-panel .zoom-controls { display: none; }

  .viewer {
    min-height: 240px;
    aspect-ratio: var(--view-ratio, 1.38);
    max-height: 58svh;
  }
  .quick-cars-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .parts-panel {
    border: 0;
    background: transparent;
    overflow: visible;
  }
  .mobile-car-context {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
  }
  .mobile-car-context img {
    width: 48px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    flex: none;
  }
  .mobile-car-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }
  .mobile-car-meta strong {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-car-meta small { font-size: 11.5px; color: var(--muted); }

  .parts-header {
    padding: 10px 0 8px;
    background: var(--bg);
    border-bottom: 0;
  }
  .parts-scroll { padding: 4px 0 12px; overflow: visible; }
  .filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .filters button { flex: none; min-height: 36px; }
  .selection-dock { display: none; }

  #full-catalog .product-grid,
  .vehicle-grid,
  .modal-car-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .upload-tiles { grid-template-columns: 1fr; }
  .part-modal-body { grid-template-columns: 1fr; }
  .product-fields { grid-template-columns: 1fr; }
  .customer-fields { grid-template-columns: 1fr; }
  .customer-entry {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 6px;
  }
  .page-title { flex-direction: column; align-items: flex-start; }
  .pricing-grid { grid-template-columns: 1fr; }
  .account-gate { padding: 20px 16px; }
  .account-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-identity { grid-column: 1 / -1; }

  .mobile-actions {
    display: flex;
    flex-direction: column;
    position: fixed;
    z-index: 22;
    inset: auto 0 calc(var(--nav-height) + var(--safe-bottom));
    background: rgba(15, 22, 19, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-strong);
  }
  .mobile-chips-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 7px var(--gutter) 2px;
  }
  .mobile-cta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px var(--gutter);
  }
  .mobile-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .mobile-meta span { font-size: 13px; font-weight: 700; }
  .mobile-meta small { font-size: 11.5px; color: #6ee7b7; font-variant-numeric: tabular-nums; }
  .mobile-buttons { display: flex; align-items: center; gap: 7px; }
  .mobile-buttons .button { min-height: 42px; }

  .catalog-float-bar {
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  }
  .toast-stack {
    top: calc(var(--top-h) + 8px);
  }
  body.studio-active .agency-credit {
    justify-content: center;
    padding: 12px 0;
  }

  .photo-dialog {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .photo-dialog .dialog-head { padding: 10px 12px; }
  .photo-dialog .dialog-picture { padding: 6px; }
  .photo-dialog .dialog-dock { padding: 6px 10px calc(8px + var(--safe-bottom)); }
  .photo-dialog #dialog-zoom-controls { display: none; }
}

.match-vehicle {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
  margin: 0 0 10px; font-size: 14px;
}
.match-vehicle select {
  min-width: 0; max-width: 100%; min-height: 44px; padding: 6px 10px;
  border: 1px solid var(--border-strong); border-radius: 8px; color: inherit;
  background: var(--bg-elevated); font: inherit;
}
.catalog-estimate, .catalog-fitment { overflow-wrap: anywhere; }
#remove-photo { min-height: 44px; white-space: nowrap; }
#vehicle-form { padding: 16px; }
