/* ================================================================ Thèmes */
:root {
  --p: #2E7D4F; --p-strong: #1F5C39; --on-p: #fff;
  --accent: var(--p);          /* couleur du thème pour le texte sur fond clair (plus foncée pour les thèmes pâles) */
  --notif: #B8860B;            /* jaune foncé des notifications */
  --notif-soft: #FBF3DC;

  --bg: #F5F6F4; --surface: #FFFFFF; --surface-2: #EEF0ED;
  --text: #1B1F1C; --muted: #5E6661; --line: #DDE1DD;
  --danger: #C62828; --danger-soft: #FDECEC;
  --p-soft: color-mix(in srgb, var(--p) 12%, var(--surface));

  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
[data-theme="vert"]    { --p: #2E7D4F; --p-strong: #1F5C39; }
[data-theme="bleu"]    { --p: #2563EB; --p-strong: #1D4ED8; }
[data-theme="violet"]  { --p: #7C3AED; --p-strong: #5B21B6; }
[data-theme="rouge"]   { --p: #B83227; --p-strong: #8E251D; }
[data-theme="orange"]  { --p: #D9600F; --p-strong: #B04D0A; }
[data-theme="ardoise"] { --p: #475569; --p-strong: #334155; }

/* Thèmes pâles : fond clair avec texte foncé. --accent (plus foncé) assure la lisibilité du texte coloré. */
[data-theme="lime"]    { --p: #C7E9A8; --p-strong: #4E8A2C; --on-p: #1B2416; --accent: var(--p-strong); }
[data-theme="ciel"]    { --p: #BCDAF6; --p-strong: #2E6BA8; --on-p: #10243A; --accent: var(--p-strong); }
[data-theme="rose"]    { --p: #F6C2D6; --p-strong: #B23E6C; --on-p: #3A1020; --accent: var(--p-strong); }
[data-theme="peche"]   { --p: #F9D2AE; --p-strong: #B5611C; --on-p: #3A220C; --accent: var(--p-strong); }
[data-theme="lavande"] { --p: #D9C8F1; --p-strong: #6F48B0; --on-p: #251638; --accent: var(--p-strong); }
[data-theme="brume"]   { --p: #D2DAE1; --p-strong: #4E5E6C; --on-p: #1A2127; --accent: var(--p-strong); }

/* Mode sombre forcé par l'utilisateur (choix dans le profil) */
:root[data-mode="dark"] {
    --bg: #111412; --surface: #1A1E1B; --surface-2: #232825;
    --text: #E8ECE9; --muted: #9AA39D; --line: #2F3531;
    --danger: #EF6B6B; --danger-soft: #3A1F1F;
    --notif: #E0A82E; --notif-soft: #33290F;
    --p-soft: color-mix(in srgb, var(--p) 22%, var(--surface));
    color-scheme: dark;
  }
:root[data-mode="dark"] [data-theme="vert"] { --p: #4CAF7A; --p-strong: #7BD3A2; }
:root[data-mode="dark"] [data-theme="bleu"] { --p: #5B8DEF; --p-strong: #93B4F5; }
:root[data-mode="dark"] [data-theme="violet"] { --p: #A07BF0; --p-strong: #C4AEF7; }
:root[data-mode="dark"] [data-theme="rouge"] { --p: #E5645A; --p-strong: #F19A92; }
:root[data-mode="dark"] [data-theme="orange"] { --p: #F08A3E; --p-strong: #F7B786; --on-p: #1B1F1C; }
:root[data-mode="dark"] [data-theme="ardoise"] { --p: #8394AB; --p-strong: #B3C0D1; }
:root[data-mode="dark"] [data-theme="lime"] { --p: #3F7A26; --p-strong: #9BD36A; --on-p: #fff; }
:root[data-mode="dark"] [data-theme="ciel"] { --p: #2A5B88; --p-strong: #93C0EA; --on-p: #fff; }
:root[data-mode="dark"] [data-theme="rose"] { --p: #8A3A5C; --p-strong: #F0A9C4; --on-p: #fff; }
:root[data-mode="dark"] [data-theme="peche"] { --p: #955021; --p-strong: #F0BC90; --on-p: #fff; }
:root[data-mode="dark"] [data-theme="lavande"] { --p: #553A88; --p-strong: #C3ACE9; --on-p: #fff; }
:root[data-mode="dark"] [data-theme="brume"] { --p: #3D4852; --p-strong: #B3BFCB; --on-p: #fff; }

/* Mode système : suit l'OS, sauf si l'utilisateur a forcé « clair » ou « sombre ». */
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]):not([data-mode="dark"]) {
    --bg: #111412; --surface: #1A1E1B; --surface-2: #232825;
    --text: #E8ECE9; --muted: #9AA39D; --line: #2F3531;
    --danger: #EF6B6B; --danger-soft: #3A1F1F;
    --notif: #E0A82E; --notif-soft: #33290F;
    --p-soft: color-mix(in srgb, var(--p) 22%, var(--surface));
    color-scheme: dark;
  }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="vert"] { --p: #4CAF7A; --p-strong: #7BD3A2; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="bleu"] { --p: #5B8DEF; --p-strong: #93B4F5; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="violet"] { --p: #A07BF0; --p-strong: #C4AEF7; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="rouge"] { --p: #E5645A; --p-strong: #F19A92; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="orange"] { --p: #F08A3E; --p-strong: #F7B786; --on-p: #1B1F1C; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="ardoise"] { --p: #8394AB; --p-strong: #B3C0D1; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="lime"] { --p: #3F7A26; --p-strong: #9BD36A; --on-p: #fff; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="ciel"] { --p: #2A5B88; --p-strong: #93C0EA; --on-p: #fff; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="rose"] { --p: #8A3A5C; --p-strong: #F0A9C4; --on-p: #fff; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="peche"] { --p: #955021; --p-strong: #F0BC90; --on-p: #fff; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="lavande"] { --p: #553A88; --p-strong: #C3ACE9; --on-p: #fff; }
:root:not([data-mode="light"]):not([data-mode="dark"]) [data-theme="brume"] { --p: #3D4852; --p-strong: #B3BFCB; --on-p: #fff; }
}

/* ================================================================ Base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { overscroll-behavior: none; }   /* pas de rebond élastique : évite la barre du haut qui se dédouble */
body {
  font: 15px/1.45 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
/* Quand un panneau est ouvert, l'arrière-plan est figé (il ne défile plus à la place du panneau). */
html.locked body { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ================================================================ Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--p); border-color: var(--p); color: var(--on-p); }
.btn-primary:hover { background: var(--p-strong); border-color: var(--p-strong); }
.btn-block { width: 100%; }
.btn-ghost-danger { border-color: transparent; background: transparent; color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-soft); }
.btn:disabled { opacity: .55; cursor: default; }
.link-btn { border: 0; background: none; color: var(--p); font-weight: 600; padding: 6px 4px; }
.icon-btn {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: transparent; color: var(--text); position: relative;
}
.icon-btn:hover { background: var(--surface-2); }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; }
.spacer { flex: 1; }

/* ================================================================ Formulaires */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--p); box-shadow: 0 0 0 3px var(--p-soft); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.field-row .field { min-width: 0; }
.field input[type=date], .field input[type=time] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; }
.form-error { color: var(--danger); font-size: 14px; margin: 0 0 10px; min-height: 0; }
.form-error:empty { display: none; }
.chips-inline { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.chip-sm { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.chip-sm:hover { border-color: var(--p); color: var(--p); }

/* ================================================================ Auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 28px 22px; box-shadow: var(--shadow); text-align: center; }
.auth-card form { text-align: left; margin-top: 20px; }
.auth-card h1 { font-size: 24px; margin-top: 12px; }
.auth-card p { margin: 6px 0 0; }
.brand-mark { width: 56px; height: 56px; border-radius: 16px; background: var(--p); color: var(--on-p); display: inline-grid; place-items: center; }
.brand-mark svg { width: 30px; height: 30px; }
.auth .link-btn { margin-top: 12px; }
.auth.login [data-only="register"] { display: none; }

/* ================================================================ Mise en page */
.app { min-height: 100%; padding: calc(60px + var(--safe-t)) 0 calc(80px + var(--safe-b)); }
.topbar {
  position: fixed; inset: 0 0 auto; z-index: 20; display: flex; align-items: center; gap: 4px;
  padding: var(--safe-t) 12px 0 16px; height: calc(60px + var(--safe-t));
  background: var(--p); color: var(--on-p);
}
.topbar .icon-btn { color: inherit; }
.topbar .icon-btn:hover { background: rgb(255 255 255 / .14); }
.topbar-title { flex: 1; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; margin-left: 6px;
  border: 2px solid rgb(255 255 255 / .6); background: rgb(255 255 255 / .18); color: inherit;
  font-weight: 700; font-size: 14px; letter-spacing: .3px;
}

/* Cloche : contour normal, remplie en jaune foncé s'il y a du non lu */
.bell.has-unread svg { fill: var(--notif); stroke: var(--notif); filter: drop-shadow(0 0 1px rgb(0 0 0 / .35)); }
.bell.has-unread svg { animation: ring .9s ease 1; transform-origin: 50% 10%; }
.bell-badge {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--notif); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--p);
}
@keyframes ring { 0%,100% { transform: rotate(0) } 20% { transform: rotate(14deg) } 40% { transform: rotate(-12deg) } 60% { transform: rotate(8deg) } 80% { transform: rotate(-4deg) } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.view { max-width: 720px; margin: 0 auto; padding: 0 16px; }

.tabbar {
  position: fixed; inset: auto 0 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar button[hidden] { display: none; }
.tabbar button {
  border: 0; background: none; height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.tabbar button[aria-selected="true"] { color: var(--accent); }
.tabbar button[aria-selected="true"] svg { background: var(--p-soft); border-radius: 999px; padding: 3px 18px; width: 58px; height: 28px; }
.tabbar button svg { padding: 3px 18px; width: 58px; height: 28px; }

.fab {
  position: fixed; z-index: 21; right: max(16px, calc(50% - 344px)); bottom: calc(80px + var(--safe-b));
  width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--p); color: var(--on-p);
  display: grid; place-items: center; box-shadow: 0 6px 18px color-mix(in srgb, var(--p) 40%, transparent);
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.2; }

/* ================================================================ Filtres projets */
.filters {
  position: sticky; top: calc(60px + var(--safe-t)); z-index: 10; background: var(--bg);
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; margin: 0 -16px; padding-inline: 16px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.chip .count { font-size: 12px; color: var(--muted); font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--p); border-color: var(--p); color: var(--on-p); }
.chip[aria-pressed="true"] .count { color: inherit; opacity: .85; }
.chip.add { border-style: dashed; color: var(--p); }
.chip.add svg { width: 16px; height: 16px; }
.chip .edit { display: grid; place-items: center; margin-right: -8px; width: 26px; height: 26px; border-radius: 50%; }
.chip .edit:hover { background: rgb(255 255 255 / .2); }
.chip .edit svg { width: 16px; height: 16px; }

/* ================================================================ Listes */
.list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.group-label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 14px 2px 2px; }
.item {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
button.item:hover, .item .item-main:hover { border-color: color-mix(in srgb, var(--p) 40%, var(--line)); }
.item-main { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 0; }
.item-title { font-weight: 600; word-wrap: break-word; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; color: var(--muted); font-size: 13px; }
.item-meta span { display: inline-flex; align-items: center; gap: 4px; }
.item-meta svg { width: 15px; height: 15px; }
.item-desc { margin-top: 6px; color: var(--muted); font-size: 14px; white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.tag { background: var(--p-soft); color: var(--p-strong); border-radius: 6px; padding: 1px 7px; font-weight: 600; font-size: 12px; }
.overdue { color: var(--danger) !important; font-weight: 600; }
.soon { color: var(--notif) !important; font-weight: 600; }

.check {
  flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: transparent; margin-top: 1px;
}
.check:hover { border-color: var(--p); }
.check svg { width: 16px; height: 16px; stroke-width: 3; }
.item.done .check { background: var(--p); border-color: var(--p); color: var(--on-p); }
.item.done .item-title { text-decoration: line-through; color: var(--muted); }

.date-badge {
  flex: none; width: 52px; border-radius: 12px; overflow: hidden; text-align: center; background: var(--p-soft); color: var(--p-strong);
}
.date-badge b { display: block; font-size: 20px; line-height: 1; padding-top: 8px; }
.date-badge small { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 0 7px; }
.item.past { opacity: .62; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; stroke-width: 1.3; color: var(--accent); opacity: .7; }
.empty p { margin: 8px 0 0; }

.done-block { margin: 6px 0 16px; }
.done-block summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  font-weight: 700; color: var(--muted); padding: 10px 2px;
}
.done-block summary::-webkit-details-marker { display: none; }
.done-block summary svg { width: 18px; height: 18px; transition: transform .2s; }
.done-block[open] summary svg { transform: rotate(180deg); }

/* ================================================================ Tiroir notifications */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .35); animation: fade .2s; }
.drawer {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(400px, 92vw);
  background: var(--bg); display: flex; flex-direction: column; box-shadow: -8px 0 30px rgb(0 0 0 / .18);
  animation: slide-in .22s ease-out; padding-top: var(--safe-t);
}
.drawer-head { display: flex; align-items: center; gap: 4px; padding: 10px 8px 10px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer-head h2 { flex: 1; font-size: 18px; }
.drawer-head .link-btn { font-size: 13px; }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 12px; display: flex; flex-direction: column; gap: 8px; padding-bottom: calc(12px + var(--safe-b)); }
.notif {
  display: block; width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); cursor: default;
}
.notif.unread { border: 2px solid var(--notif); background: var(--notif-soft); cursor: pointer; padding: 11px 13px; }
.notif-title { font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.notif.unread .notif-title::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--notif); flex: none; transform: translateY(-1px); }
.notif-body { color: var(--muted); font-size: 14px; margin-top: 2px; }
.notif-time { color: var(--muted); font-size: 12px; margin-top: 6px; }
.notif.unread .notif-time::after { content: " · Toucher pour marquer comme lue"; }
@keyframes slide-in { from { transform: translateX(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ================================================================ Panneau profil */
.panel {
  position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; animation: rise .22s ease-out;
}
.panel-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 6px;
  padding: var(--safe-t) 12px 0 6px; height: calc(60px + var(--safe-t)); background: var(--p); color: var(--on-p);
}
.panel-head .icon-btn { color: inherit; }
.panel-head h2 { font-size: 18px; }
.panel-body { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(32px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.card h3 { font-size: 16px; margin-bottom: 14px; }
.card h4 { font-size: 14px; margin-bottom: 12px; }
.card hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.swatch {
  border: 2px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 6px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
}
.swatch i { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.swatch i svg { width: 18px; height: 18px; stroke-width: 3; opacity: 0; }
.swatch[aria-checked="true"] { border-color: var(--accent); }
.swatch[aria-checked="true"] i svg { opacity: 1; }

/* ================================================================ Feuille (dialog) */
.sheet {
  border: 0; padding: 0; border-radius: 20px; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
.sheet::backdrop { background: rgb(0 0 0 / .4); }
.sheet[open] { animation: rise .2s ease-out; }
.sheet form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.sheet-head { display: flex; align-items: center; padding: 14px 8px 6px 20px; }
.sheet-head h2 { flex: 1; font-size: 18px; }
.sheet-body { padding: 8px 20px 4px; overflow-y: auto; overflow-x: hidden; min-width: 0; }
.sheet form > *, .sheet-body > * { min-width: 0; max-width: 100%; }
.sheet .form-error { padding: 0 20px; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
@media (max-width: 560px) {
  .sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; }
  .sheet form { padding-bottom: var(--safe-b); }
}

/* Liste déroulante filtrable des emplacements */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  max-height: 220px; overflow-y: auto;
}
.combo-list li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.combo-list li svg { width: 16px; height: 16px; color: var(--muted); }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--p-soft); }
.combo-list li mark { background: none; color: var(--p); font-weight: 700; }
.combo-list li.new { color: var(--accent); font-weight: 600; }

/* ================================================================ Toast */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); animation: rise .2s; max-width: calc(100vw - 32px);
}

/* ---- Zoom automatique d'iOS : les champs doivent faire 16 px minimum */
input, select, textarea { font-size: 16px; }

/* ---- Section Profil repliable */
.collapse-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; border: 0; background: none; padding: 0; text-align: left; color: inherit; }
.collapse-head h3 { margin: 0; }
.collapse-head svg { width: 20px; height: 20px; color: var(--muted); transition: transform .2s; }
.collapse-head[aria-expanded="true"] svg { transform: rotate(180deg); }
.collapse-body { margin-top: 14px; }

/* ---- Notifications : toutes cliquables (lue <-> non lue) */
.notif { font: inherit; color: inherit; cursor: pointer; }
.notif.read .notif-time::after { content: " · Toucher pour marquer comme non lue"; }

/* ---- Aujourd'hui */
.today-head { padding: 8px 2px 6px; }
.today-head h2 { font-size: 20px; }
.today-head p { margin: 4px 0 0; color: var(--muted); }
.today-time { flex: none; width: 66px; padding-top: 1px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--p-strong); }
.today-time.overdue { color: var(--danger); }

/* ---- Navigation entre les jours */
.today-nav { display: flex; align-items: center; gap: 4px; }
.today-date-wrap { flex: 1; min-width: 0; text-align: center; }
.today-nav h2 { font-size: 19px; }
.today-rel { display: block; font-size: 13px; font-weight: 600; color: var(--accent); min-height: 1em; }
.today-reset { font-size: 13px; padding: 2px 0; }
.flip svg { transform: scaleX(-1); }
.today-group { font-size: 13px; font-weight: 700; color: var(--danger); text-transform: uppercase; letter-spacing: .6px; margin: 14px 2px 2px; }
.today-group.muted { color: var(--muted); }
.today-time small { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; }

/* ---- Préférences : interrupteur */
/* ---- Préférences : apparence (clair / sombre / système) */
.pref-mode { display: flex; flex-direction: column; gap: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.seg-btn { border: 0; background: transparent; border-radius: 9px; padding: 9px 6px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.switch-row > span { display: block; }
.switch-row small { display: block; margin-top: 3px; font-size: 13px; }
.switch-row input { flex: none; width: 24px; height: 24px; accent-color: var(--accent); cursor: pointer; }

/* ---- Cases d'heures des créneaux de rappel */
.slot-chip { min-width: 60px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; }
.slot-chip:hover { border-color: var(--p); }
.slot-chip[aria-pressed="true"] { background: var(--p); border-color: var(--p); color: var(--on-p); }

/* ---- Mode rencontre */
.tabbar button span { line-height: 1.1; text-align: center; }
.mp-status { font-size: 13px; opacity: .9; }
.mp-head { margin-bottom: 14px; }
.mp-meta { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.mp-title { font-size: 24px; margin: 4px 0 8px; line-height: 1.2; word-wrap: break-word; }
.mp-desc { white-space: pre-line; margin: 0; }
.mp-desc:empty { display: none; }
/* Zones de texte qui s'ajustent à leur contenu, sans avoir à les étirer. */
.mp-notes { display: block; width: 100%; min-height: 120px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; line-height: 1.5; resize: none; overflow: hidden; outline: none; box-sizing: border-box; }
.mp-notes:focus { border-color: var(--p); box-shadow: 0 0 0 3px var(--p-soft); }
.mp-desc-edit { min-height: 72px; }

/* ---- Profil : indication discrète */
.collapse-head > div { flex: 1; min-width: 0; text-align: left; }
.collapse-hint { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--muted); }
.collapse-head[aria-expanded="true"] .collapse-hint { display: none; }

/* ---- Rencontres : étiquette et carte */
.pill { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; padding: 3px 9px 3px 7px; border-radius: 999px; background: var(--p); color: var(--on-p); font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; }
.pill svg { width: 12px; height: 12px; stroke-width: 2.4; }
.meeting-card { border-left: 4px solid var(--p); }
.mode-time { flex: none; width: 66px; padding-top: 1px; }
.mode-time b { display: block; font-size: 16px; color: var(--p-strong); font-variant-numeric: tabular-nums; }
.mode-time small { display: block; font-size: 12px; color: var(--muted); }

/* ---- Mode rencontre : barre, décalage et jours */
.mode-bar { position: sticky; top: calc(60px + var(--safe-t)); z-index: 10; display: flex; justify-content: flex-end; margin: 0 -16px; padding: 12px 16px 8px; background: var(--bg); }
.meet-bar { justify-content: stretch; align-items: center; gap: 8px; }
.meet-search { flex: 1; margin: 0; min-width: 0; }
.meet-bar .chip { flex: none; }
#mode-list, #meeting-list { margin-top: 12px; }
.day-head { margin: 16px 2px 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.day-head.is-today { color: var(--p-strong); }

/* ---- Durée */
.dur-stepper { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 4px 0 12px; font-size: 17px; font-weight: 700; }
.dur-stepper[hidden] { display: none; }

/* ---- Choix Rencontre / Tâche */
.chooser-body { padding-bottom: 20px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; margin-bottom: 10px; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); text-align: left; font-size: 16px; font-weight: 700; }
.choice small { font-size: 13px; font-weight: 400; color: var(--muted); }
.choice:hover { border-color: var(--p); }

/* ---- Formulaires sur iPhone : rien ne dépasse la largeur de l'écran */
.sheet, .sheet form { max-width: 100vw; }
.field input, .field select, .field textarea { max-width: 100%; box-sizing: border-box; }
.chips-inline { max-width: 100%; }
@media (max-width: 560px) {
  .sheet { width: 100vw; }
  .sheet-body { padding: 8px 16px 4px; }
  .field-row { gap: 8px; }
}

/* ---- Recherche */
.search-input { display: block; width: calc(100% - 32px); margin: 10px 16px 6px; min-height: 42px; padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px; outline: none; min-width: 0; }
.search-input:focus { border-color: var(--p); box-shadow: 0 0 0 3px var(--p-soft); }
/* Masque le bouton d'effacement natif (Safari) : on en met un partout, cohérent. */
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.search-wrap { position: relative; }
.search-wrap .search-input { width: 100%; margin: 0; padding-right: 42px; }
#view-tasks > .search-wrap { margin: 10px 16px 6px; }
.meet-search-wrap { flex: 1; min-width: 0; }
.search-clear { position: absolute; top: 50%; right: 7px; transform: translateY(-50%); width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.search-clear:hover { background: var(--surface-2); color: var(--text); }
.search-clear[hidden] { display: none; }
.search-clear svg { width: 17px; height: 17px; }

/* ---- Confirmation de suppression */
.confirm { width: min(380px, calc(100vw - 32px)); }
.confirm-body { padding: 22px 20px 18px; }
.confirm-body p { margin: 0 0 18px; font-size: 16px; line-height: 1.4; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-actions .btn { min-width: 110px; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); background: var(--danger); }

/* ================================================================ Feuille de temps */
.ts-entry { padding: 0; overflow: hidden; }
.ts-open { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 0; background: var(--p); color: var(--on-p); text-align: left; font: inherit; cursor: pointer; }
.ts-open:hover { background: var(--p-strong); }
.ts-open-ico { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: rgb(255 255 255 / .18); }
.ts-open-ico svg { width: 22px; height: 22px; }
.ts-open-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ts-open-txt b { font-size: 16px; }
.ts-open-txt small { margin-top: 2px; font-size: 13px; opacity: .85; }
.ts-open-chev { flex: none; width: 18px; height: 18px; transform: rotate(-90deg); }

.ts-week { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.ts-arrow { flex: none; width: 44px; height: 44px; font-size: 28px; line-height: 1; }
.ts-week-label { flex: 1; text-align: center; font-weight: 700; font-size: 16px; }
.ts-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ts-totals { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.ts-day { padding: 12px 14px; margin-bottom: 10px; }
.ts-day.is-today { border-color: var(--p); }
.ts-day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ts-day-head small { color: var(--muted); }
.ts-today-tag { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--p); color: var(--on-p); font-size: 11px; font-weight: 700; vertical-align: middle; }
.ts-menu { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ts-menu [disabled] { opacity: .45; }
.ts-empty { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

.ts-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.ts-row-main { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ts-kind { flex: none; min-width: 92px; font-size: 14px; font-weight: 600; }
.ts-amount { display: flex; align-items: center; gap: 4px; flex: none; }
.ts-amount input, .ts-project input {
  min-height: 40px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 16px; box-sizing: border-box; min-width: 0; outline: none;
}
.ts-amount input { width: 96px; }
.ts-amount input:focus, .ts-project input:focus { border-color: var(--p); box-shadow: 0 0 0 3px var(--p-soft); }
.ts-amount span { font-size: 14px; color: var(--muted); }
.ts-project { flex: 1 1 150px; min-width: 0; }
.ts-project input { width: 100%; }
.ts-row-ferie .ts-note { flex: 1; font-size: 14px; color: var(--muted); }
.ts-del { flex: none; }
