/* Palette provisoire : remplacer ces variables quand les couleurs du feed de Sam sont connues
   (penser à theme_color/background_color dans manifest.webmanifest, BG/FG/ACCENT dans scripts/icons.swift). */
:root {
  --bg: #121212;          /* fond quasi noir */
  --surface: #1E1E1E;     /* cartes */
  --surface-2: #2A2A2A;   /* champs, boutons secondaires */
  --line: #3A3A3A;        /* bordures */
  --text: #F5F5F0;        /* texte principal */
  --muted: #B4B4AC;       /* texte secondaire */
  --accent: #FF6B1A;      /* orange électrique */
  --on-accent: #121212;   /* texte sur l'accent */
  --radius: 14px;
  --tabbar-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font);
  min-height: 100vh; overflow-x: hidden;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* En-tête */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--surface-2);
}
.mark { width: 36px; height: 36px; border-radius: 8px; }
.brand { font-size: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.brand b { color: var(--text); }
.back { width: 44px; height: 44px; margin-left: -10px; display: grid; place-items: center; background: none; border: 0; border-radius: 10px; cursor: pointer; }
.back svg { width: 24px; height: 24px; fill: none; stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

main { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.view { padding-top: 18px; }

h1, h2, h3, .hello { margin: 0; font-weight: 900; text-transform: uppercase; font-style: italic; letter-spacing: -.01em; line-height: 1.05; }
h1 { font-size: 34px; }
.hello { font-size: 40px; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
.lead { margin: 6px 0 18px; color: var(--muted); }
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tag { display: inline-block; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: none; color: var(--muted); }
.meta { margin: 6px 0 14px; color: var(--muted); }
.note { margin: 10px 0 0; min-height: 1.4em; color: var(--muted); font-size: 15px; }
.note.ok { color: var(--text); }
.section-title { margin: 28px 0 12px; }

/* Cartes */
.card { display: block; background: var(--surface); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; text-decoration: none; }
.today { padding: 0; overflow: hidden; }
.today .card-body { padding: 18px; }
/* Bloc graphique à la place d'une photo (aucune image de Sam pour l'instant) */
.stripe, .hero {
  height: 92px;
  background:
    repeating-linear-gradient(-60deg, transparent 0 22px, rgba(255, 107, 26, .9) 22px 34px, transparent 34px 56px),
    linear-gradient(135deg, #2A2A2A, #161616);
}
.race .count { margin: 2px 0 12px; font-size: 30px; font-weight: 900; font-style: italic; text-transform: uppercase; line-height: 1.1; }
.race .count small { display: block; font-size: 15px; font-style: normal; font-weight: 600; text-transform: none; color: var(--muted); }
.shortcut { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 72px; }
.shortcut-status { display: block; font-weight: 700; }
.chev { font-size: 32px; line-height: 1; color: var(--accent); }
.foot { margin: 26px 0 8px; padding-top: 14px; border-top: 1px solid var(--surface-2); text-align: center; font-size: 13px; color: var(--muted); }

/* Champs */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 700; color: var(--muted); }
input[type=date], textarea {
  width: 100%; min-height: 48px; padding: 11px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #9A9A93; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px; border-radius: 12px; border: 0;
  font-weight: 800; text-transform: uppercase; letter-spacing: .06em; text-decoration: none; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { min-height: 60px; font-size: 18px; }
.btn.huge { display: flex; width: 100%; min-height: 96px; font-size: 30px; font-style: italic; margin: 14px 0; }
form .btn.primary, #race-clear { width: 100%; }
.row2 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; margin-top: 14px; }

/* Programmes */
.programs, .sessions, .posts, .blocks, .splits { list-style: none; margin: 0; padding: 0; }
.program { display: block; margin-bottom: 14px; background: var(--surface); border-radius: var(--radius); overflow: hidden; text-decoration: none; }
.program .hero { height: 72px; }
.program:nth-child(2) .hero { background: repeating-linear-gradient(90deg, transparent 0 18px, rgba(255, 107, 26, .85) 18px 26px), linear-gradient(135deg, #2A2A2A, #161616); }
.program:nth-child(3) .hero { background: radial-gradient(circle at 25% 50%, rgba(255, 107, 26, .9) 0 22px, transparent 23px), radial-gradient(circle at 45% 50%, rgba(245, 245, 240, .85) 0 22px, transparent 23px), linear-gradient(135deg, #2A2A2A, #161616); }
.program .card-body { padding: 16px 18px 18px; }
.program p { margin: 6px 0 0; color: var(--muted); }
.program .go { margin-top: 10px; color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: 14px; }

details.week { background: var(--surface); border-radius: var(--radius); margin-bottom: 10px; }
details.week summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 8px 18px; cursor: pointer; font-weight: 800;
}
details.week summary::-webkit-details-marker { display: none; }
details.week summary::after { content: "+"; font-size: 26px; font-weight: 400; color: var(--accent); }
details.week[open] summary::after { content: "–"; }
details.week summary small { display: block; font-weight: 600; color: var(--muted); font-size: 14px; }
.sessions { padding: 0 10px 10px; }
.sessions a {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 52px; padding: 8px 10px; border-top: 1px solid var(--surface-2); text-decoration: none;
}
.sessions a span:last-child { color: var(--muted); white-space: nowrap; font-size: 15px; }

/* Séance */
.blocks { margin: 12px 0 18px; }
.block { background: var(--surface); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; }
.block h3 { margin-bottom: 8px; color: var(--accent); }
.block ol, .block ul { margin: 0; padding-left: 22px; }
.block li { margin: 4px 0; }
.block li.run { color: var(--muted); }
.block li b { font-weight: 800; }

/* Timer */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; margin: 14px 0; background: var(--surface); border-radius: 12px; }
.seg button { min-height: 48px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--on-accent); }
.seg.small { margin-top: 0; }
.settings { display: grid; gap: 8px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface); border-radius: 12px; padding: 6px 6px 6px 16px; }
.stepper .lbl { font-weight: 700; }
.stepper .ctl { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 0; background: var(--surface-2); font-size: 22px; font-weight: 800; cursor: pointer; }
.stepper output { min-width: 64px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.display { margin-top: 14px; padding: 18px 12px 16px; background: var(--surface); border-radius: var(--radius); text-align: center; }
.phase { margin: 0; font-weight: 900; font-size: 20px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.display.rest .phase { color: var(--text); }
.clock { margin: 4px 0; font-size: clamp(64px, 24vw, 104px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.sub { margin: 0 0 12px; color: var(--muted); font-weight: 600; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); }
#race-panel .clock { font-size: clamp(56px, 20vw, 92px); }
.splits { margin: 0 0 12px; }
.splits li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: baseline; padding: 10px 4px; border-bottom: 1px solid var(--surface-2); }
.splits li .n { color: var(--accent); font-weight: 900; }
.splits li .t { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.splits li .t small { display: block; color: var(--muted); font-weight: 600; }

/* Check-in */
.scale { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.scale legend { padding: 0; margin-bottom: 8px; font-weight: 800; }
.scale .opts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale button { min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 800; font-size: 18px; cursor: pointer; }
.scale button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.scale .ends { display: flex; justify-content: space-between; margin-top: 4px; font-size: 13px; color: var(--muted); }

.post { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 10px; }
.post header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); font-weight: 900; flex: none; }
.post header b { display: block; font-size: 15px; }
.post header .tag { margin-top: 2px; }
.post p { margin: 0; }

/* Barre d'onglets */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #0C0C0C; border-top: 1px solid var(--surface-2);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 44px; font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current=page] { color: var(--accent); }
