/* Colours and shared sizes: one place (CLAUDE.md 7b.8). Site colours, no logo (5c.13). */
:root {
  --bg: #24272c;
  --bg-deep: #141619;
  --accent: #e32b26;
  --accent-dark: #c92520;
  --surface: #ffffff;
  --surface-soft: #f3f4f6;
  --ink: #1f2328;
  --ink-muted: #6b7280;
  --line: #e5e7eb;
  --on-dark: #f4f5f6;
  --on-dark-muted: #b9bec6;
  --page-zoom: 1;
  --side-pad: clamp(16px, 5vw, 96px);
  --screen-height: calc(100vh / var(--page-zoom));
  --compact-width: 460px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--on-dark);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
}

button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
html:not(.chat-open) .chat-column { display: none; }

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

/* ---------- Intro (left on desktop, under the chat on phones) ---------- */
.intro h1 { font-size: 27px; line-height: 1.25; margin: 0 0 14px; }
.intro-text { font-size: 15px; line-height: 1.6; color: var(--on-dark-muted); margin: 0; }
.intro-figures { display: flex; gap: 28px; list-style: none; padding: 0; margin: 22px 0 18px; }
.intro-figures strong { display: block; font-size: 18px; color: #fff; }
.intro-figures span { font-size: 12px; color: var(--on-dark-muted); }
.intro-list { font-size: 13px; line-height: 1.8; padding-left: 18px; margin: 0 0 18px; color: var(--on-dark); }
.intro-list li::marker { color: var(--accent); }
.intro-warning {
  font-size: 12px; line-height: 1.5; margin: 0; padding: 10px 12px; border-radius: 10px;
  color: var(--on-dark-muted); border: 1px solid rgba(227, 43, 38, 0.45); background: rgba(227, 43, 38, 0.08);
}
.intro-warning strong { color: #fff; }

/* ---------- Chat window ---------- */
.chat {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--ink);
  border-radius: 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.chat-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 50% 50%, #fff 0 5px, var(--accent) 6px);
}
.chat-heading { flex: 1; min-width: 0; }
.chat-heading h2 { margin: 0; font-size: 16px; }
.chat-heading p { margin: 0; font-size: 12px; color: var(--ink-muted); }
.icon-button {
  width: 36px; height: 36px; border-radius: 50%; border: 0; flex: none;
  background: var(--surface-soft); font-size: 17px; line-height: 1;
}
.icon-button:hover { background: var(--line); }

.chat-body { flex: 1; min-height: 0; display: flex; position: relative; }

.messages {
  flex: 1; min-width: 0; margin: 0; padding: 16px; list-style: none;
  overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px;
}
.message {
  max-width: 85%; padding: 10px 14px; border-radius: 16px;
  font-size: 15px; line-height: 1.45; overflow-wrap: anywhere;
}
.message p { margin: 0; }
.message ul { margin: 0; padding-left: 20px; list-style: disc; }
.message a { color: inherit; font-weight: 600; white-space: nowrap; }
.message.bot { align-self: flex-start; background: var(--surface-soft); border-bottom-left-radius: 6px; }
.message.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.message.welcome { max-width: 100%; }
.message.notice { align-self: center; background: none; color: var(--ink-muted); font-size: 13px; padding: 0; }
.chat.is-compact .messages > li:first-child { margin-top: 20px; }

.welcome-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  white-space: nowrap; padding: 7px 12px; border-radius: 999px; font-size: 13.5px;
  border: 1px solid var(--accent); color: var(--accent); background: var(--surface);
}
.chip:hover { background: rgba(227, 43, 38, 0.08); }

.typing { display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-muted); animation: typing 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Composer ---------- */
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 26px 16px 36px; border-top: 1px solid var(--line); }
.composer textarea {
  flex: 1; min-width: 0; resize: none; height: auto; padding: 14px; font-size: 17px; line-height: 24px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
}
.composer textarea::placeholder { color: var(--ink-muted); }
.send-button {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 48px; height: 48px; border-radius: 50%; border: 0; padding: 0;
  background: var(--accent); color: #fff; font-weight: 600;
}
.send-button:disabled { opacity: 0.55; cursor: default; }
.send-button svg { width: 22px; height: 22px; }
.send-button .plane { fill: #fff; }
.send-button .plane-fold { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; }
.send-label { display: none; }

/* ---------- Results ---------- */
.results { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.results-count { margin: 0; font-size: 14px; color: var(--ink-muted); }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.card {
  display: flex; flex-direction: column; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
}
.card:hover { border-color: #cfd3da; }
.card-photo { display: block; width: 100%; object-fit: cover; background: var(--surface-soft); }
.card-content { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; min-width: 0; }
.card-title {
  margin: 0; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-price { margin: 0; font-weight: 700; }
.card-price del { font-size: 0.55em; font-weight: 400; color: var(--ink-muted); margin-left: 6px; }
.card-data { margin: 0; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 6px; }
.card-actions .button { white-space: nowrap; }
.card-actions a.button { flex: 1 1 auto; }

.button {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 600; border: 1px solid transparent;
}
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-dark); }
.button-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.button:disabled { opacity: 0.45; cursor: default; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pager-info { font-size: 13px; color: var(--ink-muted); }

.zero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 18px 8px; }
.zero h3 { margin: 6px 0 0; font-size: 17px; }
.zero p { margin: 0; color: var(--ink-muted); font-size: 14px; }
.zero-art svg { width: 170px; height: auto; }
.zero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.art-ground { fill: var(--line); }
.art-body { fill: var(--bg); }
.art-glass { fill: #6b7380; }
.art-light { fill: #fff; }
.art-dark { fill: var(--bg-deep); }
.art-accent { fill: var(--accent); }
.art-mark { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; }

/* ---------- Car sheet ---------- */
.sheet { overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 24px; background: var(--surface); }
.sheet-back { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0 0 10px; }
.gallery { position: relative; }
.gallery-photo { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 14px; background: var(--surface-soft); }
.gallery-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: rgba(20, 22, 25, 0.6); color: #fff; font-size: 22px; line-height: 1;
}
.gallery-previous { left: 10px; }
.gallery-next { right: 10px; }
.thumbs { list-style: none; display: flex; gap: 6px; margin: 8px 0 0; padding: 0 0 4px; overflow-x: auto; overscroll-behavior: contain; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 8px; background: none; flex: none; }
.thumbs button[aria-current="true"] { border-color: var(--accent); }
.thumbs img { display: block; width: 64px; height: 46px; object-fit: cover; border-radius: 6px; }
.sheet-title { margin: 14px 0 4px; font-size: 19px; }
.sheet-price { margin: 0 0 10px; font-size: 22px; font-weight: 700; }
.sheet-price del { font-size: 14px; font-weight: 400; color: var(--ink-muted); }
.sheet-link { width: 100%; }
.sheet-tabs { display: flex; gap: 6px; margin: 12px 0 4px; }
.sheet-tabs button { flex: 1; padding: 8px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-soft); font-size: 13px; font-weight: 600; }
.sheet-section h4 { margin: 18px 0 8px; font-size: 15px; }
.sheet-section dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.sheet-section dt { color: var(--ink-muted); }
.sheet-section dd { margin: 0; }
.sheet-section p { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
.equipment { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; font-size: 13.5px; }
.equipment h5 { margin: 10px 0 4px; font-size: 13px; color: var(--ink-muted); }
.equipment ul { margin: 0; padding-left: 18px; line-height: 1.6; }

/* ---------- Launcher and phone scroll button ---------- */
.launcher {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px; border: 0; background: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); animation: launcher-in 0.25s ease-out;
}
.launcher svg { width: 20px; height: 20px; fill: #fff; }
@keyframes launcher-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.page-scroll {
  position: fixed; right: 8px; top: 50%; transform: translateY(-50%); z-index: 15;
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid #fff; background: var(--accent); color: #fff;
  font-size: 18px; line-height: 1; padding: 0; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* ---------- Desktop (980 px and wider) ---------- */
@media (min-width: 980px) {
  html, body { height: 100%; overflow: hidden; }
  .layout {
    zoom: var(--page-zoom);
    max-width: 1560px; margin: 0 auto; padding: 0 var(--side-pad); height: var(--screen-height);
    display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 48px; align-items: center;
  }
  .intro { max-width: 560px; transform: translate(calc(-1 * min(3vw, 60px)), calc(-1 * min(2.5vh, 28px))); }
  .chat-column { height: 100%; min-width: 0; display: flex; align-items: center; justify-content: flex-end; }
  .chat {
    --edge: calc(var(--side-pad) - 16px);
    width: calc(100% + min(60px, var(--edge)));
    height: min(780px, calc(var(--screen-height) - 140px));
    margin-right: calc(-1 * min(108px, var(--edge)));
    transition: width 0.35s ease, height 0.35s ease, margin-right 0.35s ease;
  }
  .chat.is-compact {
    width: var(--compact-width);
    height: min(700px, calc(var(--screen-height) - 140px));
    margin-right: max(0px, calc((100% - var(--compact-width)) / 2));
  }
  .results, .sheet { flex: 0 0 54%; border-left: 1px solid var(--line); }
  .sheet-open > .results { display: none; }
  .results { padding: 14px 16px; overflow-y: auto; overscroll-behavior: contain; }
  .cards { grid-template-columns: 1fr 1fr; }
  .card-photo { aspect-ratio: 1.15 / 1; }
  .card-title { font-size: 18px; }
  .card-price { font-size: 26px; }
  .card-data { font-size: 14px; white-space: normal; }
  .card-actions .button { padding: 7px 9px; font-size: 13px; }
  .chat:not(.is-compact) .send-button { width: auto; padding: 0 18px; border-radius: 999px; }
  .chat:not(.is-compact) .send-label { display: inline; }
  .page-scroll { display: none; }
}

/* ---------- Phones and tablets (under 980 px): like a messaging app ---------- */
@media (max-width: 979.98px) {
  html { min-height: 100%; }
  html.chat-open, html.chat-open body { overflow: hidden; }
  .layout { display: flex; flex-direction: column; }
  .chat-column { order: -1; height: 100vh; height: 100dvh; padding: 12px; }
  html:not(.chat-open) .chat-column { display: none; }
  .chat { width: 100%; height: 100%; border-radius: 20px; }
  .intro { padding: 28px 20px 96px; }
  .message { font-size: 14.5px; }
  .welcome-buttons { gap: 5px; flex-wrap: wrap; }
  .chip { padding: 6px 8px; font-size: 12px; }
  .results-item { list-style: none; }
  .results { width: 100%; }
  .cards { gap: 10px; }
  .card { display: grid; grid-template-columns: min(36%, 150px) minmax(0, 1fr); }
  .card-photo { height: 100%; min-height: 96px; max-height: 120px; aspect-ratio: auto; }
  .card-content { padding: 8px 10px; gap: 2px; }
  .card-title { font-size: 14px; -webkit-line-clamp: 1; }
  .card-price { font-size: 17px; }
  .card-data { font-size: 12px; }
  .card-actions { margin-top: 4px; }
  .card-actions .button, .pager .button { padding: 5px 10px; font-size: 12.5px; }
  .sheet { position: absolute; inset: 0; z-index: 2; }
  .composer { padding: 10px 12px 44px; align-items: center; }
  .composer textarea { height: 44px; padding: 9px 14px; font-size: 16px; line-height: 24px; }
  .send-button { width: 44px; height: 44px; }
}

@media (max-width: 559.98px) {
  .chat-column { padding: 0; }
  .chat { border-radius: 0; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  .chat { transition: none !important; }
  .launcher { animation: none; }
  .typing span { animation: none; opacity: 0.7; }
}
