:root {
  --paper: #f6f2e9;
  --sheet: #fffdf8;
  --ink: #1f1c17;
  --muted: #6d665a;
  --rule: #ddd5c4;
  --accent: #b5301f;
  --warn-bg: #fcf0d4;
  --warn: #7a5300;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.45 var(--sans); }
h1, h2, h3, p, dl, dd, ul { margin: 0; padding: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.masthead { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; max-width: 1180px; margin: 0 auto; padding: 28px 24px 18px; }
.masthead h1 { font: 700 34px/1 var(--serif); letter-spacing: -0.5px; }
.masthead p { color: var(--muted); }

.desk { max-width: 1180px; margin: 0 auto; padding: 0 24px 64px; }
.intake { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; }

.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 176px; padding: 24px; text-align: center; color: var(--muted); background: var(--sheet); border: 2px dashed #b9ae98; border-radius: 10px; cursor: pointer; transition: border-color .15s, color .15s; }
.dropzone:hover { border-color: var(--accent); }
.dropzone strong { font: 700 24px var(--serif); color: var(--ink); }
kbd { padding: 0 5px; font: 12px var(--sans); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; background: var(--paper); }

.phone { display: flex; gap: 16px; align-items: center; padding: 16px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; }
.phone h2 { font: 700 18px var(--serif); margin-bottom: 4px; }
.phone p { font-size: 14px; }
.qr { flex: 0 0 144px; width: 144px; height: 144px; font-size: 13px; color: var(--muted); }
.qr svg { display: block; width: 100%; height: 100%; }
.hint { color: var(--muted); font-size: 13px; }
.host { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.host select { max-width: 170px; font-size: 12px; }

.notice { margin-top: 14px; padding: 10px 14px; background: var(--warn-bg); color: var(--warn); border-radius: 6px; }
.empty { margin-top: 48px; text-align: center; color: var(--muted); font: italic 18px var(--serif); }

.view { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-top: 22px; padding: 12px 14px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; }
.view label { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 12px; color: var(--muted); }
.view input, .view select { width: 100%; max-width: 190px; padding: 5px 7px; font-size: 14px; color: var(--ink); background: #fff; border: 1px solid var(--rule); border-radius: 6px; }
.view .grow { flex: 1 1 200px; }
.view .grow input { max-width: none; }
.view .amount { width: 92px; }
.view-status { display: flex; flex: 1 0 100%; gap: 12px; align-items: baseline; font-size: 13px; color: var(--muted); }
.view-status button { padding: 0; color: var(--accent); background: none; border: 0; text-decoration: underline; }

.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 500px), 1fr)); gap: 16px; margin-top: 22px; align-items: start; }
.card { display: grid; grid-template-columns: 180px minmax(0, 1fr); background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.card.fresh { animation: arrive .25s ease-out; }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .card.fresh { animation: none; } }

.visual { position: relative; background: #2a2620; min-height: 250px; }
.photo { display: block; width: 100%; height: 100%; object-fit: contain; }
.reference { position: absolute; right: 8px; bottom: 8px; width: 58px; border-radius: 3px; box-shadow: 0 2px 8px rgb(0 0 0 / .6); }
.origin { position: absolute; left: 8px; top: 8px; padding: 1px 7px; font-size: 11px; color: #fff; background: rgb(0 0 0 / .6); border-radius: 20px; }

.details { position: relative; padding: 16px 18px; min-width: 0; }
.details h3 { font: 700 21px/1.2 var(--serif); padding-right: 24px; }
.meta { color: var(--muted); font-size: 13px; }
.remove { position: absolute; top: 8px; right: 10px; width: 28px; height: 28px; padding: 0; font-size: 20px; line-height: 1; color: var(--muted); background: none; border: 0; }
.remove:hover { color: var(--accent); }

.price { margin-top: 12px; font: 700 40px/1 var(--serif); color: var(--accent); font-variant-numeric: tabular-nums; }
.price-label { font-size: 12px; color: var(--muted); }
.no-price { margin-top: 12px; color: var(--muted); }
.check, .message { margin-top: 8px; padding: 6px 10px; font-size: 13px; color: var(--warn); background: var(--warn-bg); border-radius: 5px; }
.message { margin: 0 24px 0 0; }
.working { color: var(--muted); font: italic 18px var(--serif); animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .4; } }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { padding: 2px 10px; font-size: 13px; background: none; border: 1px solid var(--rule); border-radius: 20px; }
.chip.on { color: #fff; background: var(--ink); border-color: var(--ink); }

.figures { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--rule); }
.figures dt { font-size: 12px; color: var(--muted); }
.figures dd { font-variant-numeric: tabular-nums; font-weight: 600; }

details { margin-top: 12px; font-size: 14px; }
summary { color: var(--muted); cursor: pointer; }
.panel { margin-top: 10px; }
.search { display: flex; gap: 6px; }
.search input { flex: 1; min-width: 0; padding: 6px 9px; background: #fff; border: 1px solid var(--rule); border-radius: 6px; }
.search button { padding: 6px 12px; color: #fff; background: var(--ink); border: 0; border-radius: 6px; }

.candidates { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 10px; max-height: 300px; overflow-y: auto; }
.candidates button { display: block; width: 100%; padding: 4px; text-align: left; background: none; border: 1px solid transparent; border-radius: 6px; }
.candidates button:hover { border-color: var(--accent); }
.candidates img { display: block; width: 100%; border-radius: 3px; }
.c-name, .c-set { display: block; font-size: 11px; line-height: 1.25; overflow-wrap: anywhere; }
.c-name { font-weight: 600; margin-top: 3px; }
.c-set { color: var(--muted); }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgb(31 28 23 / .75); color: #fff; font: 700 36px var(--serif); pointer-events: none; }

.mobile main { padding: 8px 20px 32px; }
.mobile .masthead { padding: 28px 20px 18px; }
.shoot, .gallery { display: block; text-align: center; border-radius: 12px; cursor: pointer; }
.shoot { padding: 56px 16px; font: 700 26px var(--serif); color: #fff; background: var(--accent); }
.gallery { margin-top: 12px; padding: 14px; background: var(--sheet); border: 1px solid var(--rule); }
.sent { margin-top: 18px; text-align: center; }

.touch { display: none; }
.touch .hint { margin-top: 10px; text-align: center; color: var(--muted); font-size: 14px; }
/* Sur téléphone ou tablette : bouton appareil photo à la place du glisser-déposer et du QR code. */
@media (pointer: coarse) {
  .intake { grid-template-columns: minmax(0, 1fr); }
  .touch { display: block; }
  .dropzone, .phone { display: none; }
}

@media (max-width: 860px) {
  .intake { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .masthead, .desk { padding-left: 16px; padding-right: 16px; }
  .card { grid-template-columns: minmax(0, 1fr); }
  .visual { height: 260px; }
}
