:root {
  --bg: #f3efe6; --paper: #fbf9f4; --ink: #1c1915; --muted: #75695c; --line: #e2dbcd;
  --accent: #c8431f; --accent-ink: #fff; --soft: #ece5d6; --warn: #9a5a00; --warn-bg: #fbecd2;
  --sel: #fbe3d9; --term-s: #d9e7d4; --term-m: #f1e3c4; --term-l: #f2d3c6;
  --serif: "Fraunces", Georgia, serif; --sans: "Inter Tight", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100e; --paper: #1b1916; --ink: #ede7dc; --muted: #9c9285; --line: #2e2a25;
    --accent: #e26a45; --accent-ink: #160f0b; --soft: #26221d; --warn: #e8a64a; --warn-bg: #2d2214;
    --sel: #33201a; --term-s: #23331f; --term-m: #3a3019; --term-l: #3d241b;
  }
}
:root[data-theme="dark"] {
  --bg: #12100e; --paper: #1b1916; --ink: #ede7dc; --muted: #9c9285; --line: #2e2a25;
  --accent: #e26a45; --accent-ink: #160f0b; --soft: #26221d; --warn: #e8a64a; --warn-bg: #2d2214;
  --sel: #33201a; --term-s: #23331f; --term-m: #3a3019; --term-l: #3d241b;
}

* { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: inherit; text-underline-offset: 3px }
a:hover { color: var(--accent) }
button { font: inherit; color: inherit }
code { font-size: .9em; background: var(--soft); padding: 1px 5px; border-radius: 4px }
.muted, .fine { color: var(--muted) }
.fine { font-size: 13px }
.center { text-align: center }
h1, h2, h3 { font-family: var(--serif); font-weight: 650; letter-spacing: -.01em; margin: 0 }

/* ---------------------------------------------------------------- boutons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; text-decoration: none;
  padding: 9px 16px; border-radius: 99px; border: 1px solid var(--line); background: var(--paper);
  font-weight: 500; transition: border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--ink); color: var(--ink) }
.btn:active { transform: scale(.98) }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
.btn.primary:hover { filter: brightness(1.07); color: var(--accent-ink) }
.btn[disabled] { opacity: .45; pointer-events: none }
.btn.big { padding: 13px 26px; font-size: 16px }
.btn input[type=file] { display: none }
.link { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; color: var(--muted) }
.link:hover { color: var(--accent) }

/* ---------------------------------------------------------------- accueil */
.landing { min-height: 100vh; display: grid; place-content: center; justify-items: center; text-align: center; padding: 32px 16px; gap: 18px }
.landing h1 { font-size: clamp(40px, 9vw, 68px); line-height: 1 }
.lede { max-width: 30em; font-size: 18px; color: var(--muted); margin: 0 }
.record { width: 150px; aspect-ratio: 1; border-radius: 50%; position: relative; margin-bottom: 8px;
  background: repeating-radial-gradient(circle at 50%, #1a1715 0 2px, #262220 2px 4px); box-shadow: 0 18px 40px -18px rgba(0,0,0,.6);
  animation: spin 6s linear infinite }
.record span { position: absolute; inset: 34%; border-radius: 50%; background: var(--accent) }
.record span::after { content: ""; position: absolute; inset: 44%; border-radius: 50%; background: var(--bg) }
@keyframes spin { to { transform: rotate(360deg) } }
@media (prefers-reduced-motion: reduce) { .record { animation: none } }

/* ---------------------------------------------------------------- structure */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; max-width: 1080px; margin: 0 auto }
.brand { display: flex; align-items: center; gap: 10px; font: 650 20px var(--serif); text-decoration: none }
.brand .dot { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle, var(--accent) 0 28%, #1a1715 29% 100%); box-shadow: inset 0 0 0 4px #2a2522 }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px }
.who img { width: 28px; height: 28px; border-radius: 50% }
.who form { margin: 0 }
.btn.small { padding: 5px 12px; font-size: 13px }
.dg { display: flex; align-items: center; gap: 6px; font-size: 13px }
.pill { background: var(--soft); border-radius: 99px; padding: 3px 10px }
.wrap { max-width: 1080px; margin: 0 auto; padding: 8px 16px 140px }
.notice { border-radius: 10px; padding: 10px 14px; margin: 12px 0; background: var(--soft) }
.notice.warn { background: var(--warn-bg); color: var(--warn) }

/* ---------------------------------------------------------------- métriques */
.metrics { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin-top: 8px }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px }
.kpis b { display: block; font: 650 clamp(24px, 4vw, 36px)/1.1 var(--serif); font-variant-numeric: tabular-nums }
.kpis span { color: var(--muted); font-size: 13px }
.years { display: flex; align-items: flex-end; gap: 6px; height: 110px; margin: 22px 0 6px }
.year { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; text-decoration: none }
.year .bar { width: 100%; max-width: 44px; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--line); transition: background .15s }
.year:hover .bar, .year.on .bar { background: var(--accent) }
.year .y { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums }
.empty-metrics h2 { font-size: 22px; margin-bottom: 6px }
.empty-metrics p { margin: 0 0 4px; max-width: 46em; color: var(--muted) }
.upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px }
.job { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 14px }
.progress { flex: 0 0 180px; height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .4s }
.progress.indeterminate span { width: 30% !important; animation: slide 1.2s ease-in-out infinite }
@keyframes slide { from { transform: translateX(-100%) } to { transform: translateX(340%) } }

/* ---------------------------------------------------------------- onglets & liste */
.tabs { display: flex; align-items: center; gap: 4px; margin: 28px 0 10px; border-bottom: 1px solid var(--line); overflow-x: auto }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap }
.tabs a.on { color: var(--ink); border-color: var(--accent); font-weight: 600 }
.tabs select { margin-left: auto; font: inherit; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px }
.tabs .refresh { margin-left: auto; font-size: 18px }
.toolbar { display: flex; gap: 14px; align-items: center; margin: 6px 0 8px; font-size: 13px }
.toolbar .fine { margin-right: auto }

.albums { list-style: none; margin: 0; padding: 0 }
.album {
  display: grid; grid-template-columns: 2.2em 48px minmax(0, 1fr) auto 22px; align-items: center; gap: 14px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer; user-select: none; transition: background .12s;
}
.album:hover { background: var(--soft) }
.album:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px }
.album.sel { background: var(--sel) }
.album .rank { font: 500 14px var(--sans); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums }
.cover { width: 48px; height: 48px; border-radius: 4px; object-fit: cover; background: var(--soft); display: block }
.cover.none { background: radial-gradient(circle, var(--line) 0 18%, var(--soft) 19%) }
.cover.lg { width: 88px; height: 88px; border-radius: 6px }
.title { min-width: 0 }
.title b, .title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.title b { font-weight: 600 }
.title span { color: var(--muted); font-size: 14px }
.stats { display: flex; gap: 16px; font-size: 13px; color: var(--muted); align-items: center; white-space: nowrap }
.stats b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums }
.term { font-style: normal; font-size: 11px; padding: 2px 7px; border-radius: 99px; margin-left: 4px; color: var(--ink) }
.term.short_term { background: var(--term-s) } .term.medium_term { background: var(--term-m) } .term.long_term { background: var(--term-l) }
.check { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line); transition: all .12s }
.album.sel .check { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 4px var(--sel) }

.history { margin-top: 40px }
.history h2 { font-size: 20px; margin-bottom: 8px }
.history ul { list-style: none; padding: 0; margin: 0 }
.history a { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none }
.history a span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.history a .muted { flex: none; font-size: 13px }

/* ---------------------------------------------------------------- barre de sélection */
.tray {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 20px; width: max-content; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--bg); border-radius: 99px; box-shadow: 0 16px 40px -12px rgba(0,0,0,.45);
}
.tray[hidden] { display: none }
.tray .count b { font-variant-numeric: tabular-nums }
.tray .budget { font-size: 14px; display: flex; align-items: center; gap: 6px; opacity: .85 }
.tray input { width: 64px; font: inherit; padding: 5px 8px; border-radius: 8px; border: 0; background: rgba(255,255,255,.12); color: inherit }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tray input { background: rgba(0,0,0,.1) } }
.tray .limit { color: inherit; opacity: .6 }

/* ---------------------------------------------------------------- résultats */
.back { display: inline-block; margin: 6px 0 14px; font-size: 14px; color: var(--muted); text-decoration: none }
.page-title { font-size: clamp(28px, 5vw, 40px) }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-top: 18px }
.card > header { display: flex; gap: 16px; align-items: center }
.card h3 { font-size: 22px }
.picks { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin-top: 16px }
.pick { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px }
.pick .k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted) }
.pick .price { font: 650 26px/1.1 var(--serif); color: var(--accent); text-decoration: none }
.pick .what { font-size: 14px }
.pick .meta { font-size: 12px; color: var(--muted); margin-top: auto }
.pick.empty { justify-content: center }
.meter { position: relative; height: 18px; border-radius: 99px; background: var(--soft); overflow: hidden }
.meter span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--line), var(--accent)) }
.meter b { position: absolute; right: 8px; top: 0; font-size: 12px; line-height: 18px }
.review { margin: 2px 0 0; font-size: 13.5px }
.issues { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--warn) }
.tag { display: inline-block; font-style: normal; background: var(--soft); border-radius: 99px; padding: 1px 8px; font-size: 12px; margin: 2px 4px 0 0 }
.tag.warn { background: var(--warn-bg); color: var(--warn) }
details { margin-top: 14px }
summary { cursor: pointer; color: var(--muted); font-size: 14px }
.scroll { overflow-x: auto }
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap }
th { font-weight: 500; color: var(--muted) }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums }
.tags-cell { white-space: normal; min-width: 160px; color: var(--muted) }
.method { margin-top: 36px; font-size: 14px; color: var(--muted) }
.method ul { padding-left: 18px }
.pending { margin-top: 24px }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 680px) {
  .kpis { grid-template-columns: repeat(2, 1fr) }
  .album { grid-template-columns: 1.6em 44px minmax(0, 1fr) 20px; gap: 10px }
  .album .stats { grid-column: 3; grid-row: 2; margin-top: -6px }
  .album .check { grid-column: 4; grid-row: 1 }
  .hide-sm { display: none }
  .cover { width: 44px; height: 44px }
  .tray { gap: 10px; padding-left: 16px }
  .tray .budget input { width: 52px }
  .tray .limit, .tray .budget > :not(input) { display: none }
  .progress { flex-basis: 110px }
  .who > span, .dg .link { display: none }
}
