/* Interface claire et sobre : rail d'icônes, en-tête, contenu centré. */
:root {
  color-scheme: light;
  --frame: #ececec;
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f4f4f5;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;
  --border: #e9e9ec;
  --border-strong: #dcdce0;
  --accent: #18181b;
  --accent-hover: #000;
  --accent-soft: #f4f4f5;
  --ring: rgba(24, 24, 27, .08);
  --violet: #7c5cff;
  --blue: #3b82f6;
  --teal: #14b8a6;
  --ok: #16a34a;
  --ok-soft: #ecfdf3;
  --ko: #dc2626;
  --ko-soft: #fef2f2;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px -6px rgba(0, 0, 0, .08);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .04), 0 24px 48px -16px rgba(0, 0, 0, .16);
  --content: 600px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: clip; overscroll-behavior-y: none; }
img, svg, video { max-width: 100%; }
body {
  background: var(--frame); color: var(--text);
  font: 14.5px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.i { width: 17px; height: 17px; flex-shrink: 0; display: block; }

/* Cadre : rail à gauche, carte blanche à droite */
.app { display: flex; height: var(--app-h, 100dvh); padding: 10px 10px 10px 0; }

.rail {
  width: 64px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 6px;
}
.rail-logo { width: 34px; display: block; margin: 2px 0 4px; }
.rail-sep { width: 28px; height: 1px; background: #dcdcdf; margin: 6px 0; }
.rail-fill { flex: 1; }
.rail-btn, .rail .modes button {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid transparent;
  background: none; color: #52525b; cursor: pointer; padding: 0; position: relative;
}
.rail-btn:hover, .rail .modes button:hover { background: rgba(0, 0, 0, .05); color: var(--text); }
.rail .modes { display: flex; flex-direction: column; gap: 4px; }
.rail .modes button span { display: none; }
.rail .modes button.active { background: #fff; border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.rail-avatar { padding: 0; border: 0; background: none; cursor: pointer; margin-top: 6px; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, #e8e3ff, #d9e7ff); color: #4c3fd1; font-weight: 600; font-size: 12.5px;
}
.avatar .i { width: 15px; height: 15px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rail-avatar .avatar { width: 32px; height: 32px; box-shadow: 0 0 0 2px #fff, var(--shadow); }

.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; overflow: hidden;
  background: var(--bg); border-radius: 16px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .04), var(--shadow);
}
.main > :not(.messages) { flex-shrink: 0; }

/* En-tête */
.topbar { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--border); background: #fff; }
.top-title { display: flex; align-items: center; gap: 9px; font-weight: 500; font-size: 15px; margin-right: auto; }
.top-btn { padding: 6px 11px; font-size: 13.5px; font-weight: 500; gap: 7px; border-radius: 9px; }
.top-btn .i { width: 16px; height: 16px; color: var(--muted); }
.profile-pill .avatar { width: 22px; height: 22px; font-size: 11px; }
.profile-pill #pillSub { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Boutons */
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 500; font-size: 14px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: #fff; border: 1px solid var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--surface); }
.icon-btn {
  background: none; border: 0; cursor: pointer; padding: 7px; border-radius: 8px;
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link-btn { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.link-btn .i { width: 13px; height: 13px; }
.link-btn:hover { color: var(--text); }

/* Historique : panneau qui glisse depuis la gauche */
.sidebar {
  position: fixed; z-index: 20; top: 10px; bottom: 10px; left: 74px; width: 300px;
  display: flex; flex-direction: column; gap: 8px; padding: 14px;
  background: #fff; border-radius: 16px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .05), var(--shadow-lg);
  transform: translateX(-16px); opacity: 0; visibility: hidden; pointer-events: none; transition: transform .2s, opacity .2s, visibility 0s .2s;
}
.sidebar.open { transform: none; opacity: 1; visibility: visible; pointer-events: auto; transition: transform .2s, opacity .2s, visibility 0s; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 15px; }
.menu-btn, .top-new, .drawer-title-mob, .scrim { display: none; }
.drawer-modes:empty { display: none; }
.sidebar .btn-primary, .sidebar .btn-ghost { width: 100%; justify-content: flex-start; }
.section-title { font-size: 11.5px; font-weight: 500; color: var(--faint); margin: 12px 8px 4px; }
.lists { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.conv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.conv-list li { display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.conv-list li:hover { background: var(--surface-2); }
.conv-list li.active { background: var(--surface-2); color: var(--text); font-weight: 500; }
.conv-list .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-list .meta { font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.conv-list .del { opacity: 0; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 6px; display: grid; }
.conv-list .del .i { width: 14px; height: 14px; }
.conv-list .del:hover { color: var(--ko); background: var(--ko-soft); }
.conv-list li:hover .del, .conv-list li.active .del { opacity: 1; }
.account { margin-top: 6px; display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.account-row { display: flex; align-items: center; gap: 4px; }
.account-row .side-profile { flex: 1; min-width: 0; }
.google-slot { min-height: 40px; display: flex; justify-content: center; }
.side-profile .avatar { width: 26px; height: 26px; }
.side-profile .who { display: flex; flex-direction: column; min-width: 0; text-align: left; line-height: 1.25; }
.side-profile .who strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-profile .who small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.demo-banner {
  max-width: 680px; width: calc(100% - 40px); margin: 12px auto 0; border-radius: 10px;
  background: #fffbeb; color: #92400e; padding: 7px 12px; font-size: 12.5px; border: 1px solid #fde68a;
}
.demo-banner code { background: rgba(146, 64, 14, .08); padding: 1px 5px; border-radius: 5px; font-size: .92em; }

/* Messages */
.messages { flex: 1; overflow-y: auto; padding: 28px 20px 20px; }
.msg { max-width: 680px; margin: 0 auto 22px; display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: 100%; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--surface-2); padding: 9px 15px; border-radius: 16px; white-space: pre-wrap; max-width: 80%; }
.msg.assistant .bubble { width: 100%; padding: 2px 0; }
.msg .files { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.msg .files .i { width: 14px; height: 14px; }
.status { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 10px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--violet); animation: pulse 1.1s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
.error { color: var(--ko); }

.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 .75em; }
.bubble h1, .bubble h2, .bubble h3 { line-height: 1.3; margin: 1.3em 0 .45em; letter-spacing: -.01em; font-weight: 600; }
.bubble h1 { font-size: 1.3em; } .bubble h2 { font-size: 1.15em; } .bubble h3 { font-size: 1.03em; }
.bubble ul, .bubble ol { padding-left: 1.3em; margin: 0 0 .75em; }
.bubble li { margin: .2em 0; }
.bubble li::marker { color: var(--faint); }
.bubble hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }
.bubble pre { background: var(--surface); border: 1px solid var(--border); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 13px; }
.bubble code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.bubble pre code { background: none; padding: 0; }
.bubble table { border-collapse: collapse; display: block; overflow-x: auto; margin: .8em 0; font-size: 14px; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.bubble th { background: var(--surface); font-weight: 600; }
.bubble a { color: var(--blue); text-underline-offset: 2px; }
.bubble blockquote { margin: .8em 0; padding: 2px 0 2px 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

.msg-actions { margin-top: 10px; display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }
.msg-actions button { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; border-radius: 7px; padding: 5px 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.msg-actions .i { width: 14px; height: 14px; }
.msg-actions button:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.msg-actions .rate { margin-left: auto; display: flex; gap: 2px; align-items: center; }
.msg-actions .rate button:disabled { cursor: default; opacity: .45; }
.msg-actions .rate button.chosen { color: var(--text); background: var(--surface-2); opacity: 1; }
.msg-actions .rate .thanks { font-size: 12px; color: var(--muted); margin-left: 6px; }

/* Accueil */
.welcome { max-width: var(--content); margin: 0 auto; text-align: center; }
.welcome h1 { margin: 0 0 10px; font-size: 24px; line-height: 1.35; font-weight: 500; letter-spacing: -.015em; }
.welcome-sub { margin: 0 auto; color: var(--muted); font-size: 13.5px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 34px 0 10px; font-size: 13px; font-weight: 500; text-align: left; }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; min-height: 86px;
  padding: 12px; text-align: left; border-radius: 12px; cursor: pointer;
  background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-sm); transition: box-shadow .2s, border-color .2s, transform .2s;
}
.quick-card::before {
  content: ""; position: absolute; top: -30px; right: -20px; width: 130px; height: 90px; border-radius: 50%;
  filter: blur(22px); opacity: .55; pointer-events: none;
}
.quick-card.violet::before { background: radial-gradient(circle, #c4b5fd, #e0d9ff 60%, transparent); }
.quick-card.blue::before { background: radial-gradient(circle, #a5c8ff, #dbe8ff 60%, transparent); }
.quick-card.teal::before { background: radial-gradient(circle, #99e6dc, #d5f5f0 60%, transparent); }
.quick-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.quick-card .ico { position: relative; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; color: #fff; }
.quick-card .ico .i { width: 14px; height: 14px; }
.quick-card.violet .ico { background: linear-gradient(180deg, #9b7bff, #7c5cff); }
.quick-card.blue .ico { background: linear-gradient(180deg, #5b9bff, #3b82f6); }
.quick-card.teal .ico { background: linear-gradient(180deg, #2fd0bd, #14b8a6); }
.quick-card .txt { position: relative; font-size: 13px; font-weight: 500; line-height: 1.35; color: var(--text); }
.quick-card .go { position: absolute; right: 10px; bottom: 12px; color: var(--faint); }
.quick-card .go .i { width: 14px; height: 14px; }

/* Écran vide : contenu centré, suggestions en bas */
.main.is-empty { overflow-y: auto; }
.main.is-empty .messages { flex: 0 0 auto; overflow: visible; margin-top: auto; padding-top: 28px; padding-bottom: 22px; }
.main.is-empty .hint { display: none; }
.main.is-empty::before {
  content: ""; position: absolute; top: -60px; left: 15%; right: 15%; height: 170px; pointer-events: none;
  background: radial-gradient(60% 100% at 50% 0%, rgba(124, 92, 255, .10), transparent 70%); filter: blur(10px);
}
.starters { max-width: var(--content); width: calc(100% - 40px); margin: 6px auto 0; padding: 0 0 26px; }
.starters .section-head { margin-top: 26px; }
.main.is-empty .starters { margin-bottom: auto; }
.suggestions { display: flex; gap: 8px; }
.suggestions button {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 1 auto; min-width: 0; padding: 6px 12px 6px 10px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text); font-size: 12.5px; cursor: pointer; box-shadow: var(--shadow-sm);
}
.suggestions button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestions button .i { width: 12px; height: 12px; color: var(--faint); }
.suggestions button:hover { background: var(--surface); }

/* Quiz */
.quiz { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 12px 0; background: #fff; box-shadow: var(--shadow-sm); }
.quiz h3 { margin: 0 0 12px; }
.quiz .q { margin-bottom: 18px; }
.quiz .q-title { font-weight: 600; margin-bottom: 8px; }
.quiz .choices { display: grid; gap: 6px; }
.quiz .choice { text-align: left; border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 9px 13px; cursor: pointer; color: var(--text); }
.quiz .choice:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface); }
.quiz .choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.quiz .choice.wrong { border-color: var(--ko); background: var(--ko-soft); }
.quiz .choice:disabled { cursor: default; }
.quiz .expl { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.quiz .score { font-weight: 600; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.quiz-loading { color: var(--muted); font-style: italic; }

/* Zone de saisie */
.composer { padding: 6px 20px 14px; }
.composer-row {
  max-width: var(--content); margin: 0 auto;
  display: grid; grid-template-columns: auto auto auto auto auto 1fr auto; grid-template-areas: "t t t t t t t" "a c p v m . s";
  align-items: center; gap: 6px; padding: 12px 12px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.main:not(.is-empty) .composer-row { max-width: 680px; }
.composer-row:focus-within { background: #fff; border-color: var(--border-strong); box-shadow: var(--shadow), 0 0 0 4px var(--ring); }
.composer-row > textarea { grid-area: t; }
.composer-row > label { grid-area: a; }
.composer-row > .tool-sep { grid-area: p; }
.composer-row > .camera { grid-area: c; display: none; }
@media (pointer: coarse), (max-width: 760px) { .composer-row > .camera { display: inline-flex; } }
.composer-row > .voice-start { grid-area: v; }
.composer-row > .mic { grid-area: m; }
.composer-row > .send { grid-area: s; }
textarea { border: 0; outline: none; resize: none; background: transparent; padding: 0 2px 22px; max-height: 200px; font-size: 14.5px; min-width: 0; }
.main:not(.is-empty) textarea { padding-bottom: 4px; }
.composer-row textarea:focus-visible { outline: none; }
textarea::placeholder { color: var(--faint); }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text); font-size: 12.5px; font-weight: 500; box-shadow: var(--shadow-sm);
}
.tool-btn .i { width: 15px; height: 15px; color: #52525b; }
.tool-btn.square { width: 30px; padding: 0; justify-content: center; }
.tool-btn:hover { background: var(--surface-2); }
.tool-sep { width: 1px; height: 18px; background: var(--border-strong); margin: 0 2px; }
.mic.recording { color: var(--ko); border-color: #fecaca; background: var(--ko-soft); animation: pulse 1s infinite; }
.mic.recording .i { color: var(--ko); }
.send { width: 32px; height: 32px; border-radius: 9px; border: 0; background: var(--accent); color: #fff; cursor: pointer; display: grid; place-items: center; }
.send .i { width: 16px; height: 16px; }
.send:hover { background: var(--accent-hover); }
.send.stop { background: var(--ko); }
.send:disabled { opacity: .4; cursor: default; }
.hint { max-width: 680px; margin: 8px auto 0; font-size: 11.5px; color: var(--faint); text-align: center; }
.attachments { max-width: var(--content); margin: 0 auto 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.attachments:empty { display: none; }
.chip { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px 4px 10px; font-size: 12.5px; display: flex; gap: 6px; align-items: center; }
.chip button { background: none; border: 0; cursor: pointer; padding: 2px; color: var(--muted); display: grid; border-radius: 5px; }
.chip button:hover { color: var(--ko); }
.chip .i { width: 13px; height: 13px; }

/* Voix */
/* Conversation vocale : grand panneau centré, la bulle au milieu */
.voice-panel {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  max-width: 680px; width: calc(100% - 40px); margin: 0 auto 10px; padding: 22px 18px 16px;
  background: radial-gradient(120% 90% at 50% 0%, #f3efff 0%, #fff 60%); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg);
}
/* Bulle de N'karamo : forme vivante violette, reflets de verre, yeux lumineux */
.nk-orb { position: relative; display: block; width: 100%; aspect-ratio: 1; isolation: isolate; }
.nk-orb > span { position: absolute; display: block; }
.nk-orb .halo {
  inset: -14%; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, rgba(124, 77, 255, .45) 0%, rgba(90, 110, 255, .18) 45%, transparent 70%);
  filter: blur(14px); animation: halo 4s ease-in-out infinite;
}
.nk-orb .b2 {
  inset: 6% 8% 8% 4%;
  background: linear-gradient(200deg, #6fb6ff 0%, #4c7dff 45%, #7a4dff 100%);
  filter: blur(3px); opacity: .9;
  animation: morph-b 9s ease-in-out infinite;
}
.nk-orb .b1 {
  inset: 7% 5% 6% 8%;
  background:
    radial-gradient(120% 90% at 28% 22%, rgba(214, 186, 255, .95) 0%, rgba(214, 186, 255, 0) 45%),
    radial-gradient(90% 90% at 80% 85%, rgba(70, 60, 235, .9) 0%, rgba(70, 60, 235, 0) 60%),
    linear-gradient(150deg, #a774ff 0%, #7b52ff 45%, #5b45f2 100%);
  box-shadow: inset 0 -10px 24px rgba(40, 20, 160, .35), inset 0 8px 18px rgba(255, 255, 255, .25), 0 18px 40px -16px rgba(80, 50, 220, .6);
  animation: morph-a 8s ease-in-out infinite;
}
/* Reflet courbe façon verre */
.nk-orb .shine {
  inset: 15% 13% 14% 15%;
  border: 2px solid transparent; border-top-color: rgba(255, 255, 255, .55); border-right-color: rgba(255, 255, 255, .28);
  filter: blur(.6px); transform: rotate(-18deg);
  animation: morph-a 8s ease-in-out infinite;
}
.nk-orb .eyes {
  left: 50%; top: 47%; width: 34%; height: 17%; transform: translate(-50%, -50%);
  display: flex; justify-content: space-between; transition: transform .35s ease;
}
.nk-orb .eyes i {
  display: block; width: 26%; height: 100%; background: #fff;
  border-radius: 50% 50% 46% 46% / 64% 64% 36% 36%;
  -webkit-mask: radial-gradient(42% 30% at 50% 102%, transparent 96%, #000 100%);
  mask: radial-gradient(42% 30% at 50% 102%, transparent 96%, #000 100%);
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 8px rgba(235, 225, 255, 1)) drop-shadow(0 0 16px rgba(190, 165, 255, .9));
  transform-origin: 50% 70%; animation: blink 5.5s infinite;
}
@keyframes morph-a {
  0%, 100% { border-radius: 52% 48% 46% 54% / 50% 46% 54% 50%; transform: rotate(0deg); }
  33% { border-radius: 46% 54% 52% 48% / 56% 50% 50% 44%; transform: rotate(4deg); }
  66% { border-radius: 55% 45% 48% 52% / 46% 54% 46% 54%; transform: rotate(-3deg); }
}
@keyframes morph-b {
  0%, 100% { border-radius: 48% 52% 55% 45% / 52% 48% 52% 48%; transform: translate(-2%, 1%) rotate(0deg); }
  50% { border-radius: 54% 46% 44% 56% / 46% 56% 44% 54%; transform: translate(2%, -1%) rotate(-6deg); }
}
@keyframes halo { 0%, 100% { opacity: .8; transform: scale(1); } 50% { opacity: 1; transform: scale(1.05); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

/* Sur l'accueil : la bulle qui lance la conversation vocale */
.glass-btn {
  position: relative; display: block; width: 72px; margin: 0 auto 22px; padding: 0; border: 0; background: none; cursor: pointer;
  transition: transform .3s cubic-bezier(.3, 1.4, .5, 1);
}
.glass-btn.hero { width: 176px; margin-bottom: 26px; }
/* Ondes qui invitent à toucher la bulle */
.glass-btn.can-talk::before, .glass-btn.can-talk::after {
  content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 1.5px solid rgba(124, 92, 255, .35);
  animation: invite 2.8s ease-out infinite; pointer-events: none;
}
.glass-btn.can-talk::after { animation-delay: 1.4s; }
@keyframes invite { 0% { transform: scale(.95); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
.glass-btn:hover { transform: scale(1.08); }
.glass-btn:hover .eyes { transform: translate(-50%, -62%); }
.glass-btn:hover .eyes i { animation: blink .5s 1; }

/* Pendant la conversation : la bulle reste à portée de main, au-dessus de la zone de saisie */
.float-orb {
  position: absolute; right: 26px; bottom: 150px; z-index: 5; width: 64px; padding: 0; border: 0; background: none; cursor: pointer;
  display: none; transition: transform .3s cubic-bezier(.3, 1.4, .5, 1);
}
.main:not(.is-empty) .float-orb { display: block; }
.main:has(.voice-panel:not([hidden])) .float-orb { display: none; }
.float-orb:hover { transform: scale(1.08); }
.float-orb:hover .eyes { transform: translate(-50%, -62%); }
.float-tip {
  position: absolute; right: 100%; top: 50%; transform: translateY(-50%); margin-right: 8px; white-space: nowrap;
  background: #18181b; color: #fff; font-size: 12px; font-weight: 500; padding: 4px 9px; border-radius: 7px;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.float-orb:hover .float-tip, .float-orb:focus-visible .float-tip { opacity: 1; }
.hint a, .auth-legal a, .side-legal a { color: inherit; }
.side-legal { margin: 0 8px; font-size: 11.5px; color: var(--faint); }

/* Dans le panneau vocal : la bulle réagit à l'état de la conversation */
.orb { width: 120px; flex-shrink: 0; padding: 0; border: 0; background: none; cursor: pointer; margin-bottom: 4px; }
.voice-panel[data-state="listening"] .orb .eyes { transform: translate(-50%, -62%) scale(1.08); }
.voice-panel[data-state="listening"] .orb .halo { animation-duration: 1.4s; }
.voice-panel[data-state="thinking"] .orb .eyes { animation: look 1.6s ease-in-out infinite; }
.voice-panel[data-state="speaking"] .orb .b1, .voice-panel[data-state="speaking"] .orb .b2 { animation-duration: 1.6s; }
.voice-panel[data-state="speaking"] .orb .nk-orb { animation: talk .36s ease-in-out infinite alternate; }
.voice-panel[data-state="idle"] .orb .nk-orb { filter: grayscale(.85); opacity: .65; }
@keyframes look { 0%, 100% { transform: translate(-62%, -50%); } 50% { transform: translate(-38%, -50%); } }
@keyframes talk { from { transform: scale(1, 1); } to { transform: scale(1.04, .96); } }
/* Pendant la conversation vocale, l'accueil s'efface : il ne reste que N'karamo */
.main:has(.voice-panel:not([hidden])) .welcome,
.main:has(.voice-panel:not([hidden])) .starters { display: none; }
.main.is-empty:has(.voice-panel:not([hidden])) .voice-panel { margin-top: auto; padding: 34px 18px 22px; }
.main.is-empty:has(.voice-panel:not([hidden])) .composer { margin-bottom: auto; }
.main.is-empty:has(.voice-panel:not([hidden])) .orb { width: 170px; }
.voice-info { width: 100%; min-width: 0; }
.voice-status { font-weight: 600; font-size: 16px; }
.voice-transcript { color: var(--muted); font-size: 14.5px; min-height: 1.4em; overflow-wrap: anywhere; max-width: 520px; margin: 2px auto 0; }
.voice-end { flex-shrink: 0; margin-top: 4px; }
.voice-pick { width: min(280px, 100%); margin-top: 4px; }
.voice-pick span { padding: 5px 8px; font-size: 12.5px; }

/* Cours */
.course-bar {
  max-width: 680px; width: calc(100% - 40px); margin: 12px auto 0; padding: 12px 14px; border-radius: var(--radius);
  background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.course-head { display: flex; align-items: center; gap: 10px; }
.course-info { flex: 1; min-width: 0; }
.course-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course-chapter { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course-plan-btn { padding: 5px 10px 5px 12px; font-size: 13px; flex-shrink: 0; gap: 4px; }
.course-plan-btn .i { width: 15px; height: 15px; transition: transform .2s; }
.course-plan-btn.open .i { transform: rotate(180deg); }
.course-progress { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.course-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--blue)); transition: width .4s; }
.course-plan { margin: 10px 0 2px; padding: 0; list-style: none; display: grid; gap: 2px; max-height: 40vh; overflow-y: auto; }
.course-plan li button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer; font-size: 13.5px; }
.course-plan li button:hover { background: var(--surface); }
.course-plan li.current button { border-color: var(--border-strong); background: var(--surface); color: var(--text); font-weight: 500; }
.course-plan .num { color: var(--muted); width: 1.6em; flex-shrink: 0; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.course-plan .num .i { width: 15px; height: 15px; }
.course-plan li.done .num { color: var(--ok); }
.course-plan .ch-title { flex: 1; }
.course-plan .ch-score { font-size: 12px; color: var(--muted); }
.course-actions { max-width: 680px; margin: 0 auto 8px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.course-actions button { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: #fff; color: var(--text-2); border-radius: 8px; padding: 5px 11px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm); }
.course-actions .i { width: 14px; height: 14px; }
.course-actions button:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.course-actions button.next { background: var(--accent); border-color: var(--accent); color: #fff; margin-left: auto; }
.course-actions button.next:hover:not(:disabled) { background: var(--accent-hover); color: #fff; }
.course-actions button:disabled { opacity: .5; cursor: default; }

/* Fenêtres */
dialog { border: 0; border-radius: 16px; padding: 22px; width: min(440px, calc(100vw - 32px)); background: #fff; color: var(--text); box-shadow: 0 0 0 1px rgba(0, 0, 0, .05), var(--shadow-lg); }
dialog::backdrop { background: rgba(24, 24, 27, .3); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 13.5px; margin-top: 0; }
dialog label { display: block; margin: 14px 0 0; font-size: 13px; font-weight: 500; color: var(--text-2); }
dialog input, dialog select, dialog textarea { display: block; width: 100%; margin-top: 6px; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 9px; background: #fff; font-size: 14px; color: var(--text); box-shadow: var(--shadow-sm); }
dialog textarea { resize: vertical; max-height: 40vh; padding-bottom: 8px; }
dialog input:focus, dialog select:focus, dialog textarea:focus { outline: none; border-color: var(--faint); box-shadow: 0 0 0 4px var(--ring); }
.optional { font-weight: 400; color: var(--muted); }
.form-error { color: var(--ko); font-size: 13.5px; margin-top: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.google-block { margin-top: 16px; }
.google-block .or, .auth-dialog .or { display: flex; align-items: center; gap: 10px; margin-top: 16px; color: var(--faint); font-size: 12px; }
.google-block .or::before, .google-block .or::after, .auth-dialog .or::before, .auth-dialog .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Profil : étudiant ou enseignant */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; margin-top: 14px; background: var(--surface-2); border-radius: 10px; }
.seg label { margin: 0; cursor: pointer; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 7px 8px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg input:checked + span { background: #fff; color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg input:focus-visible + span { outline: 2px solid var(--blue); }

/* Historique : ma progression */
.progress-box { margin: 6px 0 2px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: linear-gradient(180deg, #faf8ff, #fff); }
.progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; }
.progress-head span { color: var(--muted); font-size: 12px; }
.progress-bar { height: 5px; border-radius: 3px; background: var(--surface-2); margin: 8px 0 10px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--blue)); }
.progress-sub { font-size: 11.5px; color: var(--faint); margin-bottom: 4px; }
.progress-sub.ok { color: var(--ok); margin: 0; }
.weak { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 5px 4px; border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--text-2); text-align: left; }
.weak:hover { background: var(--surface-2); }
.weak .i { width: 13px; height: 13px; color: var(--violet); }
.weak span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weak small { color: var(--ko); font-weight: 600; }
.stats-link { display: block; font-size: 12.5px; color: var(--violet); padding: 2px 8px; }

/* Téléphone : installation et connexion */
.net-banner {
  max-width: 680px; width: calc(100% - 40px); margin: 10px auto 0; padding: 8px 12px; border-radius: 10px;
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; font-size: 13px;
}
.install-banner {
  display: flex; align-items: center; gap: 10px; max-width: 680px; width: calc(100% - 40px); margin: 10px auto 0;
  padding: 10px 8px 10px 10px; border-radius: 14px; background: linear-gradient(135deg, #f5f1ff, #eef4ff); border: 1px solid #e3dcff;
}
.install-banner img { border-radius: 10px; flex-shrink: 0; }
.install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.install-text strong { font-size: 13.5px; }
.install-text span { font-size: 12px; color: var(--muted); }
.install-go { border: 0; border-radius: 999px; padding: 8px 14px; background: #0f0e1f; color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; flex-shrink: 0; }

/* En-tête : S'inscrire / Se connecter */
.auth-btns { display: flex; align-items: center; gap: 6px; }
.signup-btn { border: 0; background: none; padding: 7px 12px; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; border-radius: 999px; }
.signup-btn:hover { background: var(--surface-2); }
.login-btn {
  border: 0; border-radius: 999px; padding: 8px 18px; background: #0f0e1f; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px -4px rgba(15, 14, 31, .45);
}
.login-btn:hover { background: #000; }

/* Fenêtre de connexion */
.auth-dialog { width: min(400px, calc(100vw - 32px)); padding: 30px 28px 22px; text-align: center; }
.auth-dialog form { position: relative; display: flex; flex-direction: column; }
.dialog-x { position: absolute; top: -18px; right: -16px; }
.auth-orb { width: 64px; margin: 0 auto 14px; }
.auth-dialog h2 { font-size: 20px; }
.auth-dialog .muted { margin-bottom: 18px; }
.auth-dialog .google-slot { min-height: 44px; }
.auth-dialog .or { margin: 16px 0 2px; }
.auth-dialog label { text-align: left; }
.btn-primary.wide { width: 100%; margin-top: 12px; height: 42px; border-radius: 999px; background: #0f0e1f; border-color: #0f0e1f; }
.btn-primary.wide:hover { background: #000; }
.code-sent { margin: 0 0 4px !important; text-align: left; }
.code-back { align-self: center; margin-top: 12px; }
#authCode { font-size: 22px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.auth-legal { margin: 18px 0 0; font-size: 11.5px; color: var(--faint); }

/* Très petits téléphones (colonne d'onglets à gauche) : saisie compacte */
@media (max-width: 400px) {
  .composer { padding-left: 8px; padding-right: 8px; }
  .composer-row { gap: 4px; padding: 10px 8px 8px; }
  .composer-row .mic span { display: none; }
  .composer-row .mic { width: 38px; padding: 0; justify-content: center; }
  .tool-btn { height: 38px; }
  .tool-btn.square { width: 38px; }
  .composer-row > .voice-start { width: 40px; height: 40px; min-width: 40px; }
  .send { width: 40px; height: 40px; }
  .messages { padding-left: 10px; padding-right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Téléphone : tout l'écran pour travailler ; le menu se déplie depuis la gauche (bouton ☰ ou glisser) */
@media (max-width: 760px) {
  .app { padding: 0; overflow: hidden; }
  .main { border-radius: 0; box-shadow: none; transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
  .rail { display: none; }
  .menu-btn, .top-new { display: inline-flex; }
  .menu-btn { margin-left: -6px; }
  .menu-btn .i, .top-new .i { width: 22px; height: 22px; color: var(--text); }
  .top-title { margin-right: auto; }
  .top-title > .i { display: none; }
  .sidebar {
    top: 0; bottom: 0; left: 0; width: min(320px, 84vw); border-radius: 0; box-shadow: none;
    padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    transform: translateX(-100%); opacity: 1; transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s .28s;
  }
  .sidebar.open { transform: none; transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
  /* Le contenu glisse sur le côté, comme dans les applications */
  body:has(.sidebar.open) .main { transform: translateX(min(320px, 84vw)); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(15, 14, 31, .28); opacity: 0; pointer-events: none; transition: opacity .28s; }
  body:has(.sidebar.open) .scrim { opacity: 1; pointer-events: auto; }
  .drawer-title-desk { display: none; }
  .drawer-title-mob { display: inline; font-size: 18px; font-weight: 600; }
  .drawer-modes .modes { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
  .drawer-modes .modes button {
    display: flex; align-items: center; gap: 14px; width: 100%; padding: 11px 10px; border: 0; border-radius: 10px;
    background: none; color: var(--text); font-size: 15.5px; cursor: pointer; text-align: left;
  }
  .drawer-modes .modes button .i { width: 20px; height: 20px; color: var(--text-2); }
  .drawer-modes .modes button.active { background: var(--surface-2); font-weight: 600; }
  .topbar { padding: 10px 12px; }
  .top-title span { font-size: 14.5px; }
  .top-btn span { display: none; }
  #toggleSidebar { display: none; }
  .top-btn { padding: 6px 8px; }
  .profile-pill { display: none; }
  .signup-btn { padding: 6px 8px; font-size: 13px; }
  .login-btn { padding: 7px 14px; font-size: 13px; }
  .messages { padding: 18px 14px; }
  .composer { padding: 6px 10px 10px; }
  .demo-banner, .course-bar, .starters, .voice-panel { width: calc(100% - 24px); }
  .welcome h1 { font-size: 20px; }
  .glass-btn.hero { width: 140px; }
  .orb { width: 96px; }
  .section-head { margin-top: 24px; }
  .quick { grid-template-columns: 1fr; gap: 8px; }
  .suggestions { flex-direction: column; align-items: flex-start; }
  .suggestions button { max-width: 100%; }
  .quick-card { flex-direction: row; align-items: center; min-height: 0; gap: 12px; padding: 12px; }
  .quick-card .txt br { display: none; }
  .quick-card .go { position: static; margin-left: auto; }
  .voice-start span { display: none; }
  .voice-start { width: 30px; padding: 0; justify-content: center; }
  .msg.user .bubble { max-width: 88%; }
  /* Champs à 16 px : Safari sur iPhone ne zoome plus au toucher (la page ne bouge pas). */
  textarea, dialog input, dialog select, dialog textarea, .auth-dialog input { font-size: 16px; }
  #authCode { font-size: 22px; }
  .hint { display: none; }
  .composer { padding-bottom: 8px; }
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); }
  dialog { max-height: calc(var(--app-h, 100dvh) - 24px); overflow-y: auto; }
  body.typing .float-orb { display: none; }
  .net-banner, .install-banner { width: calc(100% - 24px); }
  /* Cibles tactiles confortables (44 px minimum) */
  .tool-btn { height: 40px; }
  .tool-btn.square { width: 40px; }
  .send { width: 42px; height: 42px; border-radius: 12px; }
  .msg-actions button { padding: 8px 10px; }
  /* Sur téléphone, la bulle se range dans l'en-tête : elle ne recouvre jamais le texte. */
  .float-orb { display: none !important; }
  /* Le bouton de conversation vocale devient l'appel principal, à côté de l'envoi (comme ChatGPT) */
  .composer-row > .voice-start {
    width: 42px; height: 42px; min-width: 42px; aspect-ratio: 1; padding: 0; flex: none; justify-content: center; align-items: center;
    border: 0; border-radius: 50%;
    background: radial-gradient(120% 120% at 30% 25%, #a585ff 0%, #7b52ff 45%, #5b45f2 100%);
    box-shadow: 0 6px 16px -6px rgba(91, 69, 242, .65), inset 0 1px 0 rgba(255, 255, 255, .3);
    transition: transform .15s ease, box-shadow .15s ease;
  }
  .composer-row > .voice-start:active { transform: scale(.94); }
  .composer-row > .voice-start .i { width: 20px; height: 20px; color: #fff; }
  .signup-btn { display: none; }
  .float-tip { display: none; }
  .course-actions { flex-wrap: wrap; }
  .course-actions button { flex: 1 1 auto; justify-content: center; }
}
