.vehicle-picker,
.vehicle-connector-editor {
  --vehicle-picker-ink: var(--planner-ink, var(--evmap-text, #14213a));
  --vehicle-picker-muted: var(--planner-muted, var(--evmap-muted, #68788b));
  --vehicle-picker-line: var(--planner-line, var(--evmap-line, #d9e2e9));
  --vehicle-picker-surface: var(--planner-surface, var(--evmap-surface, #fff));
  --vehicle-picker-soft: var(--planner-subtle, var(--evmap-surface-soft, #f5f8fa));
  --vehicle-picker-accent: var(--planner-accent-dark, var(--evmap-blue, #1463f3));
  --vehicle-picker-accent-soft: var(--planner-accent-soft, var(--evmap-blue-soft, #edf4ff));
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto;
  min-height: min(620px, calc(100dvh - 96px));
  color: var(--vehicle-picker-ink);
}

.vehicle-picker-battery-settings { grid-column: 1 / -1; }
.vehicle-picker-soh-controls { display: grid; grid-template-columns: minmax(110px, 150px) minmax(0, 1fr); align-items: end; gap: 16px; }
.vehicle-picker-soh-range { width: 100%; height: 44px; margin: 0; accent-color: var(--vehicle-picker-accent); cursor: pointer; }
.vehicle-picker-consumption-note { color: var(--vehicle-picker-muted); font-size: 11px; font-weight: 400; }

.vehicle-connector-editor {
  grid-template-rows: none;
  min-height: 0;
  gap: 16px;
  padding: 20px;
}

.vehicle-connector-editor h2,
.vehicle-connector-editor p {
  margin: 0;
}

.vehicle-picker-search {
  position: relative;
  z-index: 5;
  display: grid;
  gap: 6px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--vehicle-picker-line);
  background: var(--vehicle-picker-surface);
}

.vehicle-picker-search-label,
.vehicle-picker-field-label {
  color: var(--vehicle-picker-muted);
  font-size: 11px;
  font-weight: 750;
}

.vehicle-picker-search-input,
.vehicle-picker-field input,
.vehicle-picker-field select {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #bdc9d3;
  border-radius: 9px;
  background: #fff;
  color: var(--vehicle-picker-ink);
  font: 500 13px/1.2 inherit;
}

.vehicle-picker-search-input:focus-visible,
.vehicle-picker button:focus-visible,
.vehicle-picker input:focus-visible,
.vehicle-picker select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--vehicle-picker-accent) 24%, transparent);
  outline-offset: 2px;
}

.vehicle-picker-search-results {
  position: absolute;
  top: calc(100% - 8px);
  right: 20px;
  left: 20px;
  max-height: min(340px, 48dvh);
  overflow: auto;
  border: 1px solid var(--vehicle-picker-line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(18, 32, 51, .2);
}

.vehicle-picker-search-result {
  display: grid;
  width: 100%;
  gap: 3px;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid var(--vehicle-picker-line);
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.vehicle-picker-search-result span {
  color: var(--vehicle-picker-muted);
  font-size: 11px;
}

.vehicle-picker-search-result:hover,
.vehicle-picker-search-result.is-active {
  background: var(--vehicle-picker-accent-soft);
  box-shadow: inset 3px 0 var(--vehicle-picker-accent);
}

.vehicle-picker-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--vehicle-picker-line);
  background: var(--vehicle-picker-surface);
}

.vehicle-picker-back {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--vehicle-picker-line);
  border-radius: 8px;
  background: #fff;
  color: var(--vehicle-picker-accent);
  font: 750 12px/1 inherit;
  cursor: pointer;
}

.vehicle-picker-title {
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-picker-content {
  min-height: 0;
  overflow: auto;
  padding: 16px 20px;
  background: var(--vehicle-picker-soft);
}

.vehicle-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.vehicle-picker-tile,
.vehicle-picker-variant {
  border: 1px solid var(--vehicle-picker-line);
  border-radius: 10px;
  background: #fff;
  color: var(--vehicle-picker-ink);
  cursor: pointer;
}

.vehicle-picker-tile {
  display: grid;
  grid-template-rows: 84px auto auto;
  align-items: center;
  gap: 7px;
  min-height: 132px;
  padding: 10px;
  text-align: center;
}

.vehicle-picker-tile:hover,
.vehicle-picker-variant:hover {
  border-color: var(--vehicle-picker-accent);
  background: var(--vehicle-picker-accent-soft);
}

.vehicle-picker-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* PNGs retain their original alpha channel. Crop only their empty canvas margins. */
.vehicle-picker .vehicle-picker-visual {
  display: block;
  width: 100%;
  min-width: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 70%, var(--vehicle-picker-accent-soft), transparent 75%);
}

.vehicle-picker .vehicle-picker-visual .vehicle-picker-image {
  width: 100%;
  height: 100%;
  max-height: none;
}

.vehicle-picker .vehicle-picker-visual--render .vehicle-picker-image {
  object-fit: cover;
  object-position: center 20%;
}

.vehicle-picker [data-vehicle-picker-model] {
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 6px;
  padding: 10px 12px 14px;
}

.vehicle-picker-model-preview { margin-bottom: 14px; }

.user-vehicle-modal-body .vehicle-picker-content .vehicle-picker-grid:has([data-vehicle-picker-model]) {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.vehicle-picker .vehicle-picker-selected:has(.vehicle-picker-visual) {
  grid-template-columns: 176px minmax(0, 1fr);
}

@media (min-width: 721px) and (max-height: 500px) {
  .user-vehicle-modal-body .vehicle-picker [data-vehicle-picker-model] {
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-rows: auto auto;
    min-height: 104px;
    padding: 8px;
    gap: 4px 8px;
    text-align: left;
  }

  .user-vehicle-modal-body [data-vehicle-picker-model] .vehicle-picker-visual {
    grid-row: 1 / span 2;
  }
}

.vehicle-picker-tile-name {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.vehicle-picker-tile-meta,
.vehicle-picker-variant-meta,
.vehicle-picker-selected-copy span {
  color: var(--vehicle-picker-muted);
  font-size: 11px;
}

.vehicle-picker-variants {
  display: grid;
  gap: 8px;
}

.vehicle-picker-variant {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 68px;
  padding: 12px 14px;
  text-align: left;
}

.vehicle-picker-state {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 180px;
  color: var(--vehicle-picker-muted);
  text-align: center;
}

.vehicle-picker-retry,
.vehicle-picker-confirm {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: var(--vehicle-picker-accent);
  color: #fff;
  font: 800 13px/1 inherit;
  cursor: pointer;
}

.vehicle-picker-personalize {
  display: grid;
  gap: 15px;
}

.vehicle-picker-selected {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 92px;
  padding: 10px;
  border: 1px solid var(--vehicle-picker-line);
  border-radius: 10px;
  background: #fff;
}

.vehicle-picker-selected .vehicle-picker-image {
  height: 82px;
}

.vehicle-picker-selected-copy {
  display: grid;
  gap: 5px;
}

.vehicle-picker-connectors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--vehicle-picker-line);
  border-radius: 10px;
  background: #fff;
}

.vehicle-picker-connectors legend {
  width: 100%;
  padding: 0 2px;
  font-size: 12px;
  font-weight: 800;
}

.vehicle-picker-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--vehicle-picker-line);
  border-radius: 8px;
  background: var(--vehicle-picker-soft);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.vehicle-picker-check:has(input:checked) {
  border-color: var(--vehicle-picker-accent);
  background: var(--vehicle-picker-accent-soft);
  color: var(--vehicle-picker-accent);
}

.vehicle-picker-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--vehicle-picker-accent);
}

.vehicle-picker-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.vehicle-picker-field,
.vehicle-picker-capacity-field {
  display: grid;
  gap: 6px;
}

.vehicle-picker-capacity {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid var(--vehicle-picker-line);
  border-radius: 9px;
  background: var(--vehicle-picker-accent-soft);
  color: var(--vehicle-picker-accent);
  font-size: 14px;
  font-weight: 850;
}

.vehicle-picker-error {
  margin: 0;
  color: #b42335;
  font-size: 12px;
}

.vehicle-picker-confirm {
  justify-self: end;
}

.vehicle-picker-confirm:disabled {
  opacity: .65;
  cursor: wait;
}

.vehicle-picker-footer {
  min-height: 42px;
  padding: 11px 20px;
  border-top: 1px solid var(--vehicle-picker-line);
  background: var(--vehicle-picker-surface);
  color: var(--vehicle-picker-muted);
  font-size: 10px;
  line-height: 1.4;
}

.vehicle-picker-footer a {
  color: var(--vehicle-picker-accent);
}

.user-vehicle-modal-shell {
  width: min(920px, calc(100vw - 28px));
  max-height: min(900px, calc(100dvh - 28px));
}

.user-vehicle-modal-body {
  display: block;
  min-height: 0;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.user-vehicle-modal-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .8fr);
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--vehicle-picker-line);
  background: var(--vehicle-picker-surface);
}

.user-vehicle-modal-body .vehicle-picker {
  grid-template-rows: auto auto auto auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
}

/* The account dialog body owns scrolling, including the entire catalog grid. */
.user-vehicle-modal-body .vehicle-picker-content {
  overflow: visible;
}

@media (max-width: 720px) {
  .vehicle-picker {
    min-height: calc(100dvh - 24px);
  }

  .vehicle-picker-search,
  .vehicle-picker-content,
  .vehicle-picker-toolbar,
  .vehicle-picker-footer {
    padding-right: 14px;
    padding-left: 14px;
  }

  .vehicle-picker-search-results {
    right: 14px;
    left: 14px;
  }

  .vehicle-picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vehicle-picker-selected {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .vehicle-picker .vehicle-picker-selected:has(.vehicle-picker-visual) {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .user-vehicle-modal-body .vehicle-picker-content .vehicle-picker-grid:has([data-vehicle-picker-model]) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .vehicle-picker-fields {
    grid-template-columns: 1fr;
  }

  .vehicle-picker-confirm {
    justify-self: stretch;
  }

  .user-vehicle-modal-shell {
    width: 100vw;
    max-height: 92dvh;
  }

  .user-vehicle-modal-options {
    grid-template-columns: 1fr;
    padding: 12px 14px;
  }

}
/* Account appearance is optional; the existing picker layout is unchanged without its section. */
.vehicle-appearance { display: grid; gap: 12px; min-width: 0; margin: 12px 0 20px; padding: 16px; border: 1px solid var(--vehicle-picker-line, #d9e2e9); border-radius: 14px; background: var(--vehicle-picker-surface, #fff); color: var(--vehicle-picker-ink, #14213a); }
.vehicle-appearance [hidden] { display: none !important; }
.vehicle-appearance h3, .vehicle-appearance p { margin: 0; }
.vehicle-appearance h3 { font-size: 16px; }
[data-user-vehicle-form] .modal-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
[data-user-vehicle-actions] { flex: 1; min-width: 150px; }
[data-user-vehicle-actions] .vehicle-picker-confirm { width: 100%; margin: 0; min-height: 44px; background: var(--evmap-blue, #1463f3); color: #fff; }
[data-user-vehicle-actions] .vehicle-picker-error { margin: 0 0 8px; }
.vehicle-appearance button, .vehicle-appearance select, .vehicle-appearance input { box-sizing: border-box; min-height: 44px; max-width: 100%; border: 1px solid var(--vehicle-picker-line, #d9e2e9); border-radius: 8px; padding: 9px 12px; color: inherit; background: var(--vehicle-picker-surface, #fff); font: inherit; }
.vehicle-appearance button { cursor: pointer; line-height: 1.35; }
.vehicle-appearance button:disabled, .vehicle-appearance select:disabled { opacity: .58; cursor: default; }
.vehicle-appearance :is(button,input,select):focus-visible { outline: 3px solid var(--vehicle-picker-accent, #1463f3); outline-offset: 3px; }
.vehicle-appearance button[aria-pressed="true"] { border: 2px solid var(--vehicle-picker-accent, #1463f3); font-weight: 700; background: var(--vehicle-picker-accent-soft, #edf4ff); }
.vehicle-appearance-tabs { display: flex; gap: 8px; }
.vehicle-appearance-tabs button { flex: 1; }
.vehicle-appearance-stage { position: relative; height: clamp(180px, 42vw, 290px); overflow: hidden; border-radius: 10px; background: var(--vehicle-picker-soft, #f5f8fa); }
.vehicle-appearance-stage img, .vehicle-appearance-stage canvas { width: 100%; height: 100%; display: block; object-fit: contain; }
.vehicle-appearance-stage canvas { position: absolute; inset: 0; touch-action: none; }
.vehicle-appearance-note { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.vehicle-appearance-note:empty { display: none; }
.vehicle-appearance-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 6px; }
.vehicle-appearance-field { display: grid; gap: 6px; min-width: 0; font-size: 14px; font-weight: 600; }
.vehicle-appearance-field select, .vehicle-appearance-field input { width: 100%; min-width: 0; font-weight: 400; }
.vehicle-appearance-colors { min-width: 0; margin: 0; padding: 10px; border: 1px solid var(--vehicle-picker-line, #d9e2e9); border-radius: 10px; }
.vehicle-appearance-colors legend { font-weight: 600; font-size: 14px; }
.vehicle-appearance-palette { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; margin-bottom: 10px; }
.vehicle-appearance-palette button { display: flex; align-items: center; gap: 6px; padding: 7px; font-size: 12px; text-align: start; }
.vehicle-appearance-swatch { flex: 0 0 16px; width: 16px; height: 16px; border: 1px solid currentColor; border-radius: 50%; }
.vehicle-appearance-conflict { display: grid; gap: 10px; padding: 12px; border: 2px solid var(--vehicle-picker-accent, #1463f3); border-radius: 10px; overflow-wrap: anywhere; }
.vehicle-account-photo { width: 108px; height: 66px; flex: 0 0 108px; background: transparent; }
.vehicle-account-photo img { width: 100%; height: 100%; object-fit: contain; }
[data-theme="dark"] .vehicle-appearance, .theme-dark .vehicle-appearance { --vehicle-picker-surface: #172333; --vehicle-picker-ink: #edf4ff; --vehicle-picker-line: #435367; --vehicle-picker-soft: #223043; --vehicle-picker-accent-soft: #183457; --vehicle-picker-accent: #75aaff; }
@media (max-width: 360px) { .vehicle-appearance { padding: 10px; } .vehicle-account-photo { width: 78px; flex-basis: 78px; } }
