:root {
  --bg: #f7f4ee; --card: #ffffff; --ink: #24232b; --muted: #6f6c78; --line: #e6e1d8;
  --accent: #2a6f6b; --accent-ink: #ffffff; --accent-soft: #e2efed;
  --warn: #b5541c; --warn-soft: #fdeee3; --danger: #b3261e; --ok: #2e7d4f; --ok-soft: #e3f3e8;
  --weekend: #f1ede5; --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171b; --card: #222228; --ink: #ecebf0; --muted: #a09dab; --line: #34333c;
    --accent: #5fb3ac; --accent-ink: #0f1f1e; --accent-soft: #23393a;
    --warn: #f0a070; --warn-soft: #3a2a20; --danger: #ff8a80; --ok: #7fd3a0; --ok-soft: #1f3328;
    --weekend: #1d1d22; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; padding-bottom: calc(68px + var(--safe-b)); }
button, input, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px 5px 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; max-width: 55vw; }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c, #888); }

main { padding: 4px 16px 24px; max-width: 720px; margin: 0 auto; }
h2 { font-size: 20px; margin: 12px 0 8px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }

.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.warn { background: var(--warn); color: #fff; border-color: var(--warn); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.iconbtn { border: 0; background: transparent; padding: 8px; border-radius: 10px; cursor: pointer; display: inline-flex; }

input[type=text], input[type=time], input[type=number], select { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 10px; min-width: 0; }
input[type=number] { width: 70px; }
input[type=color] { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: var(--card); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }

/* Onboarding */
.who { display: grid; gap: 10px; margin-top: 12px; }
.who button { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); font-size: 17px; font-weight: 600; text-align: left; box-shadow: var(--shadow); cursor: pointer; }
.who .dot { width: 16px; height: 16px; }

/* Bandeaux */
.banner { border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; display: flex; gap: 10px; align-items: flex-start; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner b { color: inherit; }
.banner .grow { flex: 1; }

/* Calendrier */
.monthnav { display: flex; align-items: center; justify-content: space-between; margin: 6px 0; }
.monthnav h2 { margin: 0; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.day { position: relative; min-height: 66px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); padding: 4px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; overflow: hidden; text-align: left; }
.day.out { visibility: hidden; }
.day.we { background: var(--weekend); }
.day.today .num { background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 0 4px; }
.day.uncovered { border-style: dashed; border-color: var(--warn); }
.day.selected { outline: 2.5px solid var(--accent); outline-offset: -1px; background: var(--accent-soft); }
.day.mine { box-shadow: inset 0 0 0 2px var(--mycolor); }
.day .num { font-size: 13px; font-weight: 700; align-self: flex-start; }
.day .ferie { font-size: 9px; color: var(--warn); line-height: 1; }
.bar { height: 14px; border-radius: 4px; background: var(--c); color: #fff; font-size: 9px; line-height: 14px; padding: 0 2px; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 2px; font-size: 13px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }

.valid-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); display: inline-flex; gap: 5px; align-items: center; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

.selbar { position: fixed; left: 0; right: 0; bottom: calc(60px + var(--safe-b)); z-index: 6; padding: 10px 16px; background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.08); }
.selbar .inner { max-width: 720px; margin: 0 auto; }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar button { flex: 1; border: 0; background: none; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.tabbar button.active { color: var(--accent); font-weight: 700; }

/* Feuille modale */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow: auto; background: var(--card); border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + var(--safe-b)); max-width: 720px; margin: 0 auto; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet-body h2 { margin-top: 0; text-transform: capitalize; }
.entry { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--safe-b)); z-index: 30; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); }

.prof { display: grid; grid-template-columns: 38px 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prof .opts { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
.copy { display: flex; gap: 6px; }
.copy input { flex: 1; font-size: 12px; }
.steps { margin: 6px 0 0; padding-left: 20px; font-size: 13px; color: var(--muted); }
[hidden] { display: none !important; }
