:root {
  --bg: #07090D;
  --panel: #0E131A;
  --panel-2: #131A23;
  --line: #1C2530;
  --text: #E6EDF3;
  --muted: #8F9CAB;
  --accent: #4FD1E8;
  --accent-ink: #062027;
  --warn: #F2A93B;
  --warn-bg: #15110A;
  --warn-line: #3A3220;
  --crit: #FF7A6B;
  --ok: #6FD39A;
  --sans: 'Sora', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 1440px; margin: 0 auto; padding: calc(16px + var(--safe-top)) 16px calc(96px + var(--safe-bottom)); }
.boot { min-height: 80dvh; display: flex; align-items: center; justify-content: center; }

/* ---------- Orbe ---------- */
.orb { display: block; }
.orb .ring-outer { fill: none; stroke: var(--line); stroke-width: 1; }
.orb .ring-dash { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 10; opacity: .6; transform-origin: 120px 120px; animation: spin 18s linear infinite; }
.orb .ring-mid { fill: none; stroke: var(--accent); stroke-width: 1; opacity: .35; }
.orb .core-halo { fill: var(--accent); opacity: .12; }
.orb .core-mid { fill: var(--accent); opacity: .28; }
.orb .core-dot { fill: var(--accent); }
.orb .core { transform-origin: 120px 120px; animation: pulse 3.2s ease-in-out infinite; }
.orb.thinking .core { animation-duration: .9s; }
.orb.thinking .ring-dash { animation-duration: 4s; }
.orb-small { width: 72px; height: 72px; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .6; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.03); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .orb .ring-dash, .orb .core, .orb-small { animation: none; } }

/* ---------- En-tête ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-family: var(--mono); font-size: 12px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; min-height: 44px; }
.top .brand { color: var(--accent); }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg { width: 20px; height: 20px; stroke: var(--muted); }

/* ---------- Mise en page ---------- */
.layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); margin-top: 8px; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 4px; }
.hero .orb { width: 168px; height: 168px; }
.greeting { margin: 0; font-size: 21px; font-weight: 300; line-height: 1.35; text-align: center; }
.greeting small { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; }

.label { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; display: flex; justify-content: space-between; gap: 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }

/* Priorités */
.prio { display: flex; gap: 12px; align-items: flex-start; }
.prio + .prio { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.prio .num { font-family: var(--mono); font-size: 13px; color: var(--accent); padding-top: 2px; min-width: 20px; }
.prio .body { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.prio .title { font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.prio .meta { font-size: 13px; color: var(--muted); line-height: 1.4; }
.prio .step { font-size: 13px; color: var(--text); line-height: 1.4; }
.prio .step::before { content: '5 min · '; font-family: var(--mono); color: var(--accent); }
.prio.done .title { text-decoration: line-through; color: var(--muted); }
.mini-btn { min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-size: 13px; white-space: nowrap; }
.mini-btn:hover { border-color: var(--accent); }

/* Charge */
.charge { border-color: var(--line); }
.charge.elevee { border-color: var(--warn); background: var(--warn-bg); }
.charge.critique { border-color: var(--crit); background: #1A0D0B; }
.charge .head { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.charge.elevee .head { color: var(--warn); }
.charge.critique .head { color: var(--crit); }
.charge p { margin: 8px 0 0; font-size: 14px; line-height: 1.5; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stat { background: rgba(255,255,255,.03); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-family: var(--mono); font-size: 20px; font-weight: 500; }
.stat span { font-size: 11px; color: var(--muted); }

/* Agenda */
.event { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.event:first-of-type { border-top: none; }
.event time { font-family: var(--mono); font-size: 13px; color: var(--muted); min-width: 52px; }
.event .t { font-size: 14px; line-height: 1.4; }
.event .l { font-size: 12px; color: var(--muted); }
.event.now time { color: var(--accent); }
.empty { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

/* Minuteur */
.timer { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-color: var(--accent); }
.timer .clock { font-family: var(--mono); font-size: 40px; font-weight: 500; color: var(--accent); }
.timer .what { font-size: 13px; color: var(--muted); }

/* Conversation */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--panel-2); }
.msg.assistant { align-self: flex-start; border: 1px solid var(--line); }
.msg.error { align-self: flex-start; border: 1px solid var(--warn); color: var(--warn); }
.msg.pending { color: var(--muted); }

.composer { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + var(--safe-bottom)); background: linear-gradient(to top, var(--bg) 70%, rgba(7,9,13,0)); z-index: 5; }
.composer form { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 48px; max-height: 140px; resize: none; padding: 13px 16px; border-radius: 24px; border: 1px solid var(--line); background: var(--panel); font-size: 16px; line-height: 1.35; }
.composer textarea::placeholder { color: var(--muted); }
.send { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--accent); background: var(--panel); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.send svg { width: 22px; height: 22px; stroke: var(--accent); }
.send:disabled { opacity: .5; }

/* Formulaires */
.auth { max-width: 380px; margin: 0 auto; min-height: 88dvh; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.auth .orb { width: 140px; height: 140px; margin: 0 auto; }
.auth h1 { margin: 0; font-weight: 300; font-size: 24px; text-align: center; }
.auth p { margin: 0; color: var(--muted); text-align: center; font-size: 14px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.field input { min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 16px; }
.btn { min-height: 48px; border-radius: 12px; border: none; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px; padding: 0 18px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 400; }
.btn:disabled { opacity: .55; }
.note { font-size: 13px; color: var(--warn); text-align: center; min-height: 18px; }

/* Panneau réglages */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 10; display: flex; justify-content: flex-end; }
.sheet { width: min(440px, 100%); height: 100%; overflow-y: auto; background: var(--bg); border-left: 1px solid var(--line); padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 16px; }
.sheet h2 { margin: 0; font-size: 18px; font-weight: 600; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.row small { color: var(--muted); display: block; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); }

/* Grand écran : mode bureau en trois colonnes */
@media (min-width: 1024px) {
  .app { padding: 32px 40px 120px; }
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: start; }
  .hero .orb { width: 240px; height: 240px; }
  .composer { left: 33%; right: 33%; background: none; }
  .msg { font-size: 15px; }
}

/* Voix */
.orb-btn { background: none; border: none; padding: 0; border-radius: 50%; -webkit-tap-highlight-color: transparent; }
.orb.listening .core { animation-duration: .55s; }
.orb.listening .ring-dash { animation-duration: 3s; stroke: var(--warn); }
.orb.speaking .core { animation-duration: 1.3s; }
.hint { margin: 0; font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.chip:hover { border-color: var(--accent); }
.mic { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mic svg { width: 22px; height: 22px; stroke: var(--text); }
.mic.on { background: var(--warn); border-color: var(--warn); }
.mic.on svg { stroke: #15110A; }
