@font-face { font-family: "Open Runde"; src: url(/fonts/OpenRunde-Regular.otf); font-weight: 400; }
@font-face { font-family: "Open Runde"; src: url(/fonts/OpenRunde-Medium.otf); font-weight: 500; }
@font-face { font-family: "Open Runde"; src: url(/fonts/OpenRunde-Semibold.otf); font-weight: 600; }
@font-face { font-family: "Open Runde"; src: url(/fonts/OpenRunde-Bold.otf); font-weight: 700; }

:root {
  --bg: #08090b;
  --panel: #111215;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f4f6;
  --muted: rgba(244, 244, 246, 0.52);
  --accent: #2ee0e6;
  --radius: 14px;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 "Open Runde", -apple-system, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* The map renders off screen at the exact layout the video is composed at. */
#map {
  position: fixed;
  left: -3000px;
  top: 0;
  width: 405px;
  height: 720px;
}

.studio {
  display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  height: 100vh;
}

.panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 22px 22px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 38px; height: 38px; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }

.group h2 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.group-head .muted { font-size: 12px; text-align: right; }
.muted { color: var(--muted); }

.meetup-row { display: flex; gap: 12px; align-items: center; }
#meetup-logo {
  width: 48px; height: 48px; border-radius: 50%;
  background: #fff; object-fit: cover; flex: none;
}
.meetup-pick { flex: 1; min-width: 0; }
.meetup-pick p { margin: 6px 0 0; font-size: 12px; }

select, input[type="search"] {
  width: 100%;
  background: #1a1b1f;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
select:focus, input[type="search"]:focus { border-color: rgba(46, 224, 230, 0.6); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 8px; scrollbar-width: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--muted);
}
.chip.is-active { background: var(--text); color: #000; border-color: var(--text); }

.car-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 290px;
  overflow-y: auto;
  padding: 2px;
}
.car {
  background: #17181c;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 6px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
}
.car[hidden] { display: none; }
.car img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; }
.car span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.car:hover { border-color: var(--line); }
.car.is-selected { border-color: var(--accent); color: var(--text); background: rgba(46, 224, 230, 0.08); }

.paint-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.paint-row.is-disabled { opacity: 0.35; pointer-events: none; }
.paint-row .label { font-size: 12px; color: var(--muted); width: 36px; }
.swatches { display: flex; gap: 8px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  padding: 0;
}
.swatch-original {
  background: conic-gradient(#e2202a, #ffc700, #16e05c, #2ee0e6, #006ee6, #823ac6, #e2202a);
}
.swatch.is-selected, .custom-color.is-selected { outline: 2px solid var(--text); outline-offset: 2px; }
.custom-color { position: relative; width: 28px; height: 28px; border-radius: 50%; overflow: hidden; border: 2px dashed rgba(255,255,255,0.3); }
.custom-color input { position: absolute; inset: -8px; width: 44px; height: 44px; border: 0; padding: 0; background: none; cursor: pointer; }

.crew { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.driver {
  flex: none;
  width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 0;
  padding: 6px 2px;
  border-radius: 12px;
  font-size: 11px;
  color: var(--muted);
}
.driver span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.driver-face {
  position: relative;
  width: 42px; height: 42px; border-radius: 50%;
  background: #23252b center / cover no-repeat;
  border: 2px solid transparent;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: var(--text);
}
.driver-face .driver-car {
  position: absolute; right: -10px; bottom: -6px;
  width: 30px; height: 22px; object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8));
}
.driver:hover { background: #17181c; }
.driver.is-selected { color: var(--text); background: rgba(46, 224, 230, 0.08); }
.driver.is-selected .driver-face { border-color: var(--accent); }

.name-row, .car-head { display: flex; align-items: center; gap: 10px; }
.name-row { margin-bottom: 12px; }
.name-row label, .car-head .label { font-size: 12px; color: var(--muted); width: 36px; flex: none; }
.car-head { justify-content: space-between; margin-bottom: 8px; }
.car-head .muted { font-size: 12px; }
.name-row input {
  flex: 1;
  background: #1a1b1f;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  outline: none;
}
.name-row input:focus { border-color: rgba(46, 224, 230, 0.6); }

.photo-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.photo-row .label { font-size: 12px; color: var(--muted); width: 36px; flex: none; margin-right: 2px; }
.photo-preview {
  width: 40px; height: 40px; flex: none; border-radius: 50%; padding: 0;
  border: 1px solid var(--line); background: #23252b center / cover no-repeat;
}
.ghost.small { padding: 6px 12px; font-size: 12px; }
.photo-row .link { margin-left: auto; font-size: 12px; }

.sheet {
  border: 1px solid var(--line); border-radius: 20px; padding: 0;
  background: var(--panel); color: var(--text);
  width: min(360px, calc(100vw - 32px));
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet h3 { margin: 0; font-size: 16px; }
.crop { align-self: center; width: 280px; max-width: 100%; aspect-ratio: 1; border-radius: 14px; overflow: hidden; }
.crop canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.crop canvas:active { cursor: grabbing; }
.crop-zoom { width: 100%; accent-color: var(--accent); }
.crop-hint { margin: -6px 0 0; font-size: 11px; text-align: center; }
.crop-error { margin: 0; font-size: 12px; color: #ff6b6b; text-align: center; }
.sheet-actions { display: flex; align-items: center; gap: 8px; }
.sheet-actions .spacer { flex: 1; }
.sheet-actions .ghost, .sheet-actions .primary-round { padding: 8px 14px; font-size: 13px; }
.primary-round:disabled { opacity: 0.4; cursor: default; }

.map-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.map-style {
  background: #17181c;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 4px 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.map-style img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #000; }
.map-style span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.map-style:hover { border-color: var(--line); }
.map-style.is-selected { border-color: var(--accent); color: var(--text); background: rgba(46, 224, 230, 0.08); }

.group-inline { display: grid; grid-template-columns: 1fr; gap: 16px; }
.segmented {
  display: inline-flex;
  background: #1a1b1f;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 600;
}
.segmented button.is-active { background: var(--text); color: #000; }

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 14px;
  min-width: 0;
  overflow: auto;
}

.phone {
  position: relative;
  height: min(72vh, 960px);
  aspect-ratio: 9 / 16;
  border-radius: 28px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 30px 80px rgba(0,0,0,0.6);
}
#frame { width: 100%; height: 100%; display: block; }
.status {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); padding: 6px 12px; border-radius: 999px; font-size: 12px;
}
.status:empty { display: none; }

/* 240 px top, 440 px bottom, 140 px right of 1080×1920: what the apps draw over. */
.safe-zones { position: absolute; inset: 0; pointer-events: none; }
.zone {
  position: absolute;
  background: rgba(255, 45, 85, 0.22);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.zone-top { left: 0; right: 0; top: 0; height: 12.5%; }
.zone-bottom { left: 0; right: 0; bottom: 0; height: 22.92%; }
.zone-right { right: 0; top: 12.5%; bottom: 22.92%; width: 12.96%; }
.zone-right span { writing-mode: vertical-rl; letter-spacing: 0.4em; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); cursor: pointer; margin-top: -4px; }
.toggle input { accent-color: var(--accent); }

.transport {
  display: flex; align-items: center; gap: 12px;
  width: min(560px, 100%);
}
#scrub { flex: 1; accent-color: var(--accent); }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 96px; text-align: right; }
.summary { margin: -4px 0 0; font-size: 12px; }

.primary-round, .ghost, .primary, .download {
  border-radius: 999px;
  border: 0;
  padding: 9px 18px;
  font-weight: 700;
  text-decoration: none;
}
.primary-round { background: var(--text); color: #000; min-width: 84px; }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.primary { background: var(--accent); color: #001314; padding: 12px 26px; font-size: 15px; }
.download { background: #16e05c; color: #00140a; padding: 12px 26px; font-size: 15px; display: inline-block; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 0; }

.export { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(560px, 100%); }
.progress { width: 100%; }
.progress-track { height: 6px; border-radius: 3px; background: #1d1e22; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); }
.hint { font-size: 11px; text-align: center; max-width: 440px; margin: 0; }

.results { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.results:not(:has(:not([hidden]))) { display: none; }
.download-secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.crash-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #17181c; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; cursor: pointer;
}
.crash-row strong { display: block; font-size: 13px; font-weight: 600; }
.crash-row small { display: block; font-size: 11px; color: var(--muted); }
.switch {
  appearance: none; flex: none; width: 44px; height: 26px; border-radius: 13px; margin: 0;
  background: #2a2b31; position: relative; cursor: pointer; transition: background 0.15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform 0.15s;
}
.switch:checked { background: #16e05c; }
.switch:checked::after { transform: translateX(18px); }
.driver.is-crashed .driver-car { transform: rotate(180deg); }
button, .car, .map-style, .driver, .chip, .swatch { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

body.is-exporting .panel,
body.is-exporting .transport,
body.is-exporting #export { pointer-events: none; opacity: 0.4; }

/* Phones: the preview and its controls stay pinned at the top, next to each other,
   and the settings scroll underneath. */
@media (max-width: 820px) {
  html, body { height: auto; }
  .studio { display: flex; flex-direction: column; height: auto; min-height: 100svh; }

  .stage {
    order: -1;
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr;
    align-items: start;
    column-gap: 14px;
    row-gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 12px;
    background: rgba(8, 9, 11, 0.94);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .phone { grid-column: 1; grid-row: 1 / span 4; height: min(36svh, 330px); border-radius: 16px; }
  .transport { grid-column: 2; grid-row: 1; width: auto; flex-wrap: wrap; gap: 8px; }
  .transport #scrub { order: 3; flex: 1 0 100%; margin: 2px 0 0; }
  .transport .time { min-width: 0; margin-left: auto; font-size: 11px; }
  .primary-round, .ghost { padding: 8px 14px; font-size: 13px; }
  .primary-round { min-width: 0; }
  .summary { grid-column: 2; grid-row: 2; margin: 0; font-size: 11px; line-height: 1.35; }
  .export { grid-column: 2; grid-row: 3; width: auto; align-items: stretch; gap: 8px; }
  .primary { padding: 11px 14px; font-size: 14px; }
  .results { flex-direction: column; gap: 8px; }
  .download { padding: 10px 14px; font-size: 14px; text-align: center; }
  .hint { display: none; }
  .toggle { grid-column: 2; grid-row: 4; margin: 0; font-size: 11px; align-items: flex-start; }

  .panel {
    border-right: 0;
    overflow: visible;
    padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
  }
  .brand { display: none; }

  /* Under 16px, iOS zooms the page in when a field is focused. */
  select, input[type="search"], .name-row input { font-size: 16px; }

  .car-grid { max-height: 300px; }

  .sheet {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0;
    border-width: 1px 0 0;
  }
  .sheet-body { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .crew { margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
  .chips { margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
  .swatches { gap: 6px; flex-wrap: wrap; }
}
