@font-face {
  font-family: "Archivo";
  src: url(/fonts/archivo.woff2) format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --ink: #0c1826;
  --muted: #64748a;
  --line: #e2e8ef;
  --accent: #1557e0;
  --on-accent: #ffffff;
  --accent-soft: #e4edff;
  --night: #071a33;
  --lime: #c9f03a;
  --lime-ink: #1c2a00;
  --ok: #0c8a4d;
  --ok-soft: #e0f5ea;
  --no: #d93a3a;
  --maybe: #a56a00;
  --maybe-soft: #fff1cf;
  --shadow: 0 1px 2px rgba(15, 30, 60, .04), 0 8px 24px rgba(15, 30, 60, .06);
  --shadow-lift: 0 12px 32px rgba(15, 30, 60, .16);
  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --av-l: 91%;
  --av-s: 68%;
  --av-ink: 30%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070d16;
    --surface: #111a27;
    --surface-2: #1a2535;
    --ink: #f1f5fa;
    --muted: #93a1b5;
    --line: #223046;
    --accent: #6b9dff;
    --on-accent: #06122a;
    --accent-soft: #14274a;
    --ok: #3ccf87;
    --ok-soft: #10301f;
    --no: #ff6b6b;
    --maybe: #f0b93a;
    --maybe-soft: #33270b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lift: 0 12px 32px rgba(0, 0, 0, .5);
    --av-l: 22%;
    --av-s: 38%;
    --av-ink: 82%;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }

h1, h2, h3, p { margin: 0; }
small { font-size: .75rem; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.muted { color: var(--muted); font-weight: 400; }

.ic { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px 40px; }
.loading { text-align: center; color: var(--muted); padding: 40vh 0 0; }

/* ---------- scène (bandeau du haut) ---------- */

.stage {
  position: relative; isolation: isolate; overflow: hidden;
  color: #fff; background: var(--night);
  padding: max(14px, env(safe-area-inset-top)) 20px 30px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.stage > * { max-width: 528px; margin-inline: auto; }
.stage::before {
  content: ""; position: absolute; inset: 0; z-index: -2; max-width: none;
  background: radial-gradient(120% 95% at 50% 115%, #2470ff 0%, #0f3fa8 45%, #071a33 100%);
}
/* lignes d'un terrain de padel, en filigrane */
.stage::after {
  content: ""; position: absolute; inset: 0; z-index: -1; max-width: none; opacity: .13;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 420' fill='none' stroke='white' stroke-width='3'%3E%3Crect x='10' y='10' width='200' height='400'/%3E%3Cpath d='M10 210h200M10 80h200M10 340h200M110 80v260'/%3E%3C/svg%3E") right -30px top -70px / 230px no-repeat;
}
.stage.with-facts { padding-bottom: 64px; }

.stage-bar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; font-stretch: 110%; letter-spacing: .01em; }
.ball { width: 26px; height: 26px; }
.tag {
  margin-left: auto; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .14); backdrop-filter: blur(8px);
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; flex: none;
  display: grid; place-items: center; text-decoration: none;
  background: var(--surface-2); color: var(--ink);
}

.stage h1 {
  font-size: clamp(1.6rem, 7.4vw, 2.1rem); line-height: 1.02; font-weight: 900; font-stretch: 112%;
  text-transform: uppercase; letter-spacing: -.01em; text-wrap: balance; margin-top: 22px; overflow-wrap: anywhere;
}
.stage-sub { margin-top: 8px; opacity: .85; font-weight: 500; }
.stage-eyebrow { font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--lime); margin-top: 20px; }
.stage-eyebrow + h1 { margin-top: 6px; }

.who {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 16px; padding: 10px 12px 10px 14px;
  border: 0; border-radius: 14px; background: rgba(255, 255, 255, .13); color: #fff; text-align: left; backdrop-filter: blur(8px);
}
.who span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.who em { font-style: normal; font-size: .8rem; font-weight: 700; padding: 5px 11px; border-radius: 999px; background: var(--lime); color: var(--lime-ink); flex: none; }

/* ---------- chiffres clés ---------- */

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: -44px; position: relative; z-index: 1; }
.fact { background: var(--surface); border-radius: var(--r-md); padding: 12px 6px; text-align: center; box-shadow: var(--shadow-lift); min-width: 0; }
.fact small { display: block; color: var(--muted); font-weight: 600; font-size: .66rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.fact b { display: block; font-size: 1.4rem; font-weight: 800; font-stretch: 108%; line-height: 1.2; margin-top: 2px; white-space: nowrap; }
.fact b i { font-style: normal; font-size: 1rem; color: var(--muted); font-weight: 600; }
.fact.accent { background: var(--lime); color: var(--lime-ink); }
.fact.accent small { color: inherit; opacity: .75; }
.fact.empty b { color: var(--muted); font-weight: 500; }

/* ---------- semaine ---------- */

.weeknav { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.weeknav > div { flex: 1; text-align: center; line-height: 1.2; }
.weeknav b { display: block; font-size: 1.15rem; font-weight: 800; font-stretch: 105%; }
.weeknav small { color: var(--muted); font-weight: 600; }
.weeknav .icon-btn { background: var(--surface); box-shadow: var(--shadow); width: 44px; height: 44px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: var(--line); margin-top: 14px; }
.segmented button { padding: 11px 8px; border: 0; border-radius: 12px; background: none; font-weight: 700; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.hint { color: var(--muted); font-size: .9rem; }
.grid-hint { display: flex; justify-content: space-between; gap: 10px; margin: 10px 4px 8px; }
#save-status { flex: none; font-weight: 600; color: var(--ok); }

/* ---------- grille des créneaux ---------- */

.grid-card { padding: 10px 8px 12px 4px; }
.grid { display: grid; grid-template-columns: 30px repeat(7, minmax(0, 1fr)); gap: 3px; }
.gh { text-align: center; padding-bottom: 5px; line-height: 1.15; }
.gh small { display: block; font-size: .64rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.gh b { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 800; font-size: .95rem; }
.gh.today b { background: var(--accent); color: var(--on-accent); }
.gh.past { opacity: .45; }
.hour { display: grid; align-items: center; justify-items: end; padding-right: 3px; font-size: .7rem; font-weight: 700; color: var(--muted); }

.cell {
  position: relative; height: 38px; padding: 0; border: 0; border-radius: 9px;
  background: var(--surface-2); color: var(--ink); font-weight: 800; font-size: .88rem;
}
.cell.n1, .sw.n1 { background: color-mix(in srgb, var(--lime) 24%, var(--surface-2)); }
.cell.n2, .sw.n2 { background: color-mix(in srgb, var(--lime) 46%, var(--surface-2)); }
.cell.n3, .sw.n3 { background: color-mix(in srgb, var(--lime) 72%, var(--surface-2)); }
.cell.n3 { color: var(--lime-ink); }
.cell.n4, .sw.n4 { background: var(--lime); }
.cell.n4 { color: var(--lime-ink); box-shadow: inset 0 0 0 2px rgba(28, 42, 0, .28); }
.cell.past { opacity: .38; }

/* « Mes dispos » : mes créneaux en bleu plein */
.grid.mine .cell.me, .sw.me { background: var(--accent); }
.grid.mine .cell.me { color: var(--on-accent); }
.grid.mine .cell.me.n4 { box-shadow: inset 0 0 0 3px var(--lime); }
/* « Vue du groupe » : un point bleu signale mes créneaux */
.grid.group .cell.me::after {
  content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 1.5px var(--surface);
}

.grid-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 12px 4px 0 10px; font-size: .76rem; font-weight: 600; color: var(--muted); }
.grid-legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* ---------- blocs ---------- */

.block { margin-top: 28px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 0 4px; }
.block-head h2 { font-size: 1.25rem; font-weight: 800; font-stretch: 105%; letter-spacing: -.01em; }
.block-head h3 { font-size: 1rem; font-weight: 800; }
.block-head.sub { margin: 18px 0 10px; }
.block-head .count { color: var(--muted); font-weight: 600; }

.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 10px; }
.card.flush { padding: 4px 16px; }
.card.first { margin-top: 16px; }
.card.grid-card { padding: 10px 8px 12px 4px; }

.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); min-height: 60px; }
.row:last-child { border-bottom: 0; }
.row-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-text strong { font-weight: 700; }
.bubble {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center; background: var(--surface-2); color: var(--accent);
}
a.row { width: 100%; text-decoration: none; color: inherit; }
.row .chev { color: var(--muted); opacity: .6; }
.you { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.del { width: 34px; height: 34px; margin-right: -8px; border-radius: 50%; border: 0; background: none; color: var(--muted); display: grid; place-items: center; flex: none; }

.date-tile {
  width: 52px; flex: none; border-radius: 14px; padding: 7px 0; text-align: center;
  background: var(--accent); color: var(--on-accent); line-height: 1.05;
}
.date-tile small { display: block; font-size: .64rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.date-tile b { display: block; font-size: 1.35rem; font-weight: 900; font-stretch: 108%; }
.date-tile.almost { background: var(--surface-2); color: var(--muted); }

.slot-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.slot-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 40px; border: 0; border-radius: 999px;
  background: var(--lime); color: var(--lime-ink); font-weight: 800;
}
.slot-chip small { display: inline-flex; align-items: center; gap: 3px; font-size: .8rem; font-weight: 700; opacity: .8; }
.slot-chip small .ic { width: 1em; height: 1em; stroke-width: 2.4; }
.slot-chip.almost { background: var(--surface-2); color: var(--ink); }

.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: .86rem; letter-spacing: .02em;
  background: hsl(var(--h) var(--av-s) var(--av-l)); color: hsl(var(--h) 60% var(--av-ink));
}
.chip { font-size: .78rem; font-weight: 700; white-space: nowrap; padding: 5px 10px; border-radius: 999px; flex: none; background: var(--surface-2); color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.maybe { background: var(--maybe-soft); color: var(--maybe); }

.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person { display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; border-radius: 999px; background: var(--surface-2); font-weight: 600; }
.person .avatar, .pick .avatar { width: 30px; height: 30px; font-size: .7rem; }

/* ---------- boutons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 14px 20px; border: 0; border-radius: 16px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 1rem; text-decoration: none;
}
.btn.soft { background: var(--surface-2); color: var(--ink); }
.btn.text { background: none; color: var(--accent); min-height: 44px; font-weight: 600; font-size: .92rem; margin-top: 4px; }
.btn:disabled { opacity: .55; cursor: default; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action {
  display: grid; gap: 2px; justify-items: start; text-align: left; align-content: start;
  background: var(--surface); border: 0; border-radius: var(--r-md); padding: 14px; box-shadow: var(--shadow);
}
.action .bubble { margin-bottom: 8px; }
.action b { font-weight: 700; }
.action small { color: var(--muted); font-size: .8rem; }
.action.primary { background: var(--accent); color: var(--on-accent); }
.action.primary .bubble { background: rgba(255, 255, 255, .2); color: inherit; }
.action.primary small { color: inherit; opacity: .85; }
.action:disabled { opacity: .5; }

/* ---------- formulaires ---------- */

.form { display: grid; gap: 14px; }
.form.inline { grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
.form.inline .btn { width: 54px; padding: 0; }
.field { display: grid; gap: 6px; font-size: .84rem; font-weight: 700; color: var(--muted); }
.field input, .field select {
  width: 100%; min-height: 52px; padding: 14px; font-size: 16px; font-weight: 500; color: var(--ink);
  background: var(--surface-2); border: 2px solid transparent; border-radius: var(--r-sm);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.field input::placeholder { color: var(--muted); opacity: .7; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px;
  background: var(--surface-2); font-weight: 600; border: 0; min-height: 44px;
}
.pick button.on { background: var(--accent); color: var(--on-accent); }
.pick button.on .avatar { background: rgba(255, 255, 255, .25); color: inherit; }

details.fold > summary { list-style: none; display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 700; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .chev { margin-left: auto; color: var(--muted); transition: transform .2s; }
details.fold[open] > summary .chev { transform: rotate(90deg); }
details.fold[open] > summary { margin-bottom: 16px; }

.notice { display: flex; gap: 12px; align-items: flex-start; }
.notice p { font-size: .9rem; color: var(--muted); margin-top: 2px; }

.footer { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 28px; }

/* ---------- panneau ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(5, 14, 30, .55); backdrop-filter: blur(3px);
}
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-lift);
}
.sheet:focus { outline: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 999px; background: var(--line); margin: 10px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px 6px; }
.sheet-head h2 { font-size: 1.3rem; font-weight: 800; line-height: 1.15; }
.sheet-head p { color: var(--muted); font-size: .88rem; }
.sheet-head .icon-btn { margin-left: auto; }
.sheet-body { overflow-y: auto; padding: 12px 20px 8px; display: grid; gap: 18px; overscroll-behavior: contain; }
.sheet-foot { display: grid; gap: 8px; padding: 12px 20px max(16px, env(safe-area-inset-bottom)); }

.q { display: grid; gap: 10px; }
.q-label { display: flex; align-items: center; gap: 6px; font-size: .84rem; font-weight: 700; color: var(--muted); }
.q-label b { color: var(--ink); font-size: 1rem; margin-right: -4px; }
.q-label .chip { margin-left: auto; }

/* ---------- notification ---------- */

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 40;
  transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: .92rem;
  padding: 12px 18px; border-radius: 999px; max-width: calc(100vw - 32px); box-shadow: var(--shadow-lift);
  transition: opacity .2s, transform .3s cubic-bezier(.2, .9, .3, 1.4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--no); color: #fff; }

/* ---------- animations ---------- */

.btn, .action, .icon-btn, .slot-chip, .pick button, .who, .segmented button, a.row { transition: transform .12s ease, background-color .15s, color .15s; }
.cell { transition: transform .1s ease, background-color .12s; }
.btn:active, .action:active, .icon-btn:active, .slot-chip:active, .pick button:active, .who:active { transform: scale(.96); }
.cell:active { transform: scale(.88); }
a.row:active { transform: scale(.985); }

@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: no-preference) {
  .enter .stage h1, .enter .stage-sub, .enter .stage-eyebrow, .enter .who { animation: rise .45s .1s ease both; }
  .enter .fact { animation: rise .45s ease both; }
  .enter .fact:nth-child(1) { animation-delay: .18s; }
  .enter .fact:nth-child(2) { animation-delay: .24s; }
  .enter .fact:nth-child(3) { animation-delay: .3s; }
  .enter .wrap > :not(.facts) { animation: rise .45s .34s ease both; }
  .sheet-backdrop.opening { animation: fade .2s ease both; }
  .sheet-backdrop.opening .sheet { animation: sheet-up .35s cubic-bezier(.2, .9, .25, 1) both; }
}

@media (max-width: 350px) {
  .grid2, .actions { grid-template-columns: 1fr; }
  .fact b { font-size: 1.15rem; }
}
