:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #16203a;
  --muted: #5d6882;
  --line: #dde3f0;
  --primary: #1d4ed8;
  --primary-text: #ffffff;
  --accent: #f97316;
  --ok-bg: #e7f7ec;
  --ok-text: #14622b;
  --err-bg: #fdecec;
  --err-text: #9b1c1c;
  --danger: #c62828;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 32, 58, .06), 0 4px 14px rgba(22, 32, 58, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1424;
    --surface: #172038;
    --text: #e8ecf8;
    --muted: #9aa5c2;
    --line: #2a3556;
    --primary: #5b8cff;
    --primary-text: #0b1226;
    --accent: #fb923c;
    --ok-bg: #12301d;
    --ok-text: #8be0a6;
    --err-bg: #3a1717;
    --err-text: #ffb4b4;
    --danger: #ff6b6b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.container { width: 100%; max-width: 860px; margin: 0 auto; padding: 0 16px; }

a { color: var(--primary); }

h1 { font-size: 1.6rem; margin: 1.2rem 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1.05rem; margin: 0 0 .2rem; }
p { margin: .4rem 0 .8rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.note { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 8px; padding: .4rem .7rem; }

/* Barre du haut */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap; }
.topbar nav { display: flex; gap: 6px 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.topbar nav a { text-decoration: none; font-size: .95rem; }
.inline { display: inline; margin: 0; }

.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-decoration: underline; }
.foot { padding: 28px 16px 40px; text-align: center; font-size: .85rem; }

/* Cartes */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}
.card.narrow, .narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.card.dim { opacity: .65; }
.card.featured { border: 2px solid var(--primary); }
.linkcard { display: block; text-decoration: none; color: inherit; }
.linkcard:hover { border-color: var(--primary); }
.prose h2 { margin-top: 1.2rem; }
.prose ul { padding-left: 1.2rem; }

details.card > summary { cursor: pointer; }
details.more { margin: 18px 0; }
details.more > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }

.badge {
  display: inline-block; background: var(--accent); color: #fff; font-size: .75rem; font-weight: 700;
  padding: 2px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
}
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); }
.pill.home { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); border-color: transparent; }
.pill.away { background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); border-color: transparent; }

/* Tâches d'un match */
.slots { list-style: none; margin: 12px 0 0; padding: 0; }
.slot { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.slot-label { font-weight: 600; min-width: 96px; }
.slot-who { flex: 1; min-width: 120px; }
.slot.mine .slot-who { color: var(--ok-text); font-weight: 600; }
.slot form { margin: 0; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 8px 0 0; }
.chip { font-size: .8rem; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); }
.chip.taken { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.chip.free { color: var(--muted); }

/* Formulaires & boutons */
label { display: block; font-weight: 600; font-size: .92rem; margin: 0 0 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input.code { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.narrow-input { display: inline-block; width: 5.5em; margin: 0 4px; padding: 6px 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; }
.check input { width: auto; margin: 0; }
fieldset.radios { border: 0; padding: 0; margin: 0 0 12px; display: flex; gap: 18px; flex-wrap: wrap; }
fieldset.radios legend { font-weight: 600; font-size: .92rem; margin-bottom: 4px; padding: 0; }
fieldset.radios label { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: 500; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.btn.small { padding: 6px 12px; font-size: .88rem; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: transparent; }
.btn.wa { background: #25d366; border-color: #25d366; color: #06361a; }
.btn:hover { filter: brightness(.96); }

.stack > * + * { margin-top: 4px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form.wrap { flex-wrap: wrap; }
.inline-form input[type=text] { flex: 1; min-width: 140px; margin: 0; }
.inline-form input.bd-input { flex: 0 0 6.5em; min-width: 0; }
.inline-form select { margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.actions form { margin: 0; }
.row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.row form { margin: 0; }
.toolbar { display: flex; gap: 18px; flex-wrap: wrap; margin: 12px 0; font-size: .92rem; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.resend { margin-top: 12px; text-align: center; }

.share { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.share-url { flex: 1 1 220px; margin: 0; font-size: .85rem; }

/* Onglets */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 6px 0 14px; }
.tabs a { padding: 9px 10px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

/* Messages */
.flash { padding: 10px 14px; border-radius: 10px; margin: 14px 0 0; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--err-bg); color: var(--err-text); }

/* Tableau */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: 9px 12px; text-align: center; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); font-size: .85rem; }
tfoot th, tfoot td { border-bottom: 0; background: color-mix(in srgb, var(--primary) 6%, var(--surface)); font-weight: 700; }
td.zero { color: var(--muted); opacity: .6; }

@media (min-width: 640px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 1.9rem; }
}

/* Anniversaires */
.bd-input { max-width: 6.5em; flex: 0 0 auto; text-align: center; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 4px 0; }

/* Présences */
.presence { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 4px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 8%, transparent); }
.presence-q { font-weight: 600; flex: 1 1 100%; }
.btn.on-yes { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.btn.on-no { background: var(--err-bg); color: var(--err-text); border-color: transparent; }
.presence-sum { margin: 8px 0 0; }

/* Système */
code.hash { display: block; word-break: break-all; font-size: .8rem; padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); user-select: all; }
details.edit { margin: 4px 0 10px; }
details.edit > summary { cursor: pointer; color: var(--primary); }
.flash form.inline { margin-left: 8px; }
.cancel-form { margin-top: 8px; }
