/* Car helper (home page). Dark by default; light theme available. All sizes in rem. */

:root {
  --indigo: #6366f1;
  --purple: #a855f7;
  --indigo-soft: #818cf8;
  --purple-soft: #c084fc;
  --pink: #f472b6;

  --bg: #0a0c22;
  --panel: #15183c;
  --panel-glass: rgba(21, 24, 60, 0.74);
  --panel-line: rgba(129, 140, 248, 0.26);
  --inset: rgba(255, 255, 255, 0.05);
  --inset-line: rgba(255, 255, 255, 0.1);
  --text: #eef0ff;
  --muted: #b9bde6;
  --link: #c7cdff;
  --accent-text: #c4b5fd;
  --coral: #ff9b8e;
  --focus: #f0abfc;
  --assistant-bg: rgba(255, 255, 255, 0.06);
  --nav-bg: rgba(12, 14, 38, 0.78);
  --nav-bg-solid: #0e1030;
  --shadow: 0 1.25rem 3rem rgba(4, 5, 20, 0.45);
  --btn-bg: rgba(255, 255, 255, 0.08);
  --btn-bg-hover: rgba(255, 255, 255, 0.14);
  --glow-1: rgba(99, 102, 241, 0.55);
  --glow-2: rgba(168, 85, 247, 0.45);
  --glow-3: rgba(244, 114, 182, 0.32);

  --radius: 1.1rem;
  --font-head: "Space Grotesk", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --board-w: min(calc(100% - 3rem), clamp(56.25rem, 66vw, 83.75rem));
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f3f4ff;
  --panel: #ffffff;
  --panel-glass: rgba(255, 255, 255, 0.86);
  --panel-line: rgba(99, 102, 241, 0.22);
  --inset: rgba(79, 70, 229, 0.05);
  --inset-line: rgba(79, 70, 229, 0.14);
  --text: #191c3f;
  --muted: #464b78;
  --link: #4338ca;
  --accent-text: #5b21b6;
  --coral: #b4321f;
  --focus: #7e22ce;
  --assistant-bg: #f1f2ff;
  --nav-bg: rgba(255, 255, 255, 0.8);
  --nav-bg-solid: #ffffff;
  --shadow: 0 1rem 2.5rem rgba(49, 46, 129, 0.12);
  --btn-bg: rgba(79, 70, 229, 0.08);
  --btn-bg-hover: rgba(79, 70, 229, 0.15);
  --glow-1: rgba(99, 102, 241, 0.3);
  --glow-2: rgba(168, 85, 247, 0.24);
  --glow-3: rgba(244, 114, 182, 0.22);
  color-scheme: light;
}

html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-font-size="md"] { font-size: 112.5%; }
html[data-font-size="lg"] { font-size: 125%; }
html[data-font-size="xl"] { font-size: 140%; }

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(48rem 30rem at 12% -6%, var(--glow-1), transparent 70%),
    radial-gradient(40rem 28rem at 92% 4%, var(--glow-2), transparent 70%),
    radial-gradient(44rem 30rem at 60% 108%, var(--glow-3), transparent 70%);
  background-attachment: fixed;
  overflow-wrap: anywhere;
}

h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0; }
p { margin: 0; }
a { color: var(--link); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 0.18rem solid var(--focus); outline-offset: 0.15rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: 0.6rem 1rem; border-radius: 0.6rem; background: var(--panel); color: var(--text); }
.skip:focus { top: 1rem; }

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--nav-bg-solid);
  border-bottom: 1px solid var(--panel-line);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .nav { background: var(--nav-bg); -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%); }
}
.nav-row {
  width: min(calc(100% - 2rem), 100rem);
  margin: 0 auto;
  padding: 0.6rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem 1.25rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark {
  width: 2.1rem; height: 2.1rem; border-radius: 0.7rem; flex: none;
  background: linear-gradient(135deg, var(--indigo), var(--purple) 55%, var(--pink));
  box-shadow: 0 0.4rem 1.2rem rgba(99, 102, 241, 0.45);
  position: relative;
}
.brand-mark::after { content: ""; position: absolute; inset: 0.48rem; border-radius: 50%; border: 0.22rem solid #fff; }
.brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.brand-top { font-family: var(--font-head); font-weight: 700; font-size: 1rem; }
.brand-bottom { font-size: 0.8rem; color: var(--muted); }
.nav-links { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.nav-links a { padding: 0.4rem 0.8rem; border-radius: 999px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.92rem; }
.nav-links a:hover { background: var(--btn-bg); }
.nav-links a[aria-current="page"] { background: var(--btn-bg-hover); }
.nav-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem; }
.size-group { display: inline-flex; align-items: flex-end; gap: 0.15rem; padding: 0.2rem; border-radius: 999px; background: var(--btn-bg); }
.size-btn { border: 0; background: transparent; border-radius: 999px; min-width: 2rem; height: 2rem; padding: 0 0.35rem; cursor: pointer; font-family: var(--font-head); font-weight: 700; line-height: 1; color: var(--text); }
.size-btn.s1 { font-size: 0.78rem; }
.size-btn.s2 { font-size: 0.92rem; }
.size-btn.s3 { font-size: 1.06rem; }
.size-btn.s4 { font-size: 1.22rem; }
.size-btn[aria-pressed="true"] { background: linear-gradient(135deg, #4f46e5, #7e22ce); color: #fff; }
.theme-btn { display: inline-flex; align-items: center; gap: 0.35rem; border: 1px solid var(--panel-line); background: var(--btn-bg); border-radius: 999px; padding: 0.35rem 0.8rem; cursor: pointer; font-weight: 600; font-size: 0.9rem; min-height: 2.25rem; }
.theme-btn:hover { background: var(--btn-bg-hover); }

/* ---------- hero ---------- */
.hero {
  width: min(calc(100% - 2rem), 90rem);
  margin: 0 auto;
  padding: 1.1rem 0 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}
.chip {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: var(--btn-bg);
  border: 1px solid var(--panel-line);
}
.hero h1 { font-size: clamp(1.75rem, 1rem + 2vw, 2.75rem); font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
.grad {
  color: var(--accent-text);
  background: linear-gradient(90deg, var(--indigo-soft), var(--purple-soft) 55%, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
:root[data-theme="light"] .grad { background-image: linear-gradient(90deg, #4338ca, #7e22ce 55%, #be185d); }
.subline { max-width: 48rem; font-weight: 600; font-size: 1rem; color: var(--text); }
.hero-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.chip-link {
  display: inline-flex; align-items: center; min-height: 2.2rem;
  padding: 0.35rem 0.95rem; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 0.9rem;
  color: var(--text); background: var(--btn-bg); border: 1px solid var(--panel-line);
}
.chip-link:hover { background: var(--btn-bg-hover); }

/* ---------- board ---------- */
.board {
  width: var(--board-w);
  margin: 0 auto 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}
@media (max-width: 699.98px) {
  .board { width: min(calc(100% - 1.5rem), 40rem); }
}
@media (min-width: 700px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chat { grid-column: 1 / -1; grid-row: 1; }
  .top-card { grid-column: 1; grid-row: 2; }
  .short-card { grid-column: 2; grid-row: 2; }
  .details-card { grid-column: 3; grid-row: 2; }
}
@media (min-width: 1100px) {
  .board { grid-template-columns: 1.36fr 1.06fr 0.98fr 0.98fr; }
  .chat { grid-column: 1; grid-row: 1; }
  .top-card { grid-column: 2; grid-row: 1; }
  .short-card { grid-column: 3; grid-row: 1; }
  .details-card { grid-column: 4; grid-row: 1; }
}

.card {
  position: relative;
  min-width: 0;
  border-radius: var(--radius);
  border: 1px solid var(--panel-line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 1rem;
  overflow: hidden;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card { background: var(--panel-glass); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
}
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 0.2rem; }
.chat::before { background: linear-gradient(90deg, var(--indigo), var(--purple)); }
.top-card::before { background: linear-gradient(90deg, var(--purple), var(--pink)); }
.short-card::before { background: linear-gradient(90deg, var(--indigo-soft), var(--purple-soft)); }
.details-card::before { background: linear-gradient(90deg, var(--pink), var(--indigo)); }

.card h2 { font-size: 1.1rem; font-weight: 700; }

/* scroll boxes */
.scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--indigo-soft) transparent;
  min-height: 0;
}
.scroll::-webkit-scrollbar { width: 0.45rem; }
.scroll::-webkit-scrollbar-thumb { background: var(--indigo-soft); border-radius: 999px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll > * { flex: none; }

/* ---------- chat card ---------- */
.chat {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  height: clamp(24rem, 75svh, 36rem);
  container-type: inline-size;
  container-name: chat;
  scroll-margin-top: 5.5rem;
}
@media (min-width: 1100px) { .chat { height: clamp(22rem, calc(100svh - 21rem), 38rem); } }
.chat > * { flex: none; }
.chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.chat-titles { min-width: 0; flex: 1 1 6rem; }
.chat-sub { color: var(--muted); max-width: 100%; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-tools { display: flex; align-items: center; gap: 0.35rem; flex: none; }
.icon-btn, .pill-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  border: 1px solid var(--panel-line); background: var(--btn-bg); color: var(--text); cursor: pointer;
}
.icon-btn { width: 2.25rem; height: 2.25rem; border-radius: 50%; }
.pill-btn { height: 2.25rem; padding: 0 0.8rem; border-radius: 999px; font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.icon-btn:hover:not(:disabled), .pill-btn:hover { background: var(--btn-bg-hover); }
.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.count-chip { align-self: flex-start; font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.6rem; border-radius: 999px; background: var(--btn-bg); color: var(--muted); }

.log {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--indigo-soft) transparent;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.25rem 0.35rem 0.25rem 0.1rem;
  border-radius: 0.8rem;
}
.log::-webkit-scrollbar { width: 0.45rem; }
.log::-webkit-scrollbar-thumb { background: var(--indigo-soft); border-radius: 999px; }
.log > * { flex: none; }
.empty-hint { margin: auto 0; padding: 0.75rem 0.85rem; border-radius: 0.8rem; background: var(--inset); border: 1px dashed var(--inset-line); color: var(--muted); display: grid; gap: 0.35rem; font-size: 0.95rem; }
.empty-hint strong { color: var(--text); }

.msg { max-width: 92%; padding: 0.65rem 0.85rem; border-radius: 0.95rem; font-size: 0.95rem; line-height: 1.55; }
.msg p + p, .msg p + ul, .msg ul + p { margin-top: 0.5rem; }
.msg ul, .msg ol { margin: 0.4rem 0 0; padding-left: 1.2rem; text-align: left; }
.msg li + li { margin-top: 0.2rem; }
.msg.user { align-self: flex-end; color: #fff; background: linear-gradient(135deg, #4f46e5, #6d28d9); border-bottom-right-radius: 0.3rem; }
.msg.assistant { align-self: flex-start; background: var(--assistant-bg); border: 1px solid var(--inset-line); border-bottom-left-radius: 0.3rem; }
.msg .next-line { margin-top: 0.6rem; padding: 0.5rem 0.65rem; border-radius: 0.6rem; background: var(--inset); border-left: 0.2rem solid var(--purple-soft); }
.msg a { color: var(--link); }
.msg.error { align-self: stretch; max-width: none; color: var(--coral); background: transparent; border: 1px solid var(--coral); }

.thinking { display: flex; flex-direction: column; gap: 0.35rem; }
.dots { display: inline-flex; gap: 0.3rem; align-items: center; height: 1.2rem; }
.dots span { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--purple-soft); animation: pulse 1.2s ease-in-out infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
:root[data-theme="light"] .dots span { background: #7e22ce; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }
.wait-note { font-size: 0.85rem; color: var(--muted); }

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.45rem;
  align-items: end;
}
.composer textarea { grid-column: 1 / -1; }
.composer .mic-btn { grid-column: 2; justify-self: end; }
.composer .send-btn { grid-column: 3; }
@container chat (min-width: 18.5rem) {
  .composer textarea { grid-column: 1; }
}
@container chat (max-width: 22rem) {
  .pill-btn { width: 2.25rem; padding: 0; border-radius: 50%; }
  .pill-btn .full-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.composer textarea {
  width: 100%;
  min-width: 0;
  resize: none;
  min-height: 2.75rem;
  max-height: 9rem;
  overflow-y: hidden;
  padding: 0.62rem 0.85rem;
  border-radius: 1.4rem;
  border: 1px solid var(--panel-line);
  background: var(--inset);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}
.composer textarea::placeholder { color: var(--muted); opacity: 1; }
.composer textarea.is-scrolling { overflow-y: auto; }
.mic-btn { width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 1px solid var(--panel-line); background: var(--btn-bg); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--text); }
.mic-btn[hidden] { display: none; }
.mic-btn.is-on { background: linear-gradient(135deg, #be185d, #7e22ce); color: #fff; border-color: transparent; box-shadow: 0 0 0 0.25rem rgba(244, 114, 182, 0.3); }
.send-btn {
  height: 2.75rem; padding: 0 1.15rem; border: 0; border-radius: 999px; cursor: pointer;
  font-weight: 700; color: #fff; background: linear-gradient(135deg, #4f46e5, #7e22ce);
  white-space: nowrap;
}
.send-btn:disabled { opacity: 0.6; cursor: progress; }
.voice-status { font-size: 0.85rem; color: var(--muted); }
.error-line { font-size: 0.88rem; color: var(--coral); font-weight: 600; }
.chat-note { font-size: 0.78rem; color: var(--muted); }

/* full page overlay */
.chat.is-full {
  position: fixed;
  inset: 0;
  z-index: 60;
  height: auto !important;
  max-height: none !important;
  border-radius: 0;
  margin: 0;
  padding: calc(1rem + env(safe-area-inset-top, 0px)) calc(1rem + env(safe-area-inset-right, 0px)) calc(1rem + env(safe-area-inset-bottom, 0px)) calc(1rem + env(safe-area-inset-left, 0px));
  background: var(--panel);
}
.chat.is-full .log, .chat.is-full .composer, .chat.is-full .chat-head, .chat.is-full > p { width: min(100%, 60rem); margin-left: auto; margin-right: auto; }
.chat.is-full .count-chip { align-self: center; }
.chat-ghost { visibility: hidden; }

/* ---------- side cards ---------- */
.side { display: flex; flex-direction: column; gap: 0.5rem; }
.side > * { flex: none; }
.pill-label { align-self: flex-start; font-size: 0.78rem; font-weight: 700; padding: 0.2rem 0.65rem; border-radius: 999px; color: #fff; background: linear-gradient(90deg, #6d28d9, #be185d); }
.match-tile { border-radius: 0.9rem; padding: 0.9rem; color: #fff; background: linear-gradient(135deg, #4338ca, #7e22ce 55%, #be185d); display: grid; gap: 0.25rem; }
.tile-kind { font-size: 0.8rem; font-weight: 600; opacity: 0.95; }
.tile-title { font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.fit { display: flex; align-items: baseline; gap: 0.15rem; }
.fit-num { font-family: var(--font-head); font-size: 1.6rem; font-weight: 700; }
.fit-of { color: var(--muted); font-size: 0.85rem; }
.why-box { flex: 0 1 auto; font-size: 0.92rem; color: var(--text); padding-right: 0.25rem; }

.side-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.gauge { position: relative; width: 3.5rem; height: 3.5rem; flex: none; }
.gauge svg { width: 100%; height: 100%; }
.gauge-track { stroke: var(--inset-line); }
.gauge-fill { stroke: var(--purple-soft); stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
:root[data-theme="light"] .gauge-fill { stroke: #7e22ce; }
.gauge-num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 0.95rem; }
.side-note, .side-empty { font-size: 0.85rem; color: var(--muted); }
.short-list { list-style: none; margin: 0; padding: 0 0.25rem 0 0; display: flex; flex-direction: column; gap: 0.4rem; flex: 0 1 auto; }
.short-list:empty { display: none; }
.short-list li { flex: none; }
.short-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; text-align: left;
  padding: 0.55rem 0.7rem; border-radius: 0.7rem; border: 1px solid var(--inset-line); background: var(--inset); cursor: pointer; color: var(--text);
}
.short-item:hover { background: var(--btn-bg-hover); }
.short-item[aria-current="true"] { border-color: var(--purple-soft); box-shadow: inset 0 0 0 1px var(--purple-soft); }
.short-title { font-weight: 600; font-size: 0.9rem; min-width: 0; }
.short-score { flex: none; font-family: var(--font-head); font-weight: 700; font-size: 0.85rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--btn-bg-hover); }

.details-name { font-family: var(--font-head); font-weight: 600; font-size: 1rem; }
.fields { margin: 0; display: flex; flex-direction: column; gap: 0.4rem; flex: 0 1 auto; padding-right: 0.25rem; }
.fields:empty { display: none; }
.field { flex: none; padding: 0.45rem 0.6rem; border-radius: 0.6rem; background: var(--inset); border: 1px solid var(--inset-line); }
.field dt { font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.field dd { margin: 0; font-size: 0.9rem; }
.guide-link { font-weight: 600; font-size: 0.9rem; }
.guide-link[hidden] { display: none; }
.next-step { flex: none; padding: 0.6rem 0.7rem; border-radius: 0.8rem; background: var(--inset); border: 1px solid var(--panel-line); }
.next-step h3 { font-size: 0.9rem; margin-bottom: 0.25rem; color: var(--accent-text); }
.next-step p { font-size: 0.88rem; line-height: 1.45; }

/* ---------- footer ---------- */
.foot { width: var(--board-w); margin: 0 auto; padding: 0.5rem 0 calc(1.5rem + env(safe-area-inset-bottom, 0px)); text-align: center; color: var(--muted); font-size: 0.85rem; display: grid; gap: 0.25rem; }
@media (max-width: 699.98px) { .foot { width: min(calc(100% - 1.5rem), 40rem); } }

/* ---------- phones: centered text, lists stay left ---------- */
@media (max-width: 699.98px) {
  .card h2, .chat-titles, .side-note, .side-empty, .details-name, .next-step, .chat-note, .voice-status, .error-line, .fit, .side-head { text-align: center; }
  .fit, .side-head { justify-content: center; }
  .chat-head { justify-content: center; }
  .chat-sub { white-space: normal; }
  .count-chip, .pill-label { align-self: center; }
  .match-tile { text-align: center; }
  .msg ul, .msg ol, .short-list, .fields { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .dots span { animation: none; opacity: 1; transform: none; }
  .gauge-fill { transition: none; }
  * { scroll-behavior: auto !important; }
}
