/* Layout : colonne centrée façon appli mobile. En-tête de salutation, barre de commande, pastilles de navigation
   (barre d'icônes en bas sur téléphone), cartes blanches arrondies avec panneaux en verre dépoli. */
:root {
  --cream: #FFF8E8;      /* principale */
  --orange: #FFA02E;     /* secondaire */
  --leaf: #9AD872;       /* minoritaire */
  --forest: #468432;     /* optionnelle */

  --bg: var(--cream);
  --card: #FFFFFF;
  --chip: #F6EFDD;
  --line: #EFE6CF;
  --ink: #1F1E16;
  --muted: #8C866F;
  --faint: #BDB69E;
  --dark: var(--forest);
  --on-dark: #FFFFFF;
  --hour: #F3ECDA;
  --danger: #C2412D;
  --glass: rgba(28, 34, 20, .38);
  --shadow: 0 1px 2px rgba(60, 50, 20, .05), 0 12px 32px -14px rgba(60, 50, 20, .22);
  --shadow-lg: 0 24px 60px -20px rgba(40, 35, 10, .35);

  --font: "Poppins", "Segoe UI", system-ui, sans-serif;
  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --hour-h: 56px;
  --ease: cubic-bezier(.32, .72, 0, 1);      /* courbe des feuilles iOS */
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171A12; --card: #22261B; --chip: #2C3123; --line: #343A2A; --ink: #F6EEDA; --muted: #A9A38A; --faint: #6F6A57;
    --dark: #9AD872; --on-dark: #17220F; --hour: #2A2F21; --danger: #F07A63; --glass: rgba(10, 12, 6, .5);
    --shadow: 0 12px 32px -14px rgba(0, 0, 0, .7); --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171A12; --card: #22261B; --chip: #2C3123; --line: #343A2A; --ink: #F6EEDA; --muted: #A9A38A; --faint: #6F6A57;
  --dark: #9AD872; --on-dark: #17220F; --hour: #2A2F21; --danger: #F07A63; --glass: rgba(10, 12, 6, .5);
  --shadow: 0 12px 32px -14px rgba(0, 0, 0, .7); --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; letter-spacing: -0.015em; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
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); }
.small { font-size: 12.5px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.hint.tight { margin-top: -4px; }

/* Retour tactile façon iOS : léger enfoncement */
.press { transition: transform .25s var(--ease), background-color .2s, color .2s, box-shadow .2s; }
.press:active { transform: scale(.96); transition-duration: .08s; }

/* ---------- Shell ---------- */
.app {
  max-width: 1180px; margin: 0 auto; min-height: 100%;
  padding-block: 22px 48px;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 18px;
}
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.hello { font-size: clamp(26px, 4vw, 32px); font-weight: 600; line-height: 1.15; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
  background: linear-gradient(140deg, var(--orange), #FFC66E); color: #3A2508; font-weight: 600; font-size: 18px;
  box-shadow: 0 0 0 3px var(--card), var(--shadow);
}

/* ---------- Barre de commande (style champ de recherche) ---------- */
.command {
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 16px; height: 58px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 18px;
  transition: border-color .2s, box-shadow .3s var(--ease);
}
.command:focus-within { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(255, 160, 46, .14); }
.cmd-icon { color: var(--faint); width: 20px; height: 20px; }
.command input { flex: 1; min-width: 0; border: 0; background: none; padding: 8px 4px; outline: none; font-size: 15.5px; }
.command input::placeholder { color: var(--faint); }
.cmd-sep { width: 1.5px; height: 26px; background: var(--line); margin: 0 4px; }
.send, .mic {
  width: 44px; height: 44px; border-radius: 13px; border: 0; cursor: pointer; display: grid; place-items: center; position: relative;
  background: transparent; color: var(--ink);
}
.send { background: var(--dark); color: var(--on-dark); animation: popIn .35s var(--ease); }
.mic.on { color: var(--forest); background: rgba(154, 216, 114, .25); }
.mic.on::after {
  content: ""; position: absolute; inset: 6px; border-radius: 10px; border: 2px solid var(--leaf);
  animation: breathe 2.4s ease-in-out infinite;
}
.mic.heard { background: var(--orange); color: #3A2508; }
.command.voice-only input { pointer-events: none; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.18); opacity: 0; } }
.listen-status {
  margin: -10px 0 0 18px; font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: fadeUp .3s var(--ease);
}
.listen-status b { color: var(--forest); font-weight: 600; }

/* ---------- Navigation : pastilles avec indicateur qui glisse ---------- */
.tabs { position: relative; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 11px 18px; border: 0; cursor: pointer;
  background: var(--chip); border-radius: 14px; font-weight: 500; color: var(--muted); white-space: nowrap;
  transition: color .3s var(--ease), background-color .3s;
}
.tab svg { width: 18px; height: 18px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--on-dark); background: transparent; }
.tab-pill {
  position: absolute; z-index: 0; top: 2px; left: 0; height: calc(100% - 4px); border-radius: 14px; background: var(--dark);
  box-shadow: 0 8px 18px -8px rgba(70, 132, 50, .7);
  transition: transform .45s var(--ease), width .45s var(--ease);
}

/* ---------- Boutons ---------- */
.pill {
  border: 0; border-radius: 14px; padding: 10px 18px; font-weight: 500; cursor: pointer; background: var(--chip); white-space: nowrap;
}
.pill:hover { filter: brightness(.98); }
.pill.dark { background: var(--dark); color: var(--on-dark); }
.pill.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px currentColor; }
.round {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow);
  display: grid; place-items: center; cursor: pointer;
}
.round svg { width: 18px; height: 18px; }
.link { font-size: 13px; color: var(--muted); text-decoration: none; font-weight: 500; }
.link:hover { color: var(--ink); }

.main { min-width: 0; }
.view { display: flex; flex-direction: column; gap: 16px; }
.view.enter { animation: viewIn .45s var(--ease); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.day-nav { display: flex; gap: 8px; align-items: center; }
.card {
  background: var(--card); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }

/* ---------- Journée ---------- */
.day-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.day-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.day-side { display: flex; flex-direction: column; gap: 16px; }

/* Carte « héros » : paysage aux couleurs de Tempo + panneau en verre */
.hero {
  position: relative; height: 230px; border-radius: var(--r-lg); overflow: hidden; cursor: pointer; box-shadow: var(--shadow-lg);
  --sky1: #FFC56B; --sky2: #FFE9C2;
}
.hero.t-morning { --sky1: #FFD9A0; --sky2: #FFF6E2; }
.hero.t-evening { --sky1: #FF8A3D; --sky2: #FFCF8A; }
.hero.t-night { --sky1: #2E4A2A; --sky2: #6E8F4F; }
.hero-art { position: absolute; inset: 0; background: linear-gradient(180deg, var(--sky1), var(--sky2)); }
.hero-art svg { width: 100%; height: 100%; display: block; stroke: none; }
.hero-art .sun { fill: #FFF8E8; opacity: .95; transform-origin: 300px 78px; animation: sunrise 1.1s var(--ease) both; }
.hero.t-night .sun { fill: #FFF3D0; opacity: .8; }
.hero-art .h3 { fill: #B8E39A; }
.hero-art .h2 { fill: #9AD872; }
.hero-art .h1 { fill: #468432; }
.hero-glass {
  position: absolute; left: 14px; right: 14px; bottom: 14px; padding: 14px 18px; border-radius: var(--r-md);
  background: var(--glass); -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  color: #fff; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.hero-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-kicker { font-size: 12px; opacity: .85; }
.hero-txt strong { font-size: 20px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-place { display: flex; align-items: center; gap: 6px; font-size: 13px; opacity: .9; min-width: 0; }
.hero-place svg { width: 16px; height: 16px; }
.hero-place span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-time { text-align: right; flex: none; }
.hero-time small { display: block; font-size: 12px; opacity: .85; }
.hero-time b { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero-glass.swap > * { animation: fadeUp .4s var(--ease); }

/* Statistiques façon « 8 hours / 16 °C / 4.5 » */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stat i { width: 34px; height: 34px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; flex: none; color: var(--forest); }
.stat i svg { width: 17px; height: 17px; }
.stat span { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat b { color: var(--ink); font-weight: 600; }

.timeline-card { padding: 0; overflow: hidden; gap: 0; }
.allday { display: flex; gap: 6px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.allday-label { font-size: 12px; color: var(--muted); margin-right: 4px; }
.allday .block { position: static; width: auto; height: auto; padding: 5px 12px; border-radius: 999px; flex-direction: row; gap: 6px; }
.timeline-wrap { height: min(62vh, 640px); overflow-y: auto; position: relative; padding: 14px 0; scroll-behavior: smooth; }
.timeline { position: relative; margin-left: 60px; margin-right: 14px; }
.hour-row { height: var(--hour-h); border-top: 1px dashed var(--hour); position: relative; }
.hour-row span { position: absolute; left: -52px; top: -10px; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; width: 40px; text-align: right; }
.block {
  position: absolute; border-radius: 14px; padding: 7px 12px; overflow: hidden; cursor: pointer; border: 0; text-align: left;
  display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; min-width: 0;
  font-size: 13px; line-height: 1.3; box-shadow: 0 2px 8px -3px rgba(0, 0, 0, .18);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.block:hover { transform: translateY(-1px) scale(1.01); box-shadow: 0 10px 20px -8px rgba(0, 0, 0, .3); z-index: 5; }
.block:active { transform: scale(.97); }
.block strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block small { opacity: .85; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block.habit { background-image: repeating-linear-gradient(135deg, transparent 0 9px, rgba(255, 255, 255, .16) 9px 18px); }
.block.short { flex-direction: row; align-items: baseline; gap: 6px; }
.block.short strong { flex: 0 1 auto; min-width: 0; }
.block.pop { animation: popIn .55s var(--ease); }
.now-line { position: absolute; left: -6px; right: 0; height: 2px; background: var(--orange); z-index: 6; pointer-events: none; border-radius: 2px; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px rgba(255, 160, 46, .25); }

.todo-mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.todo-mini li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.empty { color: var(--muted); font-size: 13.5px; margin: 0; }

/* Légende des couleurs avec bouton d'ajout */
.legend { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 8px; border-radius: 999px;
  background: var(--chip); font-size: 13px; font-weight: 500; cursor: pointer; border: 0;
}
.chip input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }
.chip:hover .dot { transform: scale(1.2); }
.chip.add { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted); padding: 6px 12px; }
.chip.add:hover { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--orange); }
.chip.add[aria-expanded="true"] { background: var(--orange); color: #3A2508; box-shadow: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; transition: transform .3s var(--ease); }
.legend-form { display: flex; gap: 8px; align-items: center; animation: fadeUp .35s var(--ease); }
.legend-form input[type="text"], .todo-add input, .type-add input[type="text"] {
  flex: 1; min-width: 0; padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg); outline: none;
}
.legend-form input[type="text"]:focus, .todo-add input:focus, .type-add input[type="text"]:focus { border-color: var(--orange); }
.legend-form input[type="color"], .type-add input[type="color"] { width: 40px; height: 40px; border: 0; padding: 0; background: none; cursor: pointer; flex: none; border-radius: 12px; }

/* ---------- Semaine ---------- */
.week-scroll { padding: 0; overflow: auto; max-height: 72vh; }
.week { display: grid; grid-template-columns: 48px repeat(7, minmax(110px, 1fr)); min-width: 820px; }
.week-head { position: sticky; top: 0; padding: 12px 6px; text-align: center; background: var(--card); z-index: 2; cursor: pointer; border-bottom: 1px solid var(--line); }
.week-head b { display: block; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.6; }
.week-head small { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; color: var(--muted); font-weight: 500; }
.week-head.today b { color: var(--on-dark); background: var(--dark); border-radius: 12px; display: inline-block; min-width: 38px; }
.week-col { position: relative; border-left: 1px solid var(--hour); }
.week-hours div { height: 34px; font-size: 11px; color: var(--faint); text-align: right; padding-right: 6px; transform: translateY(-8px); font-variant-numeric: tabular-nums; }
.week-col .hour-line { height: 34px; border-top: 1px dashed var(--hour); }
.week-col .block { padding: 3px 7px; font-size: 11.5px; border-radius: 9px; }
.week-allday { display: flex; flex-direction: column; gap: 3px; padding: 4px 3px; min-height: 8px; }
.week-allday .block { position: static; padding: 2px 7px; font-size: 11px; border-radius: 999px; }

/* ---------- À faire ---------- */
.todo-add { display: flex; gap: 8px; max-width: 680px; }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-width: 680px; }
.todo-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow);
  animation: fadeUp .35s var(--ease) both;
}
.todo-item label { flex: 1; min-width: 0; cursor: pointer; overflow-wrap: anywhere; transition: color .3s; }
.todo-item.done label { text-decoration: line-through; color: var(--muted); }
.check {
  appearance: none; width: 22px; height: 22px; border-radius: 8px; border: 2px solid var(--faint); cursor: pointer; flex: none;
  display: grid; place-items: center; margin: 0; transition: background-color .25s var(--ease), border-color .25s;
}
.check:checked { background: var(--leaf); border-color: var(--leaf); animation: checkPop .4s var(--ease); }
.check:checked::after { content: ""; width: 10px; height: 6px; border: 2.5px solid #1F3A14; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.todo-mini .check { width: 19px; height: 19px; border-radius: 7px; }
.x { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: 10px; }
.x:hover { color: var(--danger); background: var(--chip); }

.todo-tools { display: flex; gap: 8px; flex-wrap: wrap; max-width: 680px; }
.todo-tools .pill[aria-expanded="true"] { background: var(--dark); color: var(--on-dark); }
.confirm { max-width: 680px; }

/* Historique des notes */
.history { max-width: 680px; animation: fadeUp .35s var(--ease); }
.history-day { margin: 8px 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.history-item { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--bg); font-size: 14px; }
.history-item time { color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.history-text { min-width: 0; overflow-wrap: anywhere; }
.history-item.done .history-text { text-decoration: line-through; color: var(--muted); }
.history-item.deleted .history-text { color: var(--muted); }
.status-chip { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.status-chip.open { background: rgba(255, 160, 46, .18); color: #A45F00; }
.status-chip.done { background: rgba(154, 216, 114, .3); color: var(--forest); }
.status-chip.deleted { background: var(--chip); color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--forest); font-weight: 600; font-size: 13px; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.link-btn:hover { background: var(--chip); }
@media (max-width: 480px) { .history-item { grid-template-columns: 42px minmax(0, 1fr) auto; } .history-item .link-btn { grid-column: 2 / -1; justify-self: start; padding-left: 0; } }

/* Autorisations (interrupteurs façon iOS) */
.perm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.perm { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--r-sm); background: var(--chip); }
.perm i { width: 36px; height: 36px; border-radius: 11px; background: var(--card); display: grid; place-items: center; color: var(--forest); }
.perm i svg { width: 19px; height: 19px; }
.perm b { font-weight: 600; display: block; }
.perm small { color: var(--muted); font-size: 12.5px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--faint); transition: background-color .3s var(--ease); }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.2); transition: transform .35s var(--ease); }
.switch input:checked + span { background: var(--leaf); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--orange); outline-offset: 2px; }

/* ---------- Carte ---------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.map-card { position: relative; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-lg); isolation: isolate; }
.map { height: min(68vh, 640px); background: var(--chip); z-index: 0; }
.glass {
  background: rgba(255, 252, 244, .72); -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: 0 8px 24px -10px rgba(40, 35, 10, .35), inset 0 0 0 1px rgba(255, 255, 255, .5);
}
.map-top { position: absolute; top: 14px; left: 14px; z-index: 500; }
.map-top.seg { background: rgba(255, 252, 244, .72); }
.map-ctrls { position: absolute; top: 14px; right: 14px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.map-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0; cursor: pointer; display: grid; place-items: center;
  background: rgba(255, 252, 244, .85); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); color: #1F1E16;
  box-shadow: 0 6px 18px -8px rgba(40, 35, 10, .4);
}
.map-btn svg { width: 20px; height: 20px; }
.map-btn.locate { color: var(--forest); }
.map-btn.locate.active { background: var(--forest); color: #fff; }
.map-btn.locate.active svg { fill: currentColor; }
.map-pos { position: absolute; left: 14px; bottom: 14px; z-index: 500; padding: 8px 14px; border-radius: 12px; font-size: 12.5px; color: #1F1E16; max-width: calc(100% - 28px); }
.legs { gap: 14px; }
.leg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.leg { display: grid; grid-template-columns: 34px 1fr; gap: 12px; position: relative; padding-bottom: 14px; animation: fadeUp .4s var(--ease) both; }
.leg:not(:last-child)::before { content: ""; position: absolute; left: 16px; top: 34px; bottom: 0; width: 2px; background: repeating-linear-gradient(var(--line) 0 4px, transparent 4px 8px); }
.leg .num { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.leg strong { font-weight: 600; font-size: 14px; }
.leg small { color: var(--muted); display: block; }
.leg .travel { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 10px; border-radius: 999px; background: var(--chip); font-size: 12px; font-weight: 500; color: var(--forest); }
.leg .travel.warn { color: #fff; background: var(--danger); }
.leg .travel svg { width: 14px; height: 14px; }
.leg.me-leg .num { background: #2F7BEA; color: #fff; }
.pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); display: grid; place-items: center;
  border: 3px solid #fff; box-shadow: 0 6px 14px -4px rgba(0, 0, 0, .45); animation: pinDrop .6s var(--ease) both;
}
.pin span { transform: rotate(45deg); font-weight: 700; font-size: 13px; font-family: var(--font); }
.me { width: 20px; height: 20px; border-radius: 50%; background: #2F7BEA; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); position: relative; }
.me::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; background: rgba(47, 123, 234, .25); animation: halo 2.4s ease-out infinite; }

/* Leaflet aux couleurs de Tempo */
.leaflet-container { font-family: var(--font); background: #F4EEDD; }
.leaflet-tile-pane { filter: saturate(.55) sepia(.28) hue-rotate(-6deg) brightness(1.05) contrast(.92); }
.leaflet-popup-content-wrapper { border-radius: 16px; box-shadow: var(--shadow-lg); padding: 2px; }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.45; }
.leaflet-popup-content b { font-weight: 600; }
.leaflet-popup-tip { box-shadow: none; }
.leaflet-control-attribution { background: rgba(255, 252, 244, .7) !important; border-radius: 10px 0 0 0; font-size: 10px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(.92) hue-rotate(180deg) saturate(.5) sepia(.2) brightness(.95); } :root:not([data-theme="light"]) .leaflet-container { background: #1D2017; } }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(.92) hue-rotate(180deg) saturate(.5) sepia(.2) brightness(.95); }

/* ---------- Segmented ---------- */
.seg { display: inline-flex; background: var(--chip); border-radius: 14px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 8px 14px; border-radius: 11px; cursor: pointer; font-weight: 500; color: var(--muted); transition: background-color .3s var(--ease), color .3s; }
.seg button[aria-checked="true"] { background: var(--dark); color: var(--on-dark); }
.map-top.seg button { color: #6E6852; }
.map-top.seg button[aria-checked="true"] { background: #1F1E16; color: #fff; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }

/* ---------- Réglages ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 16px; align-items: start; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.habit-list, .type-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.habit-row {
  display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px;
  border-radius: var(--r-sm); background: var(--chip); cursor: pointer; border: 0; text-align: left; width: 100%;
}
.habit-row small { display: block; color: var(--muted); font-size: 12.5px; }
.type-row { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 12px; }
.type-row input[type="color"] { width: 34px; height: 34px; border: 0; padding: 0; background: none; cursor: pointer; flex: none; }
.type-row input[type="text"] { flex: 1; min-width: 0; border: 1.5px solid transparent; background: none; padding: 6px 8px; border-radius: 10px; font-weight: 500; }
.type-row input[type="text"]:hover, .type-row input[type="text"]:focus { border-color: var(--line); background: var(--bg); outline: none; }
.type-add { display: flex; gap: 8px; align-items: center; }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px; border-radius: var(--r-sm); background: var(--chip); font-size: 14px; animation: fadeUp .3s var(--ease); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: var(--muted); }
.field input, .field select {
  padding: 11px 13px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); font-weight: 400; font-size: 15px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--orange); }

/* ---------- Feuilles (modales) ---------- */
.sheet {
  border: 0; border-radius: 30px; padding: 0; width: min(500px, calc(100vw - 32px)); max-height: calc(100vh - 40px);
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-lg);
}
.sheet[open] { animation: sheetIn .5s var(--ease); }
.sheet.closing { animation: sheetOut .25s var(--ease-out) forwards; }
.sheet::backdrop { background: rgba(25, 22, 10, .35); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fadeIn .35s ease; }
.sheet.closing::backdrop { animation: fadeOut .25s ease forwards; }
.sheet form { padding: 14px 24px 24px; display: flex; flex-direction: column; gap: 12px; }
.grabber { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin-bottom: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.days { border: 0; padding: 0; margin: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.days legend { font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; padding: 0; }
.days label { position: relative; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--chip); color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; transition: background-color .25s var(--ease), color .25s, transform .25s var(--ease); }
.days span:active { transform: scale(.92); }
.days input:checked + span { background: var(--dark); color: var(--on-dark); }
.days input:focus-visible + span { outline: 3px solid var(--orange); }
.days.small span { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; background: var(--card); }
.sheet-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.spacer { flex: 1; }

.onboarding { width: min(640px, calc(100vw - 32px)); }
.onboarding h3 { margin-top: 6px; }
.onboarding p { margin: 0; }
.ob-presets { display: flex; flex-direction: column; gap: 8px; }
.ob-preset { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--chip); transition: opacity .3s; }
.ob-preset.off .ob-detail { display: none; }
.ob-top { display: flex; align-items: center; gap: 10px; }
.ob-top label { font-weight: 600; cursor: pointer; flex: 1; }
.ob-detail { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; animation: fadeUp .3s var(--ease); }
.ob-times { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.ob-times input { padding: 6px 8px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font-size: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: rgba(31, 30, 22, .9); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); color: #FFF8E8;
  padding: 12px 14px 12px 18px; border-radius: 18px; z-index: 50; display: flex; gap: 14px; align-items: center;
  box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); font-size: 14px; animation: toastIn .5s var(--ease);
}
.toast button { background: none; border: 0; color: var(--orange); font-weight: 600; cursor: pointer; padding: 4px; }

/* ---------- Widget ---------- */
body.widget-mode .app { display: none; }
.widget { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.w-head { display: flex; gap: 8px; align-items: center; font-size: 17px; }
.w-head strong { font-weight: 600; text-transform: capitalize; }
.widget ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.widget li { display: grid; grid-template-columns: 6px 52px 1fr; gap: 10px; align-items: center; padding: 10px 12px; background: var(--card); border-radius: 14px; font-size: 14px; box-shadow: var(--shadow); }
.widget li .bar { width: 6px; height: 100%; min-height: 22px; border-radius: 3px; }
.widget li time { font-weight: 600; font-variant-numeric: tabular-nums; }
.widget li.past { opacity: .5; }

/* ---------- Animations ---------- */
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.85); } 100% { opacity: 1; transform: scale(1); } }
@keyframes checkPop { 0% { transform: scale(.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes sheetIn { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sheetOut { to { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 24px) scale(.95); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes sunrise { from { transform: translateY(40px) scale(.9); opacity: 0; } }
@keyframes pinDrop { from { opacity: 0; transform: translateY(-14px) rotate(-45deg); } to { opacity: 1; transform: rotate(-45deg); } }
@keyframes halo { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; animation-timing-function: var(--ease); }

/* ---------- Téléphone ---------- */
@media (max-width: 860px) {
  .app {
    padding-block: 16px 116px;
    padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
    gap: 16px;
  }
  /* Barre d'icônes en bas, point orange sous l'onglet actif */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; gap: 0;
    padding: 10px max(12px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    background: color-mix(in srgb, var(--card) 88%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
    border-radius: 26px 26px 0 0; box-shadow: 0 -10px 30px -16px rgba(40, 35, 10, .3);
  }
  .tab-pill { display: none; }
  .tab { flex-direction: column; gap: 6px; padding: 6px 10px; background: none; color: var(--faint); border-radius: 12px; }
  .tab span { display: none; }
  .tab svg { width: 25px; height: 25px; }
  .tab::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--orange); transform: scale(0); transition: transform .35s var(--ease); }
  .tab[aria-selected="true"] { color: var(--ink); }
  .tab[aria-selected="true"] svg { stroke-width: 2.2; }
  .tab[aria-selected="true"]::after { transform: scale(1); }
  .day-layout, .map-layout { grid-template-columns: 1fr; }
  .hero { height: 210px; }
  .timeline-wrap { height: 56vh; }
  .map { height: 56vh; }
  .stats { gap: 6px; }
  .stat i { width: 30px; height: 30px; }
  .sheet { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 30px 30px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .sheet[open] { animation: sheetUp .5s var(--ease); }
  .sheet.closing { animation: sheetDown .28s var(--ease-out) forwards; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetDown { to { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
