:root {
  --bg: #FFFFFF;
  --hover: #F4F4F4;
  --active: #ECECEC;
  --text: #0D0D0D;
  --text-2: #5D5D5D;
  --text-3: #8F8F8F;
  --text-4: #D9D9D9;
  --border: #E8E8E8;
  --border-soft: #F0F0F0;
  --green: #1A7F37;
  --green-bg: #EAF6EC;
  --red: #D1242F;
  --red-bg: #FCEBEC;
  --amber: #9A6700;
  --amber-bg: #FBF4E6;
  --info: #1D4ED8;
  --info-bg: #EAF1FF;
  --sent-blue: #0A84FF;
  --sent-blue-bg: #EAF4FF;
  --r-pill: 999px;
  --r-input: 26px;
  --r-card: 8px;
  --r-soft: 12px;
  --r-button: 999px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
*:focus { outline: none; }

html { -webkit-text-size-adjust: 100%; }
html, body {
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0;
  line-height: 1.6;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }
::selection { background: #93c5fd; color: #0f172a; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.view { min-height: 100dvh; }
.view[hidden] { display: none; }

/* ── Top bar ───────────────────────────────────────── */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; padding-top: env(safe-area-inset-top);
  background: #FFFFFF; border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 50;
  box-sizing: content-box;
}
.brand {
  font-weight: 600; font-size: 13px; letter-spacing: 0;
  text-transform: uppercase; color: var(--text);
}
.brand-caret { width: 15px; height: 15px; color: var(--text-2); flex-shrink: 0; transition: transform .15s ease; }
/* Current dealership, centered and non-interactive — the switch lives in the drawer. */
.topbar-store {
  flex: 1; min-width: 0; text-align: center;
  font-weight: 600; font-size: 13px; letter-spacing: 0; text-transform: uppercase;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-btn { margin-left: 0; }

/* Account avatar (top-right) — iMessage-blue initials, or a Google photo. */
.avatar {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--sent-blue); color: #FFFFFF; overflow: hidden;
  font-size: 13px; font-weight: 700; letter-spacing: 0.01em; line-height: 1;
  border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.avatar[hidden] { display: none; }
.avatar:active { opacity: 0.82; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-menu {
  position: fixed; z-index: 340; background: #FFFFFF;
  border: 1px solid var(--border-soft); border-radius: var(--r-soft);
  box-shadow: 0 12px 40px rgba(0,0,0,0.16); padding: 6px; min-width: 210px;
}
.avatar-menu[hidden] { display: none; }
.avatar-menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border-soft); margin-bottom: 5px; }
.avatar-menu-name { font-size: 14px; font-weight: 650; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar-menu-email { font-size: 12px; color: var(--text-3); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar-menu-item {
  display: flex; align-items: center; width: 100%; padding: 10px 10px; border: 0;
  background: transparent; border-radius: 9px; font: inherit; font-size: 14px;
  font-weight: 500; color: var(--red); cursor: pointer; text-align: left;
}
.avatar-menu-item:active { background: var(--hover); }
.showroom-embed #chat-open { display: none !important; }
.iconbtn {
  width: 36px; height: 36px; margin-left: -6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-button); color: var(--text-2);
}
.iconbtn:active { background: var(--hover); }
.iconbtn svg { width: 22px; height: 22px; }

.status-pill {
  height: 30px; display: inline-flex; align-items: center; gap: 7px;
  padding: 0 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border-soft); background: #FFFFFF;
  color: var(--text-2); font-size: 12px; font-weight: 500; user-select: none;
  transition: background .12s ease;
}
.status-pill:active { background: var(--hover); }
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status-pill.live { color: var(--green); }
.status-pill.offline { color: var(--amber); }
.status-pill.syncing { color: var(--sent-blue); }
.status-pill.syncing .dot { animation: pulse 0.7s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .4; transform: scale(.7);} to { opacity:1; transform: scale(1.2);} }

/* ── Search ───────────────────────────────────────── */
.searchwrap {
  position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 40;
  background: #FFFFFF; padding: 14px 16px 8px;
  border-bottom: 1px solid var(--border-soft);
}
.searchbar {
  display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: var(--r-input);
  background: #FFFFFF;
}
.searchbar:focus-within { border-color: var(--sent-blue); box-shadow: 0 0 0 3px rgba(10,132,255,.12); }
.searchbar .search-ic { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; }
.searchbar input {
  flex: 1; border: 0; background: none; font: inherit; font-size: 16px;
  color: var(--text); min-width: 0;
}
.searchbar input::placeholder { color: var(--text-3); }
.search-clear { width: 24px; height: 24px; border-radius: 50%; color: var(--text-3); font-size: 20px; line-height: 1; }
.search-clear:active { background: var(--hover); }

.filters { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: var(--r-pill);
  border: 1px solid var(--border-soft); background: #FFFFFF;
  color: var(--text-2); font-size: 13px; font-weight: 450; white-space: nowrap;
  transition: background .12s ease;
}
.chip:active { background: var(--hover); }
.chip.active { background: var(--hover); color: var(--text); border-color: var(--border); font-weight: 600; }
.chip.active:active { background: var(--active); }

.meta-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 4px; font-size: 12px; color: var(--text-3); gap: 10px;
}
#result-count { white-space: nowrap; flex-shrink: 0; }
.meta-right { display: flex; align-items: center; gap: 12px; margin-left: auto; min-width: 0; }
.updated-at { font-variant-numeric: tabular-nums; white-space: nowrap; }
.updated-at.stale { color: var(--amber); }

/* Filter + Sort buttons in the meta row (consistent pill style) */
.metabtn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: #FFFFFF;
  font: inherit; font-size: 12.5px; font-weight: 500; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
}
.metabtn:active { background: var(--hover); }
.metabtn svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-3); }
.metabtn.on { border-color: var(--text); color: var(--text); }
.metabtn-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--text); color: #FFFFFF; font-size: 10.5px; font-weight: 700;
}
.metabtn-count[hidden] { display: none; }

/* Custom sort menu — matches the site (no native OS dropdown) */
.sort-menu {
  position: fixed; z-index: 240; background: #FFFFFF;
  border: 1px solid var(--border-soft); border-radius: var(--r-soft);
  box-shadow: 0 12px 40px rgba(0,0,0,0.16); padding: 5px; min-width: 190px;
}
.sort-menu[hidden] { display: none; }
.sort-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 9px 12px; border: 0; background: transparent; border-radius: 9px;
  font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; text-align: left;
}
.sort-opt:active { background: var(--hover); }
.sort-opt.sel { font-weight: 600; }
.sort-opt.sel::after { content: ""; width: 15px; height: 15px; flex-shrink: 0;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230D0D0D' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }

/* Filter bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 260; }
.sheet[hidden] { display: none; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.32); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 82dvh; display: flex; flex-direction: column;
  background: #FFFFFF; border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.2);
  animation: sheet-up .22s ease;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.sheet-title { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.sheet-clear { margin-left: auto; border: 0; background: transparent; font: inherit;
  font-size: 13px; font-weight: 500; color: var(--text-3); cursor: pointer; padding: 4px 6px; }
.sheet-clear:active { color: var(--text); }
.sheet-x { width: 32px; height: 32px; }
.sheet-x svg { width: 18px; height: 18px; }
.sheet-body { overflow-y: auto; padding: 6px 14px 8px; -webkit-overflow-scrolling: touch; }
.fgroup { padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.fgroup:last-child { border-bottom: 0; }
.fgroup-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.02em; margin-bottom: 9px; }
.fchips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
.fchips::-webkit-scrollbar { display: none; }
.fchip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--r-pill); border: 1px solid var(--border);
  background: #FFFFFF; font: inherit; font-size: 13px; font-weight: 500; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
}
.fchip:active { background: var(--hover); }
.fchip.on { background: var(--hover); color: var(--text); border-color: var(--border); font-weight: 600; }
.fchip .sw { width: 13px; height: 13px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); flex-shrink: 0; }
/* how many we actually have, muted next to the label */
.fchip .fcount { font-size: 11px; font-weight: 600; opacity: 0.45; font-variant-numeric: tabular-nums; }
.sheet-foot { padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border-soft); flex-shrink: 0; }
.sheet-apply {
  width: 100%; height: 50px; border: 0; border-radius: var(--r-pill);
  background: var(--sent-blue); color: #FFFFFF; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.sheet-apply:active { background: #0069D9; }

/* New-arrival marker — minuscule dot; new arrivals pinned to top */
.vname-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.new-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sent-blue); flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--sent-blue-bg); }
.iconbtn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results ──────────────────────────────────────── */
.results { padding: 8px 16px 40px; display: flex; flex-direction: column; gap: 10px; }
.vcard {
  display: flex; gap: 14px; align-items: stretch; text-align: left; width: 100%;
  border: 1px solid var(--border-soft); border-radius: var(--r-card);
  background: #FFFFFF; overflow: hidden; padding: 10px;
  transition: background .1s ease;
}
.vcard:active { background: var(--hover); }
.vthumb {
  width: 104px; height: 78px; flex-shrink: 0; border-radius: var(--r-soft);
  background: var(--hover) center/cover no-repeat; position: relative;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-4); overflow: hidden;
}
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vthumb .ph-ic { width: 26px; height: 26px; }
.vbody { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.vname { font-size: 14.5px; font-weight: 600; letter-spacing: 0; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vtrim { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.vmeta { margin-top: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vprice { font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.vsave { font-size: 11px; font-weight: 600; color: var(--green); background: var(--green-bg);
  padding: 1px 7px; border-radius: var(--r-pill); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vstock { font-size: 11.5px; color: var(--text-3); }
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0; text-transform: uppercase;
  background: var(--border-soft); color: var(--text-2);
}
.badge.new { background: var(--border-soft); color: var(--text-2); }
.badge.used { background: var(--border-soft); color: var(--text-2); }
.badge.transit { background: var(--amber-bg); color: var(--amber); }
.badge.production { background: var(--border-soft); color: var(--text-2); }
.badge.oneowner { background: var(--sent-blue-bg); color: var(--sent-blue); }

.empty { padding: 64px 24px; text-align: center; color: var(--text-3); font-size: 14px; }

/* ── Detail ───────────────────────────────────────── */
.detail { padding: 0 0 56px; }
.gallery {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 14px 16px; scrollbar-width: none; background: var(--hover);
}
.gallery::-webkit-scrollbar { display: none; }
.gallery img,
.gallery-video {
  width: 86%; flex: 0 0 auto; height: 230px; object-fit: cover;
  border-radius: var(--r-card); scroll-snap-align: center; background: #FFF;
}
.gallery-video {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: #FFF; background: #111; font-size: 14px; font-weight: 650;
}
.gallery-video .play-ic {
  width: 54px; height: 54px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; background: rgba(255,255,255,0.18);
}
.gallery-video svg { width: 25px; height: 25px; margin-left: 3px; }
.gallery.single img { width: 100%; }
.gallery.single .gallery-video { width: 100%; }
.gallery-empty { height: 180px; display: flex; align-items: center; justify-content: center;
  color: var(--text-4); background: var(--hover); }
.gallery-empty svg { width: 48px; height: 48px; }

.dwrap { padding: 18px 16px; }
.dtitle { font-size: 22px; font-weight: 600; letter-spacing: 0; line-height: 1.15; }
.dtrim { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.dbadges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.dprice-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 18px 0 6px; }
.dprice { font-size: 28px; font-weight: 700; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.dmsrp { font-size: 14px; color: var(--text-3); text-decoration: line-through; }
.dsave { font-size: 13px; font-weight: 600; color: var(--green); }
.dincentive { font-size: 13px; color: var(--green); font-weight: 500; margin-top: 2px; }

.dlinks { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.dlink {
  flex: 1; min-width: 130px; height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-pill); font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); color: var(--text);
  transition: background .12s ease;
}
.dlink:active { background: var(--hover); }
.dlink.primary { background: transparent; color: var(--text); border-color: var(--border); }
.dlink.primary:active { background: var(--hover); }
.dlink svg { display: none; }

/* "Ask about this vehicle" — the AI chat button. White like the links around it,
   with a pulsing iMessage-blue glow to signal it's the talk-to-AI action. */
.ask-vehicle {
  width: 100%; margin: 6px 0; height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: 1px solid var(--border); border-radius: var(--r-pill); cursor: pointer;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14.5px; font-weight: 600;
  -webkit-tap-highlight-color: transparent; transition: background .12s ease;
  animation: ask-glow 2.2s ease-in-out infinite;
}
.ask-vehicle:active { background: var(--hover); }
.ask-vehicle svg { width: 19px; height: 19px; color: var(--sent-blue); }
@keyframes ask-glow {
  0%, 100% { box-shadow: 0 0 5px 0 rgba(10, 132, 255, 0.30), 0 0 0 0 rgba(10, 132, 255, 0.28); }
  50%      { box-shadow: 0 0 17px 3px rgba(10, 132, 255, 0.60), 0 0 0 3px rgba(10, 132, 255, 0.10); }
}
@media (prefers-reduced-motion: reduce) {
  .ask-vehicle { animation: none; box-shadow: 0 0 12px 1px rgba(10, 132, 255, 0.40); }
}

.section-h { font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: 0;
  text-transform: uppercase; margin: 26px 0 10px; }

.specs { border: 1px solid var(--border-soft); border-radius: var(--r-card); overflow: hidden; }
.spec { display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft); font-size: 14px; }
.spec:last-child { border-bottom: 0; }
.spec .k { color: var(--text-3); }
.spec .v { color: var(--text); font-weight: 500; text-align: right; word-break: break-word; }

/* Features / build sheet */
.feature-drawer { margin-top: 26px; }
.feat-wrap { border-top: 1px solid var(--border-soft); }
.feat-group { border-bottom: 1px solid var(--border-soft); }
.feat-group:last-child { border-bottom: 0; }
.feat-group > summary {
  min-height: 44px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text);
}
.feat-group > summary::-webkit-details-marker { display: none; }
.feat-group > summary::after {
  content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg); transition: transform .12s ease; margin-left: 2px;
}
.feat-group[open] > summary::after { transform: rotate(-135deg); }
.feat-list { list-style: none; display: grid; grid-template-columns: 1fr; gap: 6px; }
.feat-group .feat-list { padding: 0 16px 14px; }
.feature-drawer > .feat-list.plain { border-top: 1px solid var(--border-soft); padding: 14px 16px; }
.feat-list li { font-size: 13.5px; color: var(--text); padding-left: 16px; position: relative; line-height: 1.4; }
.feat-list li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--text-4); }
@media (min-width: 620px) { .feat-list { grid-template-columns: 1fr 1fr; column-gap: 20px; } }

.fin-block { border: 1px solid var(--border-soft); border-radius: var(--r-card); overflow: hidden; }
.fin-line { display: flex; justify-content: space-between; gap: 14px; padding: 11px 16px;
  border-bottom: 1px solid var(--border-soft); font-size: 13.5px; color: var(--text); }
.fin-line:last-child { border-bottom: 0; }
.fin-line .fin-amt { color: var(--green); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.desc { font-size: 14px; color: var(--text-2); line-height: 1.6; }

/* ── History (collapsible) ────────────────────────── */
.hist { margin-top: 26px; border: 1px solid var(--border-soft); border-radius: var(--r-card); overflow: hidden; }
.hist > summary {
  list-style: none; cursor: pointer; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0;
}
.hist > summary::-webkit-details-marker { display: none; }
.hist > summary::after {
  content: ""; width: 8px; height: 8px; border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .15s ease; margin-left: auto;
}
.hist[open] > summary::after { transform: rotate(-135deg); }
.hist .hist-count { background: var(--border-soft); color: var(--text-2); border-radius: var(--r-pill);
  font-size: 11px; padding: 1px 8px; margin-left: 10px; }
.hist-body { border-top: 1px solid var(--border-soft); }
.hist-row { display: flex; gap: 14px; padding: 11px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.hist-row:last-child { border-bottom: 0; }
.hist-when { color: var(--text-3); white-space: nowrap; min-width: 92px; font-variant-numeric: tabular-nums; }
.hist-what { color: var(--text); }

/* ── Lightbox ─────────────────────────────────────── */
body.lb-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 300; background: #000; }
.lightbox[hidden] { display: none; }
.lb-track {
  position: absolute; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.lb-track::-webkit-scrollbar { display: none; }
.lb-slide {
  flex: 0 0 100%; width: 100%; height: 100%; scroll-snap-align: center;
  display: flex; align-items: center; justify-content: center;
  overflow: auto; -webkit-overflow-scrolling: touch;
}
.lb-slide img,
.lb-slide video,
.lb-slide iframe { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-slide video,
.lb-slide iframe { width: 100%; height: 100%; border: 0; background: #000; }
.lb-video { padding: calc(58px + env(safe-area-inset-top)) 0 calc(54px + env(safe-area-inset-bottom)); }
.lb-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 14px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,0.5); color: #FFF;
  font-size: 26px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.lb-nav { display: none; }
.lb-counter {
  position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  color: #FFF; font-size: 13px; font-weight: 500; background: rgba(0,0,0,0.5);
  padding: 5px 12px; border-radius: var(--r-pill); font-variant-numeric: tabular-nums;
}

/* ── Chat — mirrors ASIA's assistant exactly (chat.html + base.html) ── */
body.modal-open { overflow: hidden; }
.chat { position: fixed; inset: 0; z-index: 250; background: var(--bg); display: flex; flex-direction: column; }
.chat[hidden] { display: none; }
.chat-log {
  flex: 1; overflow-y: auto; padding: 24px 16px 12px;
  display: flex; flex-direction: column; gap: 24px;
  max-width: 800px; width: 100%; margin: 0 auto;
}
.bubble {
  font-size: 15px; line-height: 1.7;
  white-space: pre-wrap; word-wrap: break-word; position: relative;
}
.bubble.user {
  align-self: flex-end; max-width: 80%; color: var(--text);
  padding: 10px 16px; border: 0; background: var(--hover); border-radius: 20px;
}
.bubble.assistant {
  align-self: flex-start; max-width: 90%;
  background: transparent; color: var(--text); padding: 0;
}

/* LLM "thinking" indicator — Axle style: a pulsing dot + the word "Thinking"
   with a light shimmer sweeping through it. Consistent everywhere LLM runs. */
.bubble.thinking {
  display: inline-flex !important;
  align-items: center;
  gap: 9px;
  align-self: flex-start;
  background: transparent !important;
  color: transparent;
  padding: 2px 0 !important;
}
.bubble.thinking::before {
  content: '';
  width: 7px; height: 7px; flex: none;
  border-radius: 50%;
  background: #0A84FF;
  animation: asia-think-dot 0.7s ease-in-out infinite alternate;
}
.bubble.thinking::after {
  content: 'Thinking';
  font-size: 13px; font-weight: 500; letter-spacing: 0.01em;
  background: linear-gradient(100deg,
    var(--text-3) 0%, var(--text-3) 32%,
    var(--text) 50%,
    var(--text-3) 68%, var(--text-3) 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: asia-think-shimmer 1.6s linear infinite;
}
@keyframes asia-think-dot {
  from { transform: scale(0.6); opacity: 0.55; }
  to   { transform: scale(1.25); opacity: 1; }
}
@keyframes asia-think-shimmer {
  0%   { background-position: 160% 0; }
  100% { background-position: -160% 0; }
}

/* ─── Rich LLM reply rendering (Markdown + Mermaid + photos) ─────────── */
.bubble.rich { line-height: 1.65; font-size: 14.5px; color: var(--text); white-space: normal; }
.rich > *:first-child { margin-top: 0; }
.rich > *:last-child { margin-bottom: 0; }
.rich p { margin: 0 0 12px; }
.rich strong { font-weight: 600; color: var(--text); }
.rich em { font-style: italic; }
.rich a { color: var(--info); text-decoration: underline; text-underline-offset: 2px; }
.rich ul, .rich ol { margin: 10px 0 14px; padding-left: 22px; }
.rich ul { list-style: disc; }
.rich ol { list-style: decimal; }
.rich li { margin: 5px 0; padding-left: 3px; }
.rich li::marker { color: var(--text-3); }
.rich li > ul, .rich li > ol { margin: 5px 0 5px; }
.rich h1, .rich h2, .rich h3, .rich h4 {
  margin: 20px 0 10px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; color: var(--text);
}
.rich h1 { font-size: 19px; } .rich h2 { font-size: 16.5px; } .rich h3 { font-size: 15px; } .rich h4 { font-size: 14px; }
/* Word-by-word reveal of the already-formatted reply (never shows raw markdown) */
.rich .asia-word { opacity: 0; transition: opacity .22s ease; }
.rich .asia-word.on { opacity: 1; }
.bubble:not(.streaming) .asia-word { opacity: 1; }
.rich code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  background: var(--hover); padding: 1px 5px; border-radius: 5px;
}
.rich pre {
  background: #0D0D0D; color: #F4F4F4; border-radius: var(--r-soft);
  padding: 12px 14px; margin: 10px 0; overflow-x: auto; font-size: 12.5px; line-height: 1.5;
}
.rich pre code { background: none; padding: 0; color: inherit; }
.rich blockquote {
  margin: 10px 0; padding: 2px 0 2px 14px; border-left: 3px solid var(--border);
  color: var(--text-2);
}
.rich hr { border: 0; border-top: 1px solid var(--border-soft); margin: 16px 0; }
.rich table {
  border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px;
  border: 1px solid var(--border-soft); border-radius: var(--r-soft); overflow: hidden;
}
.rich th, .rich td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border-soft); }
.rich th { font-weight: 600; color: var(--text-2); background: var(--hover); font-size: 12px; }
.rich tr:last-child td { border-bottom: 0; }
.rich img.asia-photo {
  display: block; max-width: 100%; width: 100%; height: auto;
  border-radius: var(--r-card); margin: 12px 0; border: 1px solid var(--border-soft);
}
/* Mermaid chart card — premium teal/coral theme from Axle */
.asia-chart {
  width: 100%; margin: 14px 0; padding: 16px 14px 12px; overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbfc 100%);
  border: 1px solid #d8e9ef; border-radius: 18px; box-shadow: 0 8px 24px rgba(15,23,42,0.06);
}
.asia-chart svg { max-width: 100% !important; width: 100% !important; height: auto !important; display: block; }
.asia-chart-err { color: var(--red); font-size: 12.5px; }

/* Composer — ASIA input-shell */
.chat-form {
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
  background: #FFFFFF; flex-shrink: 0;
}
.input-shell {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 720px; margin: 0 auto;
  background: #FFFFFF;
  border: 1px solid var(--border-soft);
  border-radius: 28px;
  padding: 8px 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.06);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input-shell:focus-within { border-color: var(--sent-blue); box-shadow: 0 0 0 3px rgba(10,132,255,.12), 0 10px 34px rgba(0,0,0,0.08); }
.chat-form input {
  flex: 1; border: 0; background: transparent; outline: none;
  font: 400 16px var(--font); letter-spacing: -0.005em; color: var(--text);
  min-width: 0; min-height: 28px; padding: 4px 0 4px 8px; line-height: 1.6;
}
.chat-form input::placeholder { color: var(--text-3); }
.chat-send {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%;
  background: var(--sent-blue); color: #FFF;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity .15s ease, transform .12s ease;
}
.chat-send svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 2.2; }
.chat-send:active { opacity: 0.82; transform: scale(0.93); }

/* ── Toast ────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 200;
  background: var(--text); color: #FFF; font-size: 13px; font-weight: 500;
  padding: 10px 18px; border-radius: var(--r-pill); box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  max-width: 88%; text-align: center;
}
.toast[hidden] { display: none; }

/* ══════════════════════════════════════════════════════════════════════════
   DESKTOP — same design language, laid out for a wide screen. Everything above
   is the phone layout; these overrides only kick in at tablet/desktop widths.
   ══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 760px) {
  .lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.45); color: #FFF; transition: background .12s ease, opacity .12s ease;
  }
  .lb-nav svg { width: 28px; height: 28px; }
  .lb-nav:hover { background: rgba(0,0,0,0.62); }
  .lb-nav:disabled { opacity: .28; cursor: default; }
  .lb-prev { left: 22px; }
  .lb-next { right: 22px; }

  body { background: #FAFAFA; }
  .view { max-width: 1440px; margin: 0 auto; background: #FFFFFF; min-height: 100dvh;
          box-shadow: 0 0 0 1px var(--border-soft); }

  /* Top bar / search / filters centered with roomy padding */
  .topbar { height: 64px; padding: 0 32px; }
  .brand { font-size: 15px; }
  .searchwrap { top: calc(64px + env(safe-area-inset-top)); padding: 18px 32px 10px; }
  .searchbar { max-width: 640px; }
  .filters { margin-top: 14px; }
  .meta-row { padding: 16px 32px 6px; font-size: 13px; }

  /* List becomes a responsive grid of vertical cards */
  .results {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px;
    padding: 20px 32px 80px;
  }
  .vcard { flex-direction: column; align-items: stretch; padding: 0; border-radius: var(--r-soft); }
  .vcard:hover { background: #FFFFFF; box-shadow: 0 8px 28px rgba(0,0,0,0.10); transform: translateY(-2px); }
  .vcard { transition: box-shadow .15s ease, transform .15s ease; }
  .vthumb { width: 100%; height: 210px; border-radius: 0; }
  .vbody { padding: 14px 16px 16px; }
  .vname { white-space: normal; font-size: 16px; line-height: 1.25; }
  .vtrim { white-space: normal; font-size: 13px; margin-top: 3px; }
  .vmeta { margin-top: 12px; }
  .vprice { font-size: 16px; }

  /* Detail: photo grid on the left, sticky info column on the right */
  .detail { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
            gap: 0 44px; max-width: 1280px; margin: 0 auto; padding: 28px 32px 80px; align-items: start; }
  .gallery {
    grid-column: 1; grid-row: 1 / 3; display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    overflow: visible; background: transparent; padding: 0; scroll-snap-type: none;
  }
  .gallery img,
  .gallery-video { width: 100%; height: 235px; scroll-snap-align: none; cursor: zoom-in; }
  .gallery img:first-child,
  .gallery-video:first-child { grid-column: 1 / -1; height: 420px; }
  .gallery.single { grid-template-columns: 1fr; }
  .gallery-empty { grid-column: 1; height: 420px; border-radius: var(--r-card); }
  .dwrap { grid-column: 2; grid-row: 1; padding: 0; position: sticky; top: 88px; }
  .dtitle { font-size: 26px; }
}

@media (min-width: 1040px) {
  .results { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1380px) {
  .results { grid-template-columns: repeat(4, 1fr); }
}

/* Chat as a centered floating panel on desktop instead of full-screen */
@media (min-width: 760px) {
  .chat { max-width: 460px; left: auto; right: 24px; top: auto; bottom: 24px;
          height: min(680px, 82vh); border: 1px solid var(--border);
          border-radius: 18px; overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,0.22); }
  .chat .topbar { height: 56px; padding: 0 16px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   SIDE DRAWER — ChatGPT-style slide-out from the left. Holds the dealership
   switcher, New chat, saved chat history, and the tools (trade-in, refresh).
   ══════════════════════════════════════════════════════════════════════════ */
.drawer { position: fixed; inset: 0; z-index: 230; }
.drawer[hidden] { display: none; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.32);
  opacity: 0; transition: opacity .22s ease; }
.drawer.open .drawer-scrim { opacity: 1; }
.drawer-panel {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: min(310px, 84vw); display: flex; flex-direction: column;
  background: #FFFFFF; border-right: 1px solid var(--border-soft);
  box-shadow: 0 0 40px rgba(0,0,0,0.18);
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-100%); transition: transform .24s cubic-bezier(.4,0,.2,1);
}
.drawer.open .drawer-panel { transform: translateX(0); }

/* Dealership switcher at the very top */
.drawer-store { position: relative; margin-bottom: 10px; }
.store-switch-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 16px; border: 1px solid var(--border-soft); border-radius: var(--r-pill);
  background: var(--hover); font: inherit; color: var(--text); cursor: pointer; text-align: left;
}
.store-switch-row:active { background: var(--active); }
.store-switch-tag { font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-3); }
.store-switch-cur { flex: 1; min-width: 0; font-size: 14px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-switch-row[aria-expanded="true"] .brand-caret { transform: rotate(180deg); }
.store-list { margin-top: 6px; padding: 5px; border: 1px solid var(--border-soft);
  border-radius: var(--r-soft); background: #FFFFFF; box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.store-list[hidden] { display: none; }
.store-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 10px 11px; border: 0; background: transparent; border-radius: 9px;
  font: inherit; font-size: 14px; color: var(--text); cursor: pointer; text-align: left;
}
.store-opt:active { background: var(--hover); }
.store-opt.sel { font-weight: 650; }
.store-opt.sel::after { content: ""; width: 15px; height: 15px; flex-shrink: 0;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230A84FF' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }

/* New chat — primary action */
.drawer-new {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 12px; margin-bottom: 12px; border: 1px solid var(--border);
  border-radius: var(--r-pill); background: #FFFFFF; font: inherit;
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer;
}
.drawer-new:active { background: var(--hover); }
.drawer-new svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-2); }

/* Chat history list — the scrollable middle */
.drawer-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  margin: 0 -4px; padding: 0 4px; }
.drawer-scroll::-webkit-scrollbar { width: 4px; }
.drawer-label { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-3); padding: 4px 8px 8px; }
.chat-list { display: flex; flex-direction: column; gap: 2px; }
.chat-item { display: flex; align-items: center; border-radius: 9px; }
.chat-item.active { background: var(--hover); }
.chat-item-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px;
  padding: 9px 8px 9px 10px; border: 0; background: transparent; border-radius: 9px;
  font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; text-align: left;
}
.chat-item-open:active { background: var(--hover); }
.chat-item-open svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-3); }
.chat-item-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-del {
  width: 30px; height: 34px; flex-shrink: 0; display: inline-flex; align-items: center;
  justify-content: center; border: 0; background: transparent; border-radius: 8px;
  color: var(--text-3); cursor: pointer; opacity: 0;
}
.chat-item.active .chat-item-del, .chat-item:hover .chat-item-del { opacity: 1; }
.chat-item-del:active { background: var(--active); color: var(--red); }
.chat-item-del svg { width: 15px; height: 15px; }
.chat-list-empty { padding: 10px 8px; font-size: 13px; color: var(--text-3); }

/* Tools — trade-in + refresh, pinned to the bottom */
.drawer-tools { border-top: 1px solid var(--border-soft); padding-top: 8px; margin-top: 8px; }
.drawer-row {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 11px 14px; border: 0; background: transparent; border-radius: var(--r-pill);
  font: inherit; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; text-align: left;
}
.drawer-row:active { background: var(--hover); }
.drawer-ic { width: 21px; height: 21px; flex-shrink: 0; color: var(--text-2); }
.drawer-row-label { flex: 1; min-width: 0; }
.drawer-row-tag { font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--sent-blue); background: var(--sent-blue-bg);
  padding: 2px 7px; border-radius: var(--r-pill); }
