:root {
  --primary: #C1121F;
  --secondary: #D4A017;
  --bg: #F5F5F5;
  --surface: #ffffff;
  --text: #1b1b1b;
  --muted: #6b6b6b;
  --danger: #B3001B;
  --radius: 10px;
  --container: #fbe9ea;
  --oncontainer: #4a0f14;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #E63946;
    --secondary: #F1C40F;
    --bg: #121212;
    --surface: #1d1d1d;
    --text: #f0f0f0;
    --muted: #a0a0a0;
    --danger: #ff6b6b;
    --container: #3a1a1c;
    --oncontainer: #ffd9db;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 700; font-size: 1.2rem; }
.who { display: flex; align-items: center; gap: 10px; }
.hidden { display: none !important; }

main { padding: 16px; padding-bottom: 88px; max-width: 1100px; margin: 0 auto; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.card.narrow { max-width: 420px; margin: 40px auto; }
.card h1 { margin-top: 0; color: var(--primary); }
.card h2 { margin-top: 0; color: var(--primary); }

label { display: block; margin: 12px 0; font-size: 0.9rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

.btn {
  padding: 10px 18px;
  border-radius: 20px;
  border: none;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { opacity: 0.9; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.danger { background: var(--danger); color: white; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { padding: 6px 12px; font-size: 0.85rem; }

.error { color: var(--danger); font-weight: 600; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 0.8rem; }
.mono { font-family: ui-monospace, monospace; word-break: break-all; }

/* ── navigation bottom bar (identité Android : NavigationBar Material3) ── */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  z-index: 30;
}
.bottom-nav .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}
.bottom-nav .tab .icon { font-size: 1.25rem; line-height: 1; }
.bottom-nav .tab.active { color: var(--primary); }

.fab {
  position: fixed;
  right: 20px;
  bottom: 76px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.6rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  cursor: pointer;
  z-index: 25;
}

/* ── chips / filtres ── */
.chiprow {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 10px;
}
.chip {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip.selected { background: var(--primary); color: white; }

.filters-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 10px;
}
.filters-row select {
  width: auto;
  flex: 0 0 auto;
  min-width: 110px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input[type="search"] { flex: 1; min-width: 160px; }
.toolbar select { width: auto; }

.collection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.collection-header h2 { margin: 0; }

.selection-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--container);
  color: var(--oncontainer);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
}
.selection-bar .count { font-weight: 700; flex: 1; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.record-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  cursor: pointer;
  border-left: 4px solid var(--secondary);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  position: relative;
}
.record-card.selected { outline: 2px solid var(--primary); }
.record-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.record-card .cover {
  width: 56px; height: 56px; border-radius: 6px; object-fit: cover;
  background: var(--bg); flex: 0 0 auto;
}
.record-card .cover.placeholder {
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.record-card .body { min-width: 0; flex: 1; }
.record-card .artist { font-weight: 700; color: var(--primary); }
.record-card .title { margin: 2px 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-card .meta { font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-card .select-check {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px;
}
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 6px;
  background: var(--secondary);
  color: #1b1b1b;
}

dialog { border: none; border-radius: var(--radius); padding: 0; max-width: 600px; width: 92%; }
dialog .card { box-shadow: none; }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.formgrid .span2 { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.dialog-actions .btn.danger { margin-right: auto; }

.discogs { display: flex; gap: 8px; margin: 10px 0; }
.discogs-results {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-bottom: 10px;
}
.discogs-result {
  display: flex;
  gap: 10px;
  padding: 8px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  align-items: center;
}
.discogs-result:hover { background: rgba(193,18,31,0.08); }
.discogs-result img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }

.recovery { columns: 2; font-family: ui-monospace, monospace; }

.qr { display: flex; justify-content: center; margin: 16px 0; }
.qr img { width: 180px; height: 180px; }

/* ── pochette dans le détail/fiche ── */
.cover-detail {
  width: 100%; max-width: 220px; aspect-ratio: 1; object-fit: cover;
  border-radius: 10px; margin: 0 auto 12px; display: block;
}
.cover-picker {
  display: flex; gap: 8px; align-items: center; margin: 10px 0;
}
.cover-picker img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }

/* ── duplicate warning ── */
.warning-box {
  background: var(--container); color: var(--oncontainer);
  border-radius: 8px; padding: 10px 12px; font-size: 0.85rem; margin: 10px 0;
}

/* ── scan EAN ── */
.scan-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#scanVideo { width: 100%; max-width: 420px; border-radius: 10px; background: #000; }
.scan-status { font-weight: 600; }

/* ── stats ── */
.stat-cards { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-card { flex: 1; min-width: 100px; background: var(--surface); border-radius: var(--radius);
  padding: 14px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.stat-card .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 0.78rem; color: var(--muted); }
.agg-card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.agg-card h3 { margin: 0 0 10px; font-size: 1rem; }
.agg-row { margin-bottom: 8px; }
.agg-row .agg-top { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 3px; }
.agg-bar-bg { background: var(--bg); border-radius: 4px; height: 6px; overflow: hidden; }
.agg-bar-fill { background: var(--primary); height: 100%; }

/* ── revente / alertes ── */
.price-refresh-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.resale-row {
  display: flex; gap: 10px; align-items: center; background: var(--surface); border-radius: var(--radius);
  padding: 10px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.resale-row .cover { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--bg); flex: 0 0 auto; }
.resale-row .body { flex: 1; min-width: 0; }
.resale-row .price { font-weight: 700; text-align: right; white-space: nowrap; }
.alert-card { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.alert-card .prices-row { display: flex; gap: 14px; font-size: 0.85rem; margin: 6px 0; flex-wrap: wrap; }
.alert-badge {
  display: inline-block; font-size: 0.78rem; font-weight: 700; padding: 3px 10px; border-radius: 8px;
  background: var(--bg); color: var(--muted);
}
.alert-badge.under-budget { background: var(--container); color: var(--oncontainer); }
.alert-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
