:root {
  --bg: #090D16;
  --bg-2: #0F172A;
  --panel: #1E293B;
  --panel-2: #172033;
  --navy: #1E40AF;
  --accent: #3B82F6;
  --accent-soft: rgba(59, 130, 246, .14);
  --text: #E5EAF3;
  --muted: #93A1B8;
  --line: rgba(148, 163, 184, .16);
  --good: #34D399;
  --warn: #FBBF24;
  --bad: #F87171;
  --radius: 16px;
  --sidebar-w: 280px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden;
}
body.lock { overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-fill { width: 20px; height: 20px; flex: none; }

/* ---------- Layout ---------- */
.app { display: flex; height: 100dvh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px; gap: 12px; z-index: 30;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }

.btn-new {
  -webkit-appearance: none; appearance: none; box-sizing: border-box;
  display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 5px 14px 5px 5px; border-radius: 14px; color: #CFE0FF; font-weight: 600; font-size: 14px;
  background: linear-gradient(160deg, rgba(59, 130, 246, .16), rgba(59, 130, 246, .05)); border: 1px solid rgba(96, 165, 250, .30);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); box-shadow: 0 0 22px rgba(59, 130, 246, .12);
  transition: background .2s, border-color .2s, box-shadow .2s, transform .1s;
}
.btn-new .ic { width: 32px; height: 32px; flex: none; padding: 8px; border-radius: 10px; color: #9CC2FF; stroke-width: 2;
  background: linear-gradient(160deg, rgba(59, 130, 246, .30), rgba(59, 130, 246, .10)); border: 1px solid rgba(96, 165, 250, .45); box-shadow: 0 0 14px rgba(59, 130, 246, .20); }
.btn-new:hover { background: linear-gradient(160deg, rgba(59, 130, 246, .26), rgba(59, 130, 246, .09)); border-color: rgba(96, 165, 250, .5); box-shadow: 0 0 26px rgba(59, 130, 246, .22); }
.btn-new:active { transform: scale(.98); }
.btn-new:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.side-scroll { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.side-scroll h3 { margin: 18px 6px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list li.empty { color: var(--muted); font-size: 13px; padding: 6px 8px; opacity: .8; }
.side-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 8px; border-radius: 10px;
  background: transparent; border: 0; color: var(--text); font-size: 14px;
}
.side-item:hover, .side-item.active { background: var(--panel); }
.side-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .ic { width: 16px; height: 16px; color: var(--muted); }
.side-item .del { opacity: .55; border: 0; background: none; padding: 2px; border-radius: 6px; color: var(--muted); display: grid; }
.side-item:hover .del, .side-item:focus-within .del { opacity: 1; }
.side-item .del .ic { width: 15px; height: 15px; }
.side-item .del:focus-visible { outline: 2px solid var(--accent, #3b82f6); }
.side-item .del:hover { color: var(--bad); }
.fav-sub { color: var(--muted); font-size: 12px; }
.settings-btn {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; font-weight: 500; transition: background .2s;
}
.settings-btn:hover { background: var(--panel); }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; gap: 12px; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.logo em, .hero h1 em { font-style: normal; color: var(--accent); }
.logo-ic { color: var(--accent); }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 12px; width: 40px; height: 40px; display: grid; place-items: center; color: var(--text); transition: background .2s; }
.icon-btn:hover { background: var(--panel); }
.profile-btn { border-color: var(--line); background: var(--bg-2); }
/* Compte connecté : carré « verre » avec l'initiale, centrée */
.profile-btn.logged { -webkit-appearance: none; appearance: none; box-sizing: border-box; flex: none; width: 44px; height: 44px; min-width: 44px; padding: 0; display: grid; place-items: center;
  border-radius: 14px; font-size: 17px; font-weight: 700; line-height: 1; color: #9CC2FF; text-align: center;
  background: linear-gradient(160deg, rgba(59, 130, 246, .30), rgba(59, 130, 246, .10)); border: 1px solid rgba(96, 165, 250, .45);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); box-shadow: 0 0 22px rgba(59, 130, 246, .18); transition: background .2s, border-color .2s, box-shadow .2s; }
.profile-btn.logged:hover { background: linear-gradient(160deg, rgba(59, 130, 246, .40), rgba(59, 130, 246, .16)); border-color: rgba(96, 165, 250, .65); box-shadow: 0 0 26px rgba(59, 130, 246, .28); }
.burger { display: none; }
.topbar .profile-btn { margin-left: auto; }
.side-logo { padding: 4px 6px 2px; font-size: 19px; }
.top-logo { display: none; }

/* ---------- Chat ---------- */
.chat { flex: 1; overflow-y: auto; padding: 0 18px 12px; scroll-behavior: smooth; }
.hero { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 22px; padding: 20px 0 80px; }
.has-chat .hero { display: none; }
.hero-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hero h1 { margin: 0; font-size: clamp(34px, 6vw, 56px); letter-spacing: -.03em; font-weight: 700; }
.hero-text { max-width: 620px; margin: 0; color: var(--muted); font-size: clamp(15px, 2vw, 18px); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 760px; }
.chip { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13.5px; color: var(--text); transition: border-color .2s, background .2s; }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }

.messages { max-width: 1060px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; padding: 10px 0 24px; }
.msg { display: flex; flex-direction: column; gap: 14px; animation: rise .35s ease both; }
.msg.user { align-items: flex-end; }
.bubble { max-width: min(720px, 92%); padding: 11px 16px; border-radius: 18px; word-wrap: break-word; }
.msg.user .bubble { background: var(--navy); border-bottom-right-radius: 6px; white-space: pre-wrap; }
/* Boutons sous le message de l'utilisateur : modifier (crayon) / recommencer (flèche) */
.msg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: -6px; }
.act { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: #9CC2FF; cursor: pointer;
  background: linear-gradient(160deg, rgba(59, 130, 246, .16), rgba(59, 130, 246, .05)); border: 1px solid rgba(96, 165, 250, .30);
  transition: background .2s, border-color .2s, box-shadow .2s, transform .1s; }
.act .ic { width: 17px; height: 17px; stroke-width: 2; }
.act:hover { background: linear-gradient(160deg, rgba(59, 130, 246, .30), rgba(59, 130, 246, .10)); border-color: rgba(96, 165, 250, .55); box-shadow: 0 0 16px rgba(59, 130, 246, .22); }
.act:active { transform: scale(.94); }
.act:focus-visible, .edit-send:focus-visible, .edit-cancel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.edit-box { width: min(720px, 100%); display: grid; gap: 10px; }
.edit-area { width: 100%; box-sizing: border-box; min-height: 84px; resize: none; padding: 12px 14px; border-radius: 16px; font: inherit; font-size: 16px; line-height: 1.45; color: var(--text);
  background: rgba(15, 22, 38, .85); border: 1px solid rgba(96, 165, 250, .45); outline: 0; }
.edit-area:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 130, 246, .2); }
.edit-row { display: flex; gap: 8px; justify-content: flex-end; }
.edit-cancel, .edit-send { height: 38px; padding: 0 16px; border-radius: 12px; font-weight: 600; font-size: 14px; cursor: pointer; }
.edit-cancel { color: #CFE0FF; background: transparent; border: 1px solid rgba(96, 165, 250, .30); }
.edit-cancel:hover { background: rgba(59, 130, 246, .12); }
.edit-send { color: #fff; background: var(--accent); border: 0; }
.edit-send:hover { filter: brightness(1.1); }
.msg.assistant .bubble { background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin: 0; }
.bubble.refusal { border-color: rgba(251, 191, 36, .4); }
.bubble.error { border-color: rgba(248, 113, 113, .5); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1.1); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.notice { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; background: var(--bg-2); }
.notice.warn { border-color: rgba(251, 191, 36, .45); background: rgba(251, 191, 36, .07); }
.notice.demo { border-color: rgba(59, 130, 246, .4); background: var(--accent-soft); }

/* ---------- Cartes ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; transition: transform .25s ease, box-shadow .25s ease, border-color .25s;
}
.card:hover, .card:focus-visible { transform: scale(1.03); box-shadow: 0 18px 40px rgba(0, 0, 0, .5); border-color: rgba(59, 130, 246, .55); z-index: 2; }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.carousel { position: relative; aspect-ratio: 16 / 10; background: #0b1220; overflow: hidden; }
.carousel img { width: 100%; height: 100%; object-fit: cover; display: block; }
.car-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(9, 13, 22, .72); color: #fff; opacity: 0; transition: opacity .2s; backdrop-filter: blur(4px); }
.car-btn.prev { left: 8px; } .car-btn.next { right: 8px; }
.card:hover .car-btn, .car-btn:focus-visible { opacity: 1; }
.car-btn .ic { width: 16px; height: 16px; }
.car-dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; gap: 5px; justify-content: center; }
.car-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .45); }
.car-dots i.on { background: #fff; }
.badge { position: absolute; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; backdrop-filter: blur(6px); }
.badge.match { top: 10px; left: 10px; background: rgba(9, 13, 22, .8); border: 1px solid currentColor; }
.badge.match.hi { color: var(--good); } .badge.match.mid { color: var(--warn); } .badge.match.lo { color: var(--bad); }
.fav-btn { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(9, 13, 22, .72); color: #fff; display: grid; place-items: center; backdrop-filter: blur(4px); }
.fav-btn.on { color: #FACC15; } .fav-btn.on .ic { fill: #FACC15; }
.fav-btn .ic { width: 17px; height: 17px; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h4 { margin: 0; font-size: 15px; line-height: 1.3; }
.card .sub { color: var(--muted); font-size: 12.5px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--panel); border-radius: 8px; padding: 3px 9px; font-size: 12.5px; color: var(--text); }
.pill.price { background: var(--navy); font-weight: 700; }
.pill.demo { background: rgba(59, 130, 246, .18); color: #9CC2FF; }
.card .ai { font-size: 13px; color: #C5CFE0; margin: 0; }
.card .tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-size: 11.5px; color: #9CC2FF; background: var(--accent-soft); border-radius: 6px; padding: 2px 7px; }
.card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); }
.card-foot label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.verdict.good { color: var(--good); } .verdict.high { color: var(--bad); }

/* ---------- Analyse / tableaux ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 13.5px; transition: background .2s, border-color .2s; }
.btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
details.analysis { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; }
details.analysis summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
details.analysis .inner { padding-bottom: 12px; display: grid; gap: 12px; }
.inner h5 { margin: 0 0 4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.inner ul { margin: 0; padding-left: 18px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--panel); position: sticky; top: 0; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td:first-child { color: var(--muted); white-space: nowrap; }
.alt-row { display: flex; flex-wrap: wrap; gap: 8px; }
.alt { text-align: left; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; max-width: 320px; transition: border-color .2s; }
.alt:hover { border-color: var(--accent); }
.alt b { display: block; } .alt span { font-size: 12.5px; color: var(--muted); }

/* ---------- Composer ---------- */
.composer { padding: 8px 18px calc(12px + env(safe-area-inset-bottom)); }
.composer-box {
  max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 6px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 26px; padding: 8px 8px 8px 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
  transition: border-color .2s, box-shadow .2s;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 10px 40px rgba(30, 64, 175, .3); }
.composer textarea { flex: 1; resize: none; background: transparent; border: 0; outline: 0; color: var(--text); font: inherit; max-height: 180px; padding: 9px 0; line-height: 1.45; }
.composer textarea::placeholder { color: var(--muted); }
.mic.recording { background: rgba(248, 113, 113, .18); color: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(248, 113, 113, .15); } }
.send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; transition: background .2s, transform .1s; flex: none; }
.send:hover:not(:disabled) { background: #5a9bff; } .send:active { transform: scale(.94); }
.send:disabled { background: var(--panel); color: var(--muted); cursor: not-allowed; }
.disclaimer { text-align: center; margin: 8px 0 0; font-size: 11.5px; color: var(--muted); opacity: .8; }

/* ---------- Overlays / modales ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
.backdrop { position: absolute; inset: 0; background: rgba(3, 6, 12, .66); backdrop-filter: blur(3px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: relative; width: min(760px, 100%); height: 100%; background: var(--bg-2); border-left: 1px solid var(--line); overflow-y: auto; animation: slide .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.close { position: absolute; top: 12px; right: 12px; z-index: 5; background: rgba(9, 13, 22, .7); border-color: var(--line); backdrop-filter: blur(6px); }
.modal { position: relative; background: var(--bg-2); border: 1px solid var(--line); border-radius: 22px; width: 100%; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: pop .22s ease; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }

.gallery { background: #0b1220; }
.gallery .big { aspect-ratio: 16 / 10; width: 100%; display: block; object-fit: cover; }
.thumbs { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; }
.thumbs img { width: 84px; height: 56px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; cursor: pointer; opacity: .7; }
.thumbs img.on { border-color: var(--accent); opacity: 1; }
.d-content { padding: 6px 22px 28px; display: grid; gap: 18px; }
.d-content h2 { margin: 6px 0 0; font-size: 22px; letter-spacing: -.01em; }
.d-price { font-size: 26px; font-weight: 700; }
.d-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.match-big { font-weight: 700; padding: 6px 14px; border-radius: 999px; border: 1px solid currentColor; }
.match-big.hi { color: var(--good); } .match-big.mid { color: var(--warn); } .match-big.lo { color: var(--bad); }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.spec { background: var(--panel-2); border-radius: 10px; padding: 8px 12px; }
.spec small { display: block; color: var(--muted); font-size: 11.5px; }
.d-section h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.d-section ul { margin: 0; padding-left: 18px; }
.d-section p { margin: 0 0 8px; white-space: pre-wrap; }
.d-source a { word-break: break-all; }
.cta {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px; background: var(--accent); color: #fff; border: 0; border-radius: 12px;
  padding: 13px 18px; font-weight: 700; text-decoration: none; transition: background .2s; cursor: pointer;
}
.cta:hover { background: #5a9bff; }
.cta[aria-disabled="true"] { background: var(--panel); color: var(--muted); cursor: not-allowed; }
.d-actions { display: grid; gap: 10px; grid-template-columns: 1fr auto; }

/* Auth */
.modal.auth { max-width: 420px; padding: 34px 28px 28px; display: grid; gap: 12px; }
.modal.auth h2 { margin: 0 0 6px; text-align: center; font-size: 20px; letter-spacing: .06em; }
.sso { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; transition: background .2s; }
.sso:hover { background: #2a3a55; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; letter-spacing: .1em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.modal form { display: grid; gap: 12px; }
.modal label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.pw-wrap { position: relative; display: grid; }
.pw-wrap input { padding-right: 46px; }
.pw-wrap input::-ms-reveal, .pw-wrap input::-ms-clear { display: none; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; }
.pw-eye:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.pw-eye:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pw-eye .ic { width: 20px; height: 20px; }
.pw-eye svg[hidden] { display: none; }
.modal input[type="email"], .modal input[type="text"]#authPass, .modal input[type="password"] { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--text); font: inherit; }
.modal input:focus { outline: 0; border-color: var(--accent); }
.form-error { color: var(--bad); margin: 0; font-size: 13px; }
.form-info { color: var(--good); margin: 0; font-size: 13px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.auth-tab { background: transparent; border: 0; border-radius: 9px; padding: 9px 12px; color: var(--muted); font-weight: 600; }
.auth-tab:hover { color: var(--text); }
.auth-tab.active { background: var(--panel); color: var(--text); }
.auth-sso { display: grid; gap: 12px; }
.auth-forgot { justify-self: center; font-size: 13px; }
.sso[disabled], .cta[disabled] { opacity: .6; cursor: wait; }

/* Settings */
.modal.settings { max-width: 760px; min-height: 420px; display: grid; grid-template-columns: 220px 1fr; overflow: hidden; }
.settings-nav { background: var(--panel-2); padding: 52px 12px 12px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); }
.tab { display: flex; align-items: center; gap: 10px; background: transparent; border: 0; padding: 10px 12px; border-radius: 10px; text-align: left; color: var(--muted); }
.tab:hover { background: var(--panel); color: var(--text); }
.tab.active { background: var(--panel); color: var(--text); font-weight: 600; }
.logout { margin-top: auto; display: flex; align-items: center; gap: 10px; background: rgba(248, 113, 113, .12); color: var(--bad); border: 1px solid rgba(248, 113, 113, .4); border-radius: 10px; padding: 10px 12px; font-weight: 600; }
.logout:hover { background: rgba(248, 113, 113, .22); }
.settings-panel { padding: 52px 26px 26px; display: grid; gap: 16px; align-content: start; }
.settings-panel h3 { margin: 0; font-size: 18px; }
.settings-panel p { margin: 0; color: var(--muted); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.btn.danger { border-color: rgba(248, 113, 113, .4); color: var(--bad); }
.meter { height: 10px; background: var(--panel); border-radius: 999px; overflow: hidden; }
.meter > div { height: 100%; background: linear-gradient(90deg, var(--navy), var(--accent)); border-radius: 999px; transition: width .4s; }
.switch { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--panel); position: relative; cursor: pointer; transition: background .2s; border: 1px solid var(--line); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch:checked { background: var(--accent); } .switch:checked::after { transform: translateX(18px); }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 90; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); max-width: 90vw; animation: rise .25s ease; }

/* ---------- Responsive ---------- */
.scrim { display: none; }
@media (max-width: 860px) {
  .burger { display: grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 20px 0 60px rgba(0, 0, 0, .5); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(3, 6, 12, .6); z-index: 25; }
  .top-logo { display: flex; position: absolute; left: 50%; transform: translateX(-50%); margin: 0; }
  .modal.settings { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; padding: 52px 12px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .logout { margin-top: 0; margin-left: auto; }
  .settings-panel { padding: 20px; }
  .grid { grid-template-columns: 1fr; }
  .d-actions { grid-template-columns: 1fr; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
@media (hover: none) { .car-btn { opacity: 1; } .card:hover { transform: none; } }

/* ================= Tri, position, contrastes ================= */
.sortbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sort-label { color: var(--muted); font-size: 13px; margin-right: 2px; }
.sort-btn { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13.5px; font-weight: 600; color: var(--muted); transition: background .2s, border-color .2s, color .2s; }
.sort-btn:hover { border-color: var(--accent); color: var(--text); }
.sort-btn[aria-pressed="true"] { background: var(--navy); border-color: var(--accent); color: #fff; }
.pos-info { color: var(--muted); font-size: 13px; margin-left: 6px; }
.link-btn { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; font-size: inherit; }
.pos-box { display: grid; gap: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; animation: rise .25s ease both; }
.pos-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.field { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; color: var(--text); font: inherit; min-width: 0; }
.field:focus { outline: 0; border-color: var(--accent); }
select.field { cursor: pointer; }
.pill.dist { background: rgba(52, 211, 153, .14); color: var(--good); }

.flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flag { font-size: 11.5px; font-weight: 700; letter-spacing: .02em; padding: 3px 9px; border-radius: 6px; }
.flag.best { background: rgba(52, 211, 153, .16); color: var(--good); }
.flag.price { background: rgba(59, 130, 246, .18); color: #9CC2FF; }
.flag.km { background: rgba(251, 191, 36, .15); color: var(--warn); }
.warn-line { margin: 0; font-size: 12.5px; color: var(--warn); background: rgba(251, 191, 36, .08); border-left: 3px solid var(--warn); border-radius: 6px; padding: 5px 9px; }
.verdict-chip { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--panel); color: var(--muted); text-transform: capitalize; }
.verdict-chip.good { background: rgba(52, 211, 153, .16); color: var(--good); }
.verdict-chip.ok { background: rgba(59, 130, 246, .16); color: #9CC2FF; }
.verdict-chip.mid { background: rgba(251, 191, 36, .15); color: var(--warn); }
.verdict-chip.high { background: rgba(248, 113, 113, .16); color: var(--bad); }
.engine-tag { font-size: 12px; color: var(--muted); }

.ai-box { display: grid; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.ai-box p { margin: 2px 0 0; }
.ai-fields { display: grid; gap: 10px; }
.ai-fields[hidden] { display: none; }

/* ================= Animations ================= */
.card.enter { animation: cardIn .55s cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: calc(var(--i) * 70ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.badge.match.hi { box-shadow: 0 0 18px rgba(52, 211, 153, .35); }

/* Fond de l'accueil : halos bleus doux qui dérivent lentement */
.main > .topbar, .main > .chat, .main > .composer { position: relative; z-index: 1; }
.bg-fx { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; transition: opacity .8s ease; }
.has-chat .bg-fx { opacity: .28; }
/* Un seul point de lumière, au centre du Hero, qui s'éteint progressivement vers la zone du texte (dégradé continu :
   aucun anneau, aucun bord). Une couche plus large « respire » doucement : l'intensité varie vers l'extérieur, pas au centre.
   Dégradés + opacity uniquement : pas de flou coûteux, composité par le GPU. */
.halo { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none; }
.halo-core { width: min(912px, 138%); height: min(672px, 94%);
  background: radial-gradient(closest-side,
    rgba(48, 94, 215, .40) 0%, rgba(46, 90, 210, .33) 12%, rgba(42, 84, 202, .25) 26%, rgba(38, 76, 192, .17) 42%,
    rgba(34, 70, 183, .10) 58%, rgba(30, 64, 175, .05) 72%, rgba(30, 64, 175, .018) 87%, transparent 100%);
  animation: halo-core 9s ease-in-out infinite alternate; }
.halo-wide { width: min(1100px, 150%); height: min(820px, 105%); opacity: .5;
  background: radial-gradient(closest-side,
    rgba(40, 80, 195, .16) 0%, rgba(38, 76, 190, .12) 25%, rgba(34, 70, 182, .07) 50%,
    rgba(30, 64, 175, .03) 75%, transparent 100%);
  animation: halo-wide 12s ease-in-out infinite alternate; }
@keyframes halo-core { from { opacity: .88; } to { opacity: 1; } }
@keyframes halo-wide { from { opacity: .15; } to { opacity: 1; } }
/* Grain très fin (statique) : casse les « bandes » visibles dans les dégradés sombres */
.bg-fx::after { content: ""; position: absolute; inset: 0; opacity: .035; background: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22220%22%20height=%22220%22%3E%3Cfilter%20id=%22n%22%20x=%220%22%20y=%220%22%20width=%22100%25%22%20height=%22100%25%22%3E%3CfeTurbulence%20type=%22fractalNoise%22%20baseFrequency=%22.85%22%20numOctaves=%222%22%20stitchTiles=%22stitch%22/%3E%3CfeColorMatrix%20values=%220%200%200%200%201%20%200%200%200%200%201%20%200%200%200%200%201%20%200%200%200%201.1%20-.35%22/%3E%3C/filter%3E%3Crect%20width=%22100%25%22%20height=%22100%25%22%20filter=%22url%28%23n%29%22/%3E%3C/svg%3E") 0 0 / 220px 220px; }
.hero > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }
.hero > *:nth-child(2) { animation-delay: .1s; } .hero > *:nth-child(3) { animation-delay: .2s; }
/* ---------- Scène animée de l'accueil : voiture monoline sur la route, décor qui défile ----------
   Tout est en transform/opacity (composité par le GPU). Décor : 300px / 7,5s = 40px/s. */
.hero-scene { position: relative; width: 260px; height: 90px; max-width: 100%; margin-bottom: 4px; }
.hero-scene svg { display: block; }
.scene-decor { position: absolute; inset: 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 26%, #000 74%, transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 26%, #000 74%, transparent 100%); }
.scene-strip { position: absolute; left: 0; top: 0; fill: none; stroke: #7D93B8; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round;
  opacity: .42; animation: scene-scroll 7.5s linear infinite; will-change: transform; }
@keyframes scene-scroll { to { transform: translate3d(-300px, 0, 0); } }

.scene-car { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: var(--accent); stroke-linecap: round; stroke-linejoin: round; overflow: visible;
  filter: drop-shadow(0 0 12px rgba(59, 130, 246, .45)); }
.scene-car .road { stroke: url(#ttc-road); stroke-width: 1.5; }
.scene-car .car-shape { stroke-width: 1.5; }                /* même proportion que le logo d'origine (1,5 sur 24), soit 4,5px à l'écran */
.scene-car .body, .scene-car .wheel { fill: rgba(9, 13, 22, .72); } /* masque en grande partie le décor qui passe derrière */
.scene-car .lamp { fill: var(--accent); stroke: none; }
.scene-car .beam { fill: url(#ttc-beam); stroke: none; animation: beam-pulse 2.6s ease-in-out infinite; }
.scene-car .car-bounce { animation: car-bounce 1.3s ease-in-out infinite; }
.scene-car .speed { stroke-width: 1.1; stroke: var(--accent); }
.scene-car .speed path { opacity: .5; animation: speed-pulse 1.8s ease-in-out infinite; }
.scene-car .speed path:nth-child(2) { animation-duration: 2.2s; animation-delay: -.7s; }
.scene-car .speed path:nth-child(3) { animation-duration: 1.6s; animation-delay: -1.1s; }
@keyframes car-bounce { 0%, 100% { transform: translateY(0); } 35% { transform: translateY(-1px); } 65% { transform: translateY(-.35px); } }
@keyframes speed-pulse { 0%, 100% { opacity: .12; transform: translateX(2px); } 50% { opacity: .6; transform: translateX(-3px); } }
@keyframes beam-pulse { 0%, 100% { opacity: .7; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .scene-strip, .scene-car .car-bounce, .scene-car .speed path, .scene-car .beam { animation: none !important; }
}

.pos-box p:empty { display: none; }

/* Estimations : négociation et coût de possession */
.est-lines { margin: 10px 0 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(59, 130, 246, .06); display: grid; gap: 4px; }
.est-lines p { margin: 0; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.est-lines strong { color: var(--text); font-weight: 650; white-space: nowrap; }
.est-lines small { color: var(--muted); font-size: 11px; opacity: .8; }
.est-big { font-size: 22px; font-weight: 700; margin: 0 0 6px; color: var(--accent); }
.est-big span { font-size: 14px; font-weight: 500; color: var(--muted); }
.est-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.tco tr:last-child td { font-weight: 650; }

/* ---------- Accueil compact sur téléphone : tout tient à l'écran, rien à faire défiler ---------- */
@media (max-width: 860px) {
  .hero { padding: 8px 0 24px; gap: 14px; }
  .hero-scene { height: 78px; }
  .hero h1 { font-size: clamp(30px, 9vw, 40px); }
  .hero-text { font-size: 14.5px; }
  body:not(.has-chat) .chat { overflow-y: auto; overscroll-behavior: contain; }
}
@media (max-width: 860px) and (min-height: 640px) {
  body:not(.has-chat) .chat { overflow-y: hidden; } /* assez de place : l'accueil n'est tout simplement pas défilable */
}
body:not(.has-chat) .messages { display: none; } /* vide sur l'accueil : ses marges créaient un faux défilement */

/* ---------- Équipements : puces entières, regroupées ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-block; max-width: 100%; line-height: 1.35; }
.d-section .tag { font-size: 12.5px; padding: 4px 10px; border-radius: 8px; }
.eq-block { margin: 12px 0 0; }
.eq-block h4 { margin: 0 0 8px; font-size: 13.5px; font-weight: 650; color: var(--text); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.eq-block h4 small { font-weight: 400; color: var(--muted); font-size: 12px; }
.eq-cat { margin: 0 0 8px; }
.eq-cat-name { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.calm { margin: 0; color: var(--muted); background: rgba(52, 211, 153, .07); border-left: 3px solid var(--good); border-radius: 6px; padding: 8px 12px; }

/* ---------- Badge Matching : même forme que les autres boutons (carré arrondi, comme la croix) ---------- */
.badge.match { top: 8px; left: 8px; height: 34px; padding: 0 12px; border-radius: 12px; display: inline-flex; align-items: center; background: rgba(9, 13, 22, .7); }
.fav-btn { border-radius: 12px; }
.match-big { height: 40px; padding: 0 16px; border-radius: 12px; display: inline-flex; align-items: center; background: rgba(9, 13, 22, .7); }

/* ---------- Barre latérale : sections repliables, favoris groupés par modèle ---------- */
.side-scroll h3 { margin: 14px 0 4px; }
.side-h { -webkit-appearance: none; appearance: none; display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; text-align: left; }
.side-h:hover { background: rgba(148, 163, 184, .08); color: var(--text); }
.side-h > span:first-child { flex: 1; }
.side-h .ic, .side-group .ic { width: 15px; height: 15px; transition: transform .2s; }
.side-h.folded .ic, .side-group.folded .ic { transform: rotate(-90deg); }
.side-count { font-size: 11px; font-weight: 600; letter-spacing: 0; color: var(--muted); background: rgba(148, 163, 184, .12); border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }
.side-count:empty { display: none; }
.side-list[hidden], .side-sub[hidden] { display: none; }
.side-grp { margin: 0 0 2px; }
.side-group { -webkit-appearance: none; appearance: none; display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: 10px; background: transparent;
  color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; text-align: left; }
.side-group:hover { background: var(--panel); }
.side-group .ic { color: var(--muted); }
.side-group .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-sub { list-style: none; margin: 0 0 4px 10px; padding: 0 0 0 8px; border-left: 1px solid var(--line); }
.side-sub .side-item { padding: 6px 8px; font-size: 13.5px; }

/* ---------- Barre de recherche : contour bleu toujours visible ---------- */
.composer-box { border-color: rgba(59, 130, 246, .65); box-shadow: 0 0 0 1px rgba(59, 130, 246, .12), 0 10px 40px rgba(30, 64, 175, .22); }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(59, 130, 246, .35), 0 10px 40px rgba(30, 64, 175, .34); }

/* ---------- Poubelle des recherches : visible seulement au survol (sur tactile, toujours visible) ---------- */
@media (hover: hover) {
  .side-item .del.del-hover { opacity: 0; }
  .side-item:hover .del.del-hover, .side-item:focus-within .del.del-hover, .side-item .del.del-hover:focus-visible { opacity: 1; }
}
/* ---------- Fenêtre de confirmation ---------- */
.modal.confirm { max-width: 400px; padding: 26px 24px 22px; display: grid; gap: 10px; text-align: center; }
.modal.confirm h2 { margin: 0; font-size: 18px; }
.modal.confirm p { margin: 0 0 8px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
.confirm-actions .btn { flex: 1; padding: 10px 14px; }
.btn.danger:hover:not(:disabled) { background: rgba(248, 113, 113, .12); border-color: var(--bad); }
