:root {
  --accent: #6b4eff;
  --bg: #ffffff;
  --surface: #f6f7f9;
  --text: #1c1f24;
  --muted: #667085;
  --line: #e4e7ec;
  --danger: #c4320a;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171b; --surface: #1e2127; --text: #eef0f3; --muted: #98a2b3; --line: #2c3038; --danger: #f97066;
  }
}
:root[data-theme="dark"] {
  --bg: #15171b; --surface: #1e2127; --text: #eef0f3; --muted: #98a2b3; --line: #2c3038; --danger: #f97066;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 640px;
}

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.count { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Sur mobile, l'en-tête natif affiche déjà le titre */
:root[data-host="ios"] .top h1, :root[data-host="android"] .top h1 { display: none; }

.list { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px; min-height: 64px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.row.on { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.row.busy { opacity: .6; cursor: progress; }
.row.disabled .name::after { content: " · désactivé"; color: var(--muted); font-weight: 400; }

.text { display: flex; flex-direction: column; min-width: 0; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: 13px; }

/* Interrupteur */
.switch {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 48px; height: 28px; border-radius: 999px; margin: 0;
  background: var(--line); position: relative; cursor: inherit; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.empty { color: var(--muted); text-align: center; padding: 32px 8px; margin: 0; }
.empty.error { color: var(--danger); }
.retry {
  align-self: center; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 8px 16px; font: inherit; cursor: pointer;
}

.status {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 608px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--text); color: var(--bg); font-size: 14px;
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.status.show { opacity: 1; transform: none; }
.status.error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
