/* ============================================================
   AminiA — coque visuelle Grok / Grok Imagine
   Chargé après app.css. Ce fichier gagne le conflit de cascade.
   1. Jetons
   2. Cadre (sidebar + scène)
   3. Chat
   4. Imagine
   5. Bibliothèque, voix, compte
   6. Mobile
   7. Connexion et chargement
   ============================================================ */

:root {
  --bg: #000000;
  --bg-elev: #141414;
  --bg-elev-2: #1c1c1c;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f4f4;
  --muted: #8e8e8e;
  --faint: #5e5e5e;
  --bubble: #1f1f1f;
  --chip: #161616;
  --inverse: #ffffff;
  --inverse-text: #111111;
  --danger: #e07a72;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --sidebar-w: 268px;
  --rail-w: 76px;
  --col: 760px;
  --composer: 740px;
  --tab-h: 58px;
  --top-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --task-h: 0px;
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #f4f4f5;
  --bg-elev-2: #e8e8ec;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(0, 0, 0, 0.07);
  --line: rgba(0, 0, 0, 0.08);
  --text: #111111;
  --muted: #66666c;
  --faint: #8a8a90;
  --bubble: #f2f2f4;
  --chip: #f4f4f5;
  --inverse: #111111;
  --inverse-text: #ffffff;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

html, body {
  background: var(--bg);
  color: var(--text);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ---------- cadre ---------- */
.app {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
.app > .stage {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.stage { background: var(--bg); }
.tabbar,
.side-scrim { display: none; }

.side {
  grid-column: 1;
  grid-row: 1;
  width: auto;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  color: var(--text);
  border-right: 1px solid var(--line);
  padding: 10px 10px 8px;
  overflow: hidden;
}
.side-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 4px 4px 2px;
}
.side-logo {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.045em;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 10px;
}
.side-logo:hover { background: var(--bg-hover); }
.side-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 4px 6px;
  padding: 0 12px;
  height: 38px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid transparent;
  color: var(--muted);
}
.side-search:focus-within { border-color: var(--line); }
.side-search svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; flex: none; }
.side-search input {
  border: 0;
  background: transparent;
  color: var(--text);
  height: 36px;
  padding: 0;
  min-width: 0;
}
.side-search input:focus { border: 0; outline: none; }

.side-nav { display: grid; gap: 2px; padding: 2px 0 4px; }
.side .side-nav > button,
#rail-admin2 button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border-radius: 12px;
  padding: 9px 12px;
  color: var(--text);
  background: transparent;
  font-size: 14.5px;
  font-weight: 500;
}
.side .side-nav > button svg { width: 18px; height: 18px; }
.side .side-nav > button:hover,
#rail-admin2 button:hover { background: var(--bg-hover); }
.side .side-nav > button.on { background: var(--bg-active); color: var(--text); }

.side-scroll { flex: 1; min-height: 0; min-width: 0; overflow: auto; }
.side-section-head,
.side-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 14px 12px 6px;
}
.hist-group {
  margin: 14px 12px 4px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
}
.side-label-row { display: flex; align-items: center; }
.side-label-row #new-chat.icon-btn {
  width: 32px;
  height: 32px;
  margin: 0 4px 0 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  font-weight: 400;
  font-size: 22px;
  text-align: center;
}
.side-label-row #new-chat.icon-btn:hover { background: var(--bg-hover); }
#hist-list { padding: 0 4px 12px; }
.conv {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  padding: 8px 8px 8px 12px;
}
.conv > span { color: inherit; }
.conv.on,
.conv:hover { background: var(--bg-hover); color: var(--text); }
.conv:hover::after,
.conv.on::after { content: none; }
.conv-more { color: var(--muted); }
.conv-more:hover { background: var(--bg-elev-2); color: var(--text); }

.side-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  text-align: left;
}
.user-chip { border-radius: 12px; margin: 0; padding: 6px; color: var(--text); }
.user-chip:hover { background: var(--bg-hover); }
.user-chip .avatar,
.avatar {
  background: var(--inverse);
  color: var(--inverse-text);
  font-weight: 700;
}
.user-meta strong { color: var(--text); font-weight: 560; }
.user-meta small,
#credit-pill { color: var(--muted); }
.legal {
  margin: 6px 8px 2px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}
.user-pop {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
}
.user-pop button { color: var(--text); }
.user-pop button:hover { background: var(--bg-hover); }

/* Rail replié, comme Grok */
@media (min-width: 961px) {
  .app.collapsed { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .app.collapsed .side { overflow: visible; padding-left: 8px; padding-right: 8px; }
  .app.collapsed .side-search,
  .app.collapsed .side-scroll,
  .app.collapsed .legal,
  .app.collapsed .user-meta,
  .app.collapsed #rail-admin2 { display: none; }
  .app.collapsed .side-brand { flex-direction: column; align-items: center; gap: 6px; }
  .app.collapsed .side-logo {
    font-size: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
  }
  .app.collapsed .side-logo::before {
    content: "ⵣ";
    font-size: 22px;
    line-height: 1;
  }
  .app.collapsed .side-nav > button {
    font-size: 0;
    justify-content: center;
    gap: 0;
    padding: 11px 0;
  }
  .app.collapsed .side-nav > button svg { width: 22px; height: 22px; }
  .app.collapsed .user-chip { justify-content: center; padding: 6px 0; }
  .app.collapsed .user-pop {
    left: calc(100% + 8px);
    right: auto;
    bottom: 0;
    width: 240px;
  }
  .app.collapsed .mobile-menu { display: none; }
}

/* ---------- chat ---------- */
#chat-view {
  background: var(--bg);
  position: relative;
}
#chat-view.home {
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: 24px 16px 56px;
}
#chat-view.home .chat-hero { padding: 0; text-align: center; }
#chat-view .chat-hero h2,
#chat-view.home .chat-hero h2 {
  margin: 0;
  font-family: Inter, "Segoe UI", sans-serif;
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 520;
  letter-spacing: -0.04em;
  color: var(--text);
}
#chat-view .messages {
  width: min(var(--col), 100%);
  max-width: var(--col);
  margin: 0 auto;
  padding: 28px 16px 12px;
  gap: 22px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
#chat-view .msg {
  width: 100%;
  max-width: 100%;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--text);
  box-shadow: none;
}
#chat-view .msg.user {
  align-self: flex-end;
  width: fit-content;
  max-width: min(82%, 540px);
  margin-left: auto;
  margin-right: 0;
  background: var(--bubble);
  border-radius: 22px;
  padding: 10px 16px;
}
#chat-view .msg.assistant {
  align-self: stretch;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 2px 2px 0;
  border-radius: 0;
  white-space: normal;
}
#chat-view .msg .md { font-size: 15.5px; line-height: 1.65; color: var(--text); }
#chat-view .msg-actions button:hover { background: var(--bg-elev-2); color: var(--text); }
#chat-view .msg-actions button.selected { background: color-mix(in srgb, var(--text) 14%, transparent); color: var(--text); }

#chat-view.home .chat-suggest,
.chat-suggest {
  display: none;
  width: min(var(--composer), calc(100% - 32px));
  margin: 0 auto;
}
#chat-view.home .chat-suggest { display: flex; }
.chat-suggest button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
}
.chat-suggest button:hover { background: var(--bg-hover); }
#chat-view .chat-disclaimer {
  color: var(--faint);
  max-width: var(--col);
}

#composer.dock {
  width: min(var(--composer), calc(100% - 32px));
  margin: 0 auto 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: none;
  display: grid;
  gap: 2px;
  padding: 12px 12px 8px;
}
#chat-view.home #composer.dock { margin: 0; }
#composer.dock:focus-within { border-color: color-mix(in srgb, var(--text) 28%, transparent); }
#composer textarea,
#composer.dock textarea {
  color: var(--text);
  background: transparent;
  border: 0;
  font-size: 16px;
  padding: 6px 8px;
  outline: none;
}
#composer textarea::placeholder { color: var(--muted); }
#composer .chat-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
  flex-wrap: nowrap;
  overflow: visible;
}
#composer .chat-bar .icon-btn,
#composer .chat-bar .plus-btn,
#composer #send-btn,
#composer #stop-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--text);
  background: transparent;
}
#composer .chat-bar .icon-btn:hover,
#composer .chat-bar .plus-btn:hover { background: var(--bg-hover); }
#composer .chat-mode,
#composer #chat-talk {
  width: auto;
  height: 36px;
  min-width: 0;
  border-radius: 999px;
  padding: 0 10px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#composer .chat-mode:hover,
#composer #chat-talk:hover,
#composer .chat-mode[aria-expanded="true"] { background: var(--bg-hover); }
#composer .mode-wrap { margin-left: auto; }
#composer #send-btn,
#composer #stop-btn {
  background: var(--inverse);
  color: var(--inverse-text);
}
#composer #send-btn svg { stroke: var(--inverse-text); fill: none; }
#composer #stop-btn svg { fill: var(--inverse-text); stroke: none; }
#chat-mode-menu,
.menu-pop {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: var(--shadow);
}
#chat-mode-menu button.on,
#chat-mode-menu button:hover { background: var(--bg-hover); }

/* ---------- Imagine ---------- */
#imagine-view.imagine {
  background: var(--bg);
  color: var(--text);
}
#imagine-view.imagine.home {
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding-bottom: 24px;
}
#imagine-view .imagine-home {
  width: min(820px, calc(100% - 48px));
  display: flex;
  flex-direction: column;
  align-items: center;
}
#imagine-view .imagine-home h2 {
  margin: 0;
  font-family: Inter, "Segoe UI", sans-serif;
  font-size: clamp(28px, 4.2vw, 42px);
  font-weight: 520;
  letter-spacing: -0.045em;
  text-align: center;
  color: var(--text);
}
#imagine-view .style-row { margin-top: 16px; }
#imagine-view .style-chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}
#imagine-view .style-chip.on,
#imagine-view .style-chip:hover {
  background: var(--inverse);
  color: var(--inverse-text);
  border-color: var(--inverse);
}

#imagine-form.composer {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  color: var(--text);
}
#imagine-view.imagine.home > #imagine-form {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  transform: none;
  width: min(820px, calc(100% - 48px));
  margin: 0;
}
#imagine-view.imagine.feed > #imagine-form,
#imagine-view.imagine.viewing > #imagine-form {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(820px, calc(100% - 32px));
  z-index: 5;
}
#imagine-form textarea,
#imagine-prompt {
  color: var(--text);
  background: transparent;
  font-size: 16px;
  min-width: 0;
}
#imagine-prompt::placeholder { color: var(--muted); }
#imagine-form .composer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  flex-wrap: nowrap;
  min-width: 0;
}
#imagine-form .composer-scroll {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#imagine-form .composer-scroll::-webkit-scrollbar { display: none; }
#imagine-form .opt-row,
#imagine-form #image-tools,
#imagine-form #video-tools {
  width: auto;
  flex: 0 0 auto;
  min-width: 0;
  gap: 6px;
  flex-wrap: nowrap;
}
#imagine-form #image-tools,
#imagine-form #video-tools,
#imagine-form #ratio-btn,
#imagine-form #mic-btn { order: 0; }
#kind-switch.mode-group {
  background: var(--chip);
  border: 1px solid var(--line);
  flex: none;
}
#kind-switch button {
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}
#kind-switch button.on,
#kind-switch button[data-kind="image"].on,
#kind-switch button[data-kind="video"].on,
#kind-switch button[data-kind="animate"].on {
  background: var(--bg-elev-2);
  color: var(--text);
  box-shadow: none;
}
#imagine-form .ratio-pill,
#imagine-form .chip,
#imagine-form .count-select,
#imagine-form .vopts-btn {
  background: var(--chip);
  color: var(--text);
  border: 1px solid transparent;
}
#imagine-form .chip.on { background: var(--inverse); color: var(--inverse-text); }
#imagine-go,
#imagine-form #imagine-go {
  position: static;
  margin-left: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: var(--inverse);
  color: var(--inverse-text);
  flex: none;
}
#imagine-go svg { stroke: var(--inverse-text); fill: none; stroke-width: 1.8; }
#imagine-go:disabled { opacity: 0.4; }

#imagine-view .imagine-feed {
  padding: 8px 16px calc(var(--dock-h, 148px) + 18px);
}
#feed-grid.feed-grid,
.feed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
@media (min-width: 1100px) {
  #feed-grid.feed-grid,
  .feed-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.feed-card {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: var(--chip);
  border: 1px solid var(--line);
}
.feed-card img,
.feed-card video {
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: contain;
  background: #000;
  display: block;
}
.prompt-pill {
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 999px;
}
.suggest button {
  background: var(--bg-elev);
  color: var(--text);
}

#imagine-view .viewer {
  padding-bottom: calc(var(--dock-h, 148px) + 12px);
}
.viewer-media img,
.viewer-media video { border-radius: 12px; }
.viewer-actions > button {
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 12px;
}
.viewer-actions > button.share {
  background: var(--inverse);
  color: var(--inverse-text);
}
.viewer-rail button { background: var(--chip); border-radius: 10px; }
.viewer-rail button.on { border-color: var(--text); }

/* ---------- bibliothèque, voix, compte ---------- */
.library,
.plans,
.pref-view,
.voice-stage { background: var(--bg); color: var(--text); }
.lib-bar { background: var(--bg); }
.lib-search {
  background: var(--bg-elev);
  border-radius: 999px;
  padding: 0 12px;
  border: 1px solid transparent;
}
.lib-filters button { background: transparent; color: var(--muted); }
.lib-filters button.on { background: var(--bg-active); color: var(--text); }
.lib-tile,
.lib-card .lib-tile { border-radius: 14px; }
#voice-view { min-width: 0; overflow: hidden; }
#voice-view .voice-stage { min-width: 0; width: 100%; max-width: 100%; overflow: hidden; }
#voice-type,
#voice-type.voice-composer {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 28px;
  width: min(760px, calc(100% - 32px));
  max-width: calc(100% - 32px);
  min-width: 0;
  box-sizing: border-box;
}
#voice-type.voice-composer .voice-type-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  flex-wrap: nowrap;
}
#voice-type.voice-composer .voice-scroll {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: visible;
}
#voice-type.voice-composer #voice-send {
  position: static;
  margin-left: 0;
  flex: none;
}
#voice-type .stt-lang { width: auto; max-width: 148px; }
#voice-type .voice-settings-wrap { flex: none; min-width: 0; }
#voice-type .voice-settings-toggle { max-width: 160px; }
#mic-btn svg,
#imagine-form .icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.voice-hero,
#voice-status { color: var(--text); }
.account-nav button.on { background: var(--bg-active); }
.pref-block,
.account-main.pref { color: var(--text); }
.top {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.top h1 {
  font-size: 15px;
  font-weight: 560;
  letter-spacing: -0.02em;
}
#side-toggle,
.top-new { color: var(--text); }
.top-new { display: none; }
.app[data-view="chat"] .top-new { display: grid; }

.upgrade-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
}
.upgrade-card strong { color: var(--text); }
.upgrade-card button {
  background: var(--inverse);
  color: var(--inverse-text);
}

/* ---------- mobile ---------- */
@media (max-width: 960px) {
  .app,
  .app.collapsed {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .app > .stage {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
  }
  .tabbar {
    display: grid;
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    height: calc(var(--tab-h) + var(--safe-b));
    padding: 4px 6px var(--safe-b);
    background: var(--bg);
    border-top: 1px solid var(--line);
    z-index: 30;
  }
  .tabbar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: 4px 2px;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 560;
    letter-spacing: -0.01em;
  }
  .tabbar button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .tabbar button span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tabbar button.on { color: var(--text); }

  .side {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 88vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    padding-top: calc(10px + var(--safe-t));
    padding-bottom: calc(8px + var(--safe-b));
    box-shadow: none;
    overflow: hidden;
  }
  .side.open {
    transform: none;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
  }
  .side.open + .side-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    border: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.55);
  }
  .app.collapsed .side-search,
  .app.collapsed .side-scroll,
  .app.collapsed .legal,
  .app.collapsed .user-meta { display: revert; }
  .app.collapsed .side-nav > button {
    display: flex;
    font-size: 14.5px;
    justify-content: flex-start;
    gap: 10px;
    padding: 9px 12px;
  }
  .app.collapsed .side-logo {
    font-size: 20px;
    width: auto;
    height: auto;
    display: inline-flex;
  }
  .app.collapsed .side-logo::before { content: none; }
  .app.collapsed .side-brand { flex-direction: row; }
  .app.collapsed .user-chip { justify-content: flex-start; }

  .mobile-menu { display: none; }
  #workspace-top.top,
  .top {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    height: calc(var(--top-h) + var(--safe-t));
    padding: var(--safe-t) 8px 0;
    gap: 4px;
  }
  .top h1 {
    grid-column: 2;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
  }
  #side-toggle { display: grid; grid-column: 1; }
  .app[data-view="chat"] .top-new { grid-column: 3; justify-self: end; }
  #status-pills { display: none; }
  #side-toggle svg,
  .top-new svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
  }

  #chat-view.home {
    justify-content: center;
    padding: 12px 0 16px;
    gap: 14px;
  }
  #chat-view .chat-hero h2 { font-size: 26px; padding: 0 18px; }
  #chat-view .messages {
    width: 100%;
    padding: 12px 12px 8px;
  }
  #chat-view .msg.user { max-width: 88%; }
  #chat-view.home #composer.dock,
  #chat-view:not(.home) #composer.dock {
    width: calc(100% - 16px);
    margin: 0 auto 8px;
    border-radius: 22px;
  }
  #chat-view.home .chat-suggest { width: calc(100% - 20px); }
  #chat-view .chat-disclaimer { position: static; padding: 0 12px 6px; }
  #chat-view.home .chat-disclaimer { order: 5; }
  #composer #chat-talk span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #composer #chat-talk { padding: 0; width: 36px; justify-content: center; }
  #composer .chat-bar { gap: 0; }
  @media (max-width: 420px) {
    #composer .chat-bar {
      overflow-x: auto;
      scrollbar-width: none;
    }
  }

  #imagine-view.imagine.home {
    justify-content: center;
    align-items: center;
    gap: 14px;
    padding: 8px 0 6px;
  }
  #imagine-view .imagine-home,
  #imagine-view.imagine.home > #imagine-form,
  #imagine-view.imagine.feed > #imagine-form,
  #imagine-view.imagine.viewing > #imagine-form {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
    width: calc(100% - 16px);
    margin: 0 auto 8px;
  }
  #imagine-view .imagine-home h2 { font-size: 26px; }
  #imagine-view .imagine-feed,
  #imagine-view .viewer {
    padding: 8px 8px 8px;
  }
  #imagine-view .viewer {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "rail" "stage";
  }
  #feed-grid.feed-grid,
  .feed-grid { grid-template-columns: 1fr; gap: 8px; }
  #imagine-form { border-radius: 22px; }
  #imagine-form textarea,
  #imagine-prompt { width: 100%; display: block; }
  #imagine-form #prompt-collapse { display: none; }
  #imagine-form .composer-bar {
    overflow: visible;
    padding-right: 0;
  }
  #imagine-form #image-tools,
  #imagine-form #video-tools { display: contents; }
  #imagine-form .composer-scroll > * { order: 5; }
  #imagine-form #kind-switch { order: 1; padding: 2px; }
  #imagine-form #kind-switch button { padding: 4px 6px; font-size: 12px; }
  #imagine-form #composer-plus { order: 2; }
  #imagine-form #ratio-btn,
  #imagine-form #video-opts-btn { order: 3; }
  #imagine-form #mic-btn { order: 4; }
  #imagine-form #speed-btn,
  #imagine-form #quality-btn,
  #imagine-form #count-switch,
  #imagine-form #count-select { order: 6; }
  #imagine-form .composer-scroll {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent);
  }
  #imagine-prompt {
    min-height: 64px;
    overflow: hidden;
  }
  #imagine-form #imagine-go {
    position: static;
    right: auto;
    bottom: auto;
    margin: 0;
    box-shadow: none;
  }
  #video-opts-pop {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(var(--tab-h) + var(--safe-b) + var(--task-h, 0px) + 12px);
    width: auto;
    max-height: min(52vh, 420px);
    overflow: auto;
    z-index: 46;
  }
  #voice-view .voice-top { display: none; }
  #voice-type.voice-composer {
    position: relative;
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
  }
  #voice-type.voice-composer .voice-scroll {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 14px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 14px), transparent);
  }
  #voice-type .voice-settings-wrap { margin-left: 0; }
  #voice-type #stt-lang {
    width: 74px;
    max-width: 74px;
    padding-left: 8px;
    padding-right: 18px;
  }
  #voice-type.voice-composer .voice-scroll::-webkit-scrollbar { display: none; }
  #voice-type.voice-composer #voice-send {
    position: static;
    right: auto;
    bottom: auto;
    margin: 0;
    box-shadow: none;
  }
  #voice-type #mic-mute-btn {
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
    font-size: 0;
    gap: 0;
    justify-content: center;
    overflow: hidden;
  }
  #voice-type #mic-mute-btn::after {
    content: "";
    width: 16px;
    height: 16px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5.3-3a5.3 5.3 0 0 1-10.6 0H5a7 7 0 0 0 6 6.9V21h2v-3.1A7 7 0 0 0 19 11h-1.7z'/></svg>") center / contain no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5.3-3a5.3 5.3 0 0 1-10.6 0H5a7 7 0 0 0 6 6.9V21h2v-3.1A7 7 0 0 0 19 11h-1.7z'/></svg>") center / contain no-repeat;
  }
  #voice-type #mic-mute-btn.muted::after {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M5 4.2 3.6 5.6 8.1 10A5 5 0 0 0 7 11H5.2A7 7 0 0 0 11 17.9V20h2v-2.1c.5-.1 1-.3 1.4-.5l4 4 1.4-1.4L5 4.2zM15 11c0 .3 0 .6-.1.9l1.6 1.6A7 7 0 0 0 18.8 11H17a5 5 0 0 1-2 0zm-3-8a3 3 0 0 0-3 3v.2l6 6V6a3 3 0 0 0-3-3z'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M5 4.2 3.6 5.6 8.1 10A5 5 0 0 0 7 11H5.2A7 7 0 0 0 11 17.9V20h2v-2.1c.5-.1 1-.3 1.4-.5l4 4 1.4-1.4L5 4.2zM15 11c0 .3 0 .6-.1.9l1.6 1.6A7 7 0 0 0 18.8 11H17a5 5 0 0 1-2 0zm-3-8a3 3 0 0 0-3 3v.2l6 6V6a3 3 0 0 0-3-3z'/></svg>");
  }
  .library .lib-bar { padding: 8px; }
  .lib-grid,
  .lib-grid.size-small,
  .lib-grid.size-medium,
  .lib-grid.size-large {
    padding-bottom: 18px;
  }
  .plans-wrap { margin-top: 12px; }
  .voice-top { display: none; }
  .voice-stage {
    padding: 8px 10px 8px;
    gap: 8px;
  }
  #voice-type { width: calc(100% - 4px); border-radius: 22px; }
  #voice-type .voice-settings-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--tab-h) + var(--safe-b) + var(--task-h, 0px) + 16px);
    width: auto;
    max-height: min(52vh, 420px);
    z-index: 46;
  }
  .agent-pop {
    bottom: calc(var(--tab-h) + var(--safe-b) + var(--task-h, 0px) + 76px);
    z-index: 32;
    max-height: min(58vh, 480px);
  }
  .toast {
    bottom: calc(var(--tab-h) + var(--safe-b) + var(--task-h, 0px) + 12px);
    z-index: 45;
  }
  .upgrade-card {
    left: 10px;
    right: 10px;
    bottom: calc(var(--tab-h) + var(--safe-b) + var(--task-h, 0px) + 10px);
    max-width: none;
  }
  .app.show-upgrade #chat-view:not(.home),
  .app.show-upgrade .voice-stage,
  .app.show-upgrade .imagine.home { padding-bottom: 8px; }
  .pref { width: min(640px, calc(100% - 20px)); margin-top: 8px; }
  .account-main.pref { padding-top: 8px; }
}

@media (max-width: 700px) {
  #feed-grid.feed-grid,
  .feed-grid { grid-template-columns: 1fr; }
}
@media (min-width: 701px) and (max-width: 960px) {
  #feed-grid.feed-grid,
  .feed-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- connexion ---------- */
.gate {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}
.gate-card { width: min(380px, calc(100% - 32px)); text-align: center; }
.mark {
  font-size: 34px;
  font-weight: 650;
  letter-spacing: -0.045em;
  color: var(--text);
}
.mark::before {
  content: "";
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: #0a0a0a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4 v16 M12 9 L5 3 M12 9 L19 3 M12 15 L5 21 M12 15 L19 21'/%3E%3C/svg%3E") center / 58% no-repeat;
}
.gate-form { text-align: left; }
.gate-form .lede { text-align: center; color: var(--muted); }
.gate-form label { color: var(--muted); }
.gate-form input {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
}
.gate-form input:focus { border-color: color-mix(in srgb, var(--text) 35%, transparent); }
.gate-tabs button#show-login.on,
.gate-form button[type="submit"],
button[type="submit"].primary {
  background: var(--inverse);
  color: var(--inverse-text);
}
#boot-loader { background: var(--bg); }
.art-plane,
.art-knife { animation: none; opacity: 0; }
.art-yaz { width: 56px; stroke: var(--text); }
.boot-word { font-weight: 700; letter-spacing: -0.05em; color: var(--text); }
.boot-word::after { display: none; }
.boot-text { color: var(--muted); }

/* ---------- bots et connexions ---------- */
#bots-view,
#links-view,
#project-view {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}
.mod-page {
  flex: 1;
  min-height: 0;
  overflow: auto;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 28px 20px 48px;
}
.mod-head h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 560;
  letter-spacing: -0.045em;
}
.mod-lead {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 62ch;
}
.mod-page h3 {
  margin: 22px 0 10px;
  font-size: 15px;
  font-weight: 600;
}
.cx-count {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 13px;
}
.cx-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 0 14px;
  height: 42px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid transparent;
  color: var(--muted);
}
.cx-search:focus-within { border-color: var(--line); }
.cx-search svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}
.cx-search input {
  border: 0;
  background: transparent;
  color: var(--text);
  height: 40px;
  padding: 0;
  min-width: 0;
  width: 100%;
}
.cx-search input:focus { border: 0; outline: none; }
.cx-stack { margin-top: 6px; }
.mod-page h3.cx-kicker {
  margin: 22px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.cx-list { display: flex; flex-direction: column; gap: 8px; }
.cx-row,
.bot-tile {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  text-align: left;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.bot-tile { align-items: start; padding: 16px; border-radius: 18px; }
.cx-row.on,
.bot-tile.on { border-color: color-mix(in srgb, var(--text) 50%, transparent); }
.cx-copy,
.bot-copy { min-width: 0; display: grid; gap: 2px; }
.bot-copy { cursor: pointer; gap: 0; }
.cx-copy strong,
.bot-title strong { font-size: 15px; font-weight: 600; }
.cx-copy small { color: var(--muted); line-height: 1.35; }
.cx-status { color: var(--faint); font-size: 12px; }
.cx-status.on { color: var(--text); }
.cx-status.on::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: #3ddc84;
  transform: translateY(-1px);
}
.cx-logo {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
}
.cx-logo svg { width: 26px; height: 26px; display: block; }
.cx-logo.sm { width: 22px; height: 22px; border-radius: 7px; font-size: 10px; }
.cx-logo.sm svg { width: 14px; height: 14px; }
.bot-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.bot-avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.bot-avatar svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bot-avatar.lg svg { width: 28px; height: 28px; }
.bot-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.bot-role { color: var(--muted); font-size: 13px; }
.bot-brief {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bot-logos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bot-tile .mod-actions { margin: 0; flex-direction: column; align-items: stretch; }
.cx-row .mod-switch,
.bot-tile .mod-switch {
  background: var(--inverse);
  color: var(--inverse-text);
  border-color: transparent;
  font-weight: 600;
}
.cx-row.on .mod-switch,
.bot-tile .mod-switch:not(.on) {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.mod-switch {
  flex: none;
  margin-left: auto;
  border-radius: 999px;
  padding: 6px 10px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 12px;
}
.mod-switch.on,
.mod-filters button.on {
  background: var(--inverse);
  color: var(--inverse-text);
  border-color: transparent;
}
.mod-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.mod-filters button {
  border-radius: 999px;
  padding: 7px 12px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.mod-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.mod-actions button,
.link-sheet button[type="submit"] { width: auto; }
.link-sheet {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
}
.link-sheet p { margin: 0; color: var(--muted); }
.mod-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mod-picks label {
  display: flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
}
.mod-picks input { width: auto; }
.cx-pick {
  position: relative;
  cursor: pointer;
  padding: 5px 10px 5px 5px;
  background: var(--bg);
}
.cx-pick input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.cx-pick:has(input:checked) {
  background: var(--inverse);
  color: var(--inverse-text);
  border-color: transparent;
}
.link-sheet input,
.link-sheet textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.cx-list .link-sheet { margin-top: 0; }
.cx-row .mod-switch { margin-left: 0; }
.cx-row:hover,
.bot-tile:hover { background: color-mix(in srgb, var(--bg-elev) 70%, var(--bg-elev-2)); }
.bot-chip {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mod-ext {
  color: var(--text);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.mod-uri {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  user-select: all;
}
.bot-id {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 16px;
}
.bot-id .mod-mark {
  width: 56px;
  height: 56px;
  font-size: 18px;
}
.bot-id h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -0.045em;
}
.bot-id p { margin: 4px 0 0; }
.bot-back { width: auto; color: var(--muted); }
.bot-list { display: grid; gap: 8px; margin-top: 14px; }
.bot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
}
.bot-row > div { display: grid; gap: 3px; flex: 1; min-width: 0; }
.bot-row small { color: var(--muted); }
.bot-row button { width: auto; margin-left: auto; }
.bot-threads { display: grid; gap: 8px; }
.bot-threads button {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
}
.conv-bot {
  flex: none;
  margin-right: 8px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}
#hero-sub {
  margin: 8px auto 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 15px;
}
@media (max-width: 720px) {
  .mod-page { padding: 16px 12px 28px; }
  .cx-row,
  .bot-tile { grid-template-columns: 40px minmax(0, 1fr); }
  .cx-row .mod-switch,
  .bot-tile .mod-actions { grid-column: 2; justify-self: start; }
  .bot-tile .mod-actions { flex-direction: row; }
}

/* ---------- tâches en cours ---------- */
.task-head { padding-top: 8px; }
.task-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--inverse);
  color: var(--inverse-text);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 18px;
  text-align: center;
}
.task-count:empty { display: none; }
.task-side,
.task-panel {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.task-side {
  max-height: 220px;
  margin: 0 6px 8px;
  overflow: auto;
}
.task-empty,
.task-kicker {
  margin: 0;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12.5px;
}
.task-kicker {
  padding-top: 4px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.task-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.task-open {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--text);
  text-align: left;
}
.task-open strong,
.task-open small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-open strong { font-size: 13px; font-weight: 560; }
.task-open small { color: var(--muted); font-size: 12px; }
.task-row.running .task-open strong { color: var(--text); }
.task-stop {
  flex: none;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
}
.task-meter {
  height: 2px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--line);
}
.task-meter > span {
  display: block;
  height: 100%;
  background: var(--text);
}
.task-strip,
.task-strip.idle,
.task-strip.live {
  display: none !important;
}
.task-strip-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 16px;
  color: var(--text);
  font-size: 13px;
  text-align: left;
}
.task-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--faint);
}
.task-strip.live .task-dot {
  background: var(--text);
  animation: task-pulse 1.2s ease-in-out infinite;
}
.task-panel {
  max-height: 240px;
  padding: 0 12px 10px;
  overflow: auto;
}
@keyframes task-pulse {
  50% { opacity: 0.35; }
}
@media (max-width: 960px) {
  .task-strip-btn { padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .task-strip.live .task-dot { animation: none; }
}

.lib-views {
  display: flex;
  flex: none;
  gap: 2px;
  max-width: 100%;
  padding: 3px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
}
.lib-views button {
  border-radius: 999px;
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 560;
  white-space: nowrap;
}
.lib-views button.on {
  background: var(--inverse);
  color: var(--inverse-text);
}
.lib-grid.lib-list,
.lib-grid.lib-list.size-small,
.lib-grid.lib-list.size-medium,
.lib-grid.lib-list.size-large {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 12px;
  padding-left: 12px;
}
.lib-file {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-elev);
}
.lib-file.on { border-color: color-mix(in srgb, var(--text) 55%, transparent); }
.lib-file-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  text-align: left;
}
.lib-file-thumb {
  position: relative;
  width: 52px;
  height: 52px;
  flex: none;
  overflow: hidden;
  border-radius: 10px;
  background: #0b0b0b;
}
.lib-file-thumb img,
.lib-file-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lib-file-thumb .dur-badge { right: 3px; bottom: 3px; font-size: 10px; padding: 1px 4px; }
.lib-file-text { display: grid; gap: 2px; min-width: 0; }
.lib-file-text strong,
.lib-file-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-file-text strong { font-size: 14px; font-weight: 560; }
.lib-file-text small { color: var(--muted); font-size: 12px; }
.lib-file-actions { display: flex; flex: none; gap: 2px; }
.lib-file-actions button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--text);
}
.lib-file .tick { position: static; flex: none; }
.project-files { display: grid; gap: 10px; margin-top: 4px; }
.project-files .mod-lead { margin: 0; }
.project-tree {
  max-height: min(560px, calc(100dvh - 240px));
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-elev);
}
.project-files > button {
  width: auto;
  justify-self: start;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
}
.project-repo {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--text);
}
.project-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 4px;
  background: var(--bg-elev);
}
.project-crumbs button {
  width: auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
}
.project-tree .bot-list { margin-top: 0; }
.project-file {
  width: 100%;
  text-align: left;
  color: var(--text);
  min-width: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.project-file:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.project-file strong,
.project-file small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-file small { color: var(--muted); }
@media (max-width: 960px) {
  .lib-views { order: 4; flex-basis: 100%; }
  .lib-grid.lib-list,
  .lib-grid.lib-list.size-small,
  .lib-grid.lib-list.size-medium,
  .lib-grid.lib-list.size-large { padding-left: 8px; padding-right: 8px; }
}

.hidden { display: none !important; }

/* ---------- robot de l'accueil : indicateur de tâche + cercle vocal ---------- */
.am-bot {
  --look: 2px;
  /* Amplitude du regard : horizontal (gauche/droite) et vertical (haut/bas). */
  --look-x: var(--look);
  --look-y: var(--look);
  --mood-brow: 0;
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  width: 28px;
  height: 34px;
  flex: none;
}
.am-bot-think {
  display: inline-flex;
  gap: 3px;
  height: 8px;
  align-items: flex-end;
}
.am-bot-think i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #d4d4d4;
  opacity: 0;
}
.am-bot-think i:nth-child(2) { animation-delay: 0.18s; }
.am-bot-think i:nth-child(3) { animation-delay: 0.36s; }
.am-bot-face {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 15%;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  /* Dôme métallique : reflet spéculaire en haut, coeur sombre, liseré lumineux en bas. */
  background:
    radial-gradient(120% 90% at 50% -18%, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 46%),
    radial-gradient(120% 120% at 28% 22%, #4a4a4c 0%, #2b2b2d 42%, #141416 72%, #08080a 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-bottom-color: rgba(255, 255, 255, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -6px 12px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(0, 0, 0, 0.35),
    0 1px 1px rgba(0, 0, 0, 0.5),
    0 8px 18px rgba(0, 0, 0, 0.5);
  /* Reflet de fenêtre + vernis : la lumière est peinte, pas simulée. */
  background-blend-mode: screen, normal;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

/* Reflet vitreux et ombre portée propre au rendu réaliste. */
.am-bot-face::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.12) 18%, rgba(255, 255, 255, 0) 38%),
    radial-gradient(60% 42% at 32% 14%, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 70%);
  mix-blend-mode: screen;
  opacity: 0.85;
  z-index: 2;
}

/* Ombre interne du bas de dôme : donne le volume de la sphère. */
.am-bot-face::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -3%;
  height: 42%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(50% 100% at 50% 100%, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0) 72%);
  opacity: 0.7;
  z-index: 1;
}
.am-bot-eye {
  position: relative;
  width: 28%;
  height: 28%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(90% 90% at 34% 26%, #ffffff 0%, #eceff2 48%, #b9bec6 100%);
  box-shadow:
    inset 0 -1px 1px rgba(0, 0, 0, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    0 0 3px rgba(0, 0, 0, 0.45);
  z-index: 3;
  transform-origin: center;
  animation: am-blink 7.2s linear infinite;
}
.am-bot-pupil {
  position: relative;
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #34343a 0%, #101014 45%, #000 100%);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}
/* Point spéculaire unique : c'est lui qui rend l'oeil crédible. */
.am-bot-pupil::after {
  content: "";
  position: absolute;
  top: 12%;
  left: 18%;
  width: 38%;
  height: 38%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%);
  animation: am-sky 3.4s ease-in-out infinite;
}
.am-bot-mouth {
  position: absolute;
  left: 50%;
  bottom: 17%;
  width: 32%;
  height: 10%;
  border: 0;
  border-bottom: 1.5px solid rgba(230, 234, 240, 0.92);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
  z-index: 3;
  border-bottom-left-radius: 80% 100%;
  border-bottom-right-radius: 80% 100%;
  background: transparent;
  box-sizing: border-box;
  /* Le trait de bouche est toujours dessiné : c'est la signature du visage. */
  opacity: 0.55;
  transform: translateX(-50%) scaleY(0.7);
  transition: opacity 0.25s ease, transform 0.25s ease, width 0.25s ease, height 0.25s ease;
}
.orb.think .am-bot-think i,
.task-strip[data-voice="think"] .am-bot-think i,
.msg.pending .am-bot-think i,
.task-row.running .am-bot-think i,
.task-strip.live:not([data-voice="listen"]):not([data-voice="speak"]) .am-bot-think i {
  opacity: 1;
  animation: am-think 0.85s ease-in-out infinite;
}
.orb.think .am-bot-pupil,
.task-strip[data-voice="think"] .am-bot-pupil,
.msg.pending .am-bot-pupil,
.task-row.running .am-bot-pupil,
.task-strip.live:not([data-voice="listen"]):not([data-voice="speak"]) .am-bot-pupil {
  animation: none;
  transform: translate(0, calc(var(--look) * -0.15));
}
.orb.speak .am-bot-mouth,
.task-strip[data-voice="speak"] .am-bot-mouth {
  opacity: 1;
  border-top: 0;
  border-bottom: 1.5px solid #f4f4f4;
  animation: am-talk 1.35s ease-in-out infinite;
}
.orb.speak .am-bot-face,
.task-strip[data-voice="speak"] .am-bot-face {
  animation: am-glow 1.1s ease-in-out infinite;
}
.orb.speak .am-bot-pupil,
.task-strip[data-voice="speak"] .am-bot-pupil,
html[data-voice="speak"] .task-row.running .am-bot-pupil {
  animation: none;
  transform: translate(0, calc(var(--look) * -0.35));
}

/* ---------- Regard vivant : balayage gauche/droite permanent ---------- */
.am-bot-orb .am-bot-eye,
.am-bot-chat .am-bot-eye {
  animation: am-blink 6.4s linear infinite, am-scan-eye 11s ease-in-out infinite;
}
.am-bot-orb .am-bot-pupil,
.am-bot-chat .am-bot-pupil {
  animation: am-look-around 11s ease-in-out infinite;
}
/* En réflexion : le regard monte, comme on lève les yeux pour chercher une idée. */
html[data-mood="think"] .am-bot-pupil,
html[data-mood="think"][data-voice="think"] .task-row.running .am-bot-pupil,
.orb.think .am-bot-pupil,
.task-strip[data-voice="think"] .am-bot-pupil {
  animation: am-look-up 2.6s ease-in-out infinite;
  transform: translate(calc(var(--look-x) * 0.25), calc(var(--look-y) * -1.25));
}
html[data-mood="think"] .am-bot-eye {
  height: 24%;
  transform: translateY(6%);
}
/* Micro-oscillation de la tête pendant la réflexion. */
html[data-mood="think"] .am-bot-face {
  animation: am-think-sway 3.2s ease-in-out infinite;
}

@keyframes am-look-around {
  0%, 8%   { transform: translate(0, calc(var(--look-y) * -0.8)); }
  16%      { transform: translate(calc(var(--look-x) * -1.15), calc(var(--look-y) * -0.5)); }
  22%, 30% { transform: translate(calc(var(--look-x) * -1.15), calc(var(--look-y) * -0.5)); }
  40%      { transform: translate(calc(var(--look-x) * 1.05), calc(var(--look-y) * -0.9)); }
  46%, 54% { transform: translate(calc(var(--look-x) * 1.05), calc(var(--look-y) * -0.9)); }
  64%      { transform: translate(0, calc(var(--look-y) * -1.3)); }
  72%      { transform: translate(calc(var(--look-x) * 0.55), calc(var(--look-y) * -0.25)); }
  82%, 92% { transform: translate(0, calc(var(--look-y) * -0.8)); }
  100%     { transform: translate(0, calc(var(--look-y) * -0.8)); }
}
@keyframes am-scan-eye {
  0%, 100% { border-radius: 50%; }
  40%, 52% { border-radius: 46% 54% 50% 50% / 52% 52% 46% 46%; }
}
@keyframes am-look-up {
  0%, 100% { transform: translate(calc(var(--look-x) * -0.2), calc(var(--look-y) * -1.05)); }
  35%      { transform: translate(calc(var(--look-x) * -0.45), calc(var(--look-y) * -1.5)); }
  70%      { transform: translate(calc(var(--look-x) * 0.4), calc(var(--look-y) * -1.35)); }
}
@keyframes am-think-sway {
  0%, 100% { transform: rotate(-2.5deg) translateY(1%); }
  50%      { transform: rotate(2.5deg) translateY(-1%); }
}
html[data-voice="listen"] .task-row.running .am-bot-think i,
html[data-voice="speak"] .task-row.running .am-bot-think i,
.task-strip[data-voice="listen"] .am-bot-think i,
.task-strip[data-voice="speak"] .am-bot-think i {
  opacity: 0;
  animation: none;
}
html[data-voice="listen"] .task-row.running .am-bot-pupil,
.task-strip[data-voice="listen"] .am-bot-pupil {
  animation: am-sky 3.4s ease-in-out infinite;
}
html[data-voice="speak"] .task-row.running .am-bot-mouth {
  opacity: 1;
  border-top: 0;
  border-bottom: 1.5px solid #f4f4f4;
  animation: am-talk 1.35s ease-in-out infinite;
}
.am-bot-orb .am-bot-mouth,
.am-bot-chat .am-bot-mouth { border-bottom-width: 2px; }

.am-bot-chat { --look: 3px; width: 46px; height: 54px; }
.am-bot-chat .am-bot-face { width: 42px; height: 42px; }
.am-bot-chat .am-bot-think i { width: 5px; height: 5px; }
.am-bot-row { --look: 1.5px; width: 28px; height: 34px; }
.am-bot-task { --look: 1.5px; width: 22px; height: 26px; }
.am-bot-task .am-bot-face { width: 20px; height: 20px; }
.am-bot-task .am-bot-think { height: 6px; gap: 2px; }
.am-bot-task .am-bot-think i { width: 2px; height: 2px; }
.am-bot-orb {
  --look: 5px;
  width: 46%;
  height: 54%;
  z-index: 1;
}
.am-bot-orb .am-bot-face {
  width: 100%;
  height: 78%;
  gap: 16%;
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.5),
    inset 0 -16px 26px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(0, 0, 0, 0.4),
    0 2px 3px rgba(0, 0, 0, 0.55),
    0 18px 38px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(120, 220, 255, 0.10),
    0 0 26px rgba(96, 200, 255, 0.16),
    0 0 64px rgba(96, 200, 255, 0.08);
}
/* Halo doux sous le dôme, comme une lumière de studio. */
.am-bot-orb .am-bot-face::after {
  height: 48%;
  opacity: 0.8;
}
.am-bot-orb .am-bot-think i { width: 7px; height: 7px; }

#chat-view .msg.assistant .am-bot { display: none; }
#chat-view .msg.assistant.pending {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
#chat-view .msg.assistant.pending .am-bot { display: inline-flex; }
#chat-view .msg.pending .md { flex: 1; min-width: 0; }
#chat-view .msg.pending .md:empty { min-height: 42px; }
#chat-view .msg.pending .md::after,
#chat-view .msg.pending:not(:has(.md))::after { content: none; }

.task-mark {
  position: relative;
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
}
.task-ring { position: absolute; inset: 0; overflow: visible; }
.task-ring-track,
.task-ring-prog { fill: none; }
.task-ring-track { stroke: rgba(255, 255, 255, 0.14); stroke-width: 1.4; }
.task-ring-prog {
  stroke: #f4f4f4;
  stroke-width: 1.7;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 18px 18px;
  stroke-dasharray: 94.248;
  stroke-dashoffset: calc(94.248 * (1 - var(--task-pct, 0) / 100));
  transition: stroke-dashoffset 0.12s linear;
}
.task-strip.indet .task-ring-prog {
  stroke-dasharray: 22 72.248;
  animation: am-spin 1.1s linear infinite;
}
.task-strip-btn { gap: 10px; }
.task-row.running { gap: 8px; }

.orb {
  background: radial-gradient(circle at 50% 42%, #1c1c1c, #070707 72%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 24px 60px rgba(0, 0, 0, 0.55);
}
.orb::before {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.04) 42%, transparent 70%);
}
.orb::after { border-color: rgba(255, 255, 255, 0.16); }
.orb.think::after,
.orb.listen::after,
.orb.speak::after { animation: none; border-color: transparent; box-shadow: none; }
.orb-ring {
  position: absolute;
  inset: -10px;
  width: calc(100% + 20px);
  height: calc(100% + 20px);
  overflow: visible;
  pointer-events: none;
}
.orb-track,
.orb-progress { fill: none; }
.orb-track { stroke: rgba(255, 255, 255, 0.14); stroke-width: 1.4; }
.orb-progress {
  stroke: #f3f3f3;
  stroke-width: 2;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  stroke-dasharray: 289.027;
  stroke-dashoffset: calc(289.027 * (1 - var(--orb-pct, 0) / 100));
  transition: stroke-dashoffset 0.08s linear;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.35));
}
.orb.indet .orb-progress,
.orb.think .orb-progress {
  stroke-dasharray: 64 225.027;
  animation: am-spin 1.15s linear infinite;
}
.orb.listen .orb-progress { stroke: #e8e8e8; }
.orb.speak .orb-progress { stroke: #ffffff; }

/* Statut vocal : ligne d'aide sous l'orbe. Couleur et taille pilotees par les
   jetons du theme (plus de #d0d0d0 en dur, qui ecrasait var(--text) et rendait
   le statut identique a la legende). Pas de troncature : les messages du JS
   vont jusqu'a 62 caracteres et portent parfois la consigne a suivre. */
#voice-status {
  margin: 0;
  max-width: min(38ch, 100%);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0.01em;
  text-wrap: balance;
  overflow-wrap: anywhere;
  min-height: 1.45em;
  transition: color 160ms ease, opacity 160ms ease;
}
/* setOrb() ecrit "" pendant la reflexion et la lecture. On ne masque pas le
   bloc (display:none ferait sauter l'orbe et sa legende) : la hauteur d'une
   ligne est reservee par min-height, donc la scene reste stable. */
/* Ecoute et lecture : l'orbe passe en couleur pleine, le statut s'aligne au lieu
   de rester gris sur l'action principale. */
#voice-view .voice-hero:has(.orb.listen) #voice-status,
#voice-view .voice-hero:has(.orb.speak) #voice-status {
  color: var(--text);
}
@media (prefers-reduced-motion: reduce) {
  #voice-status { transition: none; }
}
.orb-caption { color: #d0d0d0; }

@keyframes am-think {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-4px); }
}
@keyframes am-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes am-glow {
  0%, 100% {
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 6px 14px rgba(0, 0, 0, 0.45), 0 0 10px rgba(255, 255, 255, 0.08);
  }
  50% {
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 8px 18px rgba(0, 0, 0, 0.5), 0 0 18px rgba(255, 255, 255, 0.28);
  }
}
@keyframes am-sky {
  0%, 100% { transform: translate(calc(var(--look) * -0.3), calc(var(--look) * -1)); }
  50% { transform: translate(calc(var(--look) * 0.35), calc(var(--look) * -1.2)); }
}
@keyframes am-blink {
  0%, 88%, 92.2%, 96.4%, 100% { transform: scaleY(1); }
  90.2%, 94.4% { transform: scaleY(0.08); }
}
@keyframes am-talk {
  0%, 100% {
    width: 30%;
    height: 8%;
    border-bottom-left-radius: 60% 100%;
    border-bottom-right-radius: 100% 100%;
    transform: translateX(-50%);
  }
  50% {
    width: 36%;
    height: 16%;
    border-bottom-left-radius: 100% 100%;
    border-bottom-right-radius: 55% 100%;
    transform: translateX(-50%);
  }
}
/* Humeurs : sourire, colère, regard fixe. Le clignement et la bouche parlée restent. */
html[data-mood="stare"] .am-bot-eye,
.am-mood-stare .am-bot-eye {
  width: 32%;
  height: 32%;
}
html[data-mood="stare"] .am-bot-pupil,
.am-mood-stare .am-bot-pupil,
html[data-mood="stare"][data-voice="listen"] .task-row.running .am-bot-pupil,
html[data-mood="stare"] .task-strip[data-voice="listen"] .am-bot-pupil {
  animation: none;
  width: 58%;
  height: 58%;
  transform: translate(0, 0);
}
html[data-mood="smile"] .am-bot-eye,
.am-mood-smile .am-bot-eye {
  height: 24%;
}
html[data-mood="smile"] .am-bot-pupil,
.am-mood-smile .am-bot-pupil {
  animation: none;
  width: 36%;
  height: 36%;
  transform: translate(0, calc(var(--look) * -0.45));
}
html[data-mood="smile"] .am-bot-mouth,
.am-mood-smile .am-bot-mouth {
  opacity: 1;
  width: 34%;
  height: 14%;
  bottom: 16%;
  border-bottom: 2px solid rgba(240, 244, 250, 0.95);
  border-bottom-left-radius: 90% 100%;
  border-bottom-right-radius: 90% 100%;
  transform: translateX(-50%) scaleY(1);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7));
}
/* Réflexion : sourcils tirés, regard haut, lèvre pincée. */
html[data-mood="think"] .am-bot-mouth,
.orb.think .am-bot-mouth,
.task-strip[data-voice="think"] .am-bot-mouth {
  opacity: 0.85;
  width: 18%;
  height: 6%;
  border-bottom-width: 1.5px;
  border-bottom-color: rgba(255, 255, 255, 0.75);
  transform: translateX(-50%) rotate(-6deg);
}
html[data-mood="think"] .am-bot-face,
.orb.think .am-bot-face {
  animation: am-think-sway 3.4s ease-in-out infinite;
}
/* Tristesse : paupières basses, pupilles descendues, bouche tombante. */
html[data-mood="sad"] .am-bot-eye,
.am-mood-sad .am-bot-eye {
  height: 20%;
  transform: translateY(4%) rotate(-6deg);
}
html[data-mood="sad"] .am-bot-eye:nth-of-type(2) {
  transform: translateY(4%) rotate(6deg);
}
html[data-mood="sad"] .am-bot-pupil,
.am-mood-sad .am-bot-pupil {
  animation: none;
  width: 44%;
  height: 40%;
  transform: translate(0, calc(var(--look-y) * 0.8));
  background: radial-gradient(circle at 32% 28%, #2e2e36 0%, #0e0e12 45%, #000 100%);
}
html[data-mood="sad"] .am-bot-mouth,
.am-mood-sad .am-bot-mouth {
  opacity: 0.9;
  animation: none;
  width: 30%;
  height: 12%;
  bottom: 13%;
  border: 0;
  border-top: 1.5px solid rgba(230, 234, 240, 0.9);
  border-top-left-radius: 80% 100%;
  border-top-right-radius: 80% 100%;
  transform: translateX(-50%);
}
html[data-mood="sad"] .am-bot-orb .am-bot-mouth,
.am-mood-sad .am-bot-orb .am-bot-mouth {
  border-top-width: 2px;
}
html[data-mood="anger"] .am-bot-eye,
.am-mood-anger .am-bot-eye {
  height: 18%;
}
html[data-mood="anger"] .am-bot-pupil,
.am-mood-anger .am-bot-pupil {
  animation: none;
  width: 62%;
  height: 62%;
  background: #d23a3a;
  transform: translate(0, 15%);
}
html[data-mood="anger"] .am-bot-mouth,
.am-mood-anger .am-bot-mouth {
  opacity: 1;
  animation: none;
  width: 28%;
  height: 14%;
  bottom: 14%;
  border: 0;
  border-top: 1.5px solid #f4f4f4;
  border-radius: 50% 50% 0 0;
  transform: translateX(-50%);
}
html[data-mood="anger"] .am-bot-orb .am-bot-mouth,
html[data-mood="anger"] .am-bot-chat .am-bot-mouth,
.am-mood-anger .am-bot-orb .am-bot-mouth,
.am-mood-anger .am-bot-chat .am-bot-mouth {
  border-top-width: 2px;
}
html[data-voice="speak"] .am-bot-mouth,
.orb.speak .am-bot-mouth,
.task-strip[data-voice="speak"] .am-bot-mouth {
  opacity: 1;
  width: 32%;
  height: 10%;
  bottom: 18%;
  border: 0;
  border-bottom: 1.5px solid #f4f4f4;
  border-radius: 0;
  border-bottom-left-radius: 80% 100%;
  border-bottom-right-radius: 80% 100%;
  animation: am-talk 1.35s ease-in-out infinite;
}
html[data-voice="speak"] .am-bot-orb .am-bot-mouth,
html[data-voice="speak"] .am-bot-chat .am-bot-mouth,
.orb.speak .am-bot-orb .am-bot-mouth,
.orb.speak .am-bot-chat .am-bot-mouth {
  border-bottom-width: 2px;
}

@keyframes am-spin { to { transform: rotate(270deg); } }

@media (prefers-reduced-motion: reduce) {
  .am-bot-pupil,
  .am-bot-eye,
  .am-bot-think i,
  .am-bot-face,
  .am-bot-mouth,
  .task-strip.indet .task-ring-prog,
  .orb.indet .orb-progress,
  .orb.think .orb-progress { animation: none !important; }
  .orb.think .am-bot-think i,
  .msg.pending .am-bot-think i,
  .task-row.running .am-bot-think i,
  .task-strip.live:not([data-voice="listen"]):not([data-voice="speak"]) .am-bot-think i { opacity: 1; }
  .am-bot-pupil { transform: translate(0, calc(var(--look) * -1)); }
  .orb.speak .am-bot-mouth,
  .task-strip[data-voice="speak"] .am-bot-mouth,
  html[data-voice="speak"] .task-row.running .am-bot-mouth {
    opacity: 1;
    transform: translateX(-50%);
    width: 32%;
    height: 12%;
    border-radius: 0;
    border-bottom-left-radius: 80% 100%;
    border-bottom-right-radius: 80% 100%;
    background: transparent;
  }
}

/* Téléphone : une colonne, contrôles entiers, rien sous la barre d'onglets. */
@media (max-width: 960px) {
  #mobile-menu,
  #app-view.collapsed #mobile-menu {
    display: none;
  }

  #voice-view .voice-stage {
    padding: 6px 8px 8px;
    gap: 6px;
  }
  #voice-view .voice-hero {
    flex: 1 1 auto;
    min-height: 0;
    gap: 4px;
    justify-content: center;
  }
  #voice-view #voice-status {
    font-size: 13px;
    line-height: 1.35;
    max-width: min(36ch, 100%);
  }
  #voice-view .transcript {
    width: 100%;
    max-width: 100%;
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
    padding: 2px 2px 6px;
  }
  #voice-view .voice-stage.lecons-open .lecons-panel {
    width: 100%;
    max-width: 100%;
    max-height: min(30dvh, 220px);
    overflow: auto;
    flex: 0 1 auto;
  }
  #voice-view #voice-type.voice-composer {
    width: calc(100% - 4px);
    max-width: calc(100% - 4px);
    margin: 0 auto 2px;
    padding: 8px 8px 6px;
    border-radius: 22px;
    flex: 0 0 auto;
  }
  #voice-view #voice-type.voice-composer .voice-type-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    min-width: 0;
    min-height: 34px;
    overflow: visible;
  }
  #voice-view #voice-type.voice-composer .voice-scroll {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-mask-image: none;
    mask-image: none;
  }
  #voice-view #voice-type.voice-composer .voice-scroll::-webkit-scrollbar { display: none; }
  #voice-view #voice-type .talk-btn {
    flex: 0 0 auto;
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }
  #voice-view #voice-type #mic-mute-btn {
    flex: 0 0 auto;
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
  }
  #voice-view #voice-type #lecons-toggle {
    flex: 0 0 auto;
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }
  #voice-view #voice-type #stt-lang {
    flex: 0 0 auto;
    width: 78px;
    min-width: 78px;
    max-width: 78px;
    height: 34px;
    padding: 0 16px 0 8px;
    font-size: 12px;
  }
  #voice-view #voice-type .voice-settings-wrap {
    margin-left: 0;
    flex: 0 0 auto;
  }
  #voice-view #voice-type .voice-settings-toggle {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    gap: 0;
    font-size: 0;
    background: #2a2a2a;
    color: #f2f2f2;
    border: 1px solid rgba(255, 255, 255, 0.12);
  }
  #voice-view #voice-type .voice-settings-toggle svg { display: none; }
  #voice-view #voice-type .voice-settings-toggle::before {
    content: "⚙";
    font-size: 16px;
    line-height: 1;
  }
  #voice-view #voice-type.voice-composer #voice-send {
    position: static;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    margin: 0;
    z-index: 1;
  }

  #chat-view #composer.dock {
    min-width: 0;
    max-width: calc(100% - 16px);
    padding: 10px 8px 8px;
    box-sizing: border-box;
  }
  #composer .mode-wrap { margin-left: 0; }
  #composer #send-btn,
  #composer #stop-btn {
    margin-left: auto;
    position: sticky;
    right: 0;
    z-index: 1;
  }
  #composer .chat-bar {
    flex-wrap: nowrap;
    gap: 2px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #composer .chat-bar::-webkit-scrollbar { display: none; }
  #composer .chat-bar .icon-btn,
  #composer .chat-bar .plus-btn,
  #composer #chat-talk,
  #composer #send-btn,
  #composer #stop-btn {
    width: 34px;
    min-width: 34px;
    height: 34px;
  }
  #composer .chat-mode { padding: 0 8px; font-size: 13px; }

  #imagine-view .imagine-home {
    width: min(820px, calc(100% - 20px));
  }
  #imagine-view .imagine-home h2 {
    text-wrap: balance;
    font-size: clamp(22px, 6.4vw, 28px);
    padding: 0 8px;
    max-width: 100%;
  }
  #imagine-view #imagine-form {
    min-width: 0;
    max-width: calc(100% - 16px);
    box-sizing: border-box;
  }
  #imagine-form .composer-bar {
    min-width: 0;
    max-width: 100%;
  }
  #imagine-form .composer-scroll {
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent);
  }
  #imagine-form #imagine-go { flex: 0 0 auto; }
  #imagine-form #ratio-btn span,
  #imagine-form #ratio-label { display: inline; }
  #imagine-form #kind-switch { order: 0; flex: 0 0 auto; }
  #imagine-form #kind-switch button { padding: 4px 6px; font-size: 12px; }
  #feed-grid.feed-grid > .feed-card,
  .feed-grid > .feed-card,
  .feed-grid > .feed-card.gen-card {
    flex: none;
    width: 100%;
    max-width: 100%;
  }

  #library-view .lib-bar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "back search"
      "tools tools"
      "filters filters"
      "views views";
    align-items: center;
    gap: 8px;
    padding: 8px 10px 6px;
  }
  #library-view #lib-back { grid-area: back; }
  #library-view .lib-search {
    grid-area: search;
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  #library-view .lib-tools {
    grid-area: tools;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin: 0;
    gap: 8px;
  }
  #library-view .lib-filters {
    grid-area: filters;
    order: 0;
    flex: none;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 6px;
    scrollbar-width: none;
    padding-bottom: 1px;
  }
  #library-view .lib-filters::-webkit-scrollbar { display: none; }
  #library-view .lib-views {
    grid-area: views;
    order: 0;
    flex-basis: auto;
    width: 100%;
    max-width: 100%;
  }
  #library-view .lib-filters button,
  #library-view .lib-tools button,
  #library-view .lib-views button {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 13px;
  }
}

@media (max-width: 400px) {
  #imagine-form .composer-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "kind kind" "scroll go";
    align-items: center;
    gap: 6px;
  }
  #imagine-form #kind-switch {
    grid-area: kind;
    justify-self: start;
    width: auto;
    max-width: 100%;
    order: 0;
  }
  #imagine-form .composer-scroll { grid-area: scroll; order: 0; }
  #imagine-form #imagine-go { grid-area: go; order: 0; }
}
@media (max-width: 360px) {
  #voice-view #voice-type #lecons-toggle {
    width: 34px;
    min-width: 34px;
    padding: 0;
    font-size: 0;
    justify-content: center;
  }
  #voice-view #voice-type #lecons-toggle::before {
    content: "";
    width: 15px;
    height: 15px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M6 4.5h9.2A2.8 2.8 0 0 1 18 7.3V20H8.2A2.2 2.2 0 0 0 6 22.2V4.5zm2.2 1.6v11.2H16.2V7.3c0-.6-.5-1.2-1.2-1.2H8.2z'/></svg>") center / contain no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M6 4.5h9.2A2.8 2.8 0 0 1 18 7.3V20H8.2A2.2 2.2 0 0 0 6 22.2V4.5zm2.2 1.6v11.2H16.2V7.3c0-.6-.5-1.2-1.2-1.2H8.2z'/></svg>") center / contain no-repeat;
  }
  #voice-view #voice-type #stt-lang {
    width: 68px;
    min-width: 68px;
    max-width: 68px;
  }
}


/* TikTok : liste des vidéos publiques (Display API, lecture seule) */
.tiktok-videos { margin-top: 10px; }
.tiktok-videos-title {
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.tiktok-video-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 330px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}
.tiktok-video {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.tiktok-video:hover { border-color: rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .06); }
.tiktok-video img {
  flex: none;
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  background: #111;
}
.tiktok-video-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tiktok-video-meta strong {
  font-size: 11.5px;
  line-height: 1.3;
  font-weight: 600;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tiktok-video-meta small { font-size: 9.5px; color: var(--muted); }
@media (max-width: 640px) { .tiktok-video-list { grid-template-columns: 1fr; } }
