:root {
  --bg: #F2F4EE; --surface: #FFFFFF; --surface-2: #E9ECE4; --ink: #1B2320; --muted: #65706A; --line: #D7DCD2;
  --sport: #2F6F55; --sport-soft: #DCEBE2; --food: #9A6512; --food-soft: #F3E6CC; --rest: #8A938D; --focus: #1F5FBF; --danger: #B3261E;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141816; --surface: #1D2321; --surface-2: #262D2A; --ink: #E6EBE4; --muted: #9BA59E; --line: #2E3633;
    --sport: #5FB08C; --sport-soft: #1F3A2F; --food: #D9A54A; --food-soft: #3A2E17; --rest: #6E7873; --focus: #7FB0FF; --danger: #F2847D;
  }
}
:root[data-theme="dark"] {
  --bg: #141816; --surface: #1D2321; --surface-2: #262D2A; --ink: #E6EBE4; --muted: #9BA59E; --line: #2E3633;
  --sport: #5FB08C; --sport-soft: #1F3A2F; --food: #D9A54A; --food-soft: #3A2E17; --rest: #6E7873; --focus: #7FB0FF; --danger: #F2847D;
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
*, *::before, *::after { box-sizing: inherit; }
input, textarea, select, button { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px; line-height: 1.45; font-variant-numeric: tabular-nums;
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.2em; }
button { font: inherit; color: inherit; }
a { color: var(--sport); }
a.btn { text-decoration: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.app { max-width: 560px; margin: 0 auto; padding: 14px 16px calc(84px + env(safe-area-inset-bottom, 0px)); }
.topline { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.topline .brand { font-weight: 700; font-size: 15px; }
.topline .date { color: var(--muted); font-size: 15px; }
section[hidden] { display: none; }
.tab-title { font-size: 26px; font-weight: 700; margin: 6px 0 14px; }
.lead { color: var(--muted); font-size: 15px; margin-bottom: 14px; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.week button { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.week button span.d { font-size: 15px; font-weight: 700; }
.week button span.dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.week button.gym span.dot { background: var(--sport); }
.week button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.week button.active span.dot { background: var(--bg); }
.week button.today:not(.active) { border-color: var(--ink); }

.ticket { background: var(--surface); border-radius: 18px; overflow: hidden; border: 1px solid var(--line); }
.ticket .band { padding: 8px 18px; font-size: 14px; font-weight: 700; color: #fff; background: var(--rest); }
.ticket.gym .band { background: var(--sport); }
.ticket h1 { font-size: 34px; padding: 14px 18px 2px; }
.ticket .sub { padding: 0 18px 14px; color: var(--muted); font-size: 15px; }
.rows { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: 78px 1fr; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); font-size: 14px; padding-top: 2px; }
.row .v { font-size: 16px; white-space: pre-line; }
.row .v .small { color: var(--muted); font-size: 14px; display: block; margin-top: 2px; }
.row.sport .k { color: var(--sport); font-weight: 700; }
.row.food .k { color: var(--food); font-weight: 700; }

.btn { display: inline-block; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer; background: var(--sport); color: #fff; min-height: 44px; }
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.link { background: none; padding: 6px 0; color: var(--sport); font-weight: 700; min-height: 0; }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.done { color: var(--sport); font-weight: 700; }
.note-input { width: 100%; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; font-size: 15px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 8px 14px; cursor: pointer; font-weight: 700; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--bg); }

.block { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; margin-bottom: 14px; }
.block h2 { font-size: 20px; margin-bottom: 8px; }
.block p + p { margin-top: 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.note { background: var(--sport-soft); border-radius: 12px; padding: 10px 12px; font-size: 15px; margin-top: 10px; white-space: pre-line; }
.note.food { background: var(--food-soft); }

.exos { list-style: none; padding: 0; margin: 0; counter-reset: exo; }
.exos li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); align-items: start; }
.exos li:last-child { border-bottom: 0; }
.exos li::before { counter-increment: exo; content: counter(exo); color: var(--muted); font-weight: 700; padding-top: 2px; }
.exos .motra { font-weight: 700; }
.exos li.min .motra::after { content: " \25CF"; color: var(--sport); font-size: 10px; vertical-align: 2px; }
.exos .fr { color: var(--muted); font-size: 14px; }
.exos .tip { font-size: 14px; margin-top: 2px; }
.exos .reps { text-align: right; white-space: nowrap; font-size: 15px; padding-top: 2px; }
.legend { color: var(--muted); font-size: 14px; margin-top: 8px; }

.simple { list-style: none; padding: 0; margin: 0; }
.simple li { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.simple li:last-child { border-bottom: 0; }
.simple .r { color: var(--muted); white-space: nowrap; text-align: right; }

details { border-top: 1px solid var(--line); }
details:first-of-type { border-top: 0; }
summary { list-style: none; cursor: pointer; padding: 13px 0; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 44px; }
summary::-webkit-details-marker { display: none; }
summary .meta { color: var(--muted); font-weight: 400; font-size: 14px; white-space: nowrap; }
summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; flex: none; margin-left: 8px; }
details[open] > summary::after { transform: rotate(-135deg); }
.body { padding: 2px 0 16px; font-size: 16px; }
.body h4 { font-size: 15px; margin: 10px 0 4px; color: var(--muted); font-weight: 700; }
.body li + li { margin-top: 4px; }
.portion { background: var(--food-soft); border-radius: 10px; padding: 8px 12px; margin-top: 10px; font-size: 15px; white-space: pre-line; }

.check { list-style: none; padding: 0; margin: 0; }
.check li { border-bottom: 1px solid var(--line); }
.check li:last-child { border-bottom: 0; }
.check label { display: flex; align-items: center; gap: 12px; padding: 10px 0; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--sport); flex: none; margin: 0; }
.check input:checked + span { color: var(--muted); text-decoration: line-through; }
.group-title { font-size: 15px; font-weight: 700; color: var(--muted); margin: 14px 0 2px; border: 0; }

.rules { padding-left: 1.3em; }
.rules li { padding: 7px 0; border-bottom: 1px solid var(--line); white-space: pre-line; }
.rules li:last-child { border-bottom: 0; }
.rules b { display: block; }
.lex dl { margin: 0; }
.lex dt { font-weight: 700; margin-top: 10px; }
.lex dd { margin: 2px 0 0; font-size: 16px; white-space: pre-line; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)); }
.tabbar .inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tabbar button { border: 0; background: none; padding: 8px 0 6px; font-size: 11.5px; font-weight: 700; color: var(--muted); cursor: pointer; border-radius: 10px; min-height: 44px; white-space: nowrap; overflow: hidden; }
.tabbar button.on { color: var(--ink); background: var(--surface-2); }

/* connexion */
.login { max-width: 400px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { font-size: 30px; margin-bottom: 4px; }
.login .field { display: block; margin-top: 16px; }
.login .field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.login input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit; }
.login .btn { width: 100%; margin-top: 20px; }
.error { color: var(--danger); font-size: 15px; margin-top: 12px; min-height: 1.4em; }

@media (prefers-reduced-motion: reduce) { summary::after { transition: none; } }

.mt6 { margin-top: 6px; }
.mt8 { margin-top: 8px; }
