/* ================= Thèmes ================= */
:root,
[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --fill: #f4f4f5;
  --fill-hover: #ececee;
  --text: #09090b;
  --text-2: #52525b;
  --muted: #71717a;
  --border: #e4e4e7;
  --primary: #09090b;
  --on-primary: #ffffff;
  --accent: #ea580c;
  --positive: #16a34a;
  --negative: #dc2626;
  --overlay: rgb(9 9 11 / .32);
  --shadow: 0 16px 48px -12px rgb(9 9 11 / .18), 0 0 0 1px rgb(9 9 11 / .04);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #09090b;
  --bg-elev: #131316;
  --fill: #1c1c20;
  --fill-hover: #26262b;
  --text: #fafafa;
  --text-2: #a1a1aa;
  --muted: #8b8b94;
  --border: #27272a;
  --primary: #fafafa;
  --on-primary: #09090b;
  --accent: #f97316;
  --positive: #4ade80;
  --negative: #f87171;
  --overlay: rgb(0 0 0 / .6);
  --shadow: 0 16px 48px -12px rgb(0 0 0 / .7), 0 0 0 1px rgb(255 255 255 / .06);
  color-scheme: dark;
}

/* ================= Base ================= */
:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: 16px;
  --radius: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 768px) { :root { --gutter: 32px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 6px; }

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}
main.container { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }

.icon {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}

/* ================= Boutons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--text);
  font-size: 14px; font-weight: 500; white-space: nowrap; text-decoration: none;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: background-color .15s, opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { opacity: .88; }
.btn-secondary { background: var(--fill); }
.btn-secondary:hover, .btn-ghost:hover { background: var(--fill-hover); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { color: var(--negative); }
.btn-danger:hover, .btn-danger.confirm { background: color-mix(in srgb, var(--negative) 12%, transparent); }
.btn-sm { height: 36px; padding: 0 12px; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn-block { width: 100%; }
.btn.loading .icon { animation: spin .9s linear infinite; }

/* ================= Hero ================= */
.hero { padding: 36px 0 24px; }
@media (min-width: 768px) { .hero { padding: 64px 0 32px; } }
.hero-title { font-size: clamp(28px, 6vw, 40px); font-weight: 600; letter-spacing: -.035em; line-height: 1.1; }
.hero-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.hero-meta { color: var(--text-2); font-size: 14px; }
.hero-meta strong { color: var(--text); font-weight: 500; }

/* Pastille de valeur masquée par défaut */
.value-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px 0 10px;
  border: 0; border-radius: 999px; background: var(--fill);
  color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.value-chip:hover { background: var(--fill-hover); color: var(--text); }
.value-chip .icon { width: 15px; height: 15px; }
.value-chip .icon-eye-off, .value-chip[aria-pressed="true"] .icon-eye { display: none; }
.value-chip[aria-pressed="true"] .icon-eye-off { display: block; }
.value-amount { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.value-chip[aria-pressed="false"] .value-amount { color: var(--muted); letter-spacing: .12em; }

/* ================= Recherche + scan ================= */
.actions { display: flex; gap: 8px; margin-bottom: 48px; max-width: 680px; }
@media (min-width: 768px) { .actions { margin-bottom: 64px; } }
.search {
  position: relative; flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 4px;
  height: 44px; padding: 0 4px 0 40px;
  background: var(--fill); border-radius: var(--radius);
  transition: background-color .15s, box-shadow .15s;
}
.search:focus-within { background: var(--bg); box-shadow: inset 0 0 0 1px var(--text); }
.search-icon { position: absolute; left: 13px; color: var(--muted); width: 17px; height: 17px; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 15px; }
.search input::placeholder { color: var(--muted); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ================= Collection ================= */
.collection-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px;
  margin-bottom: 20px;
}
.h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.count { color: var(--muted); font-weight: 400; margin-left: 2px; }
.toolbar { display: flex; gap: 8px; }
@media (max-width: 599px) {
  .toolbar { flex: 1 1 100%; }
  .toolbar .filter { flex: 1; }
}
.filter, .select { position: relative; display: flex; align-items: center; }
.filter .icon, .select .icon { position: absolute; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.filter .icon { left: 11px; }
.filter input {
  width: 100%; min-width: 0; height: 36px; padding: 0 12px 0 32px;
  background: var(--fill); border: 0; border-radius: 8px; outline: 0; font-size: 14px;
}
@media (min-width: 600px) { .filter input { width: 180px; } }
.filter input:focus { background: var(--bg); box-shadow: inset 0 0 0 1px var(--text); }
.filter input::placeholder { color: var(--muted); }
.select .icon { right: 10px; }
.select select {
  appearance: none; -webkit-appearance: none; height: 36px; padding: 0 32px 0 12px;
  background: var(--fill); border: 0; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.select select:hover { background: var(--fill-hover); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 16px; }
@media (min-width: 600px)  { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px 20px; } }
@media (min-width: 900px)  { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px 24px; } }
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1500px) { .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.card {
  display: block; width: 100%; min-width: 0; padding: 0; border: 0; background: none;
  text-align: left; cursor: pointer;
  animation: rise .35s var(--ease) both;
}
.card-cover {
  aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--fill);
  margin-bottom: 12px;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease), opacity .2s; }
@media (hover: hover) { .card:hover .card-cover img { transform: scale(1.035); } }
.card-title { font-size: 14px; font-weight: 500; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-artist { font-size: 14px; color: var(--muted); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 6px; }
.card-price { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card-price.none { color: var(--muted); font-weight: 400; }
.card-cond { font-size: 12px; color: var(--muted); }

.skeleton { pointer-events: none; animation: none; }
.skeleton .card-cover, .skeleton .line { background: var(--fill); animation: pulse 1.4s ease-in-out infinite; }
.skeleton .line { height: 10px; border-radius: 4px; margin-top: 8px; width: 80%; }
.skeleton .line + .line { width: 50%; }

.empty { display: grid; justify-items: center; text-align: center; padding: 56px 0 24px; max-width: 340px; margin: 0 auto; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--fill); color: var(--muted); margin-bottom: 18px; }
.empty-icon .icon { width: 24px; height: 24px; }
.empty-title { font-weight: 600; margin-bottom: 6px; }
.empty-text { color: var(--text-2); font-size: 14px; margin-bottom: 22px; }
.no-match { text-align: center; color: var(--muted); padding: 48px 0; font-size: 14px; }

/* ================= Feuilles (dialogs) ================= */
.sheet {
  width: min(520px, calc(100vw - 32px)); max-width: none; max-height: min(86dvh, 860px);
  margin: auto; padding: 0;
  border: 0; border-radius: 16px;
  background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow);
  overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: pop .22s var(--ease); }
.sheet::backdrop { background: var(--overlay); animation: fade .2s; }
.sheet-lg { width: min(900px, calc(100vw - 48px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 12px 6px 20px; }
.sheet-title { font-size: 16px; font-weight: 600; }
.sheet-body { padding: 8px 20px 20px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-scroll { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

@media (max-width: 767px) {
  .sheet, .sheet-lg {
    width: 100vw; max-height: 94dvh; margin: auto 0 0;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet[open] { animation: slide-up .3s var(--ease); }
  .sheet-head { padding: 12px 8px 4px 16px; }
  .sheet-body { padding: 8px 16px 16px; }
}

/* Résultats */
.results-intro { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.results-intro img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.status { font-weight: 500; display: flex; align-items: center; gap: 10px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 2px; }
.hint:empty { display: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--text); animation: spin .7s linear infinite; flex-shrink: 0; }
.field-block { margin-bottom: 20px; }
.label { font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; }

.segmented {
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; padding: 3px;
  background: var(--fill); border-radius: 9px;
}
.segmented button {
  height: 32px; padding: 0; border: 0; border-radius: 6px; background: none;
  color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--bg-elev); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 0 0 1px var(--border); }
.segmented-caption { margin-top: 6px; font-size: 12px; color: var(--muted); }

.results { list-style: none; margin: 0 -8px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.result {
  display: flex; width: 100%; gap: 14px; align-items: center; padding: 8px; text-align: left;
  background: none; border: 0; border-radius: var(--radius); cursor: pointer;
  transition: background-color .12s;
  animation: rise .25s var(--ease) both;
}
.result:hover { background: var(--fill); }
.result:disabled { opacity: .45; cursor: default; }
.result.adding { opacity: 1; background: var(--fill); }
.result img { width: 52px; height: 52px; object-fit: cover; border-radius: 4px; flex-shrink: 0; background: var(--fill); }
.result-main { min-width: 0; flex: 1; }
.result-title { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-meta { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .icon { color: var(--muted); width: 16px; height: 16px; }
.result-skel { height: 68px; margin: 0 8px 4px; border-radius: var(--radius); background: var(--fill); animation: pulse 1.4s ease-in-out infinite; }

/* Détail */
.detail { display: grid; gap: 24px; padding: 20px; position: relative; }
.detail-close { position: absolute; top: 10px; right: 10px; z-index: 1; }
@media (min-width: 768px) {
  .detail { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 36px; padding: 32px; }
  .detail-media { position: sticky; top: 0; align-self: start; }
}
.detail-cover { aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--fill); }
@media (max-width: 767px) { .detail-cover { width: min(280px, 72vw); margin: 8px auto 0; } }
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-tabs { display: flex; justify-content: center; gap: 4px; margin-top: 10px; }
.cover-tabs button { height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer; }
.cover-tabs button[aria-pressed="true"] { background: var(--fill); color: var(--text); }

.detail-info { display: grid; gap: 28px; align-content: start; min-width: 0; }
.detail-artist { color: var(--muted); font-size: 14px; }
.detail-title { font-size: clamp(22px, 3.2vw, 30px); font-weight: 600; letter-spacing: -.025em; line-height: 1.15; margin-top: 2px; padding-right: 36px; }
.detail-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }

.price-label { color: var(--muted); font-size: 13px; }
.price-line { display: flex; align-items: baseline; gap: 10px; margin-top: 2px; flex-wrap: wrap; }
.price-big { font-size: 40px; font-weight: 600; letter-spacing: -.04em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.trend { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.trend.up { color: var(--positive); }
.trend.down { color: var(--negative); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 2px; }
.chart { margin-top: 20px; }
.chart svg { width: 100%; height: 64px; display: block; overflow: visible; }
.chart-caption { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; margin-top: 6px; }
.note { display: flex; gap: 10px; margin-top: 16px; padding: 12px; border-radius: var(--radius); background: var(--fill); color: var(--text-2); font-size: 13px; line-height: 1.45; }
.note .icon { width: 16px; height: 16px; margin-top: 1px; color: var(--muted); }

.specs { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 24px; margin: 0; font-size: 14px; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; overflow-wrap: anywhere; }

textarea {
  width: 100%; min-height: 76px; resize: vertical; padding: 10px 12px;
  background: var(--fill); border: 0; border-radius: var(--radius); font-size: 14px; outline: 0;
}
textarea:focus { background: var(--bg-elev); box-shadow: inset 0 0 0 1px var(--text); }
textarea::placeholder { color: var(--muted); }

.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.detail-actions .spacer { flex: 1; }
.updated { color: var(--muted); font-size: 12px; }
@media (max-width: 479px) {
  .detail-actions .btn-primary { flex: 1 1 100%; }
}

/* ================= Scanner ================= */
.viewfinder { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 12px; background: #000; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .3s; }
.viewfinder.live video { opacity: 1; }
.scan-frame {
  position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%;
  border-radius: 10px; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .5);
  outline: 2px solid #fff; outline-offset: -2px;
  transition: outline-color .2s;
}
.scan-line {
  position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
  animation: scan 1.6s ease-in-out infinite alternate;
}
.viewfinder:not(.live) .scan-line { display: none; }
.viewfinder.found .scan-frame { outline-color: var(--positive); }
.scan-status { text-align: center; color: var(--text-2); font-size: 14px; margin: 14px 0; min-height: 21px; }

/* ================= Toast ================= */
.toast {
  position: fixed; z-index: 100; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--primary); color: var(--on-primary); font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  transform: translateX(-50%); animation: toast-in .25s var(--ease);
}
@media (max-width: 767px) { .toast { bottom: calc(88px + env(safe-area-inset-bottom)); } }

/* ================= Connexion ================= */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); }
.login-card { width: min(340px, 100%); }
.login .brand { margin-bottom: 40px; }
.login h1 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.login p { color: var(--text-2); font-size: 14px; margin: 6px 0 24px; }
.login form { display: grid; gap: 10px; }
.login input {
  height: 44px; padding: 0 14px; border: 0; border-radius: var(--radius); background: var(--fill); outline: 0; font-size: 15px;
}
.login input:focus { background: var(--bg); box-shadow: inset 0 0 0 1px var(--text); }
.login .error { color: var(--negative); font-size: 13px; min-height: 20px; margin: 2px 0 0; }
.shake { animation: shake .35s; }

/* ================= Animations ================= */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.98); } }
@keyframes slide-up { from { transform: translateY(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes scan { from { transform: translateY(-34px); } to { transform: translateY(34px); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.hide-sm { display: inline; }
@media (max-width: 599px) { .hide-sm { display: none; } }
@media (max-width: 379px) { .hide-xs { display: none; } [data-scan].btn-primary:has(.hide-xs) { width: 44px; padding: 0; } }

/* Liseré discret pour que les pochettes claires ne se fondent pas dans le fond */
.card-cover, .detail-cover { position: relative; }
.card-cover::after, .detail-cover::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .07);
}
[data-theme="dark"] .card-cover::after, [data-theme="dark"] .detail-cover::after { box-shadow: inset 0 0 0 1px rgb(255 255 255 / .07); }

/* ================= Synchronisation Discogs ================= */
#syncOpen { position: relative; }
.badge-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.sync-user { margin-bottom: 16px; }
.sync-user strong { color: var(--text); font-weight: 500; }
.sync-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.sync-stats > div { padding: 14px 16px; border-radius: var(--radius); background: var(--fill); }
.sync-num { font-size: 28px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sync-progress { margin-bottom: 16px; }
.progress { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin-bottom: 8px; }
.progress-bar { height: 100%; width: 0; background: var(--text); border-radius: inherit; transition: width .4s var(--ease); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); cursor: pointer; }
.switch-title { display: block; font-size: 14px; font-weight: 500; }
.switch {
  appearance: none; -webkit-appearance: none; flex-shrink: 0; position: relative; margin: 0;
  width: 40px; height: 24px; border-radius: 12px; background: var(--fill-hover); cursor: pointer; transition: background-color .2s;
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform .2s var(--ease); }
.switch:checked { background: var(--text); }
.switch:checked::after { transform: translateX(16px); background: var(--bg); }
.sync-errors { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; }
.sync-errors li { font-size: 13px; color: var(--negative); }
.sync-foot { margin-top: 16px; }
.discogs-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.discogs-status .ok { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.discogs-status .ok .icon { width: 16px; height: 16px; color: var(--positive); }

/* ================= Fourchette & historique ================= */
.block-sub { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.sub-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.sub-title .muted { color: var(--muted); font-weight: 400; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.trio > div { padding: 10px 12px; border-radius: var(--radius); background: var(--fill); min-width: 0; }
.trio .stat-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trio .is-current { background: var(--primary); color: var(--on-primary); }
.trio .is-current .stat-label { color: inherit; opacity: .7; }
.cond-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.cond { display: grid; gap: 1px; padding: 6px 8px; border-radius: 8px; box-shadow: inset 0 0 0 1px var(--border); min-width: 0; }
.cond span { font-size: 11px; color: var(--muted); }
.cond strong { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cond.current { box-shadow: inset 0 0 0 1.5px var(--text); }

/* ================= Statistiques ================= */
.stats-body { display: grid; gap: 28px; }
@media (min-width: 768px) { .stats-body { padding: 8px 32px 32px; } }
.st-total { font-size: clamp(44px, 9vw, 56px); font-weight: 600; letter-spacing: -.04em; line-height: 1.05; margin: 2px 0 4px; }
.st-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 640px) { .st-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.st-tile { padding: 12px 14px; border-radius: var(--radius); background: var(--fill); min-width: 0; }
.st-tile-value { font-size: 20px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; }
.st-block .sub-title { margin-bottom: 4px; }
.st-block > .hint { margin-bottom: 14px; }

.evo { position: relative; width: 100%; }
.evo svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.evo svg:focus-visible { outline: 2px solid var(--text); outline-offset: 4px; border-radius: 4px; }
.evo .grid-line { stroke: var(--border); stroke-width: 1; }
.evo .axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.evo .end-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.evo .series { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.evo .end-dot, .evo .hover-dot { fill: var(--text); stroke: var(--bg-elev); stroke-width: 2; }
.evo .crosshair { stroke: var(--muted); stroke-width: 1; }
.evo-empty { padding: 20px; border-radius: var(--radius); background: var(--fill); color: var(--text-2); font-size: 14px; }

.st-table summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 12px; width: fit-content; }
.st-table table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.st-table th, .st-table td { text-align: left; padding: 6px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.st-table th { color: var(--muted); font-weight: 500; }
.st-table td:not(:first-child), .st-table th:not(:first-child) { text-align: right; }

.top-list { list-style: none; margin: 0 -8px; padding: 0; display: grid; }
.top-row {
  display: grid; grid-template-columns: 20px 44px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  width: 100%; padding: 8px; border: 0; border-radius: var(--radius); background: none; text-align: left; cursor: pointer;
}
.top-row:hover, .top-row:focus-visible { background: var(--fill); }
.top-rank { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.top-row img { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; background: var(--fill); }
.top-main { min-width: 0; display: grid; gap: 1px; }
.top-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-artist { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-bar { display: block; height: 6px; margin-top: 6px; }
.top-bar span { display: block; height: 100%; min-width: 2px; background: var(--text); border-radius: 0 3px 3px 0; }
.top-value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

.viz-tip {
  position: fixed; z-index: 5; pointer-events: none; max-width: 240px;
  padding: 8px 10px; border-radius: 8px; background: var(--primary); color: var(--on-primary);
  font-size: 12px; line-height: 1.4; box-shadow: var(--shadow);
}
.viz-tip strong { display: block; font-size: 14px; font-weight: 600; }

/* ===================================================================
   Coquille d'app : barre du haut, écrans, barre d'onglets, sensations natives
   =================================================================== */
:root { --appbar-h: 52px; --tabbar-h: 58px; }
html { touch-action: manipulation; }
body { overscroll-behavior-y: none; }
button, a, label, .card, .tabbar, .appbar, .row, .segmented { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
img { -webkit-user-drag: none; -webkit-touch-callout: none; }
/* iOS zoome sur les champs < 16px : on l'évite sur mobile */
@media (max-width: 767px) { input, select, textarea { font-size: 16px !important; } }

/* ---------- Barre du haut ---------- */
.appbar {
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
  border-bottom: .5px solid transparent;
  transition: border-color .2s;
}
.appbar.compact { border-bottom-color: var(--border); }
.appbar-inner { position: relative; display: flex; align-items: center; gap: 24px; height: var(--appbar-h); }
.appbar-title {
  position: absolute; left: 50%; transform: translate(-50%, 4px);
  font-size: 16px; font-weight: 600; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  white-space: nowrap;
}
.appbar.compact .appbar-title { opacity: 1; transform: translate(-50%, 0); }
.topnav { display: flex; gap: 2px; margin-right: auto; }
.topnav a {
  position: relative; display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: 8px;
  color: var(--text-2); font-size: 14px; font-weight: 500; text-decoration: none; transition: background-color .15s, color .15s;
}
.topnav a:hover { color: var(--text); background: var(--fill); }
.topnav a[aria-current="page"] { color: var(--text); background: var(--fill); }
.topnav .badge-dot { position: static; margin-left: 6px; }

@media (max-width: 767px) {
  .appbar .brand, .topnav, .topnav-scan { display: none; }
  .appbar-inner { justify-content: center; height: 44px; }
  :root { --appbar-h: 44px; }
}
@media (min-width: 768px) {
  .appbar-title { display: none; }
  .appbar { border-bottom-color: var(--border); }
}

/* ---------- Écrans ---------- */
main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 32px); }
@media (min-width: 768px) { main { padding-bottom: 80px; } }
.view { animation: view-in .28s var(--ease); }
.view[hidden] { display: none; }
.container.narrow { max-width: 760px; }
.view-head { padding: 8px 0 20px; }
@media (min-width: 768px) { .view-head { padding: 48px 0 28px; } }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
@media (min-width: 768px) { .large-title { font-size: 40px; font-weight: 600; } }
.view-head .hero-row, .view-head .hero-meta { margin-top: 8px; }
#view-collection .search { margin-bottom: 32px; max-width: 680px; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Barre d'onglets (mobile) ---------- */
.tabbar {
  position: fixed; z-index: 15; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: start;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 6px max(8px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
  border-top: .5px solid var(--border);
}
@media (min-width: 768px) { .tabbar { display: none; } }
.tabbar a {
  display: grid; justify-items: center; gap: 3px; padding-top: 2px;
  color: var(--muted); font-size: 10.5px; font-weight: 500; text-decoration: none; transition: color .15s, transform .1s;
}
.tabbar a .icon { width: 24px; height: 24px; stroke-width: 1.6; }
.tabbar a[aria-current="page"] { color: var(--text); }
.tabbar a[aria-current="page"] .icon { stroke-width: 2.1; }
.tabbar a:active { transform: scale(.92); }
.tab-icon { position: relative; display: block; height: 24px; }
.tab-icon .badge-dot { top: -1px; right: -4px; }
.tab-scan {
  justify-self: center; display: grid; place-items: center;
  width: 54px; height: 54px; margin-top: -16px; border: 0; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); cursor: pointer;
  box-shadow: 0 6px 20px -6px rgb(0 0 0 / .45), 0 0 0 4px var(--bg);
  transition: transform .12s;
}
.tab-scan .icon { width: 24px; height: 24px; }
.tab-scan:active { transform: scale(.92); }
.toast { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px) !important; }
@media (min-width: 768px) { .toast { bottom: 24px !important; } }

/* ---------- Listes façon Réglages iOS ---------- */
.group-title { margin: 28px 0 8px 16px; font-size: 13px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.list { border-radius: 12px; background: var(--fill); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 10px 16px;
  border: 0; background: none; text-align: left; text-decoration: none; color: var(--text); font-size: 15px; cursor: pointer;
  position: relative;
}
div.row { cursor: default; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 56px; right: 0; border-top: .5px solid var(--border); }
button.row:active, a.row:active { background: var(--fill-hover); }
.row:disabled { cursor: default; }
.row-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--bg-elev); color: var(--text-2); flex-shrink: 0; }
.row-icon .icon { width: 16px; height: 16px; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.row-sub { font-size: 13px; color: var(--muted); }
.row-value { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.row-chevron { color: var(--muted); width: 16px; height: 16px; }
.row-danger { color: var(--negative); }
.row-danger .row-icon { color: var(--negative); }
.row.loading .row-icon .icon { animation: spin .9s linear infinite; }
.list-foot { margin: 10px 16px 0; font-size: 13px; color: var(--muted); }
.list-foot.center { text-align: center; margin-top: 32px; }
#view-discogs .sync-stats { margin-bottom: 16px; }

/* ---------- Feuilles : poignée et glissement pour fermer ---------- */
.sheet-grab { display: none; }
@media (max-width: 767px) {
  .sheet-grab { display: flex; justify-content: center; padding: 8px 0 2px; touch-action: none; cursor: grab; flex-shrink: 0; }
  .sheet-head[data-drag] { touch-action: none; }
  .sheet .sheet-handle { display: block; width: 38px; height: 5px; margin: 0; border-radius: 3px; background: var(--border-strong, var(--border)); }
  .sheet.dragging { transition: none !important; animation: none !important; }
  .sheet.settling { transition: transform .25s var(--ease); }
  #detailDlg .detail-close { top: 4px; }
}

/* ---------- Appui (tactile) plutôt que survol ---------- */
.card:active .card-cover img { transform: scale(.97); transition-duration: .1s; }
.result:active, .top-row:active { background: var(--fill-hover); }
@media (hover: none) {
  .btn-ghost:hover, .btn-secondary:hover, .select select:hover, .value-chip:hover, .result:hover, .top-row:hover, .topnav a:hover { background: inherit; }
  .btn-secondary:hover { background: var(--fill); }
  .value-chip:hover, .select select:hover { background: var(--fill); }
  .btn-primary:hover { opacity: 1; }
  .btn-primary:active { opacity: .85; }
}

/* Logo (barre du haut, connexion) */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -.01em; text-decoration: none; color: var(--text); }
.brand-dot { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle, var(--accent) 0 32%, var(--text) 34%); }
