:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --text: #1f1d1a;
  --muted: #77716a;
  --line: #e4ded5;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --danger: #b83a2b;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 6px 24px rgb(0 0 0 / .06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #211f1c;
    --surface-2: #2a2824;
    --text: #f1ede7;
    --muted: #9b958d;
    --line: #34302b;
    --accent: #6cc0a6;
    --accent-ink: #0d1a16;
    --danger: #ef7a6b;
    --shadow: none;
    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.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.loading { text-align: center; color: var(--muted); margin-top: 40vh; }

/* ---------- en-tête */
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px calc(110px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 6px; }
.top .title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.top .hello { color: var(--muted); font-size: 14px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- navigation mois */
.monthbar { display: flex; align-items: center; gap: 8px; margin: 10px 0 8px; }
.monthbar h2 { flex: 1; min-width: 0; margin: 0; font-size: 19px; font-weight: 650; text-transform: capitalize; white-space: nowrap; }
@media (max-width: 350px) { .monthbar .chip-btn { display: none; } }
.monthbar .icon-btn { width: 36px; height: 36px; }
.chip-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 14px;
}

/* ---------- grille */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.cal { padding: 8px 6px 10px; touch-action: pan-y; }
.dow, .grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.dow span { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 0 6px; }
.day {
  position: relative; height: 58px; border: 0; background: none; padding: 6px 0 0;
  display: flex; flex-direction: column; align-items: center;
}
.day .num {
  width: 28px; height: 28px; line-height: 28px; border-radius: 50%;
  font-size: 15px; font-variant-numeric: tabular-nums;
}
.day.out .num { color: var(--muted); opacity: .55; }
.day.past:not(.out) .num { color: var(--muted); }
.day.today .num { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.day .bar {
  position: absolute; left: -1px; right: -1px; bottom: 5px; height: 17px;
  background: var(--c);
}
.day .lbl {
  position: absolute; left: 8px; bottom: 5px; z-index: 1; width: calc(var(--n) * 100% - 14px);
  color: #fff; font-size: 11px; font-weight: 650; line-height: 17px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.day.past .lbl { opacity: .85; }
.day.out .bar, .day.past .bar { opacity: .5; }
.day .bar.s { left: 4px; border-top-left-radius: 9px; border-bottom-left-radius: 9px; }
.day .bar.e { right: 4px; border-top-right-radius: 9px; border-bottom-right-radius: 9px; }
.day:active .num { background: var(--surface-2); }
.day.today:active .num { background: var(--accent); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 4px 0; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- liste des séjours */
.section-title { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 4px 8px; }
.list { display: flex; flex-direction: column; }
.item {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  border: 0; background: none; padding: 12px 14px; border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item .stripe { width: 5px; align-self: stretch; border-radius: 3px; background: var(--c); flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .who { font-weight: 650; }
.item .when { font-size: 14px; color: var(--muted); }
.item .note { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); flex: none; }
.badge.now { background: var(--accent); color: var(--accent-ink); }
.empty { padding: 18px; color: var(--muted); text-align: center; }

.fab {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom));
  border: 0; border-radius: 999px; padding: 14px 22px; background: var(--accent); color: var(--accent-ink);
  font-weight: 650; font-size: 17px; box-shadow: 0 6px 20px rgb(0 0 0 / .22);
}

/* ---------- feuilles (modales) */
.backdrop {
  position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 10;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .18s;
}
.backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(24px); transition: transform .2s;
}
.backdrop.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 12px; position: sticky; top: -8px; background: var(--bg); z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 20px; }
@media (min-width: 600px) {
  .backdrop { align-items: center; }
  .sheet { border-radius: 20px; }
}

/* ---------- formulaires */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); padding: 10px 12px; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
input[type=date] { display: block; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.btn {
  min-height: 48px; border-radius: 12px; border: 0; padding: 0 18px;
  background: var(--accent); color: var(--accent-ink); font-weight: 650; font-size: 17px;
}
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: none; color: var(--danger); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; }
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.err { color: var(--danger); margin: 0; font-size: 15px; }
.err:empty, .hint:empty { display: none; }
.hint { color: var(--muted); margin: 0; font-size: 14px; }
.ok { color: var(--accent); margin: 0; font-size: 15px; }
.ok:empty { display: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; background: var(--c); }
.swatch[aria-pressed=true] { border-color: var(--bg); box-shadow: 0 0 0 2px var(--text); }

.group { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.group h3 { margin: 0; font-size: 17px; }
.group p { margin: 0; }
.detail { font-size: 17px; }
.detail .who { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 20px; }

/* ---------- connexion */
.auth { max-width: 380px; margin: 0 auto; padding: 12vh 20px 40px; display: flex; flex-direction: column; gap: 18px; }
.auth img { width: 76px; height: 76px; border-radius: 18px; align-self: center; box-shadow: var(--shadow); }
.auth h1 { text-align: center; margin: 0; font-size: 26px; }
.auth .hint { text-align: center; }
select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2377716a' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
