/* =====================================================================
   Ma Maison — styles
   ===================================================================== */

:root {
  --bg: #f2f4f0;
  --surface: #ffffff;
  --surface-2: #f6f7f4;
  --surface-3: #eceee9;
  --text: #1d2a23;
  --muted: #6b766f;
  --border: #e2e6e0;
  --primary: #2e7d57;
  --primary-hover: #276c4b;
  --primary-soft: #dcefe3;
  --check: #34a36b;
  --sidebar: #2f5d4b;
  --sidebar-ink: #eaf3ee;
  --danger: #d23f3f;
  --late: #d93a3a;
  --leaf: #6cbf4b;
  --shadow: 0 1px 2px rgba(25, 45, 35, .06), 0 3px 10px rgba(25, 45, 35, .06);
  --shadow-lg: 0 10px 40px rgba(20, 40, 30, .18);
  --radius: 14px;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --hand: 'Caveat', 'Segoe Print', cursive;
  --bottom-nav: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

/* Mode sombre : automatique (système) ou forcé dans les Paramètres */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1612; --surface: #18221d; --surface-2: #121b16; --surface-3: #1f2b25;
    --text: #e6eee9; --muted: #95a49b; --border: #26332c;
    --primary: #3a9a6a; --primary-hover: #44ad79; --primary-soft: #1d3a2b; --check: #43b77b;
    --sidebar: #13241c; --sidebar-ink: #dcebe2; --late: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 10px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1612; --surface: #18221d; --surface-2: #121b16; --surface-3: #1f2b25;
  --text: #e6eee9; --muted: #95a49b; --border: #26332c;
  --primary: #3a9a6a; --primary-hover: #44ad79; --primary-soft: #1d3a2b; --check: #43b77b;
  --sidebar: #13241c; --sidebar-ink: #dcebe2; --late: #ff6b6b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 10px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- Couleurs des listes et étiquettes ---------- */
[data-c="blue"]   { --c-bg: #dce9fb; --c-fg: #1f4f8f; --c-head: #cfe2fa; --c-solid: #3b82f6; }
[data-c="yellow"] { --c-bg: #fdf0c6; --c-fg: #845c00; --c-head: #fde6a3; --c-solid: #f2b705; }
[data-c="green"]  { --c-bg: #d8f0da; --c-fg: #22703d; --c-head: #cdebd1; --c-solid: #34a853; }
[data-c="gray"]   { --c-bg: #e8ebe7; --c-fg: #4a554f; --c-head: #e4e7e3; --c-solid: #8a958f; }
[data-c="orange"] { --c-bg: #ffe4cc; --c-fg: #96480a; --c-head: #ffd9b8; --c-solid: #f28a2e; }
[data-c="red"]    { --c-bg: #fde0dd; --c-fg: #b3261e; --c-head: #fbd2ce; --c-solid: #e5484d; }
[data-c="pink"]   { --c-bg: #f7def0; --c-fg: #93306f; --c-head: #f4d0ea; --c-solid: #d6409f; }
[data-c="purple"] { --c-bg: #e9e0fb; --c-fg: #5a36a6; --c-head: #ddd1f8; --c-solid: #8e5cf0; }
[data-c="teal"]   { --c-bg: #d3f1ed; --c-fg: #136e66; --c-head: #c3ebe5; --c-solid: #14b8a6; }
[data-c="brown"]  { --c-bg: #efe3d7; --c-fg: #7a4a22; --c-head: #e8d8c8; --c-solid: #a0703f; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [data-c] { --c-bg: color-mix(in srgb, var(--c-solid) 22%, #18221d); --c-fg: color-mix(in srgb, var(--c-solid) 55%, #ffffff); --c-head: color-mix(in srgb, var(--c-solid) 28%, #18221d); }
}
:root[data-theme="dark"] [data-c] { --c-bg: color-mix(in srgb, var(--c-solid) 22%, #18221d); --c-fg: color-mix(in srgb, var(--c-solid) 55%, #ffffff); --c-head: color-mix(in srgb, var(--c-solid) 28%, #18221d); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
[hidden] { display: none !important; }
.ico { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.error { color: var(--danger); }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

input[type="text"], input[type="email"], input[type="search"], input[type="date"], input:not([type]), select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; }

.splash { height: 100dvh; display: grid; place-content: center; justify-items: center; color: var(--sidebar); font-weight: 800; font-size: 22px; }
.splash p { margin: 8px 0 0; }
.logo { width: 40px; height: 40px; color: var(--sidebar); }
.logo.big { width: 84px; height: 84px; }
.logo.tiny { width: 22px; height: 22px; vertical-align: -5px; }
:root[data-theme="dark"] .logo { color: #cfe6d9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo { color: #cfe6d9; } }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border-radius: 12px; background: var(--primary); color: #fff; font-weight: 700;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--surface-3); color: var(--text); }
.btn.ghost:hover { background: var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--danger); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; pointer-events: none; }
.link-btn { color: var(--primary); font-weight: 700; padding: 6px 4px; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; color: var(--text); position: relative;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn.sm .ico { width: 18px; height: 18px; }
.icon-btn.on { color: var(--primary); background: var(--primary-soft); }
.round-add {
  width: 46px; height: 46px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(46, 125, 87, .35); flex: none;
}
.round-add .ico { width: 24px; height: 24px; }
.round-add:hover { background: var(--primary-hover); }

/* ---------- Structure ---------- */
.shell { display: grid; grid-template-columns: 196px 1fr; height: 100dvh; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view { flex: 1; min-height: 0; overflow: auto; }
.view[data-view="tableau"] { overflow: hidden; display: flex; }

.sidebar {
  background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column;
  padding: 22px 12px 16px; gap: 6px;
}
.side-logo { display: grid; place-items: center; height: 64px; margin-bottom: 14px; }
.side-logo .ico { width: 40px; height: 40px; stroke-width: 1.8; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px; border-radius: 10px; font-weight: 600; opacity: .92; }
.side-nav a:hover { background: rgba(255, 255, 255, .08); }
.side-nav a.active { background: rgba(255, 255, 255, .16); opacity: 1; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; color: inherit; font-weight: 600; text-align: left; }
.side-user:hover { background: rgba(255, 255, 255, .08); }
.side-user span:not(.avatar) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .chev { width: 16px; }

.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 24px; min-height: 72px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.board-switch { flex: 0 1 auto; display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 800; padding: 6px 10px; border-radius: 12px; min-width: 0; }
.board-switch:hover { background: var(--surface-3); }
.board-switch .house { width: 28px; height: 28px; }
.board-switch .chev { width: 18px; height: 18px; }
.board-name { min-width: 3ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-spacer { flex: 1; }
.progress-pill { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--primary-soft); font-size: 14px; cursor: pointer; white-space: nowrap; }
.progress-pill em { font-style: normal; color: var(--muted); }
.ring { width: 30px; height: 30px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring-bg { stroke: rgba(46, 125, 87, .18); }
.ring-fg { stroke: var(--primary); stroke-linecap: round; transition: stroke-dasharray .4s; }
.search { position: relative; display: flex; align-items: center; width: 240px; }
.search .ico { position: absolute; left: 12px; width: 18px; color: var(--muted); }
.search input { padding-left: 38px; border-radius: 999px; min-height: 40px; background: var(--surface); }
.search-toggle { display: none; }
.mobile-search { display: none; }
.sync-chip { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); padding: 6px 10px; border-radius: 999px; background: var(--surface-3); cursor: pointer; white-space: nowrap; }
.sync-chip .ico { width: 16px; height: 16px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bell .badge {
  position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--late); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center;
}
.filter-btn.on { color: var(--primary); background: var(--primary-soft); }
.week-bar { display: none; }
.tabs { display: none; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 24px 0; }
.bottom-nav, .fab { display: none; }

/* ---------- Micro (création vocale) ---------- */
.round-mic {
  width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); border: 2px solid var(--primary);
}
.round-mic .ico { width: 22px; height: 22px; }
.round-mic:hover { background: var(--primary); color: #fff; }
.fab-mic { display: none; }

.voice { gap: 14px; }
.voice-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.voice-center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 8px 0 4px; }
.mic-big {
  width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; margin: 8px 0;
  background: var(--primary); color: #fff; box-shadow: 0 8px 24px rgba(46, 125, 87, .35); position: relative;
}
.mic-big .ico { width: 44px; height: 44px; }
.mic-big.on { background: var(--danger); box-shadow: 0 8px 24px rgba(210, 63, 63, .35); }
.mic-big.on::before, .mic-big.on::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--danger); animation: pulse 1.6s ease-out infinite;
}
.mic-big.on::after { animation-delay: .8s; }
@keyframes pulse { from { transform: scale(1); opacity: .7; } to { transform: scale(1.6); opacity: 0; } }
.voice-status { margin: 0; font-weight: 800; font-size: 18px; }
.voice-live { margin: 0; min-height: 1.4em; font-size: 17px; color: var(--primary); font-weight: 700; }
.voice-center .link-btn, .voice .link-btn { display: inline-flex; align-items: center; gap: 6px; }
.voice p .ico { width: 16px; height: 16px; vertical-align: -3px; }
.voice-review { display: flex; flex-direction: column; gap: 16px; }
.notice-inline { margin: 0; padding: 10px 12px; border-radius: 10px; background: #fff6dc; color: #6b4e00; font-size: 14px; }
.pill em { font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; opacity: .75; }
.pill.removable button { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: -6px; border-radius: 50%; color: inherit; }
.pill.removable button:hover { background: rgba(0, 0, 0, .08); }
.voice .pill.removable { min-height: 32px; font-size: 14px; }

/* ---------- Photos ---------- */
.thumb.missing { background: var(--surface-3); }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-preview { display: flex; flex-direction: column; gap: 10px; }
.photo-open { display: block; border-radius: 12px; overflow: hidden; align-self: flex-start; max-width: 100%; }
.photo-open img { display: block; max-width: 100%; max-height: 240px; object-fit: cover; }
.modal-wrap.light .backdrop { background: rgba(0, 0, 0, .88); }
.lightbox { position: relative; display: grid; place-items: center; max-width: 100%; max-height: 100%; }
.lightbox img { max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); border-radius: 10px; object-fit: contain; }
.lightbox .icon-btn { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; background: rgba(0, 0, 0, .5); color: #fff; }

/* ---------- Avatars et pastilles ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  background: var(--c-bg, var(--surface-3)); color: var(--c-fg, var(--text)); font-weight: 800; font-size: 13px; object-fit: cover;
}
.avatar .ico { width: 16px; height: 16px; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.sidebar .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  background: var(--c-bg); color: var(--c-fg); font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.pill .ico { width: 14px; height: 14px; }
.pill.toggle { min-height: 34px; padding: 4px 12px; opacity: .55; border: 1.5px solid transparent; }
.pill.toggle.on { opacity: 1; border-color: currentColor; }
.pill.removable { min-height: 30px; }

/* ---------- Tableau ---------- */
.board {
  flex: 1; display: flex; gap: 16px; align-items: flex-start; padding: 20px 24px;
  overflow-x: auto; overflow-y: hidden; min-height: 0;
}
.list {
  flex: none; width: 290px; max-height: 100%; display: flex; flex-direction: column;
  background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border);
}
.list-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 8px 12px 16px;
  background: var(--c-head); border-radius: var(--radius) var(--radius) 0 0;
}
.list-head h2 { font-size: 20px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-head .count { font-weight: 700; color: var(--muted); margin-right: auto; }
.list-cards > * { flex: none; }
.list-cards { flex: 1; min-height: 60px; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.add-card { display: flex; align-items: center; gap: 8px; margin: 0 10px 10px; padding: 10px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.add-card:hover { background: var(--surface-3); color: var(--text); }
.add-list-col { background: transparent; border: 0; }
.add-list {
  width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed var(--border); border-radius: var(--radius); color: var(--muted); font-weight: 700; font-size: 16px;
}
.add-list:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- Cartes ---------- */
.card {
  position: relative; display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; min-height: 60px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .12s, box-shadow .12s;
}
.card:hover { box-shadow: 0 2px 4px rgba(25, 45, 35, .08), 0 6px 16px rgba(25, 45, 35, .08); }
.card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.card.pressing { transform: scale(.97); }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.card-title { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.card.done .card-title { color: var(--muted); }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.card-meta .ico { width: 15px; height: 15px; }
.due, .meta-item { display: inline-flex; align-items: center; gap: 4px; }
.due.is-late, .due.is-soon { color: var(--late); font-weight: 700; }
.due.is-done span { text-decoration: line-through; }
.meta-item.ok { color: var(--check); }
.list-name { padding: 1px 8px; border-radius: 999px; background: var(--c-bg); color: var(--c-fg); font-weight: 700; font-size: 12px; }
.card-foot { display: flex; align-items: flex-end; gap: 8px; }
.card-foot .pills { flex: 1; }
.thumb { width: 82px; height: 66px; border-radius: 8px; object-fit: cover; flex: none; }

.check {
  width: 26px; height: 26px; flex: none; border-radius: 50%; border: 2px solid #b8c2bc; display: grid; place-items: center;
  color: transparent; background: var(--surface); transition: background .15s, border-color .15s;
  position: relative;
}
.check::after { content: ''; position: absolute; inset: -9px; } /* grande zone tactile */
.check .ico { width: 15px; height: 15px; stroke-width: 3.2; }
.check:hover { border-color: var(--check); color: var(--check); }
.check.on { background: var(--check); border-color: var(--check); color: #fff; }
.check.big { width: 32px; height: 32px; }
.check.sm { width: 22px; height: 22px; }
.check.sm .ico { width: 12px; height: 12px; }

/* Glisser-déposer */
.drag-ghost {
  position: fixed; top: 0; left: 0; z-index: 100; pointer-events: none; margin: 0;
  box-shadow: var(--shadow-lg); opacity: .96; cursor: grabbing;
}
.drag-source { display: none; }
.card-placeholder { border-radius: 12px; border: 2px dashed var(--primary); background: var(--primary-soft); opacity: .7; flex: none; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
body.is-dragging .board { scroll-snap-type: none !important; }

/* ---------- Pages (calendrier, mes tâches, paramètres) ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 24px; }
.page h1 { font-size: 26px; font-weight: 800; margin-bottom: 18px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.group { margin-bottom: 26px; }
.group h2 { font-size: 17px; font-weight: 800; margin-bottom: 10px; display: flex; gap: 8px; align-items: center; }
.group h2 .count, .count { color: var(--muted); font-weight: 700; }
.my-tasks { max-width: 680px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); display: grid; justify-items: center; gap: 6px; }
.empty .ico { width: 44px; height: 44px; color: var(--primary); opacity: .7; }
.empty strong { color: var(--text); font-size: 17px; }

/* Calendrier */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.cal-head h1 { margin: 0; text-transform: capitalize; min-width: 200px; text-align: center; }
.cal-head .btn { margin-left: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dow { text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.day {
  min-height: 104px; padding: 6px; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; text-align: left; overflow: hidden;
}
.day.out { opacity: .45; }
.day .num { font-weight: 800; font-size: 13px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.day.today .num { background: var(--primary); color: #fff; }
.day.selected { outline: 2px solid var(--primary); }
.day-items { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ev { font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--c-bg); color: var(--c-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.done { text-decoration: line-through; opacity: .6; }
.day .more { font-size: 12px; color: var(--muted); font-weight: 700; padding-left: 4px; }
.dots { display: none; }
.day-panel { margin-top: 22px; }
.day-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.day-panel-head h2 { font-size: 18px; text-transform: capitalize; }

/* Paramètres */
.settings { max-width: 760px; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 14px; }
.panel h2 { font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.panel h2 .ico { color: var(--primary); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.field > span .ico { width: 16px; height: 16px; }
.field em { font-style: normal; }
.profile-row { display: flex; align-items: center; gap: 16px; }
.profile-row p { margin: 6px 0 0; }
.segmented { display: inline-flex; background: var(--surface-3); padding: 4px; border-radius: 12px; gap: 4px; align-self: flex-start; flex-wrap: wrap; }
.segmented button { min-height: 38px; padding: 0 14px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rows li { display: flex; align-items: center; gap: 10px; }
.rows li small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.rows li.pending { opacity: .8; }
.tag { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface-3); padding: 3px 8px; border-radius: 999px; }
.inline-form { display: flex; gap: 8px; }
.inline-form.wrap { flex-wrap: wrap; }
.inline-form.wrap input { flex: 2 1 180px; width: auto; }
.inline-form.wrap select { flex: 1 1 120px; width: auto; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.label-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 4px 0 8px; }
.labels-edit input { min-height: 40px; }
.color-select {
  width: 44px !important; min-height: 40px; padding: 0; flex: none; appearance: none; -webkit-appearance: none;
  background: var(--c-solid) !important; border-color: transparent !important; color: transparent; cursor: pointer; border-radius: 10px;
}
.color-select option { color: var(--text); background: var(--surface); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); background: #fff6dc; color: #6b4e00; margin-bottom: 16px; }
.notice p { margin: 4px 0 0; }
.notice .ico { margin-top: 2px; }
:root[data-theme="dark"] .notice { background: #3a3014; color: #f5dfa0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .notice { background: #3a3014; color: #f5dfa0; } }
.about { text-align: center; color: var(--muted); font-family: var(--hand); font-size: 22px; margin: 24px 0 8px; }

/* ---------- Modales et menus ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .16s; }
.modal-wrap.closing { animation: fade .16s reverse forwards; }
.backdrop { position: absolute; inset: 0; background: rgba(12, 24, 18, .45); backdrop-filter: blur(2px); }
.modal {
  position: relative; width: min(600px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.modal.small { width: min(420px, 100%); }
.modal.small p { margin: 0; font-size: 16px; }
.modal h2 { font-size: 19px; font-weight: 800; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: .5; } }

.editor { padding: 0; gap: 0; }
.ed-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 14px 12px 20px; position: sticky; top: 0; background: var(--surface); z-index: 2; border-bottom: 1px solid var(--border); }
.ed-head .check { margin-top: 6px; }
.ed-head textarea { border: 0; padding: 6px 0; font-size: 20px; font-weight: 800; resize: none; min-height: 0; background: transparent; overflow: hidden; }
.ed-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 18px; }
.editor .modal-foot { padding: 12px 20px 18px; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.date-row { display: flex; gap: 6px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 999px; background: var(--surface-3); font-weight: 700; font-size: 14px; border: 2px solid transparent; }
.chip.on { background: var(--c-head); color: var(--c-fg); border-color: var(--c-solid); }
.label-pick { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.label-pick small, .filter-pop small, .bell-pop small { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.checklist li { display: flex; align-items: center; gap: 10px; }
.checklist input { border-color: transparent; background: var(--surface-2); min-height: 40px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches input { position: absolute; opacity: 0; }
.swatches span { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c-solid); cursor: pointer; border: 3px solid transparent; }
.swatches input:checked + span { border-color: var(--text); }
.swatches input:focus-visible + span { outline: 2px solid var(--primary); }

.popover {
  position: fixed; z-index: 60; min-width: 230px; max-width: min(340px, calc(100vw - 16px)); max-height: 70vh; overflow: auto;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; border: 1px solid var(--border);
  animation: fade .12s;
}
.popover > button, .bell-pop > button {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; text-align: left; font-weight: 600;
}
.popover > button:hover, .bell-pop > button:hover { background: var(--surface-3); }
.popover > button.on { color: var(--primary); }
.popover > button.danger { color: var(--danger); }
.popover hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.filter-pop, .bell-pop { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.bell-pop > button { padding: 8px; min-height: 52px; }
.bell-pop > button small { display: block; color: var(--muted); font-size: 12.5px; }
.bell-pop .dot { width: 10px; height: 10px; border-radius: 50%; background: #f2b705; flex: none; }
.bell-pop .dot.late { background: var(--late); }
.bell-pop p { margin: 4px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); z-index: 80;
  background: #1f2f27; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Connexion ---------- */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 20% 10%, #e3f1e6, transparent 50%), radial-gradient(circle at 90% 90%, #f3ecd9, transparent 45%), var(--bg);
}
.login-card { width: min(420px, 100%); background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 32px 26px; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.login-card h1 { font-size: 34px; font-weight: 800; color: var(--sidebar); }
.login-card .slogan { font-family: var(--hand); font-size: 26px; margin: -10px 0 8px; }
.login-card form, .login-card > .btn { width: 100%; text-align: left; }
.login-card .sent { margin: 0; }
.login-card .sent .ico { color: var(--primary); vertical-align: -4px; }
.or { width: 100%; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.btn.google { background: var(--surface); color: var(--text); border: 1px solid var(--border); min-height: 50px; font-size: 1.02rem; box-shadow: var(--shadow); }
.btn.google:hover { border-color: var(--muted); }
.google .ico { width: 20px; height: 20px; }

/* =====================================================================
   Mobile
   ===================================================================== */
@media (max-width: 899px) {
  .shell { display: flex; flex-direction: column; height: 100dvh; }
  .sidebar { display: none; }
  .main { flex: 1; padding-top: env(safe-area-inset-top, 0px); }
  .topbar { min-height: 60px; padding: 8px 8px 8px 12px; gap: 4px; border-bottom: 0; }
  .board-switch { font-size: 21px; padding: 6px; gap: 8px; }
  .progress-pill, .topbar .search, .round-add, .round-mic, .sync-chip span { display: none; }
  .sync-chip { padding: 8px; }
  .search-toggle { display: inline-grid; }
  .shell.search-open .mobile-search { display: block; padding: 0 16px 10px; background: var(--surface); }
  .mobile-search .search { width: 100%; }

  .shell:not([data-route="tableau"]) .week-bar, .shell:not([data-route="tableau"]) .tabs { display: none; }
  .week-bar {
    display: flex; align-items: center; gap: 10px; padding: 0 16px 10px; background: var(--surface); font-size: 13px; color: var(--muted);
  }
  .week-bar strong { color: var(--text); }
  .week-bar .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
  .week-bar .bar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width .4s; }

  .tabs {
    display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; scrollbar-width: none; background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; min-height: 38px; padding: 0 14px; border-radius: 10px; font-weight: 700; color: var(--muted); white-space: nowrap; }
  .tabs button.active { background: var(--c-head); color: var(--c-fg); }
  .tabs .tab-add .ico { width: 18px; }
  .active-filters { padding: 8px 16px 0; }

  .board { padding: 0; gap: 0; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; align-items: stretch; }
  .board::-webkit-scrollbar { display: none; }
  .list { width: 100%; min-width: 100%; max-height: none; height: 100%; scroll-snap-align: start; background: transparent; border: 0; border-radius: 0; }
  .list-head { display: none; }
  .list-cards { padding: 12px 16px calc(var(--bottom-nav) + 90px + var(--safe-b)); gap: 12px; }
  .add-card { display: none; }
  .add-list-col { padding: 24px 16px; }
  .card { padding: 14px; min-height: 68px; }
  .card-title { font-size: 16px; }

  .view:not([data-view="tableau"]) { padding-bottom: calc(var(--bottom-nav) + 80px + var(--safe-b)); }
  .page { padding: 16px; }
  .page h1 { font-size: 23px; }

  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--bottom-nav) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--muted); }
  .bottom-nav a .ico { width: 24px; height: 24px; }
  .bottom-nav a.active { color: var(--primary); }
  .fab {
    display: grid; place-items: center; position: fixed; z-index: 21; right: 18px; bottom: calc(var(--bottom-nav) + 18px + var(--safe-b));
    width: 60px; height: 60px; border-radius: 50%; background: var(--primary); color: #fff; box-shadow: 0 6px 18px rgba(46, 125, 87, .45);
  }
  .fab .ico { width: 28px; height: 28px; }
  .shell[data-route="parametres"] .fab { display: none; }
  .fab-mic {
    display: grid; place-items: center; position: fixed; z-index: 21; right: 90px; bottom: calc(var(--bottom-nav) + 22px + var(--safe-b));
    width: 52px; height: 52px; border-radius: 50%; background: var(--surface); color: var(--primary);
    border: 2px solid var(--primary); box-shadow: 0 4px 14px rgba(46, 125, 87, .25);
  }
  .fab-mic .ico { width: 24px; height: 24px; }
  .round-mic { display: none; }
  .shell[data-route="parametres"] .fab-mic { display: none; }

  .cal-head h1 { min-width: 0; flex: 1; font-size: 20px; }
  .cal-head .btn { margin-left: 0; }
  .cal-grid { gap: 3px; }
  .day { min-height: 54px; padding: 4px; align-items: center; box-shadow: none; background: var(--surface); }
  .day-items { display: none; }
  .dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
  .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c-solid); }
  .dots i.done { opacity: .35; }

  .modal-wrap.sheet { place-items: end stretch; padding: 0; }
  .sheet .modal { width: 100%; max-height: 94dvh; border-radius: 22px 22px 0 0; animation: rise .2s ease-out; }
  .sheet .editor .modal-foot { padding-bottom: calc(14px + var(--safe-b)); }
  .grid2 { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .inline-form:not(.wrap) { flex-direction: column; }
  #toast { bottom: calc(var(--bottom-nav) + 90px + var(--safe-b)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Rappels */
.notif-state { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; margin: 0; }
.notif-state .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; margin-top: .4em; }
.notif-state.on .dot { background: var(--check); box-shadow: 0 0 0 4px color-mix(in srgb, var(--check) 20%, transparent); }
.reminders .segmented button { text-align: left; }
.login .legal { margin: 14px 0 0; font-size: .82rem; text-align: center; }
.login .legal a, .about a { color: var(--muted); }

/* ---------- Courses ---------- */
.shell[data-route="courses"] .board-switch,
.shell[data-route="courses"] .progress-pill,
.shell[data-route="courses"] .topbar .search,
.shell[data-route="courses"] .search-toggle,
.shell[data-route="courses"] .filter-btn,
.shell[data-route="courses"] .active-filters { display: none; }
.shell[data-route="courses"] .round-mic { display: none; }
.courses { max-width: 720px; }
.shop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.shop-tabs { flex: 1; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.shop-tabs::-webkit-scrollbar { display: none; }
.shop-tab {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 800; color: var(--muted);
}
.shop-tab.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.shop-tab .count { font-size: 12px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text); }
.shop-tab.on .count { background: rgba(255, 255, 255, .25); color: #fff; }
.shop-tab.add { padding: 0 12px; }
.shop-tab.add .ico { width: 18px; height: 18px; }

.shop-add {
  position: sticky; top: 0; z-index: 3; display: flex; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 6px 6px 6px 14px; box-shadow: var(--shadow);
}
.shop-add input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 16px; padding: 10px 0; color: var(--text); outline: none; }
.shop-add .shop-mic.on { background: var(--danger); color: #fff; animation: shopPulse 1.2s infinite; }
@keyframes shopPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(210, 63, 63, .5); } 50% { box-shadow: 0 0 0 8px rgba(210, 63, 63, 0); } }
.shop-add-btn { width: 44px; padding: 0; border-radius: 12px; }
.shop-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 12px 0 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 700; color: var(--text);
}
.chip .ico { width: 16px; height: 16px; color: var(--primary); }
.chip:hover { border-color: var(--primary); }

.shop-members { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; color: var(--muted); font-weight: 700; font-size: 14px; }
.shop-members .stack { display: inline-flex; }
.shop-members .stack .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--bg); }
.shop-members .stack .avatar:first-child { margin-left: 0; }
.shop-members .ico { width: 16px; height: 16px; }
.shop-members:hover { color: var(--primary); }

.aisle, .frequent, .basket { margin-top: 18px; }
.aisle h3, .frequent h3, .basket h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; margin-bottom: 8px; color: var(--muted); text-transform: none; }
.aisle h3 small, .basket h3 small { font-weight: 700; color: var(--muted); }
.aisle-ico { font-size: 18px; }
.shop-items { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.shop-item { display: flex; align-items: center; gap: 12px; padding: 4px 8px 4px 14px; min-height: 52px; }
.shop-item + .shop-item { border-top: 1px solid var(--border); }
.shop-name { flex: 1; text-align: left; display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; font-weight: 700; color: var(--text); }
.shop-name .qty { margin-left: auto; padding: 2px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 800; white-space: nowrap; }
.shop-item.checked .shop-name { color: var(--muted); text-decoration: line-through; font-weight: 600; }
.shop-item.checked .check { background: var(--check); border-color: var(--check); color: #fff; }
.shop-item.checked .qty { background: var(--surface-3); color: var(--muted); }
.frequent .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.basket-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.basket-head h3 { margin: 0; }
.basket-head h3 .ico { width: 18px; height: 18px; }
.basket .shop-items { opacity: .85; }
.shop-edit .modal-foot .grow { flex: 1; }
.shop-share { max-width: 520px; }

#toast.has-action { display: flex; align-items: center; gap: 14px; pointer-events: auto; }
#toast button { color: #9fe0b9; font-weight: 800; text-transform: uppercase; font-size: 13px; letter-spacing: .03em; }
.notice.warn { background: #fff6dc; color: #6b4e00; }

@media (max-width: 899px) {
  .shell[data-route="courses"] .fab, .shell[data-route="courses"] .fab-mic { display: none; }
  .courses { padding: 14px 16px; }
  .bottom-nav a { font-size: 11px; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .notice.warn { background: #3a3019; color: #f3dfa6; }
}
:root[data-theme="dark"] .notice.warn { background: #3a3019; color: #f3dfa6; }
.route-title { display: none; }
.shell[data-route="courses"] .route-title { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; }
.shell[data-route="courses"] .route-title .ico { width: 24px; height: 24px; color: var(--primary); }
