:root {
  --brand: #0E8A6E;
  --brand-strong: #0A6B56;
  --brand-soft: #E3F4EF;
  --accent: #FF7A45;
  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --surface-2: #EEF2F0;
  --text: #13201C;
  --text-2: #5A6B66;
  --border: #DCE4E1;
  --danger: #C8372D;
  --danger-soft: #FCEBEA;
  --warn: #9A6200;
  --warn-soft: #FFF4DE;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 40, 32, .06), 0 4px 16px rgba(16, 40, 32, .06);
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand: #2BC79F;
  --brand-strong: #5ED9B8;
  --brand-soft: #123A31;
  --accent: #FF8F61;
  --bg: #0D1412;
  --surface: #15201D;
  --surface-2: #1C2925;
  --text: #E8F0ED;
  --text-2: #9DB0AA;
  --border: #283733;
  --danger: #FF7A70;
  --danger-soft: #3A1D1B;
  --warn: #FFC566;
  --warn-soft: #3A2D12;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-strong); }

#app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: -.01em; }
.topbar .back { border: 0; background: var(--surface); width: 40px; height: 40px; border-radius: 50%; box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; font-weight: 700; color: #fff;
  background: var(--brand); flex-shrink: 0;
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }

main { overflow-x: hidden; flex: 1; padding: 4px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px); max-width: 720px; width: 100%; margin: 0 auto; }
main.no-tabs { padding-bottom: calc(32px + var(--safe-b)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--text-2); font-size: 11.5px; font-weight: 600;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--brand); }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 0 0 14px; }
.card h2 { font-size: 17px; margin: 0 0 8px; }
.card h3 { font-size: 15px; margin: 14px 0 6px; }
.muted { color: var(--text-2); }
.small { font-size: 13.5px; }

.hero { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%); color: #fff; }
:root[data-theme="dark"] .hero { background: linear-gradient(135deg, #136C58 0%, #0E4F41 100%); }
.hero .muted { color: rgba(255, 255, 255, .85); }
.hero h2 { font-size: 24px; letter-spacing: -.02em; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--brand-soft); color: var(--brand-strong); margin: 2px 4px 2px 0; }
.badge.soon { background: var(--surface-2); color: var(--text-2); }
.badge.ok { background: var(--brand-soft); color: var(--brand-strong); }
.badge.ext { background: var(--warn-soft); color: var(--warn); }

.notice { border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 14px; font-size: 14.5px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.info { background: var(--brand-soft); color: var(--brand-strong); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12.5px; color: var(--text-2); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.row-btn { width: 100%; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; display: flex; align-items: center; gap: 12px; }
.chev { color: var(--text-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer;
  font-weight: 700; background: var(--brand); color: #fff; text-decoration: none;
}
:root[data-theme="dark"] .btn:not(.secondary):not(.danger) { color: #06231C; }
.btn svg, .row-btn svg { width: 22px; height: 22px; flex-shrink: 0; }
.chev svg { width: 18px; height: 18px; display: block; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.btn-row .btn { flex: 1; }

form .field { margin: 0 0 16px; }
label.lbl { display: block; font-weight: 600; font-size: 14.5px; margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.err { font-size: 13px; color: var(--danger); margin-top: 4px; font-weight: 600; }
input[type="text"], input[type="number"], input[type="date"], input[type="password"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; font-size: 14.5px; font-weight: 600;
}
.chip input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }
.chip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.yesno { display: flex; gap: 8px; margin-top: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.check input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--brand); flex-shrink: 0; }

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

.empty-illu { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--brand-soft); color: var(--brand); margin-bottom: 10px; }
.empty-illu svg { width: 32px; height: 32px; }

.welcome { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px; max-width: 520px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.logo svg { width: 52px; height: 52px; }
.logo b { font-size: 30px; letter-spacing: -.03em; }
.welcome h2 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 12px; }
.feature { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; }
.feature .dot { width: 32px; height: 32px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex-shrink: 0; font-weight: 800; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 600; font-size: 14.5px;
  z-index: 50; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}

dialog { border: 0; border-radius: var(--radius); padding: 20px; background: var(--surface); color: var(--text); width: min(360px, calc(100% - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.pin-input { letter-spacing: .6em; text-align: center; font-size: 24px; }

table.status { width: 100%; border-collapse: collapse; font-size: 14px; }
table.status td { padding: 8px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }

@media (min-width: 720px) {
  .tabbar { left: 50%; transform: translateX(-50%); max-width: 720px; border-radius: 20px 20px 0 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .view { animation: fade .18s ease-out; }
  @keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}

/* ===== v0.2 : design modernisé ===== */
:root { --radius: 22px; --ink-hero: #0B2B24; }
body { letter-spacing: -.005em; }
.topbar h1 { font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.card { border: 1px solid var(--border); box-shadow: none; }
:root[data-theme="dark"] .card { border-color: transparent; }
.hero {
  position: relative; overflow: hidden; border: 0; padding: 22px;
  background: radial-gradient(120% 140% at 100% 0%, #1FB58F 0%, #0E8A6E 35%, #0B3D33 100%);
}
.hero::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 200px; height: 200px; border-radius: 50%; border: 28px solid rgba(255,255,255,.07); }
:root[data-theme="dark"] .hero { background: radial-gradient(120% 140% at 100% 0%, #1A9C7B 0%, #0E5E4C 40%, #0A221D 100%); }
.hero h2 { font-size: 30px; font-weight: 800; }
.hero-row { display: flex; align-items: center; gap: 16px; position: relative; z-index: 1; }
.ring { width: 76px; height: 76px; flex-shrink: 0; }
.ring text { font-weight: 800; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 18px; position: relative; z-index: 1; }
.week .d { text-align: center; font-size: 12px; font-weight: 700; color: rgba(255,255,255,.7); }
.week .dot { margin: 6px auto 0; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; background: rgba(255,255,255,.1); color: #fff; }
.week .dot.train { background: rgba(255,255,255,.22); }
.week .dot.done { background: #FF7A45; }
.week .dot.today { outline: 2px solid #fff; outline-offset: 2px; }

.session-card { display: block; text-decoration: none; color: inherit; }
.session-card .kicker { font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.session-card h2 { font-size: 22px; margin: 4px 0 6px; letter-spacing: -.02em; }
.meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-2); font-size: 14px; font-weight: 600; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.ex-mini { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ex-mini span { font-size: 13px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); font-weight: 600; }

.ex { display: flex; gap: 14px; align-items: flex-start; }
.ex .num { width: 36px; height: 36px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-strong); display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.ex h3 { margin: 2px 0 4px; font-size: 16.5px; }
.rx { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.rx b { background: var(--surface-2); border-radius: 10px; padding: 6px 10px; font-size: 13.5px; }
details.more summary { cursor: pointer; color: var(--brand-strong); font-weight: 700; font-size: 14px; list-style: none; padding: 6px 0; }
details.more summary::-webkit-details-marker { display: none; }
details.more ol { padding-left: 20px; margin: 6px 0; }
.why { font-size: 13.5px; color: var(--text-2); border-left: 3px solid var(--brand); padding: 2px 0 2px 10px; margin: 8px 0; }
.phase { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); margin: 0 0 14px; font-weight: 700; }
.phase small { color: var(--text-2); font-weight: 600; }

.day-row { display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit; padding: 14px 0; border-bottom: 1px solid var(--border); }
.day-row:last-child { border-bottom: 0; }
.day-row .dayname { width: 46px; font-weight: 800; color: var(--text-2); font-size: 13px; text-transform: uppercase; }
.day-row.rest { opacity: .55; }
.check-done { color: var(--accent); font-weight: 800; }

.tabbar { left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); height: var(--tabbar-h); padding: 0 6px; border-radius: 24px; border: 1px solid var(--border); box-shadow: 0 8px 30px rgba(0,0,0,.12); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); }
.tabbar a { border-radius: 18px; margin: 6px 2px; }
.tabbar a[aria-current="page"] { background: var(--brand-soft); }
main { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 40px); }
@media (min-width: 720px) { .tabbar { left: 50%; right: auto; width: 696px; transform: translateX(-50%); border-radius: 24px; } }
.toast { bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px); }
.btn { min-height: 52px; font-size: 16px; }
.btn.accent { background: var(--accent); color: #fff; }
.phase { flex-wrap: wrap; gap: 2px 12px; }
.phase small { flex-basis: 100%; }
.pics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 4px; }
.pics figure { margin: 0; position: relative; }
.pics img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 12px; background: var(--surface-2); display: block; }
.pics figcaption { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
