:root {
  --bg: #0e0f11;
  --surface: #17191c;
  --surface-2: #1f2226;
  --line: #2a2e33;
  --text: #eceae4;
  --muted: #9a9890;
  --gold: #c9a35b;
  --gold-soft: #c9a35b22;
  --red: #d9695f;
  --green: #6fb38a;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  min-height: 100dvh;
}
#app { max-width: 720px; margin: 0 auto; padding: calc(var(--safe-t) + 18px) 16px calc(var(--safe-b) + 96px); }
h1 { font-size: 26px; letter-spacing: .02em; margin: 4px 0 2px; font-weight: 650; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 26px 0 10px; font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 8px; font-size: 14px; }
.brand { font-size: 12px; letter-spacing: .35em; color: var(--gold); font-weight: 700; }
a { color: var(--gold); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card + .card { margin-top: 10px; }
.next { border-color: var(--gold); background: linear-gradient(180deg, var(--gold-soft), transparent 70%), var(--surface); }
.next .label { color: var(--gold); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
.next .title { font-size: 20px; font-weight: 600; margin: 6px 0 4px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #17140c; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.small { padding: 8px 10px; min-height: 36px; font-size: 14px; }
.btn[disabled] { opacity: .5; }
.big-action { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; }
.big-action small { color: var(--muted); font-weight: 500; font-size: 12px; }
.btn.primary small { color: #3b3220; }

.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.task.today { border-left: 3px solid var(--gold); }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); background: none; flex: none; cursor: pointer; margin-top: 1px; }
.check.done { background: var(--green); border-color: var(--green); }
.task .t { font-weight: 560; overflow-wrap: anywhere; }
.task.isdone .t { text-decoration: line-through; color: var(--muted); }
.meta { color: var(--muted); font-size: 13px; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.pill.p1 { color: var(--red); border-color: #d9695f55; }
.pill.gold { color: var(--gold); border-color: #c9a35b66; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; border: 1px dashed var(--line); border-radius: 12px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin: 10px 0; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 8px 10px; border-radius: 9px; font: inherit; font-size: 14px; white-space: nowrap; cursor: pointer; }
.seg button.on { background: var(--surface-2); color: var(--text); }

input, textarea, select {
  width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; font: inherit; font-size: 16px;
}
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.note { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-meta { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* Agents */
.chat { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.msg { padding: 10px 14px; border-radius: 14px; max-width: 88%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--gold); color: #17140c; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.pending { color: var(--muted); font-style: italic; }
.composer { position: sticky; bottom: calc(var(--safe-b) + 76px); display: flex; gap: 8px; margin-top: 12px; background: var(--bg); padding-top: 8px; }
.composer textarea { min-height: 46px; max-height: 140px; }
.notice { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 8px; }

/* Focus */
.focus { text-align: center; padding-top: 6vh; }
.timer { font-size: clamp(64px, 22vw, 120px); font-variant-numeric: tabular-nums; font-weight: 300; letter-spacing: .02em; margin: 18px 0; }
.ring { color: var(--gold); }
.presets { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  align-items: center; background: #0e0f11f2; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(var(--safe-b) + 6px); z-index: 10;
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 11px; padding: 6px 0; }
.tabbar a .ico { font-size: 18px; }
.tabbar a.on { color: var(--gold); }
.capture { justify-self: center; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--gold); color: #17140c; font-size: 30px; font-weight: 500; margin-top: -22px; box-shadow: 0 6px 20px #0008; cursor: pointer; }

/* Bottom sheet */
.sheet { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 18px 18px 0 0; width: 100%; max-width: 720px; margin: auto auto 0; padding: 18px 16px calc(var(--safe-b) + 18px); }
.sheet::backdrop { background: #000a; }
.sheet h3 { margin: 0 0 6px; }
.sheet .row.end { justify-content: flex-end; margin-top: 16px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 92px); background: var(--surface-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 30; max-width: 90vw; }

/* Auth */
.auth { max-width: 380px; margin: 12vh auto 0; }
.auth .brand { display: block; margin-bottom: 8px; }
.err { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 1em; }
.spacer { height: 10px; }

[hidden] { display: none !important; }

/* v3 — agenda, modules, réglages */
.seg a, .seg label { flex: 1; text-align: center; color: var(--muted); padding: 8px 10px; border-radius: 9px; font-size: 14px; white-space: nowrap; text-decoration: none; cursor: pointer; }
.seg a.on, .seg label:has(input:checked) { background: var(--surface-2); color: var(--text); }
.seg label input { display: none; }
.actions.four { grid-template-columns: repeat(4, 1fr); }
.big-action { font-size: 20px; }
.big-action span { font-size: 12px; font-weight: 600; color: var(--muted); }
.event { display: flex; gap: 12px; align-items: center; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid #6f8fb3; border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.event .when { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 46px; color: #a9c1dc; font-size: 14px; }
.event .when small { color: var(--muted); font-weight: 400; }
.event .t { font-weight: 560; }
.nav { margin: 6px 0 4px; }
.center { text-align: center; text-transform: capitalize; }
.center-row { justify-content: center; margin-top: 10px; }
.empty.small { padding: 10px; font-size: 14px; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.month span { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0; }
.day { position: relative; aspect-ratio: 1; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; font: inherit; cursor: pointer; }
.day.out { opacity: .4; }
.day.now { border-color: var(--gold); color: var(--gold); font-weight: 700; }
.day i { position: absolute; right: 4px; bottom: 3px; font-style: normal; font-size: 10px; background: var(--gold); color: #17140c; border-radius: 99px; padding: 0 5px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.tile span { color: var(--muted); font-size: 13px; }
.tile.off { opacity: .45; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; margin: 10px 0 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); }
.notice { display: block; text-decoration: none; }
.notice.warn { color: #e8c48a; border-color: #c9a35b55; }
.col { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.col .btn { text-align: left; }
.check.small { width: 20px; height: 20px; }
.sub-row, .sub { margin: 4px 0; }
.row.sub { padding: 4px 0; }
.muted { color: var(--muted); }
.card.muted { opacity: .6; }
.strike { text-decoration: line-through; }
.timer.paused { opacity: .45; }
.pick { padding: 8px 0; border-bottom: 1px solid var(--line); }
.tabbar a .ico { font-size: 17px; }
