* { box-sizing: border-box; }
:root {
  --panel: #171a20;
  --panel-border: #2a2f39;
  --field: #0f1217;
  --field-border: #343b47;
  --page: #101114;
  --stage: #0b0d11;
  --text: #f1f1f1;
  --muted: #c7ced8;
  --accent: #e52e2e;
}
html, body {
  height: 100%;
}
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--page);
  color: var(--text);
}
code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 6px;
}
.app-shell {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}
.controls {
  padding: 20px;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.controls h1 { margin: 0 0 8px; font-size: 26px; }
.subtext, .hint { color: var(--muted); line-height: 1.45; }
label { display: block; margin: 14px 0; }
label span { display: block; margin-bottom: 6px; font-size: 14px; }
input[type="text"], select, input[type="file"], button { width: 100%; }
input[type="text"], select, input[type="file"] {
  background: var(--field);
  color: #fff;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  padding: 12px;
}
input[type="range"] { width: 100%; }
.row.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.button-row.single { grid-template-columns: 1fr; }
button {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
  background: #2c3442;
  color: #fff;
  cursor: pointer;
}
button.primary { background: var(--accent); }
.preview-panel {
  position: relative;
  padding: 18px;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.stage-wrap {
  position: sticky;
  top: 18px;
  width: min(100%, 1280px);
}
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--stage);
  border: 1px solid #29303a;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}
#carImage, .overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#carImage {
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.overlay { overflow: visible; z-index: 2; touch-action: none; }
.draggable-group {
  cursor: grab;
  touch-action: none;
}
.draggable-group.dragging { cursor: grabbing; }
.svg-banner {
  dominant-baseline: middle;
  text-transform: uppercase;
  white-space: pre;
  paint-order: stroke fill;
  pointer-events: none;
}

.selection-box {
  fill: rgba(0, 224, 255, 0.08);
  stroke: #00e0ff;
  stroke-width: 2.5;
  stroke-dasharray: 12 8;
  display: none;
  pointer-events: none;
}
.draggable-group.selected .selection-box {
  display: block;
}
.drag-hitbox {
  fill: rgba(255,255,255,0.001);
  stroke: transparent;
  pointer-events: all;
}
.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  color: #cfd7e2;
  background: rgba(11,13,17,0.78);
  z-index: 1;
}
.placeholder.hidden { display: none; }
.placeholder-car {
  width: 68%;
  height: 36%;
  background: linear-gradient(180deg, #303846, #1b212b);
  clip-path: polygon(10% 70%, 17% 55%, 31% 46%, 46% 30%, 72% 30%, 86% 44%, 92% 60%, 98% 62%, 97% 73%, 88% 74%, 85% 82%, 70% 82%, 62% 72%, 38% 72%, 30% 82%, 16% 82%, 13% 73%, 7% 73%);
  opacity: 0.7;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
  }
  .preview-panel {
    order: -1;
    padding: 10px 10px 0;
    overflow: visible;
    background: var(--page);
    border-bottom: 1px solid var(--panel-border);
  }
  .stage-wrap {
    position: sticky;
    top: 0;
    z-index: 5;
    width: 100%;
    background: var(--page);
    padding-bottom: 10px;
  }
  .stage {
    max-height: 38vh;
  }
  .controls {
    border-right: 0;
    border-bottom: 0;
    padding-top: 14px;
  }
}
