/* Tokens. Rayon : 14px pour les blocs, 10px pour les contrôles (boutons, champs, créneaux). */
:root {
  --bg: #f7f7f8;
  --surface: #fdfdfd;
  --surface-2: #f0f0f2;
  --text: #17171a;
  --muted: #5e5e66;
  --line: #e2e2e6;
  --accent: #0b7356;
  --accent-ink: #fdfdfd;
  --accent-soft: #e3f2ec;
  --danger: #b4322a;
  --danger-soft: #fbeceb;
  --warn: #8a5a00;
  --warn-soft: #fbf1dc;
  --shadow: 0 1px 2px rgb(23 23 26 / .04), 0 8px 28px rgb(23 23 26 / .06);
  --r: 14px;
  --r-sm: 10px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e10;
    --surface: #161618;
    --surface-2: #1f1f22;
    --text: #ededef;
    --muted: #a3a3ab;
    --line: #2a2a2e;
    --accent: #3fcf9f;
    --accent-ink: #062b1f;
    --accent-soft: #11291f;
    --danger: #f07a70;
    --danger-soft: #2c1513;
    --warn: #f0c060;
    --warn-soft: #2a2110;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 28px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Geist", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.025em; line-height: 1.15; font-weight: 600; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
.num { font-family: "Geist Mono", ui-monospace, monospace; font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Layout */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; text-decoration: none; color: inherit; }
.mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 15px;
}
.topbar .ghost { font-size: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: transform .15s var(--ease), opacity .2s, background .2s;
}
.btn:hover { opacity: .92; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; }
.ghost {
  background: none; border: 0; color: var(--muted); cursor: pointer; display: inline-flex;
  align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px;
}
.ghost:hover { color: var(--text); background: var(--surface-2); }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; font-size: 17px;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Forms */
.field { display: grid; gap: 6px; }
.field label { font-size: 13.5px; font-weight: 550; }
.field .hint { font-size: 13px; color: var(--muted); }
.field .err { font-size: 13px; color: var(--danger); }
.input, textarea.input, select.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 104px; padding: 12px 14px; resize: vertical; }
.input::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.alert { padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert i { font-size: 18px; margin-top: 1px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--accent-soft); color: var(--accent); }

/* Gate (code / mot de passe) */
.gate { display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center; min-height: calc(100dvh - 64px); padding: 24px 0 48px; }
.gate h1 { font-size: clamp(34px, 4.6vw, 52px); letter-spacing: -0.035em; max-width: 13ch; }
.gate p.lead { margin-top: 16px; font-size: 17px; color: var(--muted); max-width: 42ch; }
.gate form { margin-top: 32px; display: grid; gap: 12px; max-width: 380px; }
.gate .row { display: flex; gap: 10px; }
.gate .row .input { flex: 1; }
.gate figure { margin: 0; border-radius: 22px; overflow: hidden; aspect-ratio: 4 / 5; background: var(--surface-2); }
.gate figure img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.85); }
@media (max-width: 860px) {
  .gate { grid-template-columns: 1fr; gap: 32px; min-height: 0; padding-top: 32px; }
  .gate figure { aspect-ratio: 16 / 10; order: -1; }
}

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h2 { font-size: 19px; text-transform: capitalize; }
.cal-head .nav { display: flex; gap: 6px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: 12px; color: var(--muted); text-align: center; padding-bottom: 4px; font-weight: 500; }
.day {
  position: relative; aspect-ratio: 1 / 1; min-height: 44px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; cursor: default;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 15px; color: color-mix(in srgb, var(--muted) 70%, transparent);
  transition: background .15s, border-color .15s, transform .15s var(--ease);
}
.day .sub { font-size: 10.5px; line-height: 1; color: var(--muted); }
.day.open { background: var(--accent-soft); color: var(--text); font-weight: 550; cursor: pointer; }
.day.open:hover { border-color: var(--accent); }
.day.open:active { transform: scale(.97); }
.day.full { background: var(--surface-2); color: var(--muted); text-decoration: line-through; cursor: not-allowed; }
.day.selected, .day.selected:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.day.selected .sub { color: var(--accent-ink); opacity: .85; }
.day.today::after { content: ""; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.day.blank { visibility: hidden; }
.legend { display: flex; gap: 18px; margin-top: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend b { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* Empty state */
.empty { display: grid; place-items: center; text-align: center; gap: 10px; padding: 64px 12px; color: var(--muted); }
.empty i { font-size: 34px; color: var(--accent); }
.empty h3 { color: var(--text); font-size: 17px; }

/* Skeleton */
.skel { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; border-radius: var(--r-sm); }
@media (prefers-reduced-motion: no-preference) {
  .skel { animation: shimmer 1.4s linear infinite; }
  .reveal { animation: reveal .5s var(--ease) both; }
  .reveal.d1 { animation-delay: .06s; } .reveal.d2 { animation-delay: .12s; } .reveal.d3 { animation-delay: .18s; }
}
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes reveal { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: var(--r-sm);
  font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

.footer { padding: 32px 0 40px; font-size: 13px; color: var(--muted); }

/* Petits écrans : le calendrier doit tenir dans 360px */
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .cal { gap: 4px; }
  .day { min-height: 0; font-size: 14px; }
  .day .sub { font-size: 9px; }
  .tabs { scrollbar-width: none; }
}

/* Bandeau d'installation */
.install {
  position: fixed; z-index: 40; left: 16px; right: 16px; bottom: 16px; margin: 0 auto; max-width: 520px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.install img { border-radius: 11px; display: block; }
.install-text { display: grid; gap: 2px; font-size: 14px; }
.install-text p { color: var(--muted); }
.install-text i { vertical-align: -2px; font-size: 16px; color: var(--text); }
.install-actions { display: flex; gap: 6px; align-items: center; }
@media (max-width: 520px) {
  .install { grid-template-columns: auto 1fr; }
  .install-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (prefers-reduced-motion: no-preference) {
  .install { animation: reveal .45s var(--ease) both; }
}
