/* ---------- Thème (modifiez ces variables pour votre charte) ---------- */
:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F4F4F5;        /* survols, fonds secondaires */
  --surface-3: #E9E9EC;        /* survol appuyé */
  --ink: #0A0A0A;              /* texte */
  --muted: #6B6B72;
  --line: #E4E4E7;
  --accent: #0D0CA2;           /* couleur primaire */
  --accent-hover: #0A0983;
  --accent-soft: rgba(13, 12, 162, .12);
  --on-accent: #FFFFFF;
  --user-bubble: #F4F4F5;
  --danger: #C62828;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --radius: 22px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Lora", "Iowan Old Style", Georgia, serif;
  --glitter: url("glitter.jpg");   /* paillettes bleues de la marque */
  color-scheme: light;
}
/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.app { height: 100dvh; display: flex; flex-direction: column; position: relative; z-index: 1; }

/* ---------- Barre du haut ---------- */
.topbar {
  flex: 0 0 auto; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px; position: relative; z-index: 2;
}
.brand { justify-self: center; display: flex; align-items: center; min-width: 0; }
.brand img { height: 64px; max-width: 72vw; object-fit: contain; width: auto; display: block; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--muted); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:focus-visible, .send-btn:focus-visible, .voice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.banner {
  margin: 0 16px 8px; padding: 10px 14px; border-radius: 12px; font-size: 14px;
  background: var(--accent-soft); color: var(--ink); text-align: center;
}

/* ---------- Zone principale ---------- */
.main { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.app.is-empty .main { flex: 0 0 auto; margin-top: auto; overflow: visible; }
.app.is-empty .composer-wrap { margin-bottom: auto; }
.app:not(.is-empty) .welcome { display: none; }

.welcome { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 16px 28px; }
.welcome-title { font: 600 clamp(28px, 5.4vw, 40px)/1.15 var(--serif); margin: 18px 0 8px; letter-spacing: -.01em; }
.welcome-sub { margin: 0; color: var(--muted); font-size: 15px; }

/* Avatar central */
.stage { display: flex; flex-direction: column; align-items: center; padding: 8px 0 4px; }
.app:not(.is-empty) .stage {
  position: sticky; top: 0; z-index: 1; padding: 6px 0 20px;
  background: linear-gradient(rgba(255,255,255,.96) 72%, rgba(255,255,255,0));
}
.avatar { position: relative; border-radius: 50%; flex: 0 0 auto; }
.avatar img { position: relative; z-index: 1; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: var(--surface-2); }
/* Cadre pailleté */
.avatar-xl {
  width: 144px; height: 144px; padding: 5px; transition: width .35s ease, height .35s ease;
  background: var(--glitter) 0 0 / 96px; box-shadow: 0 6px 24px rgba(13,12,162,.22);
}
.app:not(.is-empty) .avatar-xl { width: 84px; height: 84px; padding: 4px; }
.avatar-xl.is-speaking { animation: shimmer 3s linear infinite; }
@keyframes shimmer { to { background-position: 96px 96px; } }

/* Anneau tournant (arc en couleur primaire) */
.avatar-xl::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%; z-index: 0;
  background: conic-gradient(from 0deg, transparent 0 8%, var(--accent) 40%, transparent 60%, var(--accent) 90%, transparent 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  opacity: 0; transition: opacity .3s;
}
/* Ondes qui se propagent quand il parle */
.avatar-xl::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: 0;
  border: 2px solid var(--accent); opacity: 0;
}
.avatar-xl.is-thinking::before { opacity: .55; animation: spin 1.1s linear infinite; }
.avatar-xl.is-speaking::before { opacity: 1; animation: spin 2.6s linear infinite; }
.avatar-xl.is-speaking::after { animation: wave 1.5s cubic-bezier(.2,.6,.4,1) infinite; }
.avatar-xl.is-speaking img { animation: breathe 1.5s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wave { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(1.38); opacity: 0; } }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.025); } }

/* ---------- Fil de discussion ---------- */
.thread { max-width: 760px; margin: 0 auto; padding: 0 16px 24px; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 10px; align-items: flex-end; animation: in .25s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
.msg-user { justify-content: flex-end; }
.bubble {
  max-width: min(80%, 560px); background: var(--user-bubble); padding: 10px 16px; border-radius: 20px 20px 6px 20px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble .dictated { display: inline-flex; vertical-align: -3px; margin-right: 6px; color: var(--muted); }
.bubble .dictated svg { width: 16px; height: 16px; }

.msg-assistant { align-items: center; }
.voice {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  min-width: 0; width: min(100%, 320px); text-align: left;
}
.voice-btn {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); transition: background .15s;
}
.voice-btn { background: var(--glitter) center / 60px; box-shadow: inset 0 0 0 40px rgba(13,12,162,.3); }
.voice:hover .voice-btn { box-shadow: inset 0 0 0 40px rgba(13,12,162,.1); }
.voice.is-playing { border-color: rgba(13,12,162,.3); }
.voice:hover { border-color: var(--surface-3); }
.voice-btn svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.voice .i-pause, .voice.is-playing .i-play { display: none; }
.voice.is-playing .i-pause { display: block; }
.bars { flex: 1 1 auto; display: flex; align-items: center; gap: 3px; height: 28px; min-width: 0; overflow: hidden; }
.bars i { flex: 1 0 3px; max-width: 4px; border-radius: 2px; background: var(--line); height: var(--h); transition: background .2s; }
.bars i.on { background: var(--accent); }
.voice.is-playing .bars i { animation: bar 1s ease-in-out infinite; animation-delay: var(--d); }
@keyframes bar { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(.45); } }
.voice-time { flex: 0 0 auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

/* Réflexion en cours */
.voice.is-thinking .voice-btn { background: var(--surface-2); }
.voice.is-thinking:hover .voice-btn { background: var(--surface-2); }
.voice.is-thinking .voice-btn svg { display: none; }
.dots { display: none; gap: 4px; padding-left: 2px; }
.voice.is-thinking .dots { display: flex; }
.voice.is-thinking .bars, .voice.is-thinking .voice-time { display: none; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .15s; } .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%,80%,100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.voice.is-thinking .thinking-label { display: inline; }
.thinking-label { display: none; font-size: 14px; color: var(--muted); }

.msg-error { color: var(--danger); font-size: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.link-btn { border: 0; background: none; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }

/* ---------- Zone de saisie ---------- */
.composer-wrap { flex: 0 0 auto; padding: 8px 16px max(12px, env(safe-area-inset-bottom)); }
.composer {
  max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 12px 10px 18px;
  display: flex; align-items: flex-end; gap: 8px; transition: border-color .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink);
  font: inherit; line-height: 1.5; max-height: 200px; padding: 6px 0; min-height: 36px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-actions { display: flex; align-items: center; gap: 6px; }
.send-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 0; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; transition: opacity .15s, transform .1s;
}
.send-btn:not(:disabled) { background: var(--glitter) center / 64px; box-shadow: inset 0 0 0 40px rgba(13,12,162,.3); }
.send-btn:not(:disabled):hover { box-shadow: inset 0 0 0 40px rgba(13,12,162,.1); }
.send-btn:disabled { background: var(--surface-3); color: var(--muted); opacity: 1; cursor: default; }
.send-btn:not(:disabled):active { transform: scale(.94); }
.send-btn .i-stop { display: none; fill: currentColor; stroke: none; }
.send-btn.is-stop .i-send { display: none; }
.send-btn.is-stop .i-stop { display: block; }
.mic-btn.is-listening { color: #fff; background: var(--accent); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 var(--accent-soft); } 50% { box-shadow: 0 0 0 7px var(--accent-soft); } }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0 0; }

/* ---------- Tiroir des conversations ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 9; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw); background: var(--surface); border-right: 1px solid var(--line);
  z-index: 10; transform: translateX(-102%); transition: transform .25s ease; display: flex; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 10px 12px;
}
.drawer.is-open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 0 10px; }
.drawer-title { display: flex; align-items: center; gap: 8px; font: 600 19px/1.2 var(--serif); }
.drawer-title img { width: 22px; height: 22px; }
.drawer-new {
  margin: 10px 0; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); text-align: left; transition: background .15s;
}
.drawer-new:hover { background: var(--surface-2); }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv-item { display: flex; align-items: center; border-radius: 10px; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.is-current { background: var(--surface-3); }
.conv-open { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 10px 12px; }
.conv-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.conv-date { display: block; font-size: 12px; color: var(--muted); }
.conv-del { opacity: 0; width: 34px; height: 34px; }
.conv-item:hover .conv-del, .conv-item.is-current .conv-del, .conv-del:focus-visible { opacity: 1; }
@media (hover: none) { .conv-del { opacity: 1; } }
.drawer-empty { color: var(--muted); font-size: 14px; padding: 8px 12px; }

/* ---------- Fenêtre code d'accès ---------- */
.modal { border: 0; border-radius: 20px; padding: 24px; width: min(380px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(0,0,0,.35); }
.modal h2 { margin: 0 0 6px; font: 600 22px/1.2 var(--serif); letter-spacing: -.01em; }
.modal p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.modal input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; margin-bottom: 12px; }
.modal .modal-error { color: var(--danger); margin-top: -4px; }
.primary-btn { width: 100%; padding: 12px; border-radius: 12px; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 600; transition: background .15s; }
.primary-btn { background: var(--glitter) center / 80px; box-shadow: inset 0 0 0 80px rgba(13,12,162,.3); }
.primary-btn:hover { box-shadow: inset 0 0 0 80px rgba(13,12,162,.12); }
.modal-star { width: 40px; height: 40px; display: block; margin-bottom: 12px; }
.modal input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

@media (max-width: 520px) {
  .brand img { height: 42px; }
  .app:not(.is-empty) .avatar-xl { width: 68px; height: 68px; }
  .bubble { max-width: 85%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================= Univers Clo-Clo ================= */

/* Projecteurs (discrets au repos, allumés quand il chante) */
.spotlights { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.beam {
  position: absolute; top: -12vh; width: 34vw; min-width: 220px; height: 115vh; transform-origin: 50% 0;
  background: linear-gradient(to bottom, rgba(13,12,162,.09), rgba(13,12,162,0) 78%);
  clip-path: polygon(46% 0, 54% 0, 100% 100%, 0 100%); filter: blur(10px);
  opacity: .35; transition: opacity .6s ease;
}
.beam-l { left: 4vw; transform: rotate(-24deg); }
.beam-r { right: 4vw; transform: rotate(24deg); }
body.is-live .beam { opacity: 1; }
body.is-live .beam-l { animation: sweep-l 5s ease-in-out infinite; }
body.is-live .beam-r { animation: sweep-r 5s ease-in-out infinite; }
@keyframes sweep-l { 0%,100% { transform: rotate(-24deg); } 50% { transform: rotate(-14deg); } }
@keyframes sweep-r { 0%,100% { transform: rotate(24deg); } 50% { transform: rotate(14deg); } }

/* Reflets de boule à facettes */
.disco {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0; transition: opacity .8s ease;
  background-image:
    radial-gradient(circle, rgba(13,12,162,.16) 0 2.5px, transparent 3.5px),
    radial-gradient(circle, rgba(13,12,162,.09) 0 1.8px, transparent 2.8px),
    radial-gradient(circle, rgba(120,120,140,.14) 0 1.5px, transparent 2.5px);
  background-size: 150px 120px, 95px 140px, 70px 85px;
  background-position: 0 0, 40px 60px, 20px 10px;
}
body.is-live .disco { opacity: 1; animation: facets 16s linear infinite; }
@keyframes facets { to { background-position: 300px 120px, -150px 200px, 140px -85px; } }

/* Podium, étoiles et Clodettes */
.podium { position: relative; display: flex; flex-direction: column; align-items: center; }
.podium::after {
  content: ""; position: absolute; left: 50%; top: calc(100% - 26px); width: 220px; height: 34px; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(13,12,162,.14), rgba(13,12,162,0)); z-index: -1;
}
.app:not(.is-empty) .podium::after { width: 140px; top: calc(100% - 20px); }
.sparkle { position: absolute; z-index: 2; pointer-events: none; animation: twinkle 3.2s ease-in-out infinite; }
.sparkle.s1 { width: 30px; left: -30px; top: 4px; }
.sparkle.s2 { width: 18px; right: -22px; top: 22px; animation-delay: -1.1s; }
.sparkle.s3 { width: 22px; right: -34px; top: 96px; animation-delay: -2.2s; }
.app:not(.is-empty) .sparkle.s1 { width: 18px; left: -18px; top: 0; }
.app:not(.is-empty) .sparkle.s2 { width: 12px; right: -14px; top: 8px; }
.app:not(.is-empty) .sparkle.s3 { display: none; }
@keyframes twinkle { 0%,100% { transform: scale(.85) rotate(0deg); opacity: .75; } 50% { transform: scale(1.1) rotate(25deg); opacity: 1; } }
body.is-live .sparkle { animation-duration: 1.2s; }

.clodettes { display: flex; gap: 10px; margin-top: 12px; height: 20px; align-items: flex-end; }
.clodettes i { width: 16px; height: 16px; background: url("star.png") center / contain no-repeat; opacity: .45; transition: opacity .3s; }
.app:not(.is-empty) .clodettes { margin-top: 8px; gap: 8px; height: 14px; }
.app:not(.is-empty) .clodettes i { width: 12px; height: 12px; }
body.is-rehearsing .clodettes i { opacity: .8; animation: sway 1s ease-in-out infinite; }
body.is-rehearsing .clodettes i:nth-child(2) { animation-delay: .15s; }
body.is-rehearsing .clodettes i:nth-child(3) { animation-delay: .3s; }
body.is-live .clodettes i { opacity: 1; animation: kick .6s ease-in-out infinite alternate; }
body.is-live .clodettes i:nth-child(2) { animation-delay: .2s; }
body.is-live .clodettes i:nth-child(3) { animation-delay: .4s; }
@keyframes sway { 0%,100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
@keyframes kick { from { transform: translateY(0) rotate(-18deg) scale(.95); } to { transform: translateY(-8px) rotate(18deg) scale(1.1); } }

.stage-status {
  margin: 8px 0 0; min-height: 16px; font-size: 11px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent);
}
.stage-status:empty { display: none; }

/* Texte pailleté */
.glitter-text {
  background: var(--glitter) 0 0 / 110px; -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent; animation: shimmer-text 8s linear infinite;
}
@keyframes shimmer-text { to { background-position: 110px 55px; } }

/* Bandeau "Au programme ce soir" */
.marquee {
  width: min(100%, 600px); overflow: hidden; margin: 20px auto 0;
  -webkit-mask: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
          mask: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.marquee-track { display: inline-flex; align-items: center; gap: 14px; white-space: nowrap; animation: marquee 38s linear infinite; }
.marquee-track span { font: italic 500 15px/1.4 var(--serif); color: var(--ink); }
.marquee-track span:nth-of-type(8n+1) { font: 600 11px/1.4 var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.marquee-track b { color: var(--accent); font-size: 11px; font-weight: 400; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* Suggestions façon titres de chansons */
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: min(100%, 620px); margin: 22px auto 0; }
.chip {
  text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 16px;
  padding: 11px 14px; font-size: 14px; color: var(--ink); transition: border-color .15s, background .15s, transform .15s;
}
.chip em { display: block; font: italic 500 13px/1.3 var(--serif); color: var(--accent); margin-bottom: 2px; }
.chip:hover { background: var(--surface-2); border-color: rgba(13,12,162,.25); transform: translateY(-1px); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 520px) {
  .avatar-xl { width: 118px; height: 118px; }
  .chip { padding: 10px 12px; font-size: 13px; }
  .welcome-sub { font-size: 14px; }
  .beam { opacity: .25; }
}
@media (max-height: 760px) { .chips { display: none; } }
