/* Mise en page : une colonne centrée ; nav en haut (ordi) ou en bas (téléphone) ; bouton + flottant. */
:root {
  --bg: #f8dde7; --surface: #fff8fa; --fg: #2b1a21; --muted: #7a5f68; --line: #efdce3;
  --accent: #b8456f; --accent-soft: #fae2eb; --hot: #a8231c; --hot-soft: #fbe0dc;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --c0: #1f6fa8; --c0s: #dfeefa; --c1: #b8456f; --c1s: #fae2eb; --c2: #8a3a9e; --c2s: #f2e3f7;
  --c3: #2f7d4f; --c3s: #dff2e6; --c4: #a35b00; --c4s: #fbebd6; --c5: #0f7f7a; --c5s: #d9f2f0;
  --c6: #6b5a00; --c6s: #f2efd6; --c7: #4b55b8; --c7s: #e4e6fa; --c8: #666; --c8s: #ececec;
  --on-label: #fff;
  color-scheme: light;
}
/* Sombre : automatique selon le système, sauf choix explicite (data-theme sur <html>, voir js/theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1216; --surface: #241a1f; --fg: #f3e7ec; --muted: #b59ba5; --line: #3b2a31;
    --accent: #f191b5; --accent-soft: #43232f; --hot: #ff8b7d; --hot-soft: #40201c;
    --c0: #7fbcea; --c0s: #1c2e3d; --c1: #f191b5; --c1s: #43232f; --c2: #d29be0; --c2s: #352340;
    --c3: #7ccf9c; --c3s: #1d3326; --c4: #f0b060; --c4s: #3a2a16; --c5: #6fd3cc; --c5s: #173533;
    --c6: #d8c96a; --c6s: #33301a; --c7: #a3abf5; --c7s: #262a48; --c8: #bdbdbd; --c8s: #2e2e2e;
    --on-label: #1a1216;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1216; --surface: #241a1f; --fg: #f3e7ec; --muted: #b59ba5; --line: #3b2a31;
  --accent: #f191b5; --accent-soft: #43232f; --hot: #ff8b7d; --hot-soft: #40201c;
  --c0: #7fbcea; --c0s: #1c2e3d; --c1: #f191b5; --c1s: #43232f; --c2: #d29be0; --c2s: #352340;
  --c3: #7ccf9c; --c3s: #1d3326; --c4: #f0b060; --c4s: #3a2a16; --c5: #6fd3cc; --c5s: #173533;
  --c6: #d8c96a; --c6s: #33301a; --c7: #a3abf5; --c7s: #262a48; --c8: #bdbdbd; --c8s: #2e2e2e;
  --on-label: #1a1216;
  color-scheme: dark;
}
.topbar .icons { display: flex; gap: 2px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--body); padding: 16px 16px 96px; }
.app { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
body[data-view="week"] .app, body[data-view="month"] .app { max-width: 1760px; }
main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
h1, h2 { font-family: var(--display); margin: 0; text-wrap: balance; }
h1 { font-size: 1.9rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; }
.eyebrow { font-family: var(--mono); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
button, input, select, textarea { font: inherit; color: var(--fg); }
button { cursor: pointer; border-radius: 8px; border: 1px solid transparent; padding: 8px 14px; background: none; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; width: 100%;
}
.primary { background: var(--accent); color: var(--surface); font-weight: 700; }
.ghost { border-color: var(--line); }
.danger { color: var(--hot); border-color: var(--hot); margin-right: auto; }
.link { color: var(--muted); padding: 4px 8px; font-size: .85rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
nav.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
nav.tabs button { border-radius: 999px; padding: 6px 16px; color: var(--muted); }
nav.tabs button[aria-current=page] { background: var(--accent-soft); color: var(--fg); font-weight: 700; }
.icon { font-size: 1.2rem; padding: 6px 10px; }
.fab { position: fixed; right: 20px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); width: 56px; height: 56px; border-radius: 50%; padding: 0;
  background: var(--accent); color: var(--surface); font-size: 1.8rem; line-height: 1; box-shadow: 0 4px 14px rgb(0 0 0 / .2); }
body.logged-out .topbar, body.logged-out .fab { display: none; }
.status { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; margin: 0; background: var(--fg); color: var(--bg);
  padding: 6px 14px; border-radius: 999px; font-size: .85rem; max-width: calc(100vw - 32px); }
.status:empty { display: none; }
@media (max-width: 699px) {
  body { padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px)); }
  nav.tabs { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 5; box-shadow: 0 2px 12px rgb(0 0 0 / .15); }
  nav.tabs button { flex: 1; padding: 10px 4px; }
  .topbar { justify-content: flex-end; }
  .fab { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .status { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
}

.state { color: var(--muted); padding: 18px; background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; }
.note { font-size: .85rem; color: var(--muted); margin: 0; }
.day-head { display: flex; flex-direction: column; gap: 6px; }
.gauge { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); max-width: 420px; }
.gauge .bar { height: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.gauge .bar span { display: block; height: 100%; background: var(--accent); }
.gauge.over { color: var(--hot); }
.gauge.over .bar span { background: var(--hot); }
.claude-note, .plan p { margin: 0; border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; font-style: italic; white-space: pre-wrap; max-width: 70ch; }
.plan { display: flex; flex-direction: column; gap: 6px; }

ul.tasks { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
li.task { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 12px;
  border-top: 1px solid var(--line); box-shadow: inset 4px 0 0 var(--cc, transparent); }
li.task:first-child { border-top: 0; }
li.task input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
li.task .t { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 0; min-width: 0; border: 0; }
.title { overflow-wrap: anywhere; }
li.done .title { text-decoration: line-through; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .72rem; font-weight: 600; line-height: 1.45; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); white-space: nowrap; }
.chip.dur, .chip.date { font-family: var(--mono); }
.chip.date.late { background: var(--hot); border-color: var(--hot); color: var(--on-label); }
.chip.star { background: var(--c4); border-color: var(--c4); color: var(--on-label); }
.chip.cat { background: var(--cc); border-color: var(--cc); color: var(--on-label); }
.group { display: flex; flex-direction: column; gap: 6px; }
.group h2 small { font-family: var(--mono); font-weight: 400; font-size: .75rem; color: var(--muted); }
.group.late h2 { color: var(--hot); }
.group.catg h2 { color: var(--cc); }
.group.catg ul { border-top: 3px solid var(--cc); }
details.done-today summary { cursor: pointer; color: var(--muted); margin-bottom: 6px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar select { width: auto; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--surface); border-color: var(--accent); font-weight: 700; }
.toggle { display: flex; gap: 6px; align-items: center; cursor: pointer; }

/* Semaine : 7 colonnes d’au moins 210 px ; sur un écran moyen, la grille défile horizontalement plutôt que d’écraser les cartes. */
.week { display: grid; grid-template-columns: repeat(7, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.day { background: color-mix(in srgb, var(--surface) 55%, var(--bg)); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex;
  flex-direction: column; gap: 8px; min-width: 0; min-height: 160px; }
.day.today { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.day.drop { background: var(--accent-soft); }
.dh { display: flex; flex-direction: column; gap: 6px; padding: 2px 2px 4px; }
.dtitle { display: flex; align-items: baseline; gap: 6px; }
.dtitle b { font-family: var(--display); font-size: 1rem; font-weight: 600; color: var(--fg); }
.dtitle span { font-size: .85rem; color: var(--muted); }
.load { height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.load span { display: block; height: 100%; background: var(--accent); }
.dh small { font-family: var(--mono); font-size: .72rem; color: var(--muted); }
.day.over .load span { background: var(--hot); }
.day.over .dh small { color: var(--hot); font-weight: 600; }
.dnote { margin: 0; font-size: .76rem; font-style: italic; color: var(--muted); }
.blk { border-radius: 8px; padding: 10px 12px; font-size: .9rem; line-height: 1.35; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgb(0 0 0 / .06); display: flex; flex-direction: column; gap: 8px; cursor: grab; overflow: hidden; }
.blk:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.blk .bt { font-weight: 500; color: var(--fg); }
.btop { display: flex; align-items: flex-start; gap: 8px; }
.btop input { width: 17px; height: 17px; margin: 1px 0 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.blk.done { background: color-mix(in srgb, var(--surface) 50%, var(--bg)); box-shadow: none; }
.blk.done .bt { color: var(--muted); text-decoration: line-through; }
.blk.done .meta { opacity: .5; filter: grayscale(1); }
.blk .meta { gap: 4px; }
.blk.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.blk.drop-after { box-shadow: 0 3px 0 var(--accent); }
.blk.provisoire { border-style: dashed; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: none;
  background: color-mix(in srgb, var(--surface) 70%, transparent); }
li.task.provisoire .title { font-style: italic; }
.chip.reportee { background: var(--hot); border-color: var(--hot); color: var(--on-label); }
.day.past { opacity: .6; }

/* En-tête des vues calendrier : titre, navigation ‹ › et période. */
.cal-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.cal-head .eyebrow { flex-basis: 100%; }
.cal-nav { display: flex; gap: 4px; }
.cal-nav button { padding: 6px 12px; }
.cal-nav button:disabled { opacity: .45; cursor: default; }

/* Mois : grille lundi → dimanche ; chaque case ouvre sa semaine. */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.mhead { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; color: var(--muted); padding: 0 4px; }
.mday { display: flex; flex-direction: column; gap: 4px; align-items: stretch; text-align: left; min-height: 104px; padding: 6px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.mday:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.mday.out { background: transparent; opacity: .55; }
.mday.past { opacity: .6; }
.mday.today { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.mday.over .load span { background: var(--hot); }
.mnum { font-family: var(--display); font-weight: 600; font-size: .9rem; }
.mtasks { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mtask { font-size: .72rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 6px;
  border-left: 3px solid var(--cc, var(--accent)); }
.mtask.provisoire { font-style: italic; color: var(--muted); }
.mmore { font-size: .7rem; color: var(--muted); }
@media (max-width: 699px) {
  .month { gap: 3px; }
  .mday { min-height: 64px; padding: 4px; }
  .mtask { font-size: 0; padding-left: 0; border-left-width: 0; height: 4px; border-radius: 2px; background: var(--cc, var(--accent)); }
  .mmore { font-size: .62rem; }
}
.bt { overflow-wrap: anywhere; }
@media (max-width: 699px) { .week { grid-template-columns: 1fr; overflow-x: visible; } .day { min-height: 0; } }

dialog.sheet { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--fg); padding: 18px;
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
dialog::backdrop { background: rgb(0 0 0 / .35); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.field > span, .sheet h3 { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.day-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.day-picks button { border: 1px solid var(--line); }
.day-picks button[aria-pressed=true] { background: var(--accent-soft); font-weight: 700; }
ul.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cat-row input[type=text] { flex: 1; width: auto; }
.cat-row select, .row input[type=number] { width: auto; }
.swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--cc); flex: none; }
.dispo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.login { max-width: 320px; margin: 15vh auto 0; display: flex; flex-direction: column; gap: 12px; }
@media (prefers-reduced-motion: no-preference) { li.task { transition: background .15s; } li.task:hover { background: var(--accent-soft); } }
