/* Agenda — skinned with the Karmahub charte ("La rigueur qui met à l'aise"), same tokens as the LMS
   Life Cockpit: Nuit by default, Clair via [data-theme="day"]. */
:root {
  --surface: #141a2b; --surface-raised: #1c2440; --surface-brand: #1858b8; --surface-deep: #23417a;
  --surface-tint: #243a66; --ink: #f0f0e0; --ink-muted: #a9b0c4; --on-brand: #f0f0e0;
  --brand: #7fa8ec; --brand-strong: #5f90e0;
  --corail: #f0646a; --ambre: #f0b038; --vert: #5cc59a;
  --line: #2e3858; --focus: #7fa8ec;
  --shadow-float: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-soft: inset 0 1px 0 rgba(255, 255, 255, .055), 0 2px 6px rgba(0, 0, 0, .3);
  --font: "Source Sans 3", "Source Sans Pro", "Segoe UI", system-ui, sans-serif;
  --font-display: "Outfit", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r-lg: 20px; --r-md: 12px; --r-sm: 6px;
  --hour: 52px;
  color-scheme: dark;
}
:root[data-theme="day"] {
  --surface: #f0f0e0; --surface-raised: #fafaf2; --surface-deep: #0e2f66;
  --surface-tint: #d6e2f5; --ink: #1c1f2a; --ink-muted: #5b6170;
  --brand: #1858b8; --brand-strong: #12479a;
  --corail: #b8232a; --ambre: #8a5a05; --vert: #1f6e53;
  --line: #d9d8c6; --focus: #1858b8;
  --shadow-float: 0 8px 24px rgba(14, 47, 102, .12);
  --shadow-soft: inset 0 1px 0 rgba(255, 255, 255, .85), 0 2px 6px rgba(14, 47, 102, .1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--surface); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .brand, .seg button, .eyebrow { font-family: var(--font-display); }
h1 { font-size: 1.35rem; margin: 0; font-weight: 600; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; font-weight: 600; }
.num, .time, input[type="time"], input[type="date"] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-muted); }
.eyebrow { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); margin: 0 0 .4rem; }

/* ---------- shell ---------- */
#app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: 100%; }
.top { grid-row: 1; display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; padding-top: max(.6rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--surface-raised); flex-wrap: wrap; }
.top h1 { flex: 1; min-width: 8rem; }
main { grid-row: 2; overflow: auto; padding: .8rem; min-height: 0; }
main.flush { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.tabs { grid-row: 3; display: flex; border-top: 1px solid var(--line); background: var(--surface-raised);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; background: none; border: 0; padding: .5rem .2rem .45rem; display: grid; justify-items: center; gap: .1rem;
  font-size: .72rem; color: var(--ink-muted); min-height: 52px; }
.tabs button[aria-current="page"] { color: var(--brand); }
.tabs svg, .icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand { display: none; }
@media (min-width: 900px) {
  #app { grid-template-columns: 208px 1fr; grid-template-rows: auto 1fr; }
  .tabs { grid-row: 1 / 3; grid-column: 1; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 1rem .6rem; gap: .2rem; }
  .tabs button { flex: none; grid-auto-flow: column; justify-content: start; gap: .7rem; font-size: .98rem; padding: .6rem .8rem; border-radius: var(--r-md); min-height: 44px; }
  .tabs button[aria-current="page"] { background: var(--surface-tint); color: var(--ink); }
  .brand { display: block; font-size: 1.3rem; font-weight: 700; padding: .2rem .8rem 1rem; letter-spacing: .01em; }
  .brand small { display: block; font: 400 .72rem var(--font); color: var(--ink-muted); letter-spacing: 0; }
  .top { grid-column: 2; padding: .8rem 1.2rem; }
  main { grid-column: 2; padding: 1.2rem; }
}

/* ---------- controls ---------- */
.btn { border: 1px solid var(--line); background: var(--surface-raised); border-radius: var(--r-md); padding: .5rem .9rem; min-height: 40px;
  box-shadow: var(--shadow-soft); }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--surface-brand); border-color: var(--surface-brand); color: var(--on-brand); font-weight: 600; }
.btn.danger { color: var(--corail); }
.btn.small { padding: .25rem .6rem; min-height: 32px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-tint); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.seg button { border: 0; background: none; padding: .4rem .7rem; min-height: 38px; font-size: .9rem; color: var(--ink-muted); }
.seg button[aria-pressed="true"] { background: var(--surface-tint); color: var(--ink); font-weight: 600; }
input[type="text"], input[type="search"], input[type="email"], input[type="tel"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: .5rem .6rem; min-height: 40px; }
textarea { resize: vertical; min-height: 5rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
label.field, div.field { display: grid; gap: .25rem; font-size: .85rem; color: var(--ink-muted); }
label.field > *, div.field > * { font-size: 1rem; color: var(--ink); }
div.field > span:first-child { font-size: .85rem; color: var(--ink-muted); }
label.check { display: flex; align-items: center; gap: .5rem; min-height: 40px; }
label.check input { width: 20px; height: 20px; accent-color: var(--surface-brand); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1; min-width: 8rem; }
.row > .fit { flex: none; min-width: 0; }
.stack { display: grid; gap: .8rem; }
.card { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem; box-shadow: var(--shadow-soft); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: .25rem .7rem; min-height: 34px; font-size: .92rem; }
button.chip[aria-pressed="true"] { background: var(--surface-tint); border-color: var(--brand); color: var(--ink); font-weight: 600; }
.chip .x { border: 0; background: none; padding: 0 0 0 .2rem; color: var(--ink-muted); font-size: 1.1rem; line-height: 1; }
.banner { display: flex; align-items: center; gap: .8rem; background: var(--surface-tint); border: 1px solid var(--brand);
  border-radius: var(--r-md); padding: .6rem .8rem; margin: .6rem .8rem 0; }
.banner span { flex: 1; }
.empty { color: var(--ink-muted); padding: 1.2rem .4rem; text-align: center; }
.fab { position: fixed; right: 1rem; bottom: calc(68px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--surface-brand); color: var(--on-brand); font-size: 1.9rem; line-height: 1; box-shadow: var(--shadow-float); z-index: 5; }
@media (min-width: 900px) { .fab { bottom: 1.5rem; right: 1.5rem; } }
#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink);
  color: var(--surface); padding: .6rem 1rem; border-radius: var(--r-md); box-shadow: var(--shadow-float); z-index: 50; max-width: 90vw; }
#toast.error { background: var(--corail); color: #141a2b; }

/* ---------- event rows / chips ---------- */
.ev { --c: var(--brand-strong); display: flex; gap: .7rem; align-items: baseline; width: 100%; text-align: left; border: 0;
  border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface-raised)); border-radius: var(--r-sm);
  padding: .5rem .7rem; }
.ev:hover { background: color-mix(in srgb, var(--c) 24%, var(--surface-raised)); }
.ev .time { font-size: .86rem; color: var(--ink-muted); min-width: 6.4rem; flex: none; }
.ev .what { min-width: 0; flex: 1; }
.ev .title { font-weight: 600; overflow-wrap: anywhere; }
.ev .sub { font-size: .88rem; color: var(--ink-muted); overflow-wrap: anywhere; }
.ev.cancelled .title { text-decoration: line-through; opacity: .65; }
.ev.tentative { border-left-style: dashed; }
.daylist { display: grid; gap: .4rem; }
.dayhead { display: flex; align-items: baseline; gap: .6rem; margin: 1rem 0 .4rem; }
.dayhead:first-child { margin-top: 0; }
.dayhead h2 { margin: 0; }
.dayhead.today h2 { color: var(--brand); }

/* ---------- month ---------- */
.month-wrap { display: grid; gap: 1rem; padding: .8rem; overflow: auto; flex: 1; align-content: start; grid-auto-rows: max-content; }
@media (min-width: 1100px) { .month-wrap { grid-template-columns: 1fr 340px; align-items: start; padding: 1.2rem; } }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.month .wd { text-align: center; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-muted); padding: .35rem 0;
  background: var(--surface-raised); border-bottom: 1px solid var(--line); }
.cell { border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); min-height: 58px;
  padding: .25rem; text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden; }
.cell:nth-child(7n) { border-right: 0; }
.cell.out { opacity: .45; }
.cell .d { font: 500 .85rem var(--font-mono); width: 1.7rem; height: 1.7rem; display: grid; place-items: center; border-radius: 50%; }
.cell.today .d { background: var(--surface-brand); color: var(--on-brand); }
.cell[aria-pressed="true"] { background: var(--surface-tint); }
.cell .mini { --c: var(--brand-strong); font-size: .74rem; line-height: 1.25; padding: 1px 4px; border-radius: 4px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; background: color-mix(in srgb, var(--c) 26%, var(--surface)); border-left: 3px solid var(--c); display: none; }
.cell .more { font-size: .72rem; color: var(--ink-muted); display: none; }
.cell .dots { display: flex; gap: 3px; flex-wrap: wrap; padding-left: .3rem; }
.cell .dot { --c: var(--brand-strong); width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
@media (min-width: 700px) {
  .cell { min-height: 104px; }
  .cell .mini, .cell .more { display: block; }
  .cell .dots { display: none; }
}

/* ---------- time grid (week / day) ---------- */
.tg { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.tg-head, .tg-allday { display: grid; grid-template-columns: 3.2rem repeat(var(--n), minmax(0, 1fr)); border-bottom: 1px solid var(--line);
  background: var(--surface-raised); }
.tg-head button { border: 0; background: none; padding: .35rem .1rem; display: grid; justify-items: center; font-size: .72rem; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: .06em; }
.tg-head button .d { font: 500 1rem var(--font-mono); color: var(--ink); width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; }
.tg-head button.today .d { background: var(--surface-brand); color: var(--on-brand); }
.tg-allday > div { padding: 2px; display: grid; gap: 2px; min-width: 0; border-left: 1px solid var(--line); align-content: start; }
.tg-allday > div:first-child { border-left: 0; font-size: .68rem; color: var(--ink-muted); padding: .3rem .2rem; text-align: right; }
.tg-body { overflow: auto; flex: 1; display: grid; grid-template-columns: 3.2rem repeat(var(--n), minmax(0, 1fr)); position: relative; }
.tg-hours div { height: var(--hour); font: .7rem var(--font-mono); color: var(--ink-muted); text-align: right; padding-right: .35rem; transform: translateY(-.5em); }
.tg-col { position: relative; height: calc(var(--hour) * 24); border-left: 1px solid var(--line);
  background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) - 1px), var(--line) calc(var(--hour) - 1px), var(--line) var(--hour)); }
.tg-col.today { background-color: color-mix(in srgb, var(--surface-tint) 35%, transparent); }
.tg-ev { --c: var(--brand-strong); position: absolute; border: 0; border-left: 3px solid var(--c); border-radius: 5px; padding: 1px 4px; text-align: left;
  background: color-mix(in srgb, var(--c) 30%, var(--surface-raised)); overflow: hidden; font-size: .78rem; line-height: 1.25; box-shadow: 0 0 0 1px var(--surface); }
.tg-ev b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.tg-ev.cancelled b { text-decoration: line-through; opacity: .65; }
.tg-ev.chip-ad { position: static; white-space: nowrap; text-overflow: ellipsis; width: 100%; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--corail); z-index: 2; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--corail); }

/* ---------- dialog ---------- */
dialog { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-raised); color: var(--ink); padding: 0;
  width: min(640px, 100vw); max-height: 100dvh; box-shadow: var(--shadow-float); }
dialog::backdrop { background: rgba(8, 12, 24, .6); }
dialog form, dialog .dlg { display: flex; flex-direction: column; max-height: min(100dvh, 880px); }
dialog header { display: flex; align-items: center; gap: .5rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
dialog header h2 { flex: 1; margin: 0; }
dialog .body { padding: 1rem; overflow: auto; display: grid; gap: .9rem; }
dialog footer { display: flex; gap: .5rem; padding: .8rem 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
dialog footer .spacer { flex: 1; }
@media (max-width: 640px) { dialog { width: 100vw; height: 100dvh; max-width: none; border-radius: 0; border: 0; margin: 0; }
  dialog form, dialog .dlg { height: 100dvh; max-height: none; } dialog .body { flex: 1; } }
fieldset { border: 1px solid var(--line); border-radius: var(--r-md); padding: .7rem .8rem .8rem; margin: 0; display: grid; gap: .7rem; min-width: 0; }
legend { font: 600 .8rem var(--font-display); color: var(--ink-muted); padding: 0 .4rem; letter-spacing: .04em; }

/* ---------- pages ---------- */
.page { max-width: 780px; margin: 0 auto; display: grid; gap: 1rem; }
.list { display: grid; gap: .4rem; }
.item { display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface-raised);
  border-radius: var(--r-md); padding: .6rem .8rem; min-height: 52px; }
button.item:hover { border-color: var(--brand); }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .s { font-size: .88rem; color: var(--ink-muted); overflow-wrap: anywhere; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-tint); display: grid; place-items: center; font: 600 .9rem var(--font-display); flex: none; }
.badge { font-size: .74rem; border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem; color: var(--ink-muted); white-space: nowrap; }
.badge.ok { color: var(--vert); border-color: var(--vert); }
.save-state { font-size: .82rem; color: var(--ink-muted); min-height: 1.2em; }
.save-state.err { color: var(--corail); }
.swatch { width: 44px; min-width: 44px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); flex: none; }
.login { height: 100%; display: grid; place-items: center; padding: 1rem; grid-column: 1 / -1; grid-row: 1 / -1; }
.login form { width: min(360px, 100%); display: grid; gap: .9rem; }
.login h1 { font-size: 1.8rem; }
pre.diff { white-space: pre-wrap; font: .82rem var(--font-mono); margin: .3rem 0 0; color: var(--ink-muted); }
@media (prefers-reduced-motion: no-preference) { .btn, .ev, .cell, .item { transition: background-color .12s, border-color .12s; } }
@media (max-width: 700px) { .tg:not(.single) .tg-ev { padding: 1px 2px; font-size: .68rem; }
  .tg:not(.single) .tg-ev b { overflow-wrap: normal; white-space: nowrap; }
  .tg:not(.single) .tg-ev .time, .tg:not(.single) .tg-ev div { display: none; } }
