/* CarGPT customer chat — ChatGPT-style layout. Light/dark follow the device unless the user picks one. */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; background: var(--bg); color: var(--ink); display: flex; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }

/* ---------- sidebar ---------- */
#side { width: 260px; flex: none; background: var(--side); display: flex; flex-direction: column; padding: 10px; gap: 6px; height: 100%; }
.brand { display: flex; align-items: center; gap: 8px; padding: 6px 8px 10px; font-weight: 700; font-size: 17px; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 15px; font-weight: 800; flex: none; }
.side-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 14px; text-decoration: none; color: var(--ink); }
.side-btn:hover { background: var(--hover); }
#history { flex: 1; overflow-y: auto; margin-top: 6px; }
.hgroup { font-size: 12px; color: var(--muted); padding: 12px 10px 4px; font-weight: 600; }
.hitem { display: flex; align-items: center; border-radius: 8px; }
.hitem:hover, .hitem.active { background: var(--hover); }
.hitem button.open { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 8px 10px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hitem button.del { border: 0; background: none; color: var(--muted); padding: 6px 8px; visibility: hidden; font-size: 13px; }
.hitem:hover button.del, .hitem.active button.del { visibility: visible; }
.side-foot { border-top: 1px solid var(--line); padding-top: 8px; }
.side-btn.wa { color: #1a8f4d; font-weight: 600; }
.side-note { font-size: 11px; color: var(--muted); padding: 4px 10px; }

/* ---------- main column ---------- */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; position: relative; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 52px; }
.topbar .title { font-weight: 600; font-size: 17px; }
.icon-btn { border: 0; background: transparent; width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; font-size: 18px; }
.icon-btn:hover { background: var(--hover); }
#menuBtn { display: none; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); white-space: nowrap; }
.spacer { flex: 1; }

#scroll { flex: 1; overflow-y: auto; }
.col { max-width: 760px; margin: 0 auto; padding: 0 16px; }
#log { display: flex; flex-direction: column; gap: 22px; padding: 12px 0 24px; }

/* start screen */
#hero { text-align: center; padding: 12vh 0 18px; }
#hero h1 { font-size: clamp(24px, 5.5vw, 32px); line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.01em; }
#hero p { color: var(--muted); margin: 0 auto; max-width: 460px; font-size: 15px; }
.examples { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 0; }
.chip { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.chip:hover { background: var(--hover); }
.chip b { font-size: 14px; font-weight: 600; }
.chip span { font-size: 13px; color: var(--muted); }
.chip b, .chip span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { .examples { grid-template-columns: 1fr 1fr; } }
body.chatting #hero, body.chatting .examples { display: none; }

/* messages */
.m-user { align-self: flex-end; max-width: 80%; background: var(--user-bubble); padding: 10px 16px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.m-user .atts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.m-user .atts img { width: 120px; height: 90px; object-fit: cover; border-radius: 10px; display: block; }
.m-ai { display: flex; gap: 12px; align-items: flex-start; }
.m-ai .logo { margin-top: 2px; }
.m-ai .body { flex: 1; min-width: 0; }
.m-ai .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.m-ai .status { color: var(--muted); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.dots::after { content: "●●●"; letter-spacing: 2px; font-size: 9px; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.caret::after { content: "▍"; animation: blink 1s infinite; color: var(--muted); }
.actions { display: flex; gap: 2px; margin-top: 6px; }
.actions button { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 4px 8px; border-radius: 6px; }
.actions button:hover { background: var(--hover); color: var(--ink); }
.att-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }

/* price cards */
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-top: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 2px; font-size: 15px; line-height: 1.3; }
.card .sub { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.card .row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 2px 0; }
.card .row span:last-child { white-space: nowrap; }
.card .row.hl { color: var(--accent); font-weight: 600; }
.card .total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 700; font-size: 16px; }
.card .cstatus { font-size: 12px; color: var(--warn); margin-bottom: 6px; }
.btn { border: 0; border-radius: 10px; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.card .btn { margin-top: 10px; width: 100%; }
.notice { margin-top: 12px; background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.followup { margin-top: 12px; }

/* ---------- composer ---------- */
.composer-wrap { padding: 0 0 14px; }
body.chatting .composer-wrap { background: linear-gradient(transparent, var(--bg) 24%); padding-top: 8px; }
form.composer { background: var(--panel); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); padding: 8px; }
form.composer:focus-within { border-color: var(--muted); }
form.composer.drag { border-color: var(--accent); border-style: dashed; }
#attList { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 6px 8px; }
#attList:empty { display: none; }
.att { position: relative; }
.att img { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; display: block; border: 1px solid var(--line); }
.att .file { height: 58px; display: flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); font-size: 12px; line-height: 20px; padding: 0; }
textarea#text { width: 100%; border: 0; background: transparent; color: var(--ink); resize: none; font: inherit; padding: 6px 10px; max-height: 200px; outline: none; display: block; }
.tools { display: flex; align-items: center; gap: 4px; }
.tools select { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 6px 4px; border-radius: 8px; }
.round { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: transparent; display: grid; place-items: center; font-size: 17px; flex: none; }
.round:hover { background: var(--hover); }
.round.send { background: var(--ink); color: var(--bg); border: 0; }
.round.send:disabled { opacity: .3; cursor: default; }
.round.live { background: var(--bad); color: #fff; border-color: var(--bad); animation: blink 1s infinite; }
.fine { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- dialog ---------- */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--ink); max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin-top: 0; }
dialog label { display: block; font-size: 13px; margin: 10px 0 4px; color: var(--muted); }
dialog input, dialog select, dialog textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); width: 100%; }
dialog .consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink); }
dialog .consent input { width: auto; margin-top: 3px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 6px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 14px; z-index: 50; }

/* ---------- phones ---------- */
#scrim { display: none; }
@media (max-width: 768px) {
  #side { position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; }
  body.side-open #side { box-shadow: var(--shadow); }
  body.side-open #side { transform: none; }
  body.side-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
  #menuBtn { display: grid; }
  .m-user { max-width: 88%; }
  .m-ai .logo { display: none; }
  #hero { padding-top: 8vh; }
}

/* start screen: heading + search box + examples centred together, like ChatGPT's empty chat */
body:not(.chatting) #main { justify-content: center; }
body:not(.chatting) .topbar { position: absolute; top: 0; left: 0; right: 0; }
body:not(.chatting) #scroll { flex: none; overflow: visible; }
body:not(.chatting) #hero { padding: 0 0 22px; }
body:not(.chatting) .fine { position: absolute; bottom: 12px; left: 0; right: 0; padding: 0 16px; }

/* ---------- EKX brand: Ivory & Ink ---------- */
.wordmark { display: inline-block; height: 22px; aspect-ratio: 1270 / 556; background: var(--ink);
  -webkit-mask: url(/ekx-wordmark.png) center / contain no-repeat; mask: url(/ekx-wordmark.png) center / contain no-repeat; }
.brand { padding: 10px 10px 16px; }
.brand .wordmark { height: 26px; }
.topbar .wordmark { display: none; }
@media (max-width: 768px) { .topbar .wordmark { display: inline-block; } }
/* dealer logo (co-branding) in the sidebar and, on phones, the top bar */
.brand .dealer-brand { --logo-h: 44px; }
.topbar .dealer-brand { display: none; --logo-h: 32px; gap: 2px; }
@media (max-width: 768px) { .topbar .dealer-brand { display: inline-flex; } }
.brand .powered .wordmark, .topbar .powered .wordmark { height: 10px; }
.logo { background: var(--ink); color: var(--bg); border-radius: 50%; font-family: var(--serif); font-weight: 600; font-size: 16px; line-height: 1; }
#hero h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 7vw, 44px); letter-spacing: -0.015em; line-height: 1.1; }
#hero p { font-size: 15px; }
.card { border-radius: 12px; }
.card h3 { font-family: var(--serif); font-weight: 600; font-size: 17px; letter-spacing: -0.005em; }
.card .row.hl { color: var(--ink); font-weight: 700; }
.card .total { font-size: 17px; }
.btn { border-radius: 10px; letter-spacing: .01em; }
.btn.ghost { color: var(--ink); border-color: var(--ink); }
.side-btn.wa { color: var(--ink); font-weight: 500; }
.chip { border-radius: 12px; }
.chip b { font-weight: 600; }
.badge { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.side-note { letter-spacing: .02em; }
.hgroup { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
.side-btn svg { flex: none; }
.round svg, .icon-btn svg { display: block; }
.round.live svg { animation: none; }
.att-chip { font-size: 12px; }
.brand { flex-direction: column; align-items: flex-start; gap: 4px; }
.brand .dealer { font-size: 12px; color: var(--muted); letter-spacing: .04em; }

/* viewing booking */
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.pick { display: grid; gap: 6px; }
.pick .consent { margin: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card .where { font-size: 12px; color: var(--muted); margin-top: 2px; }
.btn.wa-btn { display: inline-block; margin-top: 12px; text-decoration: none; }

/* car photos on price cards */
.card { padding: 0 0 14px; overflow: hidden; }
.card > *:not(.gallery) { margin-left: 14px; margin-right: 14px; }
.card > h3 { margin-top: 12px; }
.card > .btn { width: calc(100% - 28px); }
.gallery { position: relative; aspect-ratio: 4 / 3; background: var(--side); }
.gallery .strip { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; height: 100%; scrollbar-width: none; }
.gallery .strip::-webkit-scrollbar { display: none; }
.gallery .strip img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: start; cursor: zoom-in; }
.gallery .count { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 99px; }
.ph-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 10px;
  background: repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--line) 45%, transparent) 14px 15px); }
.ph-name { font-family: var(--serif); font-size: 22px; font-weight: 500; }
.ph-note { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
#viewer { padding: 0; border: 0; background: #000; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; margin: 0; }
#viewer::backdrop { background: #000; }
#viewer img { width: 100%; height: calc(100% - 56px); object-fit: contain; display: block; }
#viewer .vbar { height: 56px; display: flex; align-items: center; justify-content: center; gap: 18px; color: #fff; }
#viewer button { background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 99px; width: 40px; height: 40px; font-size: 20px; }
#viewer .vclose { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,.5); }

/* specs, documents, share */
.card details.specs { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.card details.specs summary { cursor: pointer; font-size: 14px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.card details.specs summary::after { content: "+"; color: var(--muted); }
.card details.specs[open] summary::after { content: "–"; }
.card details.specs summary::-webkit-details-marker { display: none; }
.spec-line { font-size: 13px; margin-top: 6px; }
.fchips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.fchip { font-size: 12px; border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; }
.cond { font-size: 13px; color: var(--muted); margin-top: 8px; }
.docs { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; font-size: 14px; }
.docs a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; padding: 3px 0; }
.card .docs { border-top: 1px solid var(--line); padding-top: 8px; }
.doc-reply { margin-top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.doc-head { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.doc-car { font-size: 13px; font-weight: 600; margin-top: 8px; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.card-actions .btn { flex: 1; margin-top: 0; width: auto; }
.card-actions .btn.share { flex: 0 0 auto; padding: 8px 16px; }
.fine a, .side-note a, .consentLine a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- start screen car stage: blueprint cars drawn in Ivory & Ink, one after another (public/media/hero-car.mp4) ----------
   Sits between the heading and the search box, so the car's ground line runs just above the box.
   The clip is 3:2; the stage shows a 2:1 band of it (the cars sit in the middle).
   Blending: light mode keeps the darker of clip and page (the ivory paper vanishes, the pencil stays); dark mode inverts
   the clip and keeps the lighter. Nothing on the way up to the page may create a stacking context (no transform), or the blend stops. */
.stage { --w: min(100%, 72vh); position: relative; width: var(--w); margin: 6px 0 0 calc(50% - var(--w) / 2); aspect-ratio: 2 / 1; pointer-events: none; }
#heroBg { opacity: 0; } /* hidden until it is really playing; the still picture #heroStill shows meanwhile */
#heroBg.on { opacity: 1; }
#heroStill, #heroBg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; mix-blend-mode: darken;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
@media (max-width: 600px) { .stage { --w: min(100vw, 72vh); } } /* phones: edge to edge */
/* short phones (iPhone SE and similar): drop the subtitle and put the examples in one sliding row, so everything still fits */
@media (max-width: 600px) and (max-height: 760px) {
  body:not(.chatting) #hero p { display: none; }
  body:not(.chatting) #hero { padding-bottom: 12px; }
  .examples { display: flex; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
  .examples::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
}
:root[data-theme="dark"] #heroBg, :root[data-theme="dark"] #heroStill { filter: invert(1); mix-blend-mode: lighten; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #heroBg, :root:not([data-theme="light"]) #heroStill { filter: invert(1); mix-blend-mode: lighten; } }
