:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --text: #17171a;
  --muted: #6b6a70;
  --border: #e0ded8;
  --accent: #17171a;
  --accent-text: #ffffff;
  --cercle: #f2cf00;
  --cercle-soft: #fff6bf;
  --poses: #a5806a;
  --poses-soft: #f1e7df;
  --ok: #1d7a46;
  --warn: #b35c00;
  --danger: #b4232c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 14px rgba(0, 0, 0, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113;
    --surface: #1b1b1f;
    --surface-2: #26262b;
    --text: #f1f0ee;
    --muted: #a09fa6;
    --border: #2f2f35;
    --accent: #f1f0ee;
    --accent-text: #111113;
    --cercle: #f2cf00;
    --cercle-soft: #3a3410;
    --poses: #c9a48c;
    --poses-soft: #362c26;
    --ok: #52c483;
    --warn: #f0a24a;
    --danger: #f06b72;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button, input { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- Barre du haut */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  max-width: 1500px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 10px; flex: none; }
.brand h1 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.brand p { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { border-color: var(--muted); }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; }
.count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
}

/* ---------- Menu compte */
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  width: 230px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
}
.menu-title { padding: 8px 10px 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.menu-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }

/* ---------- Contrôles */
.controls {
  max-width: 1500px;
  margin: 0 auto;
  padding: 4px 16px 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}
.weeknav { display: flex; align-items: center; gap: 6px; min-width: 0; }
.weeknav h2 { font-size: 16px; font-weight: 600; margin-left: 6px; white-space: nowrap; }
.filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.chip[aria-pressed="false"] { opacity: .55; }
.chip[aria-pressed="false"] .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--text); }
.s-cercle .dot, .dot.s-cercle { background: var(--cercle); }
.s-poses .dot, .dot.s-poses { background: var(--poses); }

/* ---------- Bandeau des jours */
.day-strip {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  max-width: 1500px;
  margin: 0 auto;
}
.day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 0 5px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  min-width: 0;
}
.day-btn .dname { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.day-btn .dnum { font-size: 18px; font-weight: 650; }
.day-btn .dcount { font-size: 11px; color: var(--muted); }
.day-btn.is-today .dnum { color: var(--danger); }
.day-btn.is-selected { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
.day-btn.is-empty .dnum { color: var(--muted); }

/* ---------- Statut */
.status {
  max-width: 1500px;
  margin: 6px auto;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
  width: calc(100% - 32px);
}
.status.error { border-color: var(--danger); color: var(--danger); }
.status button { margin-left: 8px; }

/* ---------- Planning */
.board {
  max-width: 1500px;
  margin: 0 auto;
  padding: 4px 16px 24px;
}
.day-col { display: none; }
.day-col.is-selected { display: block; }
.day-head { display: none; }
.day-col .cards { display: flex; flex-direction: column; gap: 8px; }
.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.card {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 4px 12px;
  padding: 12px 12px 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  width: 100%;
}
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: var(--muted);
}
.card.s-cercle::before { background: var(--cercle); }
.card.s-poses::before { background: var(--poses); }
.card:hover { border-color: var(--muted); }
.card:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.card-time { display: flex; flex-direction: column; }
.card-time strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.card-time span { font-size: 12px; color: var(--muted); }
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.card-body h3 { font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.card-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 10px; }
.card-meta .room { display: inline-flex; align-items: center; gap: 5px; }
.card-meta .dot, .tag .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.spots { font-size: 13px; font-weight: 600; }
.spots.ok { color: var(--ok); }
.spots.low { color: var(--warn); }
.spots.full, .spots.cancelled { color: var(--danger); }
.spots.past { color: var(--muted); font-weight: 500; }
.book-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.book-btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.card.is-past, .card.is-cancelled { opacity: .55; box-shadow: none; }
.card.is-cancelled h3 { text-decoration: line-through; }

.skeleton {
  height: 92px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Grand écran : la semaine complète en colonnes */
@media (min-width: 1000px) {
  .day-strip { display: none; }
  .board {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
  }
  .day-col { display: block; min-width: 0; }
  .day-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 10px 2px 8px;
    background: var(--bg);
  }
  .day-head .dname { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .day-head .dnum { font-size: 20px; font-weight: 700; margin-left: 4px; }
  .day-head .dcount { font-size: 12px; color: var(--muted); }
  .day-head.is-today .dnum { color: var(--danger); }
  .card { grid-template-columns: 1fr; padding: 10px 10px 10px 14px; }
  .card-time { flex-direction: row; align-items: baseline; gap: 6px; }
  .card-foot { flex-direction: column; align-items: stretch; }
  .book-btn { width: 100%; height: 30px; background: var(--surface-2); color: var(--text); border-color: transparent; }
  .book-btn:hover { background: var(--accent); color: var(--accent-text); }
  .book-btn.secondary { background: transparent; border-color: var(--border); }
  .empty { padding: 18px 8px; font-size: 13px; }
}

/* ---------- Fenêtres (dialog) */
dialog.sheet {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  margin: 0;
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet-inner {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  overflow: hidden;
}
.sheet-tall .sheet-inner { height: 94vh; max-height: 94vh; }
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.sheet-head h2 { font-size: 17px; flex: 1; min-width: 0; }
.book-title { flex: 1; min-width: 0; }
.book-title h2, .book-title p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-title p { font-size: 13px; color: var(--muted); }
.sheet-body { padding: 8px 16px 16px; overflow-y: auto; }
.sheet-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

@media (min-width: 700px) {
  .sheet-inner {
    left: 50%;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(560px, calc(100% - 32px));
    max-height: 88vh;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  }
  .sheet-tall .sheet-inner { width: min(520px, calc(100% - 32px)); height: min(860px, 92vh); }
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.offer-row .muted { font-size: 13px; }
.fgroup .chip[aria-pressed="false"] { opacity: 1; }
.fgroup .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.fgroup { padding: 12px 0; border-bottom: 1px solid var(--border); }
.fgroup:last-child { border-bottom: 0; }
.fgroup h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.fgroup-head { display: flex; align-items: baseline; justify-content: space-between; }
.switch { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.switch input, .checklist input { width: 18px; height: 18px; accent-color: var(--text); flex: none; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 12px; }
.checklist label { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; font-size: 14px; min-width: 0; }
.checklist label span.lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checklist .n { color: var(--muted); font-size: 12px; margin-left: auto; }
.checklist .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* Détail d'un cours */
.offer-cover { width: 100%; height: 170px; object-fit: cover; display: block; background: var(--surface-2); }
.offer-main { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.offer-main .tag {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tag.s-cercle { background: var(--cercle-soft); }
.tag.s-poses { background: var(--poses-soft); }
.offer-main h2 { font-size: 21px; }
.offer-when { font-size: 15px; font-weight: 500; }
.offer-rows { display: grid; gap: 8px; font-size: 14px; }
.offer-row { display: flex; align-items: center; gap: 10px; }
.offer-row .k { color: var(--muted); width: 72px; flex: none; }
.coach-photo { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }
.offer-desc { font-size: 14px; color: var(--muted); white-space: pre-line; border-top: 1px solid var(--border); padding-top: 12px; }
.offer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.offer-actions .btn.primary { flex: 1; justify-content: center; height: 42px; font-size: 15px; }
.close-float {
  position: absolute;
  top: 10px;
  right: 10px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
}

.frame-wrap { position: relative; flex: 1; min-height: 0; background: #fff; }
.frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.frame-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #6b6a70; font-size: 14px; }
.frame-hint { font-size: 12px; color: var(--muted); padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }

.foot {
  max-width: 1500px;
  margin: 0 auto;
  padding: 8px 16px 28px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 520px) {
  .brand p { display: none; }
  .weeknav h2 { font-size: 15px; }
  .controls { padding-top: 0; }
  .filterbar { width: 100%; justify-content: space-between; }
}
