:root {
  --bg: #f7f3ee;
  --card: #ffffff;
  --text: #1f1b16;
  --muted: #6f665c;
  --line: #e8e0d6;
  --accent: #b3261e;
  --accent-ink: #ffffff;
  --green: #1f5f3f;
  --price-bg: #fdf0ee;
  --shadow: 0 1px 2px rgba(40, 25, 10, 0.06), 0 6px 20px rgba(40, 25, 10, 0.06);
  --radius: 18px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120f;
    --card: #211d19;
    --text: #f3ede6;
    --muted: #a99f93;
    --line: #342e28;
    --accent: #e0574d;
    --green: #6fbf8f;
    --price-bg: #3a1f1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* En-tête */
.hero { padding: calc(28px + env(safe-area-inset-top)) 0 18px; text-align: center; }
.hero .badge { font-size: 40px; line-height: 1; }
.hero h1 { margin: 10px 0 4px; font-size: 28px; letter-spacing: -0.02em; font-weight: 750; }
.hero p { margin: 0; color: var(--muted); font-size: 15px; }

/* Grille de cartes */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; padding: 8px 0 40px; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card .media {
  aspect-ratio: 4 / 3;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}
.card .media img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .media .ph { font-size: 64px; opacity: 0.85; }
.card .body { padding: 16px 16px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card .meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .site { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.card .price {
  font-weight: 700; font-size: 15px; color: var(--accent);
  background: var(--price-bg); padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.card h2 { margin: 0; font-size: 18px; line-height: 1.3; font-weight: 650; }
.card .desc {
  margin: 0; color: var(--muted); font-size: 14.5px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.card .desc.open { -webkit-line-clamp: unset; }
.card .more { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; text-decoration: underline; align-self: flex-start; cursor: pointer; }
.card .note { font-size: 14px; color: var(--green); margin: 0; }
.card .spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 0;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: transform 0.08s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 12px; }
.btn.danger { background: transparent; color: var(--accent); border: 1px solid var(--line); }

.empty, .loading { text-align: center; color: var(--muted); padding: 40px 0; }
footer { text-align: center; color: var(--muted); font-size: 13px; padding: 0 0 32px; }
footer a { color: var(--muted); }

/* ---------- Admin ---------- */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 18px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }
input[type=text], input[type=url], input[type=password], textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.row .btn { flex: 0 0 auto; }
.msg { font-size: 14px; margin: 10px 0 0; min-height: 1em; }
.msg.err { color: var(--accent); }
.msg.ok { color: var(--green); }
.preview { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.preview img { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.list .item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.list .item:first-child { border-top: 0; }
.list .thumb { width: 56px; height: 56px; flex: 0 0 56px; border-radius: 10px; background: #fff; border: 1px solid var(--line); object-fit: contain; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.list .info { flex: 1; min-width: 0; }
.list .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.list .info span { font-size: 13px; color: var(--muted); }
.list .actions { display: flex; gap: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 16px; cursor: pointer; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: calc(16px + env(safe-area-inset-top)) 0 12px; }
.topbar h1 { font-size: 22px; margin: 0; }
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100% - 24px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog form { padding: 16px; }
.hidden { display: none !important; }
