:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --ink: #141625;
  --muted: #5d6275;
  --line: #e1e4ee;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --ok: #2f7d4f;
  --warn: #a8670b;
  --err: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f111a;
    --surface: #181b27;
    --ink: #eef0f8;
    --muted: #9ba1b6;
    --line: #2a2e3d;
    --accent: #8f8bff;
    --accent-ink: #11121c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f111a;
  --surface: #181b27;
  --ink: #eef0f8;
  --muted: #9ba1b6;
  --line: #2a2e3d;
  --accent: #8f8bff;
  --accent-ink: #11121c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
/* L'attribut hidden doit toujours l'emporter sur les display: grid/flex des composants. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand img { border-radius: 8px; }

main { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.intro { padding: 32px 0 8px; }
.intro h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); line-height: 1.1; margin: 0 0 10px; letter-spacing: -.02em; }
.intro p { color: var(--muted); margin: 0; max-width: 100ch; }

.step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 20px 0;
}
.step h2 { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin: 0 0 14px; }
.num {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: var(--bg); font-size: .85rem;
}

.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 36px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); outline: none; }
.drop-inner { display: grid; gap: 4px; }
.drop-inner strong { font-size: 1.05rem; }
.drop-inner span, .drop-inner small { color: var(--muted); }

.status { margin: 0 0 10px; font-size: .95rem; }
.status[data-kind="ok"] { color: var(--ok); }
.status[data-kind="warn"] { color: var(--warn); }
.status[data-kind="error"] { color: var(--err); }
.status[data-kind="busy"]::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .95rem; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

.options { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 18px; }
.options label { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); min-width: 0; }
.options .grow { flex: 1 1 260px; }
select, input[type="text"], textarea {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 16px; border-radius: 999px;
  transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); padding: 12px 22px; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: .88rem; }

.results-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.results-head h2 { margin: 0; }
.muted { color: var(--muted); font-size: .92rem; }

.tag {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.65); color: #fff; font-size: .72rem; padding: 3px 8px; border-radius: 999px;
}

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow); z-index: 20;
}

.foot { max-width: 980px; margin: 0 auto; padding: 8px 16px 32px; color: var(--muted); font-size: .8rem; }

.num { min-width: 26px; width: auto; padding: 0 6px; border-radius: 13px; }
textarea {
  font: inherit; color: var(--ink); background: var(--bg); width: 100%;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; resize: vertical;
}
.field-head { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; font-weight: 600; font-size: .92rem; }
.field-head .muted { font-weight: 400; margin-left: auto; }
.field-head .muted:empty { display: none; }
.field-head .btn { margin-left: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.update {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; z-index: 21;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  padding: 10px 12px 10px 16px; border-radius: 12px; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
}
.camera-btn { width: 100%; margin-top: 10px; }
.offline {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30; text-align: center; font-size: .85rem;
  background: #7a4b00; color: #fff; padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top));
}

/* Mode de détourage */
.top-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- AnnonceFacile ---------- */
.small { font-size: .84rem; }
.sr-only { position: fixed; left: -9999px; opacity: 0; }
.options .full { flex: 1 1 100%; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 14px; }
.step > .muted.small { margin: 12px 0 0; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-bottom: 12px; }
.photos:empty { display: none; }
.photo { position: relative; margin: 0; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .remove, .history .remove {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.camera-btn:disabled { display: none; }

/* Résultat */
.alert { border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); color: var(--ink); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: .92rem; }
.chip.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); color: var(--warn); }
.field-head small { font-weight: 400; }
.summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; margin-top: 18px; padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.etat-final { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); align-content: start; }
.price { display: grid; gap: 4px; align-content: start; }
.price strong { font-size: 1.5rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.price strong[data-confiance="faible"] { color: var(--muted); }
.compare { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin-top: 4px; }
.link { color: var(--accent); font-weight: 600; font-size: .9rem; text-underline-offset: 3px; }

.tabs { display: flex; gap: 6px; margin-top: 22px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.tab {
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; color: var(--muted);
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab.off { opacity: .55; }
.panel { padding-top: 6px; }
.field input[type="text"] { font-weight: 600; }
.count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.count.over { color: var(--err); font-weight: 600; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 16px 0 0; font-size: .9rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.meta.specs { margin-top: 0; }
.notice { border: 1px dashed var(--line); border-radius: 12px; padding: 14px 16px; margin-top: 14px; }
.notice p { margin: 0 0 8px; }
.notice p:last-child { margin: 0; }
.notice.warn { border-style: solid; border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); color: var(--warn); font-size: .92rem; }
a.btn { display: inline-block; text-decoration: none; }
#by { margin: 14px 0 0; }

/* Historique */
.history { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.history li { position: relative; }
.history .open {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 8px 44px 8px 8px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit; cursor: pointer;
}
.history li.current .open { border-color: var(--accent); }
.history img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: none; }
.history .open span { display: grid; min-width: 0; }
.history b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .remove { top: 50%; transform: translateY(-50%); right: 10px; }

@media (max-width: 560px) {
  .step { padding: 16px; }
  .summary { grid-template-columns: 1fr; }
  .actions .btn { flex: 1 1 auto; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.top .btn { white-space: nowrap; }
.step { scroll-margin-top: 72px; }
