/* Colors and sizes in one place (rule 7b.8). Dark blue with the dealer site's orange accent. */
:root {
  --bg-top: #050b20;
  --bg-bottom: #101b44;
  --accent: #ff3600;
  --accent-strong: #d92e00;
  --accent-soft: rgba(255, 54, 0, 0.12);
  --on-accent: #ffffff;
  --chat-bg: #ffffff;
  --surface: #f4f5f8;
  --text: #121826;
  --muted: #5d6475;
  --line: #e3e6ee;
  --intro-text: #d7dcea;
  --intro-muted: #9aa3bd;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --gutter: clamp(16px, 5vw, 96px);
  --page-zoom: 1;
  --chat-compact: 460px;
  /* The wide chat may enter the right margin, but always leaves 16 screen pixels free (also when zoomed). */
  --edge: calc(16px / var(--page-zoom));
  --grow: min(60px, max(0px, calc(var(--gutter) - var(--edge))));
  --shift: min(48px, max(0px, calc(var(--gutter) - var(--edge) - var(--grow))));
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bottom) 100%) fixed;
  background-color: var(--bg-top);
}
button, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Page ---------- */
.topbar { display: none; }
.page {
  zoom: var(--page-zoom);
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.75fr) minmax(0, 1.25fr);
  gap: 48px;
  align-items: center;
  min-height: calc(100vh / var(--page-zoom));
}

/* ---------- Intro (left text) ---------- */
.intro {
  color: var(--intro-text);
  transform: translate(calc(-1 * min(3vw, 60px)), calc(-1 * min(2.5vh, 28px)));
}
.intro h1 { margin: 0 0 14px; font-size: 27px; line-height: 1.25; color: #ffffff; }
.intro h1 span { color: var(--accent); }
.intro p { margin: 0 0 18px; font-size: 15px; line-height: 1.6; }
.figures { display: flex; gap: 28px; margin: 0 0 18px; padding: 0; list-style: none; }
.figures strong { display: block; font-size: 18px; color: #ffffff; }
.figures span { font-size: 12px; color: var(--intro-muted); }
.features { margin: 0 0 18px; padding-left: 18px; font-size: 13px; line-height: 1.8; }
.features li::marker { color: var(--accent); }
.attention {
  font-size: 12px; line-height: 1.5; color: var(--intro-muted);
  border: 1px solid rgba(255, 255, 255, 0.14); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 10px 12px; margin: 0;
}
.attention b { color: var(--intro-text); }

/* ---------- Chat window ---------- */
.chat {
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  width: var(--chat-compact);
  height: min(700px, calc(100vh / var(--page-zoom) - 140px));
  margin-left: auto;
  margin-right: max(0px, calc((100% - var(--chat-compact)) / 2));
  transition: width 0.35s ease, height 0.35s ease, margin-right 0.35s ease, transform 0.35s ease;
}
.chat.is-wide {
  width: calc(100% + var(--grow));
  height: min(780px, calc(100vh / var(--page-zoom) - 140px));
  margin-right: calc(-1 * var(--grow));
  transform: translateX(var(--shift));
}
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.chat-title { flex: 1; min-width: 0; }
.chat-title strong { display: block; font-size: 16px; }
.chat-title span { font-size: 12px; color: var(--muted); }
.chat-title span::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px;
  border-radius: 50%; background: #22a55a; vertical-align: 1px;
}
.icon-button {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  border: 1px solid var(--line); background: #ffffff; color: var(--text); font-size: 17px; line-height: 1;
}
.icon-button:hover, .icon-button:focus-visible { border-color: var(--accent); color: var(--accent); }
.icon-button:disabled { opacity: 0.45; cursor: default; }

.chat-body {
  flex: 1; min-height: 0; position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
}
.chat.is-wide .chat-body { grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.4fr); }
.messages { grid-column: 1; grid-row: 1; }
.chat.is-wide .panel, .chat.is-wide .sheet { grid-column: 2; grid-row: 1; }

/* ---------- Messages ---------- */
.messages {
  margin: 0; padding: 16px; list-style: none;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px;
}
.message { max-width: 85%; font-size: 15px; line-height: 1.5; }
.message .bubble { padding: 10px 14px; border-radius: 16px; overflow-wrap: anywhere; }
.message.bot { align-self: flex-start; }
.message.bot .bubble { background: var(--surface); border-bottom-left-radius: 6px; }
.message.user { align-self: flex-end; }
.message.user .bubble { background: var(--accent-strong); color: var(--on-accent); border-bottom-right-radius: 6px; }
.message.welcome { max-width: 100%; align-self: stretch; }
.chat:not(.is-wide) .message.welcome:first-child { margin-top: 20px; }
.bubble p { margin: 0; }
.bubble ul { margin: 0; padding-left: 20px; list-style: disc; }
.bubble a { color: var(--accent-strong); font-weight: 600; text-decoration: none; }
.message.user .bubble a { color: var(--on-accent); }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  flex: 1 1 auto; white-space: nowrap; padding: 9px 12px; border-radius: 999px;
  border: 1px solid var(--accent); background: #ffffff; color: var(--accent-strong); font-weight: 600; font-size: 14px;
}
.chip:hover, .chip:focus-visible { background: var(--accent-soft); }
.typing .bubble { display: inline-flex; gap: 5px; align-items: center; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---------- Results panel ---------- */
.panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; border-left: 1px solid var(--line); background: #fbfbfd; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.panel-head strong { color: var(--text); font-size: 16px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card { background: #ffffff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.card-photo { aspect-ratio: 1.15; background: var(--surface); padding: 0; border: 0; display: block; width: 100%; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { margin: 0; font-size: 18px; font-weight: 700; }
.card-price { font-size: 26px; font-weight: 800; color: var(--accent-strong); }
.card-facts { font-size: 14px; color: var(--muted); }
.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.button {
  flex: 1; text-align: center; padding: 9px 12px; border-radius: 10px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--accent-strong); text-decoration: none; background: #ffffff; color: var(--accent-strong);
}
.button.primary { background: var(--accent-strong); color: var(--on-accent); }
.button:disabled { opacity: 0.45; cursor: default; }
.pager { display: flex; gap: 10px; margin-top: 14px; }

/* ---------- Zero results ---------- */
.zero { text-align: center; padding: 24px 8px; }
.zero svg { width: 170px; height: auto; }
.zero h3 { margin: 10px 0 6px; font-size: 18px; }
.zero p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.zero .pager { justify-content: center; }
.zero-body { fill: var(--surface); stroke: var(--bg-bottom); stroke-width: 4; }
.zero-roof { fill: none; stroke: var(--bg-bottom); stroke-width: 4; stroke-linejoin: round; }
.zero-glass { fill: #dfe6f5; }
.zero-light { fill: #ffffff; stroke: var(--accent); stroke-width: 4; }
.zero-grill { fill: var(--bg-bottom); }
.zero-wheel { fill: var(--bg-bottom); }
.zero-badge { fill: var(--accent-strong); }
.zero-mark { fill: var(--on-accent); font-size: 28px; font-weight: 800; font-family: var(--font); }
.send .plane { fill: var(--on-accent); }
.send .fold { fill: none; stroke: var(--accent-strong); stroke-width: 1.6; stroke-linecap: round; }

/* ---------- Car sheet ---------- */
.sheet {
  position: relative; z-index: 2; min-height: 0; background: #ffffff;
  overflow-y: auto; overscroll-behavior: contain; padding: 16px; border-left: 1px solid var(--line);
}
.sheet-back { border: 0; background: none; color: var(--accent-strong); font-weight: 600; padding: 4px 0; margin-bottom: 8px; }
.gallery { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface); aspect-ratio: 4 / 3; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, 0.9); color: var(--text); font-size: 22px; line-height: 1;
}
.gallery-arrow.prev { left: 10px; }
.gallery-arrow.next { right: 10px; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0 12px; padding-bottom: 4px; list-style: none; padding-left: 0; }
.thumbs button { flex: none; width: 70px; height: 52px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--surface); }
.thumbs button[aria-current="true"] { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet h2 { margin: 0; font-size: 20px; }
.sheet-price { font-size: 26px; font-weight: 800; color: var(--accent-strong); margin: 4px 0 2px; }
.sheet-note { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.sheet-links { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 10px 0 14px; }
.sheet-links button { padding: 7px 4px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; }
.sheet section { padding: 12px 0; border-top: 1px solid var(--line); }
.sheet h3 { margin: 0 0 8px; font-size: 16px; }
.sheet dl { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 14px; font-size: 14px; }
.sheet dt { color: var(--muted); }
.sheet dd { margin: 0; font-weight: 600; }
.sheet section p { margin: 0 0 6px; font-size: 14px; }
.sheet section a { color: var(--accent-strong); font-weight: 600; text-decoration: none; }

/* ---------- Composer ---------- */
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 26px 16px 44px; border-top: 1px solid var(--line); }
.composer textarea {
  flex: 1; resize: none; height: auto; padding: 14px; font-size: 17px; line-height: 24px;
  border: 1px solid var(--line); border-radius: 14px; outline: none; color: var(--text); background: #ffffff;
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.send {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none;
  height: 52px; padding: 0 20px; border: 0; border-radius: 14px;
  background: var(--accent-strong); color: var(--on-accent); font-weight: 700;
}
.send:disabled { opacity: 0.5; cursor: default; }
.send svg { width: 22px; height: 22px; flex: none; }
.round-send .send { width: 48px; height: 48px; padding: 0; border-radius: 50%; }
.round-send .send-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Reopen and page scroll buttons ---------- */
.reopen {
  position: fixed; right: 20px; bottom: 20px; z-index: 20;
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px;
  border: 2px solid #ffffff; border-radius: 999px; background: var(--accent-strong); color: var(--on-accent);
  font-weight: 700; box-shadow: var(--shadow); animation: pop-in 0.3s ease;
}
.reopen svg { width: 22px; height: 22px; }
@keyframes pop-in { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.scroll-toggle {
  position: fixed; right: 6px; top: 50%; transform: translateY(-50%); z-index: 20;
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid #ffffff;
  background: var(--accent-strong); color: var(--on-accent); font-size: 18px; line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* Short desktop screens: lower photos, so both cars and the paging buttons stay in view. */
@media (min-width: 980px) and (max-height: 760px) {
  .card-photo { aspect-ratio: 1.6; }
}

@media (prefers-reduced-motion: reduce) {
  .chat, .reopen { transition: none; animation: none; }
  .typing i { animation: none; opacity: 0.7; }
}

/* ---------- Phone and tablet: like a messaging app ---------- */
@media (max-width: 979.98px) {
  html { min-height: 100%; }
  html.chat-open, html.chat-open body { overflow: hidden; }
  .page { padding: 0; }
  .layout { display: flex; flex-direction: column; min-height: 0; }
  .chat, .chat.is-wide {
    order: -1; width: auto; height: calc(100dvh - 32px); margin: 16px; transform: none; transition: none;
  }
  .chat-body, .chat.is-wide .chat-body { grid-template-columns: minmax(0, 1fr); }
  .sheet, .chat.is-wide .sheet { position: absolute; inset: 0; border-left: 0; }
  .intro { transform: none; padding: 28px 20px 96px; }
  html:not(.chat-open) .topbar {
    display: block; padding: 14px 20px; color: #ffffff; font-weight: 700; font-size: 17px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }
  .panel { border-left: 0; padding: 0; background: none; overflow: visible; }
  .message.results { max-width: 100%; align-self: stretch; }
  .panel-head { margin-bottom: 8px; font-size: 13px; }
  .panel-head strong { font-size: 14px; }
  .cards { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .card { flex-direction: row; border-radius: 12px; }
  .card-photo { width: 36%; aspect-ratio: auto; flex: none; }
  .card-body { padding: 8px 10px; gap: 2px; min-width: 0; }
  .card-title { font-size: 14px; }
  .card-price { font-size: 17px; }
  .card-facts { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card-actions { gap: 6px; padding-top: 4px; }
  .button { padding: 5px 8px; font-size: 12px; border-radius: 8px; }
  .pager { margin-top: 8px; }
  .zero { padding: 12px 4px; }
  .zero svg { width: 120px; }
  .welcome-actions { gap: 6px; }
  .chip { padding: 7px 8px; font-size: 12.5px; }
  .composer { padding: 10px 12px 44px; gap: 8px; align-items: center; }
  .composer textarea { height: 44px; padding: 9px 12px; font-size: 16px; line-height: 24px; }
  .sheet-links button { font-size: 12px; }
}
@media (max-width: 559.98px) {
  .chat, .chat.is-wide { height: 100dvh; margin: 0; border-radius: 0; box-shadow: none; }
}
