:root {
  --bg: #FBF7F2;
  --surface: #FFFFFF;
  --surface-2: #F3EEE7;
  --border: #E7DFD4;
  --text: #2C2620;
  --text-secondary: #7A6F62;
  --text-muted: #A99C8C;
  --accent: #D4537E;
  --accent-dark: #A83A61;

  --c-travail: #9FE1CB; --c-travail-text: #04342C; --c-travail-strong: #1D9E75;
  --c-rdv: #F5C4B3; --c-rdv-text: #4A1B0C; --c-rdv-strong: #D85A30;
  --c-vacance: #C0DD97; --c-vacance-text: #173404; --c-vacance-strong: #639922;
  --c-perso: #EEEDFE; --c-perso-text: #26215C; --c-perso-strong: #7F77DD;

  --p-toi: #7F77DD;
  --p-copine: #D4537E;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 24px 12px 100px;
}
#app { width: 100%; max-width: 420px; }

h1 { font-size: 18px; font-weight: 600; margin: 0; }
.subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.avatars { display: flex; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 600;
  border: 2px solid var(--bg);
}
.avatar:not(:first-child) { margin-left: -12px; }

.chip-row { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  padding: 6px 13px; border-radius: 12px; font-size: 12px; cursor: pointer;
  background: var(--surface-2); color: var(--text-secondary); border: none;
  display: flex; align-items: center; gap: 6px; font-family: inherit;
  transition: transform .1s ease;
}
.chip:active { transform: scale(0.96); }
.chip.active { background: var(--accent); color: #fff; font-weight: 600; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }

.seg-control {
  display: flex; background: var(--surface-2); border-radius: 14px; padding: 3px; margin-bottom: 14px;
}
.seg-btn {
  flex: 1; border: none; background: none; padding: 8px 0; border-radius: 11px;
  font-size: 12px; font-weight: 600; color: var(--text-secondary); cursor: pointer; font-family: inherit;
}
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

.nav-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.nav-arrow {
  width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--surface-2);
  color: var(--text-secondary); font-size: 15px; cursor: pointer; display:flex; align-items:center; justify-content:center;
}
.nav-label { font-size: 13px; font-weight: 600; text-transform: capitalize; }

.week-day-block { margin-bottom: 14px; }
.week-day-block:last-child { margin-bottom: 0; }
.week-day-header {
  font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.week-day-header .today-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.week-day-empty { font-size: 12px; color: var(--text-muted); padding: 8px 10px; background: var(--surface-2); border-radius: 10px; }

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month-dow { text-align: center; font-size: 10px; color: var(--text-muted); padding-bottom: 6px; }
.month-cell {
  aspect-ratio: 1; border-radius: 12px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; cursor: pointer; gap: 3px; position: relative;
}
.month-cell .num { font-size: 12px; }
.month-cell.out-month .num { color: var(--text-muted); opacity: 0.5; }
.month-cell.selected { background: var(--c-rdv-strong); }
.month-cell.selected .num { color: #fff; font-weight: 700; }
.month-cell.today:not(.selected) .num { color: var(--accent); font-weight: 700; }
.month-dots { display: flex; gap: 2px; }
.month-dots span { width: 4px; height: 4px; border-radius: 50%; }

.day-strip { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 4px; }
.day-pill {
  flex: 0 0 auto; width: 40px; text-align: center; padding: 6px 0;
  border-radius: 14px; background: var(--surface-2); cursor: pointer; border: none;
  font-family: inherit;
}
.day-pill .dow { font-size: 10px; color: var(--text-muted); }
.day-pill .num { font-size: 13px; font-weight: 600; color: var(--text); }
.day-pill.active { background: var(--c-rdv-strong); }
.day-pill.active .dow, .day-pill.active .num { color: #fff; }

.card {
  background: var(--surface); border-radius: 20px; padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.grid-wrap { display: flex; position: relative; }
.hours-col { width: 38px; flex-shrink: 0; font-size: 10px; color: var(--text-muted); }
.hour-row { height: 52px; }
.events-col { position: relative; flex: 1; border-left: 1px solid var(--border); min-height: 728px; }
.event-block {
  position: absolute; left: 8px; right: 4px; border-radius: 12px; padding: 8px;
  cursor: pointer; overflow: hidden;
}
.event-block .ev-title { font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; gap:6px; }
.event-block .ev-time { font-size: 11px; margin-top: 2px; }
.ev-badge {
  width: 16px; height: 16px; border-radius: 50%; color: #fff; font-size: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.list-day-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 14px 0 8px; }
.list-day-label:first-child { margin-top: 0; }
.list-card {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; margin-bottom: 8px;
}
.list-card .stripe { width: 4px; align-self: stretch; border-radius: 2px; }
.list-card .info { flex: 1; }
.list-card .info .t { font-size: 13px; font-weight: 600; }
.list-card .info .h { font-size: 11px; margin-top: 1px; }

.empty-state { text-align: center; padding: 40px 16px; color: var(--text-muted); font-size: 13px; }

.tabbar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 420px;
  background: var(--surface); border-radius: 24px; padding: 10px 20px;
  display: flex; justify-content: space-around; align-items: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.tab-btn {
  background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer;
  padding: 6px; font-family: inherit;
}
.tab-btn.active { color: var(--accent); }
.tab-fab {
  width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff;
  border: none; font-size: 22px; cursor: pointer; margin-top: -26px;
  box-shadow: 0 0 0 4px var(--bg);
}

.cat-row {
  display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface-2);
  border-radius: 14px; margin-bottom: 8px; cursor: pointer;
}
.cat-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.cat-row .name { flex: 1; font-size: 13px; font-weight: 600; }
.cat-row .badge { font-size: 10px; color: var(--text-muted); background: var(--surface); padding: 2px 8px; border-radius: 8px; }

.settings-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface-2);
}
.settings-group { border-radius: 14px; overflow: hidden; margin-bottom: 18px; }
.settings-group .settings-row + .settings-row { border-top: 1px solid var(--bg); }
.settings-label { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; padding-left: 4px; }
.toggle { width: 36px; height: 20px; border-radius: 10px; position: relative; cursor: pointer; flex-shrink:0; }
.toggle.on { background: var(--accent); }
.toggle.off { background: var(--border); }
.toggle .knob { width: 16px; height: 16px; border-radius: 50%; background: #fff; position: absolute; top: 2px; transition: left .15s ease; }
.toggle.on .knob { left: 18px; }
.toggle.off .knob { left: 2px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(44,38,32,0.35); display: none;
  align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); width: 100%; max-width: 420px; border-radius: 24px 24px 0 0;
  padding: 20px; max-height: 88vh; overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header .close-x { font-size: 18px; color: var(--text-secondary); cursor: pointer; background:none; border:none; }
.modal-header .save-btn { font-size: 14px; font-weight: 600; color: var(--accent); background: none; border: none; cursor: pointer; font-family: inherit; }
.modal-header .title { font-size: 15px; font-weight: 600; }

label.field-label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 8px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px;
  font-size: 13px; font-family: inherit; background: var(--surface); color: var(--text); margin-bottom: 16px;
}
textarea { resize: none; min-height: 56px; }
.field-group { margin-bottom: 16px; }

.pill-select { padding: 9px 14px; border-radius: 14px; font-size: 12px; cursor: pointer; background: var(--surface-2); color: var(--text-secondary); border: none; font-family: inherit; }
.pill-select.selected { font-weight: 600; }
.add-pill { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1.5px dashed var(--text-muted); display:flex; align-items:center; justify-content:center; cursor:pointer; font-size: 16px; color: var(--text-secondary); }

.row-3 { display: flex; gap: 10px; }
.row-3 > div { flex: 1; }

.color-swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display:inline-block; }
.color-swatch.selected { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.icon-cell { aspect-ratio: 1; border-radius: 12px; background: var(--surface-2); display:flex; align-items:center; justify-content:center; cursor:pointer; font-size: 17px; }
.icon-cell.selected { background: var(--c-perso); box-shadow: 0 0 0 1.5px var(--c-perso-strong); }

.top-right-btn { font-size: 20px; background: none; border: none; cursor: pointer; color: var(--text-secondary); }

/* ---------- Écrans d'authentification / onboarding (pleine page) ---------- */
.auth-wrap { max-width: 380px; margin: 0 auto; padding-top: 24px; }
.brand { text-align: center; margin-bottom: 28px; }
.brand .logo { font-size: 34px; }
.brand h1 { font-size: 26px; margin-top: 6px; }
.brand .tag { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.auth-card { background: var(--surface); border-radius: 20px; padding: 22px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.btn-primary {
  width: 100%; padding: 13px; border-radius: 14px; border: none; background: var(--accent);
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-secondary {
  width: 100%; padding: 13px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.auth-switch { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 16px; }
.auth-switch a { color: var(--accent); font-weight: 600; text-decoration: none; cursor: pointer; }
.form-error { background: #FBE3EB; color: #993C1D; font-size: 12px; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; display: none; }
.form-error.show { display: block; }
.divider { text-align: center; font-size: 11px; color: var(--text-muted); margin: 16px 0; }
.invite-code-box {
  font-size: 26px; font-weight: 700; letter-spacing: 4px; text-align: center; background: var(--surface-2);
  padding: 16px; border-radius: 14px; margin: 16px 0; color: var(--text);
}
.qr-box { display: flex; justify-content: center; margin: 16px 0; }
.qr-box canvas, .qr-box img { border-radius: 12px; }
.share-link { font-size: 12px; color: var(--text-secondary); word-break: break-all; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; }
.whatsapp-btn { background: #25D366; color: #fff; }
.spacer-8 { height: 8px; }
.spacer-16 { height: 16px; }
