:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #d8dde3;
  --text: #1f2933;
  --muted: #5c6873;
  --accent: #2c5f9f;
  --accent-hover: #1f4877;
  --success: #1f7a4d;
  --warning: #b35900;
  --error: #b3261e;
  --bubble-user: #d9e8f6;
  --bubble-assistant: #ffffff;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  letter-spacing: 0.02em;
  color: var(--text);
}
header nav { display: flex; gap: 1rem; align-items: center; font-size: 0.9rem; color: var(--muted); }

main { max-width: 900px; margin: 1.5rem auto; padding: 0 1.25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--card-shadow);
}
.card h1 { margin-top: 0; }

label { display: block; margin-bottom: 0.85rem; font-weight: 500; }
label input, label textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}
label textarea { resize: vertical; min-height: 7rem; font-family: inherit; }
label input:focus, label textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button, .btn {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 0.55rem 1.1rem;
  border-radius: 4px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 400; }

.error { color: var(--error); padding: 0.5rem 0.75rem; background: #fbe9e7; border-left: 3px solid var(--error); border-radius: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table th, table td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--border); }
table th { color: var(--muted); font-weight: 500; }
table code { background: #eef2f6; padding: 0.1rem 0.35rem; border-radius: 3px; font-size: 0.95em; }

.created {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #e8f4ec;
  border-left: 3px solid var(--success);
  border-radius: 2px;
}
.created p { margin: 0 0 0.5rem 0; }
.copy-row { display: flex; gap: 0.4rem; align-items: stretch; }
.copy-row input { flex: 1; padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 4px; font-family: monospace; font-size: 0.9rem; }

/* ---------- chat ---------- */

.chat { display: flex; flex-direction: column; gap: 1rem; }
.chat h1 { font-size: 1.4rem; margin: 0 0 0.5rem 0; }

#messages { display: flex; flex-direction: column; gap: 1rem; }

.turn { display: flex; flex-direction: column; gap: 0.75rem; }
.turn.user { align-items: flex-end; }
.turn.assistant { align-items: flex-start; }

.bubble {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bubble-assistant);
  box-shadow: var(--card-shadow);
}
.turn.user .bubble {
  background: var(--bubble-user);
  border-color: #b9d3eb;
  border-bottom-right-radius: 3px;
}
.turn.assistant .bubble { border-bottom-left-radius: 3px; }
.bubble p:first-child { margin-top: 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0.4rem 0; padding-left: 1.4rem; }
.bubble strong { font-weight: 600; }
.bubble code { background: #eef2f6; padding: 0.05rem 0.3rem; border-radius: 3px; font-size: 0.92em; }
.bubble hr { border: 0; border-top: 1px solid var(--border); margin: 0.75rem 0; }
.bubble table {
  width: 100%;
  margin: 0.5rem 0;
  border-collapse: collapse;
  font-size: 0.92em;
}
.bubble th, .bubble td {
  border: 1px solid var(--border);
  padding: 0.3rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
.bubble th { background: #eef2f6; font-weight: 600; }

.cards {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}

.vehicle-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  color: inherit;
  transition: box-shadow 0.08s ease;
}
.vehicle-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); }
.vc-image-link, .vc-title-link {
  text-decoration: none;
  color: inherit;
  display: block;
}
.vc-title-link:hover { color: var(--accent-hover); }
.vehicle-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: #e6e9ed;
  display: block;
}
.image-placeholder {
  height: 160px;
  background: #e6e9ed;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.vc-body { padding: 0.75rem 0.9rem 0.9rem; display: flex; flex-direction: column; gap: 0.4rem; }
.vc-body h3 { margin: 0; font-size: 1rem; line-height: 1.3; }
.vc-price {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.vc-price-change {
  font-size: 0.78rem;
  color: var(--success);
  font-weight: 500;
}
.vc-specs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.55rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.vc-specs li { white-space: nowrap; }
.vc-specs li + li::before { content: "•"; margin-right: 0.55rem; color: var(--border); }
.vc-tow { margin: 0; font-size: 0.82rem; color: var(--muted); }
.vc-warning {
  margin: 0;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  background: #fff5e6;
  color: var(--warning);
  border-radius: 3px;
  border-left: 2px solid var(--warning);
}
.vc-dealer { margin: 0; font-size: 0.8rem; color: var(--muted); font-style: italic; }
.vc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.reactions {
  display: flex;
  gap: 0.25rem;
}
.reaction-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  font-size: 1rem;
  line-height: 1.2;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.reaction-btn:hover { opacity: 1; }
.reaction-btn.active {
  opacity: 1;
}
.reaction-up.active {
  background: #e3f3e8;
  border-color: var(--success);
}
.reaction-down.active {
  background: #fbe6e3;
  border-color: var(--error);
}

/* ---------- compose form ---------- */

#msg-form {
  display: flex;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
#msg-form input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}
#thinking {
  padding: 0.5rem 1rem;
  background: #eef2f6;
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* HTMX indicator: only visible during in-flight request */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }
