:root {
  --bg: #f3f7fb;
  --surface: #ffffff;
  --text: #0f1e2e;
  --muted: #5b6b7d;
  --line: #dde6ef;
  --accent: #0b5cab;
  --accent-soft: #e3effb;
  --ok: #137a4b;
  --ok-soft: #e2f4ea;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 30, 46, .06), 0 4px 16px rgba(15, 30, 46, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1724; --surface: #132233; --text: #e8f0f8; --muted: #93a6ba; --line: #22364b;
    --accent: #5fa8f5; --accent-soft: #17324f; --ok: #5cd69c; --ok-soft: #133528;
    --warn: #f2c260; --warn-soft: #3a2e12; --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 18px; }
h2 { font-size: 20px; margin-bottom: 4px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); margin: 0; font-size: 14px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; gap: 10px; align-items: center; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 8px; border-radius: 10px; }

main { padding: 4px 16px 16px; max-width: 640px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.search { display: flex; gap: 8px; margin: 8px 0 12px; }
input, select {
  flex: 1; min-width: 0; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
button, .ghost { font: inherit; cursor: pointer; }
.primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 12px;
  padding: 0 16px; font-weight: 600; min-height: 46px;
}
@media (prefers-color-scheme: dark) { .primary { color: #08131f; } }
.ghost {
  display: block; text-align: center; text-decoration: none;
  background: transparent; color: var(--accent); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; margin-top: 10px;
}
.wide { width: 100%; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 14px;
}
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }

.status { margin: 14px 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.status.err { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 14px; margin: 12px 0;
}
.card-head { display: flex; gap: 12px; align-items: center; }
.date {
  flex: none; width: 52px; height: 56px; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
}
.date .d { font-size: 22px; font-weight: 700; }
.date .m { font-size: 12px; text-transform: uppercase; margin-top: 3px; }
.who { margin: 12px 0 8px; font-size: 14px; }
.who b { font-weight: 600; }
.slot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--ok-soft); color: var(--ok); border-radius: 12px; padding: 10px 12px; margin-top: 6px;
}
.slot .t { font-weight: 700; font-variant-numeric: tabular-nums; }
.slot .j { font-size: 13px; opacity: .9; }
.slot a { color: inherit; font-size: 13px; white-space: nowrap; }
.slot.pending { background: var(--warn-soft); color: var(--warn); }
.links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.links a { color: var(--accent); font-size: 14px; text-decoration: none; }

.watch-list { list-style: none; padding: 0; margin: 14px 0; }
.watch-list li {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.watch-list button { background: none; border: 0; color: var(--muted); font-size: 14px; }
.watch-list .go { color: var(--accent); font-weight: 600; text-align: left; padding: 0; font-size: 16px; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 5; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px;
}
.tab.on { color: var(--accent); font-weight: 600; }

dialog {
  border: 0; border-radius: 20px; padding: 20px; width: min(92vw, 420px);
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog label { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; font-size: 14px; color: var(--muted); }
.row { display: flex; gap: 10px; justify-content: flex-end; }
.row .ghost { margin: 0; }

.skeleton { height: 140px; border-radius: var(--radius); margin: 12px 0;
  background: linear-gradient(90deg, var(--surface), var(--line), var(--surface)); background-size: 200% 100%;
  animation: sh 1.2s infinite linear; }
@keyframes sh { to { background-position: -200% 0; } }

/* résultats */
.podium { margin-top: 10px; border-radius: 12px; padding: 12px; background: var(--accent-soft); color: var(--text); }
.podium.p1 { background: #fbf1cc; } .podium.p2 { background: #eceff3; } .podium.p3 { background: #f6e3d3; }
@media (prefers-color-scheme: dark) {
  .podium.p1 { background: #3b3215; } .podium.p2 { background: #263241; } .podium.p3 { background: #3a2a1d; }
}
.podium-head { display: flex; align-items: center; gap: 14px; }
.rank { flex: none; white-space: nowrap; font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.rank sup { font-size: 15px; font-weight: 700; }
.rank small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.pts { font-weight: 700; font-size: 17px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; margin-top: 10px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--text) 12%, transparent); }
.seg span:first-child { font-weight: 600; }
.podium a { display: inline-block; margin-top: 10px; font-size: 14px; color: var(--accent); text-decoration: none; }
.podium.order .rank { font-size: 26px; }

/* détails dans l'appli */
.slot .est { font-size: 13px; margin-top: 2px; }
.more { margin-top: 8px; }
.det { border-top: 1px solid var(--line); }
.det summary, .sources summary {
  cursor: pointer; list-style: none; padding: 11px 2px; font-size: 14px; font-weight: 600; color: var(--accent);
  display: flex; justify-content: space-between; align-items: center;
}
.det summary::-webkit-details-marker, .sources summary::-webkit-details-marker { display: none; }
.det summary::after, .sources summary::after { content: "›"; font-size: 18px; transition: transform .15s; }
.det[open] summary::after, .sources[open] summary::after { transform: rotate(90deg); }
.rows { list-style: none; margin: 0 0 10px; padding: 0; }
.rows li {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 2px 10px; align-items: center;
  padding: 8px 10px; border-radius: 10px; font-size: 14px; font-variant-numeric: tabular-nums;
}
.rows li:nth-child(odd) { background: color-mix(in srgb, var(--line) 35%, transparent); }
.rows li.me { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.rows .n { font-weight: 700; color: var(--muted); }
.rows li.me .n { color: inherit; }
.rows .x small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.rows .x.nw { white-space: nowrap; }
.rows .r small { display: block; font-size: 11px; font-weight: 500; }
.rows .r { text-align: right; white-space: nowrap; color: var(--muted); font-size: 13px; }
.rows li.me .r { color: inherit; }
.rows .grp { grid-column: 1 / -1; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 4px; }
.rows li:has(.x:only-child) { grid-template-columns: 1fr; }
.sources { border-top: 1px solid var(--line); }
.sources summary { color: var(--muted); font-weight: 500; }
.sources .links { margin: 0 0 6px; }
