:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dde1e7;
  --text: #16191f;
  --muted: #5d6573;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --danger: #c4314b;
  --ok: #1f8a4c;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1a1d24;
    --border: #2c313b;
    --text: #e8eaee;
    --muted: #9aa2b1;
    --accent: #6d8dff;
    --accent-text: #0b0d12;
    --danger: #ff6b81;
    --ok: #4cc38a;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); margin: 8px 0 0; }

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.bar > h1, .bar > h2 { margin-right: auto; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

/* --- Formulaires et boutons --- */

form.stack { display: grid; gap: 10px; max-width: 360px; }

label { font-size: 0.9rem; color: var(--muted); }

input, select, textarea {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}
select { width: auto; }
textarea { font-family: var(--mono); font-size: 0.9rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, .zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#code {
  font-family: var(--mono);
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
}

button, .button {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-text);
  display: inline-block;
}
button:disabled { opacity: 0.6; cursor: default; }
button.secondary, .button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-weight: 400;
  text-decoration: underline;
}
button.big { font-size: 1.15rem; padding: 14px 24px; }
button.small { font-size: 0.85rem; padding: 5px 10px; }

/* --- Page de dépôt --- */

.zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 220px;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 24px;
  font-size: 1.2rem;
  cursor: text;
}
.zone.over { border-color: var(--accent); }

.sent { list-style: none; padding: 0; margin: 16px 0 0; }
.sent li {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.sent .status { width: 1.2em; text-align: center; }
.sent .ok { color: var(--ok); }
.sent .ko { color: var(--danger); }
.sent .label { overflow-wrap: anywhere; }

/* --- Page de lecture --- */

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}
.dot.on { background: var(--ok); }

.code-display {
  font-family: var(--mono);
  font-size: clamp(2rem, 10vw, 3.2rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 12px 0 4px;
  user-select: all;
}
.code-display + .muted { text-align: center; }

.alert {
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.list { list-style: none; padding: 0; margin: 12px 0 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.list li > span:first-child { margin-right: auto; }

.items { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.item header {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: baseline;
  margin-bottom: 8px;
}
.item .name { font-weight: 600; overflow-wrap: anywhere; margin-right: auto; }
.item pre {
  font-family: var(--mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow: auto;
  background: var(--bg);
  border-radius: 6px;
  padding: 10px;
  margin: 0 0 10px;
}
.item img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  border-radius: 6px;
  margin: 0 0 10px;
  background: var(--bg);
}
.item .actions { display: flex; gap: 8px; flex-wrap: wrap; }

footer { margin-top: 32px; text-align: center; }
