/* Keri — styles */
:root {
  --bg: #f6f2fb;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1ebf8;
  --text: #24182f;
  --muted: #6e6280;
  --border: #e3d9ef;
  --accent: #7b4bb7;
  --accent-2: #a77ee0;
  --accent-text: #ffffff;
  --danger: #c2415b;
  --good: #2f9e6e;
  --eye-white: #eef3ff;
  --eye-line: #6a46a3;
  --iris: #3a1352;
  --iris-light: #6c3a8f;
  --pupil: #1d0a2b;
  --brow: #141018;
  --shadow: 0 10px 30px rgba(74, 38, 120, 0.12);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15111c; --bg-2: #1c1626; --surface: #211a2c; --surface-2: #2b2238; --text: #f1eaf8; --muted: #a89bb8;
    --border: #372c47; --accent: #a77ee0; --accent-2: #c7a6f2; --accent-text: #1a1022; --eye-white: #f2f5ff;
    --eye-line: #b292e6; --brow: #f1eaf8; --shadow: 0 10px 30px rgba(0, 0, 0, 0.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15111c; --bg-2: #1c1626; --surface: #211a2c; --surface-2: #2b2238; --text: #f1eaf8; --muted: #a89bb8;
  --border: #372c47; --accent: #a77ee0; --accent-2: #c7a6f2; --accent-text: #1a1022; --eye-white: #f2f5ff;
  --eye-line: #b292e6; --brow: #f1eaf8; --shadow: 0 10px 30px rgba(0, 0, 0, 0.35); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 30% -10%, var(--bg-2), var(--bg));
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; max-width: 1280px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; letter-spacing: 0.02em; }
.brand img { border-radius: 8px; }
.status { font-size: 0.8rem; font-weight: 500; color: var(--muted); background: var(--surface-2); padding: 2px 10px; border-radius: 99px; }
.status.live { color: var(--accent-text); background: var(--accent); }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); display: grid; place-items: center;
  background: var(--surface); cursor: pointer; font-size: 1.15rem;
}
.icon-btn:hover { border-color: var(--accent-2); }

.layout {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 20px;
  max-width: 1280px; margin: 0 auto; padding: 0 20px 24px;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 16px 24px; }
  .topbar { padding: 10px 16px; }
}

/* --- Scène --- */
.stage {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0;
}
.bubble {
  position: relative; max-width: 560px; width: 100%; min-height: 64px;
  background: var(--surface-2); border-radius: 18px; padding: 12px 18px; text-align: center;
  font-size: 1.05rem; transition: transform 0.2s;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%);
  border: 10px solid transparent; border-top-color: var(--surface-2); border-bottom: 0;
}
.bubble p { margin: 0; }
.bubble.pop { animation: pop 0.25s ease-out; }
@keyframes pop { from { transform: scale(0.96); } to { transform: scale(1); } }

.eyes-wrap { position: relative; width: 100%; max-width: 560px; }
#eyes { width: 100%; height: auto; display: block; cursor: pointer; touch-action: manipulation; user-select: none; }
#eyes .eye-white { fill: var(--eye-white); }
#eyes .eye-line { fill: none; stroke: var(--eye-line); stroke-width: 3; }
#eyes .lid-line { fill: none; stroke: var(--eye-line); stroke-width: 3.5; stroke-linecap: round; }
#eyes .lid-line.thin { stroke-width: 2.5; }
#eyes .pupil { fill: var(--pupil); }
#eyes .highlight { fill: #fff; }
#eyes .brow { fill: var(--brow); }
#eyes .zzz { fill: var(--muted); font: 700 28px system-ui, sans-serif; transition: opacity 0.4s; }

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.confetti i {
  position: absolute; left: 50%; top: 45%; width: 9px; height: 14px; border-radius: 2px;
  animation: confetti 1.3s cubic-bezier(.2,.7,.4,1) forwards;
}
@keyframes confetti {
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

.interim { min-height: 1.4em; margin: 0; color: var(--muted); font-style: italic; text-align: center; }

.controls { display: flex; align-items: center; gap: 18px; }
.mic {
  width: 72px; height: 72px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 18px rgba(123, 75, 183, 0.35);
  display: grid; place-items: center; transition: transform 0.15s;
}
.mic:hover { transform: scale(1.05); }
.mic.on { animation: pulse 1.3s infinite; background: var(--danger); }
.mic:disabled { opacity: 0.45; cursor: not-allowed; animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(194, 65, 91, 0.5); }
  100% { box-shadow: 0 0 0 22px rgba(194, 65, 91, 0); }
}
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

.chat-form, .row-form { display: flex; gap: 8px; width: 100%; max-width: 560px; }
.chat-form input, .row-form input, .settings-form input[type="text"], .settings-form select {
  flex: 1; min-width: 0; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-2);
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.btn {
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: var(--accent-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 0.88rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 560px; }
.chips button {
  border: 1px solid var(--border); background: var(--bg-2); border-radius: 99px; padding: 6px 12px;
  cursor: pointer; font-size: 0.9rem;
}
.chips button:hover { border-color: var(--accent-2); }

/* --- Panneau --- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; min-width: 0; display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100dvh - 90px); position: sticky; top: 12px;
}
@media (max-width: 900px) { .panel { max-height: none; position: static; } }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  flex: 1 0 auto; border: none; background: transparent; padding: 8px 12px; border-radius: 10px; cursor: pointer;
  color: var(--muted); font-weight: 600;
}
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.count { font-size: 0.75rem; background: var(--accent); color: var(--accent-text); border-radius: 99px; padding: 0 7px; margin-left: 2px; }
.count:empty { display: none; }
.tab-panel { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.empty { color: var(--muted); text-align: center; margin: 12px 0; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 4px 0; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--border);
}
.list li.done .text { text-decoration: line-through; color: var(--muted); }
.list li.urgent { border-color: var(--accent-2); }
.list .text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .meta { display: block; font-size: 0.8rem; color: var(--muted); }
.list .meta.late { color: var(--danger); }
.list input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; cursor: pointer; }
.mini { border: none; background: transparent; cursor: pointer; font-size: 1.05rem; padding: 4px; border-radius: 8px; color: var(--muted); }
.mini:hover { background: var(--surface-2); color: var(--text); }
.mini.star.on { color: #e0a100; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; background: var(--accent); }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 8px 0; border-left: 2px solid var(--border); margin-left: 6px; padding-left: 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent-2); }
.timeline li.now::before { background: var(--accent); }
.timeline li.break { color: var(--muted); }
.timeline li.event .label::after { content: " · agenda"; color: var(--muted); font-size: 0.8rem; }
.timeline time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.9rem; padding-top: 2px; }

.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.log li { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: var(--surface-2); overflow-wrap: anywhere; }
.log li.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); }
.log time { display: block; font-size: 0.72rem; opacity: 0.7; }

/* --- Réglages --- */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(20, 10, 30, 0.45); }
.settings-form { display: flex; flex-direction: column; gap: 14px; padding: 20px; max-height: 85dvh; overflow-y: auto; }
.settings-form h2 { margin: 0; }
.settings-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.92rem; }
.settings-form label.check { flex-direction: row; align-items: center; font-weight: 500; }
.settings-form fieldset { border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; margin: 0; }
.settings-form legend { font-weight: 700; padding: 0 6px; }
.settings-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-form input[type="range"] { accent-color: var(--accent); }
.settings-form code { font-size: 0.85rem; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  .mic.on, .bubble.pop, .confetti i { animation: none; }
}

/* --- Mode compagnon : uniquement les yeux, plein écran (paysage tactile ou bouton) --- */
body.immersive { overflow: hidden; }
body.immersive .topbar,
body.immersive .panel,
body.immersive .bubble,
body.immersive .interim,
body.immersive .controls,
body.immersive .chat-form,
body.immersive .chips { display: none; }
body.immersive .layout { display: block; padding: 0; max-width: none; }
body.immersive .stage {
  position: fixed; inset: 0; z-index: 10; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border: 0; border-radius: 0; box-shadow: none; background: var(--bg); justify-content: center;
}
body.immersive .eyes-wrap { max-width: none; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
body.immersive #eyes { width: 100%; height: 100%; max-height: 100dvh; }
.interim.dim { opacity: 0.6; }
.mic-allow { display: flex; justify-content: center; }
body.immersive .mic-allow { display: none; }
.diag {
  margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow-y: auto;
}
.link-btn { border: none; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 0.85rem; padding: 2px; }
body.immersive .link-btn { display: none; }
