:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --text: #1b1d22;
  --muted: #6b6f78;
  --line: #e6e1d6;
  --accent: #2b4c9b;
  --accent-text: #ffffff;
  --fav: #e0a100;

  --w-low-bg: #dff3e4;   --w-low: #17623a;
  --w-mid-bg: #fdf0c9;   --w-mid: #7a5a00;
  --w-high-bg: #fde0c8;  --w-high: #9a3f00;
  --w-max-bg: #fbd5d5;   --w-max: #a1161b;
  --w-off-bg: #ecebe8;   --w-off: #6b6f78;
  --w-down-bg: #fbd5d5;  --w-down: #a1161b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1c1f25;
    --text: #f1f2f4;
    --muted: #9aa0aa;
    --line: #2b2f37;
    --accent: #8fb0ff;
    --accent-text: #0d1322;
    --fav: #ffc53d;

    --w-low-bg: #173a25;   --w-low: #8be3a9;
    --w-mid-bg: #3d3214;   --w-mid: #ffd866;
    --w-high-bg: #45290f;  --w-high: #ffad6b;
    --w-max-bg: #4a1719;   --w-max: #ff8f8f;
    --w-off-bg: #262a31;   --w-off: #9aa0aa;
    --w-down-bg: #4a1719;  --w-down: #ff8f8f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  padding: 0 max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
main, .top, .foot { max-width: 640px; margin: 0 auto; }

/* En-tête collant */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: 8px;
}
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 28px; line-height: 1.15; margin: 4px 0 12px; letter-spacing: -0.02em; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px; border: 0;
  background: var(--surface); color: var(--accent);
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 0 0 1px var(--line);
}
.actions { display: flex; gap: 8px; flex: none; }
.icon-btn[hidden] { display: none; }
.icon-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); box-shadow: none; }
.icon-btn[aria-pressed="true"] path { fill: currentColor; }

.notice {
  position: relative; background: var(--surface); border-radius: 14px; padding: 12px 44px 12px 14px;
  margin: 8px 0 12px; font-size: 15px; box-shadow: inset 4px 0 0 var(--accent), 0 0 0 1px var(--line);
}
.notice.warn { box-shadow: inset 4px 0 0 var(--w-high), 0 0 0 1px var(--line); }
.notice[hidden] { display: none; }
.notice-close {
  position: absolute; top: 4px; right: 4px; width: 40px; height: 40px; border: 0; background: transparent;
  font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer;
}

.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--surface); padding: 4px; border-radius: 14px;
  box-shadow: 0 0 0 1px var(--line);
}
.tabs button {
  border: 0; background: transparent; padding: 10px 6px; border-radius: 10px;
  font-weight: 600; font-size: 16px; cursor: pointer; min-height: 44px;
}
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.hours { margin: 10px 2px 0; color: var(--muted); font-size: 15px; }

/* Résumé */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 14px; }
.stat {
  background: var(--surface); border-radius: 14px; padding: 10px 12px;
  box-shadow: 0 0 0 1px var(--line);
}
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }

/* Raccourcis de filtre : grille 2×2, tous visibles d'un coup */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters button {
  border: 0; border-radius: 999px; padding: 8px 10px; min-height: 44px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line);
  font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.filters button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); box-shadow: none; }
.chip.height { color: var(--text); font-weight: 600; }

/* Contrôles */
.controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.seg { display: inline-flex; background: var(--surface); border-radius: 10px; padding: 3px; box-shadow: 0 0 0 1px var(--line); }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); cursor: pointer; min-height: 44px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

/* Liste */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ride {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: 16px; padding: 12px 12px 12px 6px;
  box-shadow: 0 0 0 1px var(--line);
}
.fav {
  flex: none; width: 40px; height: 44px; border: 0; background: transparent;
  color: var(--line); cursor: pointer; display: grid; place-items: center; padding: 0;
}
.fav[aria-pressed="true"] { color: var(--fav); }
.fav svg { width: 22px; height: 22px; }
.ride-main { flex: 1; min-width: 0; }
.ride-name { font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.ride-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { font-size: 13px; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 2px 7px; }
.wait {
  flex: none; min-width: 72px; text-align: center; border-radius: 12px; padding: 6px 8px;
  font-variant-numeric: tabular-nums;
}
.wait b { display: block; font-size: 26px; line-height: 1.1; }
.wait small { font-size: 12px; font-weight: 600; }
.wait.txt b { font-size: 15px; line-height: 1.3; padding: 4px 0; }
.w-low  { background: var(--w-low-bg);  color: var(--w-low); }
.w-mid  { background: var(--w-mid-bg);  color: var(--w-mid); }
.w-high { background: var(--w-high-bg); color: var(--w-high); }
.w-max  { background: var(--w-max-bg);  color: var(--w-max); }
.w-off  { background: var(--w-off-bg);  color: var(--w-off); }
.w-down { background: var(--w-down-bg); color: var(--w-down); }
.ride.closed .ride-name { color: var(--muted); }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 4px 0; }

.status { text-align: center; color: var(--muted); font-size: 14px; margin: 16px 0; min-height: 1.4em; }
.status.error { color: var(--w-down); }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 0 24px; }
.foot a { color: inherit; }
