/* Faufil Studio — layout : barre latérale fixe + plan de travail gris studio ; motif signature = points de bâti en pointillés */
:root {
  --ground: #ecedef;      /* gris studio, cousin du #EEEEEE des marques */
  --surface: #ffffff;
  --ink: #20242b;
  --muted: #646b78;
  --line: #d5d8de;
  --thread: #2f5bea;      /* fil de bâti cobalt */
  --thread-soft: #e3e9fd;
  --ok: #1f8a5b; --warn: #b8770d; --ko: #c2393a; --idle: #7b8291;
  --f-display: "Gloock", Georgia, serif;
  --f-body: "Instrument Sans", system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #15171c; --surface: #1d2027; --ink: #e9ebf0; --muted: #9aa1ae; --line: #2e323c;
    --thread: #7d97ff; --thread-soft: #232c4a; --ok: #4cc58c; --warn: #e2a63d; --ko: #ef6b6b; --idle: #8a90a0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #15171c; --surface: #1d2027; --ink: #e9ebf0; --muted: #9aa1ae; --line: #2e323c;
  --thread: #7d97ff; --thread-soft: #232c4a; --ok: #4cc58c; --warn: #e2a63d; --ko: #ef6b6b; --idle: #8a90a0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--ground); color: var(--ink); font: 15px/1.55 var(--f-body); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font: 400 2.2rem/1.1 var(--f-display); }
h2 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
.eyebrow { font: 500 .72rem var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--thread); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--thread); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 24px 18px; border-right: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; gap: 12px; align-items: center; }
.brand strong { font: 400 1.5rem/1 var(--f-display); display: block; }
.brand small { color: var(--muted); font-size: .78rem; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.logout { font-size: .8rem; color: var(--muted); text-decoration: none; padding: 0 12px; }
.logout:hover { color: var(--ink); }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { padding: 9px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
nav a:hover { background: var(--ground); color: var(--ink); }
nav a.active { background: var(--thread-soft); color: var(--ink); box-shadow: inset 3px 0 0 var(--thread); }
.engine { margin-top: auto; font: .75rem var(--f-mono); color: var(--muted); padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; }
.engine b { color: var(--ink); }

main { padding: 32px max(16px, env(safe-area-inset-right, 0px)) 64px max(24px, env(safe-area-inset-left, 0px)); min-width: 0; }
section { display: flex; flex-direction: column; gap: 24px; max-width: 1280px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 2px dashed var(--line); }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 9px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.thread { background: var(--thread); border-color: var(--thread); color: #fff; }
.btn.ok { color: var(--ok); border-color: currentColor; }
.btn.warn { color: var(--warn); border-color: currentColor; }
.btn.ko { color: var(--ko); border-color: currentColor; }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 1.1rem; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi span { font-size: .8rem; color: var(--muted); }
.kpi b { font: 400 2rem/1 var(--f-display); font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: .78rem; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.statuses { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini { display: flex; gap: 10px; align-items: center; cursor: pointer; padding: 6px; border-radius: 8px; }
.mini:hover { background: var(--ground); }
.mini img { width: 40px; height: 60px; object-fit: cover; border-radius: 4px; background: var(--ground); }
.empty { color: var(--muted); font-size: .9rem; padding: 24px; text-align: center; border: 2px dashed var(--line); border-radius: var(--radius); }

.pill { display: inline-flex; align-items: center; gap: 6px; font: 500 .72rem var(--f-mono); padding: 3px 9px; border-radius: 999px; background: var(--ground); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.ko { color: var(--ko); } .pill.run { color: var(--thread); } .pill.idle { color: var(--idle); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: .85rem; }
.filters button.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.shot { background: var(--surface); border-radius: var(--radius); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; border: 1px solid transparent; }
.shot:hover { border-color: var(--thread); }
.shot .img { aspect-ratio: 2 / 3; background: var(--ground); position: relative; max-width: 100%; }
.shot .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot .img .spin { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font: .8rem var(--f-mono); }
.shot .meta { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.shot .meta b { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot .meta small { color: var(--muted); font: .72rem var(--f-mono); }
.running { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card .visual { aspect-ratio: 2 / 3; background: var(--ground); display: grid; place-items: center; color: var(--muted); font: .8rem var(--f-mono); max-width: 100%; }
.card .visual img { width: 100%; height: 100%; object-fit: cover; }
.card .visual.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; aspect-ratio: 4 / 3; }
.card .visual.pair img { object-fit: contain; background: var(--ground); }
.card .body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card .body .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .code { font: 500 .8rem var(--f-mono); color: var(--thread); }
.card .desc { color: var(--muted); font-size: .86rem; }
.card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }

.prompt-list { display: flex; flex-direction: column; gap: 16px; }
.prompt { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.prompt header { display: flex; justify-content: space-between; gap: 10px; padding: 14px 16px; align-items: center; flex-wrap: wrap; }
.prompt pre { margin: 0; padding: 16px; background: var(--ink); color: var(--surface); font: .78rem/1.55 var(--f-mono); white-space: pre-wrap; overflow-x: auto; max-height: 360px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: .9rem; }
.kv dt, .kv span.k { color: var(--muted); }
.kv dd { margin: 0; }
dl.kv { margin: 0; font-size: .84rem; }
.kv code { font-family: var(--f-mono); font-size: .82rem; }

/* Panneau de détail */
.drawer { position: fixed; inset: 0; background: rgba(20, 22, 28, .45); display: flex; justify-content: flex-end; z-index: 20; }
.drawer-inner { width: min(980px, 100%); height: 100%; overflow-y: auto; background: var(--ground); padding: 28px max(20px, env(safe-area-inset-right, 0px)) 40px 28px; position: relative; }
.close { position: absolute; top: 18px; right: 20px; }
.compare { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; margin: 18px 0; }
.compare figure { margin: 0; background: var(--surface); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.compare figcaption { font: .72rem var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.compare img { width: 100%; border-radius: 6px; background: var(--ground); }
.scores { width: 100%; border-collapse: collapse; font-size: .88rem; }
.scores td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.scores td.s { font: 600 .85rem var(--f-mono); width: 54px; }
.review { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.review input { width: 80px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
details.prompt-used summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
details.prompt-used pre { white-space: pre-wrap; font: .75rem/1.5 var(--f-mono); background: var(--surface); padding: 12px; border-radius: 8px; }

/* Formulaires */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100% - 32px)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(20, 22, 28, .5); }
dialog form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: .82rem; font-weight: 600; }
.field small { color: var(--muted); font-size: .76rem; }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--ground); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { border: 1px dashed var(--line); border-radius: 8px; padding: 6px 10px; display: flex; gap: 6px; align-items: center; font-size: .86rem; cursor: pointer; }
.checks input:checked + span { color: var(--thread); font-weight: 600; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }

.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); right: max(20px, env(safe-area-inset-right, 0px)); background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 10px; z-index: 30; font-size: .9rem; max-width: 420px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { flex-direction: row; flex-wrap: wrap; }
  .engine { margin-top: 0; }
  main { padding: 20px 16px 48px; }
  .compare, .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .running { animation: none; } }

/* Libre-service : parcours pilote */
.banner { background: var(--thread-soft); border-left: 3px solid var(--thread); padding: 12px 16px; border-radius: 8px; font-size: .92rem; }
.banner.warn { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border-color: var(--warn); }
.steps { display: flex; flex-direction: column; gap: 10px; counter-reset: st; }
.step { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 14px; align-items: center; counter-increment: st; }
.step::before { content: counter(st); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 500 .9rem var(--f-mono); color: var(--thread); border: 1.5px dashed var(--thread); }
.step.done::before { content: "✓"; background: var(--ok); color: #fff; border: 0; }
.step.locked { opacity: .55; }
.step b { display: block; }
.step span { color: var(--muted); font-size: .88rem; }
.quota { display: flex; flex-direction: column; gap: 6px; font-size: .78rem; color: var(--muted); padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; margin-top: auto; }
.quota b { color: var(--ink); }
.bar { height: 6px; background: var(--ground); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--thread); border-radius: 99px; }
.side .engine { margin-top: 0; }
.charte-form { background: var(--surface); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 14px; max-width: 720px; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--line); vertical-align: middle; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.list th, table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.list th { font: 500 .72rem var(--f-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.review textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); }
@media (max-width: 820px) { .step { grid-template-columns: 34px minmax(0, 1fr); } .step > :last-child { grid-column: 1 / -1; } .quota { margin-top: 0; } }
.drop { border: 2px dashed var(--thread); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; cursor: pointer; background: var(--thread-soft); }
.drop span:not(.btn) { color: var(--muted); font-size: .9rem; }
.drop.over { background: var(--surface); }
.drop.busy { opacity: .7; pointer-events: none; }
.drop.busy b { animation: pulse 1.4s ease-in-out infinite; }
.field.found input, .field.found textarea { border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.field.found label::after { content: " · lu dans votre document"; color: var(--ok); font-weight: 500; }
.compare img { max-height: 72vh; object-fit: contain; }
.decision-top { margin-top: 16px; }
.field input[type="color"] { width: 72px; height: 42px; padding: 3px; cursor: pointer; background: var(--surface); }

/* Photo prise au téléphone */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--ground); border-radius: 10px; }
.segmented label { position: relative; text-align: center; padding: 9px 10px; border-radius: 7px; cursor: pointer; font-size: .9rem; font-weight: 500; color: var(--muted); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--thread); }
.tips { background: var(--thread-soft); border-left: 3px solid var(--thread); border-radius: 8px; padding: 12px 14px; font-size: .88rem; }
.tips ul { margin: 6px 0 8px; padding-left: 18px; display: grid; gap: 3px; }
.tips small { color: var(--muted); }
.card .visual.before-after { gap: 2px; }
.card .visual.before-after figure { margin: 0; position: relative; overflow: hidden; }
.card .visual.before-after img { width: 100%; height: 100%; object-fit: cover; }
.card .visual.before-after figcaption { position: absolute; left: 8px; bottom: 8px; font: 500 .7rem var(--f-body); background: rgba(255, 255, 255, .88); color: #20242b; padding: 2px 7px; border-radius: 99px; }
.card .visual.pair .running { display: grid; place-items: center; font: .78rem var(--f-mono); color: var(--muted); }

.grid2 > * { min-width: 0; }
.field input, .field select, .field textarea { min-width: 0; width: 100%; }
