:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #15181e;
  --muted: #5d6573;
  --border: #e1e4ea;
  --accent: #2f5bea;
  --accent-soft: #e6ecfd;
  --accent-ink: #ffffff;
  --good: #0d8a5c;
  --warn: #b45309;
  --c1: #2f5bea;
  --c2: #e07b00;
  --c3: #0d9a6a;
  --c4: #d43f8d;
  --c5: #7a4fd6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a21; --surface-2: #20242d; --text: #eceef2; --muted: #9aa3b2;
    --border: #2a2f3a; --accent: #6f8fff; --accent-soft: #1f2a4d; --accent-ink: #0b0d12;
    --good: #3ccf91; --warn: #f0a24a;
    --c1: #6f8fff; --c2: #ffa53d; --c3: #3ccf91; --c4: #ff6fb5; --c5: #b08cff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a21; --surface-2: #20242d; --text: #eceef2; --muted: #9aa3b2;
  --border: #2a2f3a; --accent: #6f8fff; --accent-soft: #1f2a4d; --accent-ink: #0b0d12;
  --good: #3ccf91; --warn: #f0a24a;
  --c1: #6f8fff; --c2: #ffa53d; --c3: #3ccf91; --c4: #ff6fb5; --c5: #b08cff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, Heebo, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.units { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.units button { border: 0; background: none; padding: 4px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.units button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* buttons */
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 10px 18px; font-weight: 600; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.lg { padding: 14px 24px; font-size: 16px; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .opt:focus-visible, .seg button:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* intro */
.hero { padding: 56px 0 32px; max-width: 720px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; color: var(--accent); margin: 0 0 8px; }
.hero h1 { font-size: clamp(30px, 5vw, 44px); }
.lede { font-size: 17px; color: var(--muted); margin: 16px 0 28px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 40px; }
.panel h2 { font-size: 18px; margin-bottom: 12px; }
.qlist { margin: 0; padding-inline-start: 22px; display: grid; gap: 10px; }
.qlist li span { display: block; color: var(--muted); font-size: 13px; }

/* quiz */
.quiz { max-width: 760px; margin: 0 auto; padding: 32px 0 48px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent); transition: width .25s ease; }
.stepcount { color: var(--muted); font-size: 13px; margin: 16px 0 6px; }
.quiz h1 { font-size: clamp(24px, 4vw, 32px); }
.help { color: var(--muted); margin: 8px 0 0; }
.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 24px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: start;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px;
  transition: border-color .15s, background .15s;
}
.opt:hover { border-color: var(--muted); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt-icon { font-size: 24px; width: 32px; text-align: center; flex: none; }
.opt-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.opt-label { font-weight: 600; }
.opt-desc { color: var(--muted); font-size: 13px; }
.tick { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border); flex: none; }
.opt[aria-pressed="true"] .tick { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--accent-soft); }
.quiz-nav { display: flex; justify-content: space-between; margin-top: 32px; }

.range-wrap { margin-top: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.big-value { display: block; font-size: 40px; font-weight: 700; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.chip.static { background: var(--surface-2); border-color: transparent; }

.prio { margin-top: 24px; display: grid; gap: 10px; }
.prio-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; flex-wrap: wrap; }
.prio-text { display: flex; flex-direction: column; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; width: 36px; height: 32px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* results */
.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 32px 0 20px; }
.results-head h1 { font-size: clamp(26px, 4vw, 36px); }
.head-actions { display: flex; gap: 8px; }
.section-title { font-size: 20px; margin: 40px 0 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--series);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.card-top { display: flex; justify-content: space-between; align-items: center; }
.rank { font-weight: 700; color: var(--series); font-size: 14px; }
.icon-btn { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.card h3 { font-size: 17px; margin-top: 6px; }
.card .muted.small { margin: 4px 0 10px; }
.price { font-size: 13px; color: var(--muted); }
.price strong { font-size: 18px; color: var(--text); }
.match { display: flex; align-items: center; gap: 8px; margin: 10px 0 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.match-bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.match-bar div { height: 100%; background: var(--series); border-radius: 999px; }
.why { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13px; }
.why li { padding-inline-start: 20px; position: relative; }
.why .pro::before { content: "✓"; position: absolute; inset-inline-start: 0; color: var(--good); font-weight: 700; }
.why .con::before { content: "!"; position: absolute; inset-inline-start: 4px; color: var(--warn); font-weight: 700; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.badge { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--series); border-radius: 12px; padding: 12px 14px; }
.badge-icon { font-size: 22px; }
.badge div { display: flex; flex-direction: column; min-width: 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.cmp { width: 100%; border-collapse: collapse; min-width: 760px; font-size: 14px; }
.cmp th, .cmp td { padding: 10px 14px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--border); }
.cmp thead th { position: sticky; top: 0; background: var(--surface); font-size: 14px; }
.cmp thead th .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--series); margin-inline-end: 6px; }
.cmp tbody th { color: var(--muted); font-weight: 500; white-space: nowrap; width: 150px; }
.cmp tr.group th { background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 8px 14px; }
.cmp td.best { font-weight: 700; color: var(--good); }
.cmp td.best::after { content: " ★"; font-size: 11px; }
.mini { margin: 0; padding-inline-start: 16px; font-size: 13px; }
.mini li { margin-bottom: 2px; }

.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.chart { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.chart figcaption { font-weight: 700; margin-bottom: 12px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar div { height: 100%; background: var(--series); border-radius: 999px; }
.bar-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.others { display: grid; gap: 8px; margin-bottom: 40px; }
.other { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.other > div { display: flex; flex-direction: column; min-width: 0; }
.score-pill { font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); padding: 3px 10px; border-radius: 999px; white-space: nowrap; }

.footer { color: var(--muted); font-size: 12px; padding-top: 16px; padding-bottom: 32px; border-top: 1px solid var(--border); margin-top: 24px; }

@media (max-width: 560px) {
  .options { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 84px 1fr auto; }
  .other { grid-template-columns: 1fr auto; }
  .other .score-pill { display: none; }
  .seg button { width: 32px; }
}

/* Hebrew */
:lang(he) body, body:lang(he) { font-family: Heebo, Inter, system-ui, sans-serif; }
[dir="rtl"] .eyebrow { letter-spacing: 0; }
[dir="rtl"] .cmp tr.group th { letter-spacing: 0; }

/* Ask AI */
.ask-btn { margin-top: auto; align-self: flex-start; }
.card .why { margin-bottom: 14px; }
.ask { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 20px 16px; margin-top: 40px; }
.ask-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ask .section-title { margin: 16px 0 6px; }
.ask > .muted { margin: 0 0 14px; }
.ask-about { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
.ask-about select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; max-width: 100%; }
.suggest { margin: 0 0 14px; }
.suggest .chip { text-align: start; }
.chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 460px; overflow-y: auto; padding: 4px 2px 12px; margin-bottom: 12px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-end-end-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-end-start-radius: 4px; }
.msg.error { color: var(--warn); }
.msg p { margin: 0 0 8px; }
.msg p:last-child, .msg ul:last-child { margin-bottom: 0; }
.msg ul { margin: 0 0 8px; padding-inline-start: 20px; }
.typing { color: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form textarea { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; resize: vertical; min-height: 46px; }
.chat-form textarea:focus-visible, .ask-about select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ask .small.muted { margin: 10px 0 0; }
@media (prefers-reduced-motion: reduce) { .typing { animation: none; } }

/* Model year */
.year-pick { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.year-pick select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; }
.year-pick select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.year-note { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.gen-warn { color: var(--warn); }
