:root {
  --ink: #111318;
  --muted: #667085;
  --line: #dfe3e8;
  --paper: #ffffff;
  --soft: #f4f6f8;
  --night: #090b0f;
  --red: #ef123f;
  --red-dark: #c90c31;
  --green: #138a5b;
  --amber: #b96000;
  --shadow: 0 16px 40px rgba(15, 23, 42, .12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-height: 100%;
  background: var(--soft);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--night) 0 254px, var(--soft) 254px 100%);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 18px calc(36px + env(safe-area-inset-bottom));
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: env(safe-area-inset-top);
}

.brand-logo {
  display: block;
  width: 170px;
  height: 40px;
  object-fit: contain;
  object-position: left center;
}

.status-pill,
.step-kind {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  padding: 5px 10px;
  color: #fff;
  background: rgba(255, 255, 255, .08);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.intro {
  min-height: 110px;
  padding: 10px 0 24px;
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: #ff6b87;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0;
  max-width: 620px;
  font-size: 30px;
  line-height: 1.08;
  font-weight: 780;
}

.intro p {
  max-width: 620px;
  margin: 10px 0 0;
  color: #cbd1d9;
  font-size: 15px;
  line-height: 1.5;
}

.progress-band {
  position: sticky;
  z-index: 20;
  top: 0;
  margin: 0 -18px;
  padding: 13px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 248, .96);
  backdrop-filter: blur(16px);
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 13px;
}

.progress-row strong {
  font-size: 14px;
}

.progress-row span {
  color: var(--muted);
  font-weight: 650;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #d8dde4;
}

.progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), #ff4e6f);
  transition: width 260ms ease;
}

.step-nav {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 42px;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -18px;
  padding: 15px 18px 8px;
  scrollbar-width: none;
}

.step-nav::-webkit-scrollbar {
  display: none;
}

.step-dot {
  width: 42px;
  height: 42px;
  border: 1px solid #cfd5dd;
  border-radius: 50%;
  color: #475467;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.step-dot.active {
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 18, 63, .12);
}

.step-dot.done {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.step-dot.optional {
  border-style: dashed;
}

.capture-card,
.details-panel,
.complete-panel,
.error-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.capture-card {
  overflow: hidden;
}

.step-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 16px;
}

.step-index {
  display: block;
  margin-bottom: 4px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.step-heading h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.18;
}

.step-heading .step-kind {
  flex: none;
  border-color: #d5dae1;
  color: #475467;
  background: #f8fafc;
}

.guide-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-block: 1px solid #23272f;
  background:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px),
    #0d1015;
  background-size: 24px 24px;
}

.guide-stage::before,
.guide-stage::after {
  content: "";
  position: absolute;
  inset: 10%;
  border: 1px solid rgba(255, 255, 255, .12);
  pointer-events: none;
}

.guide-stage::after {
  inset: 50% 0 auto;
  border-width: 1px 0 0;
}

.guide-sprite,
.live-guide {
  width: min(95%, 620px);
  aspect-ratio: 1.15;
  background-repeat: no-repeat;
  filter:
    brightness(0) invert(1)
    drop-shadow(0 0 1px rgba(255, 255, 255, .95))
    drop-shadow(0 0 12px rgba(239, 18, 63, .7));
  opacity: .84;
}

.sprite-exterior {
  background-image: url("/assets/vehicle-angle-overlay.png");
  background-size: 480% 240%;
}

.sprite-detail {
  background-image: url("/assets/vehicle-detail-overlay.png");
  background-size: 480% 240%;
}

.sprite-1 { background-position: 2.6% 7%; }
.sprite-2 { background-position: 34.2% 7%; }
.sprite-3 { background-position: 65.8% 7%; }
.sprite-4 { background-position: 97.4% 7%; }
.sprite-5 { background-position: 2.6% 93%; }
.sprite-6 { background-position: 34.2% 93%; }
.sprite-7 { background-position: 65.8% 93%; }
.sprite-8 { background-position: 97.4% 93%; }

.sprite-exterior.sprite-3 {
  background-position: 62.8% 7%;
}

.guide-caption {
  position: absolute;
  right: 14px;
  bottom: 12px;
  left: 14px;
  color: rgba(255, 255, 255, .76);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.capture-copy {
  padding: 17px 20px 20px;
}

.capture-copy > p {
  margin: 0 0 16px;
  color: #475467;
  font-size: 14px;
  line-height: 1.5;
}

.button-stack,
.review-actions,
.step-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button-stack {
  grid-template-columns: 1fr;
}

.button {
  min-height: 48px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 11px 16px;
  color: #fff;
  background: var(--ink);
  font-size: 14px;
  font-weight: 760;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button.primary {
  border-color: var(--red);
  background: var(--red);
  box-shadow: 0 8px 20px rgba(239, 18, 63, .22);
}

.button.primary:active {
  background: var(--red-dark);
}

.button.secondary {
  border-color: #cfd5dd;
  color: #344054;
  background: #fff;
}

.button:disabled {
  cursor: not-allowed;
  opacity: .46;
  box-shadow: none;
}

.capture-fallbacks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.text-button {
  min-height: 40px;
  border: 0;
  color: #475467;
  background: transparent;
  font-size: 13px;
  font-weight: 720;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.upload-state {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  border: 1px solid #a7dfc8;
  border-radius: 6px;
  padding: 10px 12px;
  color: #08724a;
  background: #edf9f4;
  font-size: 13px;
  font-weight: 720;
}

.upload-state::before {
  content: "\2713";
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
}

.review-panel {
  padding: 20px;
}

.review-image {
  display: block;
  width: 100%;
  max-height: 480px;
  border-radius: 6px;
  object-fit: contain;
  background: #0b0d11;
}

.quality-result {
  margin: 12px 0;
  border-left: 3px solid var(--green);
  padding: 10px 12px;
  color: #176348;
  background: #eef9f5;
  font-size: 13px;
  line-height: 1.45;
}

.quality-result.review {
  border-color: var(--amber);
  color: #7a4300;
  background: #fff8eb;
}

.quality-result.fail {
  border-color: var(--red);
  color: #9b1730;
  background: #fff0f3;
}

.step-actions {
  margin-top: 14px;
}

.details-panel,
.complete-panel,
.error-panel {
  padding: 22px 20px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0 0 6px;
  font-size: 21px;
}

.section-heading p,
.complete-panel p,
.error-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: #344054;
  font-size: 12px;
  font-weight: 780;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfd5dd;
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  font-size: 14px;
  outline: 0;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 18, 63, .11);
}

.consent-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  margin: 18px 0;
  color: #344054;
  font-size: 13px;
  line-height: 1.45;
}

.consent-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--red);
}

.complete-panel {
  border-top: 4px solid var(--green);
}

.complete-panel h2,
.error-panel h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.error-panel {
  border-top: 4px solid var(--red);
}

.loading-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 50px 20px;
  color: #344054;
  text-align: center;
}

.loading-state strong {
  margin-top: 16px;
  font-size: 18px;
}

.loading-state span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.loader {
  width: 34px;
  height: 34px;
  border: 3px solid #d7dce2;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.camera-view {
  position: fixed;
  z-index: 1000;
  inset: 0;
  overflow: hidden;
  color: #fff;
  background: #000;
}

.camera-view[hidden] {
  display: none;
}

.camera-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .74), transparent 22%, transparent 72%, rgba(0, 0, 0, .8));
  pointer-events: none;
}

.live-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(92vw, 760px);
  opacity: .7;
  transform: translate(-50%, -52%);
  pointer-events: none;
}

.camera-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
}

.camera-header > div {
  min-width: 0;
  text-align: center;
}

.camera-header span {
  display: block;
  color: rgba(255, 255, 255, .72);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.camera-header strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, .35);
  font-size: 29px;
  line-height: 1;
}

.live-badge {
  justify-self: end;
  width: 42px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 4px;
  padding: 5px 0;
  color: #fff !important;
  background: var(--red);
  text-align: center;
}

.camera-instruction {
  position: absolute;
  right: 20px;
  bottom: calc(124px + env(safe-area-inset-bottom));
  left: 20px;
  margin: 0 auto;
  max-width: 560px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-shadow: 0 1px 5px #000;
}

.camera-controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  height: calc(108px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}

.shutter {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 3px solid #fff;
  border-radius: 50%;
  padding: 5px;
  background: rgba(0, 0, 0, .22);
}

.shutter span {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #fff;
  transition: transform 100ms ease;
}

.shutter:active span {
  transform: scale(.9);
}

.toast {
  position: fixed;
  z-index: 1200;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 18px;
  max-width: 520px;
  margin: auto;
  border-radius: 6px;
  padding: 12px 14px;
  color: #fff;
  background: rgba(17, 19, 24, .96);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .28);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.visually-hidden {
  position: fixed !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 560px) {
  .app-shell {
    padding-inline: 14px;
  }

  .progress-band,
  .step-nav {
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .brand-logo {
    width: 150px;
  }

  .intro h1 {
    font-size: 27px;
  }

  .step-heading,
  .capture-copy,
  .review-panel,
  .details-panel {
    padding-right: 16px;
    padding-left: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field.full {
    grid-column: auto;
  }
}

@media (max-width: 380px) {
  .status-pill {
    max-width: 106px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .button-stack,
  .capture-fallbacks,
  .review-actions,
  .step-actions {
    grid-template-columns: 1fr;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .camera-header {
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .live-guide {
    width: min(66vw, 620px);
    transform: translate(-50%, -50%);
  }

  .camera-instruction {
    right: 112px;
    bottom: 18px;
    left: 112px;
  }

  .camera-controls {
    top: 50%;
    right: calc(14px + env(safe-area-inset-right));
    bottom: auto;
    left: auto;
    width: 86px;
    height: 86px;
    padding: 0;
    transform: translateY(-50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
