/* ===== Design tokens (the only place with raw colours) — sober, calendar-style ===== */
:root {
  --brand-bg: #ffffff;
  --brand-surface: #ffffff;
  --brand-surface-2: #f1f3f4;
  --brand-surface-hover: #f1f3f4;
  --brand-surface-sel: #e8f0fe;
  --brand-border: #dadce0;
  --brand-line: #e3e5e8;
  --brand-text: #3c4043;
  --brand-strong: #202124;
  --brand-muted: #70757a;
  --brand-on-accent: #ffffff;
  --brand-accent: #1a73e8;
  --brand-accent-text: #1967d2;
  --brand-danger: #d93025;
  --brand-warn: #e37400;
  --brand-good: #188038;
  --brand-overlay: rgba(32, 33, 36, .4);
  --brand-shadow-1: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  --brand-shadow-2: 0 4px 8px 3px rgba(60, 64, 67, .15), 0 1px 3px rgba(60, 64, 67, .3);
  --brand-shadow-3: 0 24px 38px 3px rgba(60, 64, 67, .14), 0 9px 46px 8px rgba(60, 64, 67, .12), 0 11px 15px -7px rgba(60, 64, 67, .2);
  --prio-1: #d93025;
  --prio-2: #e37400;
  --prio-3: #1a73e8;
  --prio-4: #9aa0a6;
  /* project colours (Tomate, Flamant, Mandarine, Banane, Sauge, Basilic, Paon, Myrtille, Lavande, Raisin, Graphite) */
  --proj-0: #d50000; --proj-1: #e67c73; --proj-2: #f4511e; --proj-3: #f6bf26; --proj-4: #33b679; --proj-5: #0b8043;
  --proj-6: #039be5; --proj-7: #3f51b5; --proj-8: #7986cb; --proj-9: #8e24aa; --proj-10: #616161;
  --event-text: #ffffff;
  --brand-radius-sm: 4px;
  --brand-radius-md: 8px;
  --brand-radius-lg: 16px;
  --font-body: "Google Sans Text", "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: "Google Sans", "Segoe UI Variable Display", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  --hour-h: 48px;
  --side-w: 256px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-bg: #1f1f1f; --brand-surface: #2a2a2a; --brand-surface-2: #303134; --brand-surface-hover: #3c4043; --brand-surface-sel: #394457;
    --brand-border: #5f6368; --brand-line: #3c4043; --brand-text: #e3e3e3; --brand-strong: #ffffff; --brand-muted: #9aa0a6;
    --brand-accent: #8ab4f8; --brand-accent-text: #8ab4f8; --brand-on-accent: #202124; --brand-overlay: rgba(0, 0, 0, .6);
    --brand-shadow-1: 0 1px 3px rgba(0, 0, 0, .6); --brand-shadow-2: 0 4px 12px rgba(0, 0, 0, .6); --brand-shadow-3: 0 12px 40px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  --brand-bg: #1f1f1f; --brand-surface: #2a2a2a; --brand-surface-2: #303134; --brand-surface-hover: #3c4043; --brand-surface-sel: #394457;
  --brand-border: #5f6368; --brand-line: #3c4043; --brand-text: #e3e3e3; --brand-strong: #ffffff; --brand-muted: #9aa0a6;
  --brand-accent: #8ab4f8; --brand-accent-text: #8ab4f8; --brand-on-accent: #202124; --brand-overlay: rgba(0, 0, 0, .6);
  --brand-shadow-1: 0 1px 3px rgba(0, 0, 0, .6); --brand-shadow-2: 0 4px 12px rgba(0, 0, 0, .6); --brand-shadow-3: 0 12px 40px rgba(0, 0, 0, .7);
}

/* ===== Base ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { display: grid; grid-template-columns: var(--side-w) 1fr; grid-template-rows: 64px 1fr; background: var(--brand-bg); color: var(--brand-text);
  font: 14px/1.43 var(--font-body); overflow: hidden; }
body.side-closed { --side-w: 0px; }
body.side-closed .side { visibility: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: transparent; border: 0; border-radius: var(--brand-radius-sm); padding: 8px 14px; color: var(--brand-text); }
button:hover { background: var(--brand-surface-hover); }
button.primary { background: var(--brand-accent); color: var(--brand-on-accent); border-radius: var(--brand-radius-sm); font-weight: 500; padding: 8px 22px; }
button.primary:hover { box-shadow: var(--brand-shadow-1); background: var(--brand-accent); }
button.outline { border: 1px solid var(--brand-border); border-radius: var(--brand-radius-sm); font-weight: 500; }
button.text { color: var(--brand-accent-text); font-weight: 500; }
button.danger { color: var(--brand-danger); }
button:disabled { opacity: .45; cursor: default; }
.iconbtn { width: 40px; height: 40px; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; color: var(--brand-muted); position: relative; flex: none; }
.iconbtn.sm { width: 28px; height: 28px; }
.iconbtn .ic { display: block; }
input, select, textarea { background: var(--brand-surface); border: 1px solid var(--brand-border); border-radius: var(--brand-radius-sm); padding: 7px 10px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-accent); box-shadow: inset 0 0 0 1px var(--brand-accent); }
a { color: var(--brand-accent-text); text-decoration: none; }
h1 { font: 400 22px var(--font-display); color: var(--brand-strong); margin: 0; }
h2 { font: 500 16px var(--font-display); color: var(--brand-strong); margin: 0 0 8px; }
h3 { font: 500 14px var(--font-display); color: var(--brand-strong); margin: 20px 0 6px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--brand-muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; }
.sq { display: inline-block; width: 14px; height: 14px; border-radius: 4px; flex: none; }
kbd { font: 11px var(--font-mono); background: var(--brand-surface-2); border: 1px solid var(--brand-border); border-radius: 4px; padding: 0 5px; }
.empty { color: var(--brand-muted); padding: 28px 0; text-align: center; }

/* ===== Top bar ===== */
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 4px; padding: 8px 16px 8px 8px; border-bottom: 1px solid var(--brand-line); background: var(--brand-bg); min-width: 0; }
.logo { display: flex; align-items: center; gap: 10px; font: 400 22px var(--font-display); color: var(--brand-text); padding: 0 24px 0 4px; min-width: 170px; }
.logo-mark { width: 40px; height: 40px; border-radius: 8px; background: var(--brand-accent); display: inline-grid; place-items: center; color: var(--brand-on-accent); font: 500 15px var(--font-display); }
.topnav { display: flex; align-items: center; gap: 2px; }
.topnav .outline { margin-right: 12px; }
.today-ic { display: none; }
.top-title { font: 400 22px var(--font-display); color: var(--brand-strong); padding-left: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--brand-danger); color: var(--brand-on-accent); font-size: 10px; display: grid; place-items: center; padding: 0 3px; }
#viewsel select { border: 1px solid var(--brand-border); font-weight: 500; padding: 8px 12px; margin-left: 8px; cursor: pointer; background: var(--brand-bg); }
.timerpill { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 18px; background: var(--brand-surface-sel); color: var(--brand-accent-text); margin-right: 8px; max-width: 340px; }
.timerpill .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.timerpill .clock { font: 500 14px var(--font-mono); }
.timerpill .iconbtn { width: 30px; height: 30px; color: var(--brand-accent-text); }

/* ===== Sidebar ===== */
.side { display: flex; flex-direction: column; overflow-y: auto; padding: 8px 0 12px; background: var(--brand-bg); min-width: 0; }
.create-wrap { position: relative; padding: 8px 8px 16px 8px; }
.create { display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px 0 16px; border-radius: var(--brand-radius-lg); background: var(--brand-surface);
  box-shadow: var(--brand-shadow-1); font: 500 14px var(--font-display); color: var(--brand-strong); }
.create:hover { box-shadow: var(--brand-shadow-2); background: var(--brand-surface-sel); }
.create .ic { color: var(--brand-accent); }
.create-menu { position: absolute; top: 70px; left: 8px; z-index: 30; background: var(--brand-surface); box-shadow: var(--brand-shadow-2); border-radius: var(--brand-radius-sm); padding: 8px 0; min-width: 220px; }
.create-menu button { display: flex; width: 100%; align-items: center; gap: 14px; border-radius: 0; padding: 10px 18px; text-align: left; }
.create-menu small { display: block; color: var(--brand-muted); font-size: 12px; }
.side-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 4px 24px; font: 500 14px var(--font-display); color: var(--brand-strong); }
.nav a { display: flex; align-items: center; gap: 14px; height: 36px; padding: 0 12px 0 24px; margin-right: 12px; border-radius: 0 18px 18px 0; color: var(--brand-text); }
.nav a:hover { background: var(--brand-surface-hover); }
.nav a.on { background: var(--brand-surface-sel); color: var(--brand-accent-text); font-weight: 500; }
.nav a .ic { color: var(--brand-muted); }
.nav a.on .ic { color: var(--brand-accent-text); }
.nav a .n { margin-left: auto; font-size: 12px; color: var(--brand-muted); }
.nav a .n.alert { color: var(--brand-on-accent); background: var(--brand-danger); border-radius: 10px; padding: 0 7px; font-weight: 500; }
.tree a { height: 32px; }
.tree a.lvl1 { padding-left: 44px; }
.tree a.lvl2 { padding-left: 64px; font-size: 13px; }
.tree a .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* mini calendar */
.minical { padding: 0 12px 8px 24px; user-select: none; }
.minical .mh { display: flex; align-items: center; font: 500 14px var(--font-display); color: var(--brand-strong); padding: 0 0 6px 4px; }
.minical .mh .iconbtn { width: 28px; height: 28px; }
.minical .g { display: grid; grid-template-columns: repeat(7, 28px); gap: 1px 0; font-size: 10px; text-align: center; }
.minical .g .w { color: var(--brand-muted); height: 22px; line-height: 22px; font-weight: 500; }
.minical .g button { width: 26px; height: 26px; padding: 0; border-radius: 50%; font-size: 10px; margin: 0 auto; }
.minical .g button.out { color: var(--brand-muted); }
.minical .g button.sel { background: var(--brand-surface-sel); color: var(--brand-accent-text); font-weight: 500; }
.minical .g button.today { background: var(--brand-accent); color: var(--brand-on-accent); font-weight: 500; }
.minical .g button.has::after { content: ""; display: block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; margin: -3px auto 0; opacity: .5; }

/* ===== Main ===== */
main { overflow-y: auto; min-width: 0; position: relative; }
main.agenda { overflow: hidden; display: flex; }
.page { padding: 20px 32px 60px; max-width: 1100px; }
.page-h { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; min-height: 40px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--brand-line); margin: 4px 0 16px; }
.tabs a { padding: 10px 16px; color: var(--brand-muted); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand-accent-text); border-bottom-color: var(--brand-accent); }
.card { background: var(--brand-surface); border: 1px solid var(--brand-line); border-radius: var(--brand-radius-md); padding: 16px; }

/* ===== Calendar (day / week) ===== */
.cal { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cal-head { display: grid; grid-template-columns: 64px repeat(var(--days), 1fr) 8px; border-bottom: 1px solid var(--brand-line); }
.cal-head .dh { text-align: center; padding: 10px 0 6px; border-left: 1px solid transparent; }
.cal-head .dh .w { font: 500 11px var(--font-display); color: var(--brand-muted); text-transform: uppercase; letter-spacing: .8px; }
.cal-head .dh .d { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; font: 400 26px var(--font-display); color: var(--brand-text); margin-top: 2px; cursor: pointer; }
.cal-head .dh .d:hover { background: var(--brand-surface-hover); }
.cal-head .dh.today .w { color: var(--brand-accent-text); }
.cal-head .dh.today .d { background: var(--brand-accent); color: var(--brand-on-accent); }
.cal-allday { display: grid; grid-template-columns: 64px repeat(var(--days), 1fr) 8px; border-bottom: 1px solid var(--brand-line); min-height: 26px; }
.cal-allday .gl { font-size: 10px; color: var(--brand-muted); text-align: right; padding: 6px 8px 0 0; }
.cal-allday .ad { border-left: 1px solid var(--brand-line); padding: 2px 4px 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-allday .ad.over { background: var(--brand-surface-sel); }
.cal-body { flex: 1; overflow-y: auto; position: relative; }
.cal-grid { display: grid; grid-template-columns: 64px repeat(var(--days), 1fr); position: relative; }
.gut .hour { height: var(--hour-h); position: relative; }
.gut .hour span { position: absolute; top: -7px; right: 8px; font-size: 10px; color: var(--brand-muted); }
.gut .hour:first-child span { display: none; }
.col { position: relative; border-left: 1px solid var(--brand-line); }
.col .hour { height: var(--hour-h); border-top: 1px solid var(--brand-line); }
.col .hour:first-child { border-top-color: transparent; }
.col .off { position: absolute; left: 0; right: 0; background: var(--brand-surface-2); opacity: .55; pointer-events: none; }
.col .now { position: absolute; left: -6px; right: 0; height: 2px; background: var(--brand-danger); z-index: 4; pointer-events: none; }
.col .now::before { content: ""; position: absolute; left: 0; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand-danger); }
.ev { position: absolute; border-radius: var(--brand-radius-sm); background: var(--c); color: var(--event-text); padding: 2px 6px; font-size: 12px; line-height: 15px; overflow: hidden;
  cursor: pointer; z-index: 2; box-shadow: 0 0 0 1px var(--brand-bg); user-select: none; }
.ev b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { opacity: .9; }
.ev.sm { white-space: nowrap; } .ev.sm b { display: inline; } .ev.sm span { margin-left: 4px; }
.ev.done { opacity: .55; } .ev.done b { text-decoration: line-through; }
.ev.note { background: var(--brand-surface); color: var(--brand-text); border: 1px solid var(--c); }
.ev .rs { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize; }
.ev.running { box-shadow: 0 0 0 2px var(--brand-bg), 0 0 0 4px var(--c); }
.chipev { background: var(--c); color: var(--event-text); border-radius: var(--brand-radius-sm); font-size: 12px; padding: 1px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.chipev.done { opacity: .55; text-decoration: line-through; }
.chipev.late { background: var(--brand-surface); color: var(--brand-danger); box-shadow: inset 0 0 0 1px var(--brand-danger); }
.ghost-slot { position: absolute; left: 2px; right: 6px; border-radius: var(--brand-radius-sm); background: var(--brand-surface-sel); border: 1px solid var(--brand-accent); color: var(--brand-accent-text); font-size: 12px; padding: 2px 6px; z-index: 3; pointer-events: none; }

/* month */
.month { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: auto; grid-auto-rows: 1fr; border-left: 1px solid var(--brand-line); overflow: hidden; }
.month .mw { text-align: center; font: 500 11px var(--font-display); color: var(--brand-muted); text-transform: uppercase; padding: 6px 0 0; border-right: 1px solid var(--brand-line); }
.month .md { border-right: 1px solid var(--brand-line); border-bottom: 1px solid var(--brand-line); padding: 2px 4px; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.month .md.over { background: var(--brand-surface-sel); }
.month .md .n { align-self: center; min-width: 24px; padding: 0 6px; height: 24px; border-radius: 12px; white-space: nowrap; display: grid; place-items: center; font-size: 12px; font-weight: 500; cursor: pointer; }
.month .md.out .n { color: var(--brand-muted); }
.month .md.today .n { background: var(--brand-accent); color: var(--brand-on-accent); }
.month .more { font-size: 12px; color: var(--brand-muted); padding-left: 6px; cursor: pointer; }

/* side panel of the agenda: tasks to place */
.cal-side { width: 300px; border-left: 1px solid var(--brand-line); overflow-y: auto; padding: 14px 12px 40px 16px; flex: none; }
.cal-side h3:first-child { margin-top: 2px; }

/* ===== Task rows (lists) ===== */
.tasks { display: flex; flex-direction: column; }
.task { display: flex; align-items: flex-start; gap: 10px; padding: 8px 8px 8px 4px; border-radius: var(--brand-radius-md); position: relative; }
.task:hover { background: var(--brand-surface-hover); }
.task .chk { flex: none; width: 20px; height: 20px; padding: 0; margin-top: 1px; border-radius: 50%; border: 2px solid var(--pc, var(--brand-muted)); display: grid; place-items: center; color: transparent; }
.task .chk:hover { color: var(--pc, var(--brand-muted)); background: transparent; }
.task.p1 { --pc: var(--prio-1); } .task.p2 { --pc: var(--prio-2); } .task.p3 { --pc: var(--brand-muted); } .task.p4 { --pc: var(--prio-4); }
.task.done .chk { background: var(--brand-accent); border-color: var(--brand-accent); color: var(--brand-on-accent); }
.task.done .title { text-decoration: line-through; color: var(--brand-muted); }
.task .body { flex: 1; min-width: 0; cursor: pointer; }
.task .title { color: var(--brand-strong); overflow-wrap: anywhere; }
.task .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--brand-muted); margin-top: 2px; align-items: center; }
.task .meta .late { color: var(--brand-danger); }
.task .meta .today { color: var(--brand-accent-text); }
.task .meta .m { display: inline-flex; align-items: center; gap: 4px; }
.task .acts { display: flex; gap: 0; opacity: 0; }
.task:hover .acts, .task.running .acts { opacity: 1; }
.task .acts .iconbtn { width: 32px; height: 32px; }
.task.running { background: var(--brand-surface-sel); }
.task.dragging { opacity: .4; }
.sec-h { display: flex; align-items: center; gap: 8px; margin: 22px 0 4px; font: 500 14px var(--font-display); color: var(--brand-strong); }
.sec-h .c { color: var(--brand-muted); font-weight: 400; }
.add-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 4px; color: var(--brand-accent-text); cursor: pointer; border-radius: var(--brand-radius-md); font-weight: 500; }
.add-row:hover { background: var(--brand-surface-hover); }

/* ===== Notes ===== */
.capture { max-width: 600px; margin: 8px auto 24px; background: var(--brand-surface); border-radius: var(--brand-radius-md); box-shadow: var(--brand-shadow-1); padding: 4px 4px 4px 16px; }
.capture input, .capture textarea { border: 0; width: 100%; padding: 10px 0; box-shadow: none; background: transparent; }
.capture textarea { resize: none; min-height: 60px; display: none; }
.capture.open textarea { display: block; }
.capture .row { padding: 0 8px 8px 0; display: none; justify-content: flex-end; }
.capture.open .row { display: flex; }
.notes-grid { columns: 300px; column-gap: 16px; }
.ncard { break-inside: avoid; background: var(--brand-surface); border: 1px solid var(--brand-border); border-radius: var(--brand-radius-md); padding: 12px 14px 6px; margin-bottom: 16px; }
.ncard:hover { box-shadow: var(--brand-shadow-1); }
.ncard .nt { font: 500 15px var(--font-display); color: var(--brand-strong); margin-bottom: 4px; overflow-wrap: anywhere; }
.ncard .nb { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--brand-text); max-height: 200px; overflow: hidden; }
.ncard .nf { display: flex; align-items: center; gap: 2px; margin-top: 8px; color: var(--brand-muted); font-size: 12px; }
.ncard .nm { font-size: 12px; color: var(--brand-muted); margin-bottom: 4px; }
.ncard .nf .iconbtn { width: 32px; height: 32px; }
.ncard.old { border-color: var(--brand-warn); }
.ncard .age { color: var(--brand-warn); }
.banner { display: flex; align-items: center; gap: 12px; background: var(--brand-surface-sel); color: var(--brand-accent-text); border-radius: var(--brand-radius-md); padding: 10px 16px; margin: 0 0 16px; }

/* ===== Project page ===== */
.ptree .sec { margin-top: 14px; }
.ptree .sec .sec { margin-left: 26px; }
.ptree .sec-h .iconbtn { opacity: 0; }
.ptree .sec-h:hover .iconbtn { opacity: 1; }
.pnote { display: flex; gap: 10px; padding: 8px 8px 8px 4px; border-radius: var(--brand-radius-md); color: var(--brand-text); cursor: pointer; }
.pnote:hover { background: var(--brand-surface-hover); }
.pnote .ic { color: var(--brand-muted); margin-top: 1px; flex: none; }

/* ===== Dialogs ===== */
.modal-bg { position: fixed; inset: 0; background: var(--brand-overlay); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--brand-surface); border-radius: var(--brand-radius-md); box-shadow: var(--brand-shadow-3); width: min(560px, 94vw); max-height: 90vh; overflow-y: auto; padding: 8px 0 12px; }
.modal .mh { display: flex; justify-content: flex-end; padding: 0 8px; }
.modal .ttl { width: calc(100% - 72px); margin: 0 24px 0 56px; border: 0; border-bottom: 1px solid var(--brand-border); border-radius: 0; font: 400 22px var(--font-display); padding: 6px 0; box-shadow: none; background: transparent; }
.modal .ttl:focus { border-bottom: 2px solid var(--brand-accent); box-shadow: none; }
.kind { display: flex; gap: 6px; margin: 12px 24px 6px 56px; }
.kind button { border-radius: var(--brand-radius-sm); padding: 6px 12px; font-weight: 500; }
.kind button.on { background: var(--brand-surface-sel); color: var(--brand-accent-text); }
.frow { display: flex; align-items: flex-start; gap: 16px; padding: 8px 24px 8px 16px; }
.frow > .ic { margin: 7px 0 0 4px; color: var(--brand-muted); flex: none; }
.frow .fc { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.frow select, .frow input { background: var(--brand-surface-2); border-color: transparent; }
.frow textarea { width: 100%; min-height: 80px; background: var(--brand-surface-2); border-color: transparent; resize: vertical; }
.frow .hint { font-size: 12px; color: var(--brand-muted); width: 100%; }
.prio { display: flex; gap: 4px; }
.prio button { padding: 5px 10px; border: 1px solid var(--brand-border); border-radius: var(--brand-radius-sm); display: inline-flex; gap: 6px; align-items: center; }
.prio button .ic { color: var(--pc); }
.prio button.on { background: var(--brand-surface-sel); border-color: var(--brand-accent); color: var(--brand-accent-text); }
.prio .p1 { --pc: var(--prio-1); } .prio .p2 { --pc: var(--prio-2); } .prio .p3 { --pc: var(--prio-3); } .prio .p4 { --pc: var(--prio-4); }
.modal .foot { display: flex; align-items: center; gap: 8px; padding: 12px 24px 4px 56px; }

/* ===== Detail panel (drawer) ===== */
.drawer { position: fixed; top: 64px; right: 0; bottom: 0; width: 440px; max-width: 100vw; background: var(--brand-surface); box-shadow: var(--brand-shadow-3);
  transform: translateX(105%); transition: transform .18s ease; z-index: 40; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer .dh { display: flex; align-items: center; gap: 2px; padding: 8px 8px 0 12px; }
.drawer .db { overflow-y: auto; padding: 4px 0 40px; }
.drawer .dtitle { display: flex; align-items: flex-start; gap: 16px; padding: 4px 24px 8px 20px; }
.drawer .dtitle .sq { margin-top: 9px; }
.drawer .dtitle textarea { flex: 1; font: 400 22px var(--font-display); color: var(--brand-strong); border: 0; padding: 2px 0; resize: none; min-height: 34px; background: transparent; }
.drawer .dtitle textarea:focus { box-shadow: none; border-bottom: 2px solid var(--brand-accent); }
.drawer .frow { padding: 6px 20px 6px 16px; }
.drawer .timebox { display: flex; align-items: center; gap: 10px; }
.drawer .timebox .clock { font: 500 18px var(--font-mono); color: var(--brand-strong); }
.drawer .sub-add input { width: 100%; border: 0; background: transparent; padding: 6px 0; box-shadow: none; }
.drawer .tasks .task { padding: 4px 4px 4px 0; }
.quick { display: flex; gap: 4px; flex-wrap: wrap; }
.quick button { font-size: 12px; padding: 3px 9px; border: 1px solid var(--brand-border); border-radius: 12px; }
.quick button.on { background: var(--brand-surface-sel); border-color: var(--brand-accent); color: var(--brand-accent-text); }
.entries { font-size: 12px; color: var(--brand-muted); width: 100%; }

/* ===== Popups, toasts, focus ===== */
.pop { position: fixed; top: 58px; right: 64px; width: 380px; max-height: 70vh; overflow-y: auto; background: var(--brand-surface); border-radius: var(--brand-radius-md); box-shadow: var(--brand-shadow-2); z-index: 60; padding: 8px 0; }
.pop .notif { padding: 10px 16px; border-bottom: 1px solid var(--brand-line); }
.pop .notif.unread { background: var(--brand-surface-sel); }
.pop .notif .b { color: var(--brand-muted); font-size: 13px; white-space: pre-line; }
.toasts { position: fixed; left: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 70; }
.toast { background: var(--brand-strong); color: var(--brand-bg); border-radius: var(--brand-radius-sm); padding: 12px 16px; min-width: 300px; max-width: 460px; box-shadow: var(--brand-shadow-2); }
.toast .b { opacity: .8; font-size: 13px; white-space: pre-line; }
.toast .row { margin-top: 6px; justify-content: flex-end; }
.toast button { color: var(--brand-surface-sel); font-weight: 500; padding: 6px 10px; }
.toast button:hover { background: transparent; text-decoration: underline; }
.focus { position: fixed; inset: 0; background: var(--brand-bg); z-index: 80; display: grid; place-items: center; text-align: center; }
.focus .phase { color: var(--brand-muted); font: 500 14px var(--font-display); text-transform: uppercase; letter-spacing: 1px; }
.focus .t { font: 400 26px var(--font-display); color: var(--brand-strong); margin-top: 8px; }
.focus .clock { font: 300 110px var(--font-display); color: var(--brand-strong); margin-top: 10px; }

/* ===== Stats / settings ===== */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; }
.bars .b { flex: 1; display: flex; flex-direction: column-reverse; height: 100%; background: var(--brand-surface-2); border-radius: 3px; overflow: hidden; }
.bars-l { display: flex; gap: 6px; font-size: 10px; color: var(--brand-muted); } .bars-l span { flex: 1; text-align: center; }
.hbar { display: grid; grid-template-columns: 170px 1fr 70px; gap: 10px; align-items: center; margin: 7px 0; font-size: 13px; }
.hbar .track { height: 8px; background: var(--brand-surface-2); border-radius: 4px; overflow: hidden; } .hbar .track i { display: block; height: 100%; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--brand-muted); padding: 6px 8px; border-bottom: 1px solid var(--brand-line); }
td { padding: 6px 8px; border-bottom: 1px solid var(--brand-line); }
.danger { color: var(--brand-danger); }
.fg { display: grid; grid-template-columns: 260px 1fr; gap: 12px 16px; align-items: center; }
.fg > label { color: var(--brand-muted); }
.days-pick { display: flex; gap: 4px; }
.days-pick label { cursor: pointer; } .days-pick input { display: none; }
.days-pick span { display: inline-grid; place-items: center; width: 34px; height: 30px; border-radius: 15px; border: 1px solid var(--brand-border); font-size: 12px; }
.days-pick input:checked + span { background: var(--brand-accent); color: var(--brand-on-accent); border-color: transparent; }
.colors { display: flex; flex-wrap: wrap; gap: 6px; }
.colors button { width: 24px; height: 24px; padding: 0; border-radius: 50%; background: var(--c); }
.colors button.on { box-shadow: 0 0 0 2px var(--brand-surface), 0 0 0 4px var(--c); }
.plan-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--brand-line); }
.mono { font-family: var(--font-mono); }

@media (max-width: 1100px) { .cal-side { display: none; } }

/* ---------- agendas (événements : teinte pâle + bord coloré ; les tâches restent pleines) ---------- */
.chipcal { --tint: color-mix(in srgb, var(--c) 20%, var(--brand-surface)); background: var(--tint); color: var(--brand-strong); border-left: 3px solid var(--c);
  border-radius: var(--brand-radius-sm); font-size: 12px; padding: 1px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; flex: none; }
.chipcal:hover { background: color-mix(in srgb, var(--c) 32%, var(--brand-surface)); }
.chipcal .tm { color: var(--brand-muted); }
.evt { position: absolute; z-index: 2; border-radius: var(--brand-radius-sm); background: color-mix(in srgb, var(--c) 22%, var(--brand-surface)); color: var(--brand-strong);
  border-left: 4px solid var(--c); padding: 2px 6px; font-size: 12px; line-height: 15px; overflow: hidden; cursor: pointer; box-shadow: 0 0 0 1px var(--brand-bg); }
.evt b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evt span { color: var(--brand-muted); }
.evt.sm { white-space: nowrap; } .evt.sm b { display: inline; } .evt.sm span { margin-left: 4px; }
.evt:hover { background: color-mix(in srgb, var(--c) 34%, var(--brand-surface)); }
.evbg { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--c) 11%, transparent); border-left: 3px solid var(--c); pointer-events: none; }
.cal-allday .ad > * { flex: none; }
.cal-allday .more { font-size: 12px; color: var(--brand-muted); padding-left: 6px; cursor: pointer; }
.cal-allday .more:hover, .month .more:hover { color: var(--brand-strong); }

.cals { padding: 0 12px 4px 18px; }
.calrow { display: flex; align-items: center; gap: 2px; height: 32px; border-radius: 0 16px 16px 0; padding-left: 4px; }
.calrow:hover { background: var(--brand-surface-hover); }
.calrow label { flex: 1; display: flex; align-items: center; gap: 12px; cursor: pointer; min-width: 0; }
.calrow .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calrow input[type=checkbox] { appearance: none; width: 18px; height: 18px; border-radius: 3px; border: 2px solid var(--c); margin: 0; padding: 0; flex: none; display: grid; place-items: center; cursor: pointer; background: transparent; }
.calrow input[type=checkbox]:checked { background: var(--c); }
.calrow input[type=checkbox]:checked::after { content: ""; width: 5px; height: 9px; border: solid var(--event-text); border-width: 0 2px 2px 0; transform: translate(0, -1px) rotate(45deg); }
.calrow .iconbtn { width: 28px; height: 28px; visibility: hidden; }
.calrow:hover .iconbtn { visibility: visible; }
.calrow .warn { color: var(--brand-warn); display: grid; }

.evpop { display: flex; gap: 18px; align-items: flex-start; padding: 4px 24px 8px 22px; }
.evpop .sq { width: 16px; height: 16px; border-radius: 4px; margin-top: 7px; flex: none; }
.evpop .et { font: 400 22px var(--font-display); color: var(--brand-strong); }

.rules { display: flex; flex-direction: column; }
.rule { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--brand-line); }
.rule:first-child { border-top: 0; }
.rule.off .rb { opacity: .5; }
.rule .rb { flex: 1; min-width: 0; }
.rule .rw { color: var(--brand-muted); font-size: 13px; }
.rule .rw select, .rule .rw input { padding: 3px 6px; font-size: 13px; margin: 2px 0; }

/* jours fériés : journée grisée (on peut quand même y mettre des tâches) */
.col.holiday { background: var(--brand-surface-2); }
.cal-head .dh.holiday .w, .cal-head .dh.holiday .d { color: var(--brand-muted); }
.month .md.holiday { background: var(--brand-surface-2); }
.evt.cancel, .chipcal.cancel { opacity: .55; } .evt.cancel b, .chipcal.cancel { text-decoration: line-through; }

/* ======================================================= Téléphone (≤ 760 px) */
#bottomnav, #fab, #side-scrim { display: none; }
html, body { overflow-x: clip; }
.drawer:not(.open) { visibility: hidden; transition: transform .18s ease, visibility 0s .18s; }
@media (max-width: 760px) {
  :root { --hour-h: 52px; --gut: 44px; }
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: 56px minmax(0, 1fr) 60px; height: 100dvh; -webkit-tap-highlight-color: transparent; }
  .topbar { padding: 4px 4px 4px 2px; gap: 0; }
  .logo, .topnav #prev, .topnav #next, .timerpill .t, .timerpill #tp-focus { display: none; }
  .topbar { overflow: hidden; }
  .topnav .outline { margin: 0 2px; padding: 0; width: 40px; height: 40px; border: 0; display: grid; place-items: center; }
  .topnav .outline .lbl { display: none; }
  .today-ic { display: grid; place-items: center; width: 22px; height: 22px; border: 2px solid var(--brand-muted); border-radius: 5px; font-size: 11px; font-weight: 700; color: var(--brand-muted); }
  .timerpill .dur, .timerpill #tp-stop { display: none; }
  .timerpill { cursor: pointer; }
  #bell { width: 36px; }
  .top-title { font-size: 19px; padding-left: 4px; flex: 1; min-width: 0; }
  .topbar > .spacer { display: none; }
  #viewsel select { margin-left: 2px; padding: 6px 6px; font-size: 13px; }
  .timerpill { padding: 2px 4px 2px 8px; margin-right: 2px; }
  .timerpill .clock { font-size: 13px; }

  /* menu latéral = tiroir par-dessus */
  .side { position: fixed; z-index: 45; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); visibility: visible; transform: translateX(-102%);
    transition: transform .2s ease; box-shadow: var(--brand-shadow-3); padding-top: 12px; }
  body.side-open .side { transform: none; }
  body.side-closed .side { visibility: visible; }
  #side-scrim { display: block; position: fixed; inset: 0; z-index: 44; background: var(--brand-overlay); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.side-open #side-scrim { opacity: 1; pointer-events: auto; }
  .side .create-wrap { display: none; }
  .nav a { height: 44px; }
  .tree a { height: 40px; }
  .calrow { height: 40px; }
  .calrow .iconbtn { visibility: visible; }
  .minical .g { grid-template-columns: repeat(7, 34px); }
  .minical .g button { width: 32px; height: 32px; font-size: 12px; }

  /* barre du bas + bouton Créer flottant */
  main { grid-column: 1; grid-row: 2; }
  #bottomnav { display: flex; grid-column: 1; grid-row: 3; border-top: 1px solid var(--brand-line); background: var(--brand-bg); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  #bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--brand-muted); font-size: 11px; font-weight: 500; position: relative; }
  #bottomnav a .ic { width: 24px; height: 24px; }
  #bottomnav a.on { color: var(--brand-accent-text); }
  #bottomnav a.on .pill { background: var(--brand-surface-sel); }
  #bottomnav .pill { display: grid; place-items: center; width: 56px; height: 28px; border-radius: 14px; }
  #bottomnav .n { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--brand-danger); color: var(--brand-on-accent); font-size: 10px; display: grid; place-items: center; }
  #fab { display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 30; width: 56px; height: 56px; padding: 0;
    border-radius: 16px; background: var(--brand-surface-sel); color: var(--brand-accent-text); box-shadow: var(--brand-shadow-2); }
  body.modal-open #fab { display: none; }

  /* pages */
  .page { padding: 12px 14px 96px; }
  .page-h { flex-wrap: wrap; }
  .tabs { overflow-x: auto; scrollbar-width: none; margin-top: 0; }
  .tabs a { padding: 10px 12px; white-space: nowrap; }
  .grid2 { grid-template-columns: 1fr; }
  .fg { grid-template-columns: 1fr; gap: 4px 0; }
  .fg > label { margin-top: 10px; font-size: 13px; }
  .hbar { grid-template-columns: 110px 1fr 56px; }
  .notes-grid { columns: 1; }
  .capture { margin-top: 0; }
  .rule { flex-wrap: wrap; }
  .rule .rb { flex-basis: calc(100% - 40px); }
  .rule .rw select { max-width: 100%; }
  table { font-size: 12px; } td, th { padding: 6px 4px; }
  .task { padding: 10px 4px; }
  .task .chk { width: 24px; height: 24px; }
  .task .acts [data-act=del] { display: none; }
  .add-row { padding: 12px 4px; }
  .ptree .sec .sec { margin-left: 12px; }
  .ptree .sec-h .iconbtn { opacity: 1; }

  /* agenda */
  .cal-head, .cal-allday { grid-template-columns: var(--gut) repeat(var(--days), 1fr) 0; }
  .cal-grid { grid-template-columns: var(--gut) repeat(var(--days), 1fr); }
  .cal-head .dh { padding: 6px 0 4px; }
  .cal-head .dh .d { width: 34px; height: 34px; font-size: 18px; }
  .cal-allday .gl { font-size: 9px; padding: 4px 3px 0 0; overflow: hidden; }
  .gut .hour span { right: 4px; }
  .ev, .evt { padding: 2px 4px; font-size: 11px; line-height: 14px; }
  .ev .rs { display: none; }
  .chipev, .chipcal { font-size: 11px; padding: 1px 4px; }
  .month .mw { font-size: 10px; }
  .month .md { padding: 1px 1px; gap: 1px; }
  .month .md .n { font-size: 11px; height: 20px; min-width: 20px; padding: 0 4px; }
  .month .chipev, .month .chipcal { font-size: 10px; padding: 0 3px; border-left-width: 2px; border-radius: 3px; }
  .month .chipcal .tm { display: none; }
  .month .more { font-size: 10px; padding-left: 2px; }

  /* fenêtres en plein écran */
  .modal-bg { place-items: stretch; }
  .modal { width: 100vw; max-height: none; height: 100dvh; border-radius: 0; padding: 4px 0 calc(16px + env(safe-area-inset-bottom)); }
  .modal[style] { padding: 16px !important; }
  .modal .ttl { width: calc(100% - 32px); margin: 0 16px; font-size: 20px; }
  .kind { margin: 12px 16px 6px; }
  .frow { gap: 12px; padding: 8px 16px 8px 12px; }
  .frow .fc input[type=date], .frow .fc input[type=time], .frow .fc select { min-height: 40px; }
  .prio { flex-wrap: wrap; }
  .modal .foot { padding: 12px 16px 4px; position: sticky; bottom: 0; background: var(--brand-surface); flex-wrap: wrap; }
  .evpop { padding: 4px 16px 8px 14px; }
  .days-pick { flex-wrap: wrap; }
  .days-pick span { width: 40px; height: 36px; }
  .colors button { width: 32px; height: 32px; }
  .drawer { top: 0; width: 100vw; z-index: 46; padding-bottom: env(safe-area-inset-bottom); }
  .drawer .frow { padding: 6px 12px; }
  .drawer .dtitle { padding: 4px 16px 8px 14px; }
  .pop { top: 56px; right: 8px; left: 8px; width: auto; max-height: calc(100dvh - 140px); }
  .toasts { left: 8px; right: 8px; bottom: calc(72px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }
  .focus .clock { font-size: 72px; }
  .focus .t { font-size: 20px; padding: 0 16px; }
  .create-menu.sheet { position: fixed; left: 0; right: 0; top: auto; bottom: 0; border-radius: 16px 16px 0 0; padding: 8px 0 calc(16px + env(safe-area-inset-bottom)); z-index: 60; }
  .create-menu.sheet button { padding: 14px 20px; }
}
@media (hover: none) { .task .acts { opacity: 1; } .ptree .sec-h .iconbtn { opacity: 1; } }
body.local .kbd-card { display: none; }
