:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #12151b;
  --muted: #5d6573;
  --line: #dfe3e8;
  --accent: #0F5132;
  --accent-soft: #DCEDE2;
  --on-accent: #ffffff;
  --ok: #1b8a4b;
  --danger: #C62828;
  --radius: 14px;
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #171b22;
    --surface-2: #20252e;
    --text: #eef1f5;
    --muted: #98a1b0;
    --line: #2a303a;
    --accent: #3DBE7A;
    --accent-soft: #12301F;
    --on-accent: #05140B;
    --ok: #3ccf7f;
    --danger: #FF6B5E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #171b22; --surface-2: #20252e; --text: #eef1f5; --muted: #98a1b0;
  --line: #2a303a; --accent: #3DBE7A; --accent-soft: #12301F; --on-accent: #05140B; --ok: #3ccf7f; --danger: #FF6B5E;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: inherit; }
button { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.top h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; flex: 1; }
.tv.sim { background: var(--accent-soft); color: var(--accent); }
.choices.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 4px; padding: 4px 16px; scrollbar-width: none; }
.choices.scroll .choice { flex: none; }
.sources { display: grid; gap: 8px; }
.source { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.source .grow { flex: 1; }
.dot.err { background: var(--danger); }
.err-text { color: var(--danger); margin: -4px 0 4px 20px; }
#view { padding: 0 16px; max-width: 640px; margin: 0 auto; }

/* Onglets */
.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; font-size: 11px; font-weight: 600; color: var(--muted);
}
.tabs a span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabs a.active { color: var(--accent); }
.tabs a.active span { filter: none; opacity: 1; }

/* Blocs */
.section-title {
  margin: 22px 2px 8px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.list { display: grid; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* Segmented control */
.segment {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface-2); border-radius: 10px; padding: 3px; margin: 4px 0 6px;
}
.segment button {
  border: 0; background: none; padding: 7px 10px; border-radius: 8px;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.segment button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }

/* Événement */
.event { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; text-decoration: none; }
.event .time { text-align: center; }
.event .time b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.event .time small { font-size: 11px; color: var(--muted); }
.event .title { font-weight: 650; }
.event .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.event .bell { font-size: 16px; }
.event .bell.off { opacity: .2; filter: grayscale(1); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tv {
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text); text-decoration: none;
}

/* Choix (chips sélectionnables) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 12px; border-radius: 99px; font-size: 14px; cursor: pointer;
}
.choice[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }

.sport-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sport-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 8px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.sport-tile span { font-size: 30px; }

.search {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.result { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.result:last-child { border-bottom: 0; }
.result .grow { flex: 1; }

.step { margin-top: 18px; }
.step h3 { margin: 0 0 8px; font-size: 15px; }
.back { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 0; cursor: pointer; }

.summary { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 10px); margin-top: 22px; box-shadow: 0 6px 24px rgb(0 0 0 / .18); }
.summary .what { font-weight: 700; font-size: 17px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer;
  background: var(--accent); color: var(--on-accent); text-decoration: none;
}
.btn.block { width: 100%; margin-top: 12px; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .5; cursor: default; }

/* Alertes */
.rule { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; }
.rule .emoji { font-size: 26px; text-align: center; }
.rule .name { font-weight: 650; }
.rule select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface-2);
  border: 0; border-radius: 8px; padding: 6px 8px; margin-top: 6px;
}
.icon-btn { border: 0; background: none; font-size: 18px; padding: 8px; cursor: pointer; color: var(--muted); }

/* Détail */
.hero { text-align: center; padding: 20px 14px; }
.hero .emoji { font-size: 40px; }
.hero h2 { margin: 6px 0 4px; font-size: 22px; letter-spacing: -0.01em; }
.hero .when { font-weight: 700; color: var(--accent); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.person { font-size: 13px; padding: 4px 9px; border-radius: 99px; background: var(--surface-2); }
.person.hl { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.watch { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; text-decoration: none; font-weight: 650; }

/* Aperçu notification */
.notif { display: grid; grid-template-columns: 38px 1fr; gap: 10px; background: var(--surface-2); border-radius: 16px; padding: 12px; }
.notif img { width: 38px; height: 38px; border-radius: 9px; }
.notif b { display: block; font-size: 14px; }
.notif p { margin: 2px 0 0; font-size: 13px; white-space: pre-line; color: var(--muted); }

.status { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px;
  font-size: 14px; font-weight: 600; z-index: 20; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.code-row { display: flex; gap: 8px; align-items: center; }
.code-row code {
  flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13px;
  background: var(--surface-2); padding: 10px 12px; border-radius: 10px;
}

/* Tutoriel */
body.onboarding .tabs, body.onboarding .top { display: none; }
body.onboarding { padding-bottom: 0; }
.ob { padding: calc(env(safe-area-inset-top) + 16px) 0 calc(env(safe-area-inset-bottom) + 96px); }
.ob-progress { display: flex; gap: 6px; margin-bottom: 22px; }
.ob-progress span { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.ob-progress span.on { background: var(--accent); }
.ob-hero { text-align: center; margin: 12px 0 24px; }
.ob-hero img { border-radius: 18px; }
.ob-hero h2, .ob-title { margin: 12px 0 6px; font-size: 26px; letter-spacing: -0.02em; }
.ob-point { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.ob-code { margin-top: 20px; }
.ob-code summary { color: var(--accent); font-weight: 600; cursor: pointer; padding: 6px 0; }
.ob-code .search { margin-top: 8px; }
.sport-tile.picked { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ob-sec { margin: 8px 0 14px; }
.ob-sec-title { margin: 0 2px 6px; font-weight: 600; }
.ob-search { margin-bottom: 8px; padding: 9px 12px; font-size: 15px; }
.ob-alerts { padding: 4px 14px; }
.ob-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.ob-row:last-child { border-bottom: 0; }
.ob-row .grow { flex: 1; }
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: .2s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgb(0 0 0 / .3); }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 21px; }
.ob-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; gap: 10px;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.ob-footer .grow { flex: 1; }
.ob-skip { display: block; margin: 14px auto 0; }
.ob ol { padding-left: 20px; line-height: 1.6; }

/* Connexion */
.auth { display: grid; gap: 10px; margin-top: 8px; }
.g-btn { display: flex; justify-content: center; min-height: 44px; }
.code-input { text-align: center; font-size: 24px; letter-spacing: 8px; font-weight: 700; }
.danger-text { color: var(--danger); }

/* Mes suivis */
.sport-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 8px; font-weight: 750; font-size: 17px; }
.sport-head a { color: var(--accent); text-decoration: none; font-weight: 600; }
.sport-card { padding: 4px 14px 6px; }
.kind-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 2px; }
.rule-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.rule-row:last-child { border-bottom: 0; }
.rule-row .grow { flex: 1; min-width: 0; }
.rule-row .name { font-weight: 650; }
.rule-row .next { margin-top: 2px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  flex: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  border-radius: 99px; padding: 6px 10px; font-size: 13px; font-weight: 650; cursor: pointer;
}
.pill.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
