*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Loop brand palette */
  --header-bg:      #1a1b1e;
  --header-border:  rgba(255,255,255,0.07);
  --header-h:       56px;

  /* Accent — Loop lime */
  --accent:         #9BC20A;
  --accent-hover:   #8aae09;
  --accent-glow:    rgba(155, 194, 10, 0.18);
  --accent-ring:    rgba(155, 194, 10, 0.45);

  /* Surfaces */
  --bg:             #f4f5f7;
  --surface:        #ffffff;
  --surface-hi:     #f0f2f5;
  --border:         #e2e6ea;

  /* Text */
  --text:           #111827;
  --text-muted:     #6b7280;
  --text-faint:     #9ca3af;

  /* Header text */
  --hdr-text:       #ffffff;
  --hdr-muted:      rgba(255,255,255,0.45);

  /* Bubbles */
  --user-bg:        #1a1b1e;
  --vera-bg:        rgba(255,255,255,0.95);
  --vera-bdr:       rgba(226,230,234,0.8);

  /* Chat glass panel */
  --chat-w:         380px;
  --chat-glass-bg:  rgba(248, 249, 250, 0.88);
  --chat-transition: 0.38s cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --composer-bottom: 20px;
  --composer-side:   24px;

  --r:              16px;
  --r-sm:           10px;
  --font:           'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-float:   0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  background: #111;
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ═══ Header (fixed, always on top) ══════════════════════════════════════ */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  z-index: 100;
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 100%;
}

.header-identity { display: flex; align-items: center; gap: 14px; }

.header-loop-logo {
  height: 28px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.header-sep {
  width: 1px; height: 22px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}

.header-logo {
  width: 34px; height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(155,194,10,0.5);
}
.header-logo img {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(1.4);
  transform-origin: center 40%;
}

.header-titles { display: flex; flex-direction: column; gap: 1px; }
.header-name {
  font-size: 13px; font-weight: 600;
  color: var(--hdr-text);
  letter-spacing: -0.01em; line-height: 1.2;
}
.header-sub {
  font-size: 10.5px; color: var(--hdr-muted);
  letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.2;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.status-badge {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 100px;
  padding: 4px 12px 4px 8px;
  font-size: 12px; color: var(--hdr-muted);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transition: background 0.4s, box-shadow 0.4s;
  flex-shrink: 0;
}
.status-dot.online  { background: var(--accent); box-shadow: 0 0 0 3px rgba(155,194,10,0.2); }
.status-dot.loading { background: #CDE916; box-shadow: 0 0 0 3px rgba(205,233,22,0.15); animation: pulse 1.2s ease-in-out infinite; }
.status-dot.error   { background: #ef4444; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.icon-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--hdr-muted);
  cursor: pointer; padding: 7px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.icon-btn:hover:not(:disabled) {
  color: var(--hdr-text);
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.18);
}
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn.active {
  color: var(--accent) !important;
  background: rgba(155,194,10,0.14) !important;
  border-color: rgba(155,194,10,0.35) !important;
}

/* ═══ Avatar — occupe la zone gauche (à côté du chat panel) ═════════════ */

.avatar-bg {
  position: fixed;
  top: var(--header-h);
  left: 0;
  /* Laisse de la place pour le chat panel — rempli en plein écran quand caché */
  right: var(--chat-w);
  bottom: 0;
  z-index: 0;
  background: #1a1b1e;
  overflow: hidden;
  transition: right var(--chat-transition);
}

/* Quand le chat est masqué, l'avatar remplit tout l'écran */
.app.chat-hidden .avatar-bg {
  right: 0;
}

#avatarVideo {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Stage overlay (loading / error state) ─────────────────────────────── */

.stage-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(26, 27, 30, 0.92);
  backdrop-filter: blur(8px);
  z-index: 5;
  transition: opacity 0.5s ease;
}
.stage-overlay.hidden { opacity: 0; pointer-events: none; }

/* ── Loading sub-state (spinner + message) ────────────────────────────── */

.overlay-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.overlay-loading p {
  font-size: 13px; color: rgba(255,255,255,0.55);
  letter-spacing: 0.01em;
}

/* ── Start sub-state (shown once avatar is connected) ─────────────────── */

.overlay-start {
  display: none; /* shown by JS */
  flex-direction: column;
  align-items: center;
  gap: 18px;
  animation: fade-up 0.35s ease-out;
}

.overlay-start-avatar {
  width: 76px; height: 76px;
  border-radius: 50%;
  overflow: hidden;
  border: 2.5px solid var(--accent);
  box-shadow: 0 0 0 6px rgba(155,194,10,0.15);
}
.overlay-start-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(1.4);
  transform-origin: center 40%;
}

.overlay-start-name {
  font-size: 22px; font-weight: 700;
  color: #fff; letter-spacing: -0.02em; line-height: 1;
}
.overlay-start-role {
  font-size: 11px; font-weight: 500;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-top: -10px;
}

.overlay-start-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-family: var(--font);
  font-size: 14px; font-weight: 600;
  padding: 13px 24px;
  border-radius: 100px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(155,194,10,0.4);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  margin-top: 4px;
}
.overlay-start-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.03);
  box-shadow: 0 6px 28px rgba(155,194,10,0.5);
}
.overlay-start-btn:active { transform: scale(0.97); }

.overlay-text-only {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  margin-top: -6px;
  transition: color 0.15s;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.overlay-text-only:hover { color: rgba(255,255,255,0.75); }

.loader-ring {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Talking aura — full-screen inset glow when Vera speaks ──────────────── */

.talking-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  box-shadow: inset 0 0 80px rgba(155, 194, 10, 0.0);
  transition: opacity 0.5s ease, box-shadow 0.5s ease;
}
.talking-ring.active {
  opacity: 1;
  box-shadow: inset 0 0 80px rgba(155, 194, 10, 0.22);
  animation: aura-pulse 2.5s ease-in-out infinite;
}
@keyframes aura-pulse {
  0%, 100% { box-shadow: inset 0 0 60px rgba(155, 194, 10, 0.15); }
  50%       { box-shadow: inset 0 0 110px rgba(155, 194, 10, 0.38); }
}

/* ── Identity bar — above composer, shows name + speaking state ──────────── */

.avatar-infobar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px 8px 10px;
  background: rgba(18, 18, 22, 0.62);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  pointer-events: none;
  animation: fade-up 0.25s ease-out;
}

.infobar-identity { display: flex; align-items: center; gap: 9px; }

.infobar-avatar-img {
  width: 32px; height: 32px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid rgba(155,194,10,0.6);
  flex-shrink: 0;
}
.infobar-avatar-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(1.4);
  transform-origin: center 40%;
}

.infobar-name  { font-size: 13px; font-weight: 600; color: #fff; letter-spacing: -0.01em; line-height: 1.2; }
.infobar-role  {
  font-size: 10px; color: rgba(255,255,255,0.45);
  letter-spacing: 0.05em; text-transform: uppercase; line-height: 1.2; margin-top: 1px;
}

.speaking-badge {
  display: flex; align-items: center; gap: 6px;
  background: rgba(155,194,10,0.18);
  border: 1px solid rgba(155,194,10,0.35);
  border-radius: 100px;
  padding: 4px 10px 4px 8px;
  font-size: 11px; font-weight: 500;
  color: #d4f05a;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.speaking-badge.visible { opacity: 1; }

.speak-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: pulse 1s ease-in-out infinite;
}

/* ═══ Chat panel — sidebar droite (desktop) / drawer bas (mobile) ════════ */

.chat-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 0;
  width: var(--chat-w);
  z-index: 20;

  /* Sidebar claire avec légère transparence — pas d'overlay sur l'avatar */
  background: rgba(247, 248, 250, 0.97);
  border-left: 1px solid var(--border);
  box-shadow: -2px 0 16px rgba(0,0,0,0.06);

  display: flex;
  flex-direction: column;
  overflow: hidden;

  transition:
    transform var(--chat-transition),
    opacity 0.25s ease;
}

.chat-panel.hidden {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

/* Drag handle — rendered by CSS, shown only on mobile */
.drawer-handle {
  display: none;
  width: 40px; height: 4px;
  background: rgba(0,0,0,0.12);
  border-radius: 2px;
  margin: 12px auto 4px;
  flex-shrink: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 2px; }

/* Mobile backdrop — tap outside to close drawer */
.chat-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.chat-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ═══ Welcome screen ═════════════════════════════════════════════════════ */

.welcome {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0 4px;
  animation: fade-up 0.3s ease-out;
}

.welcome-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: rgba(155,194,10,0.06);
  border: 1px solid rgba(155,194,10,0.15);
  border-radius: 14px;
}
.welcome-hero-img {
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(155,194,10,0.4);
  flex-shrink: 0;
}
.welcome-hero-img img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.4); transform-origin: center 40%; }
.welcome-hero-text { display: flex; flex-direction: column; gap: 2px; }
.welcome-hero-name { font-size: 14px; font-weight: 600; color: var(--text); }
.welcome-hero-role { font-size: 11px; color: var(--text-muted); letter-spacing: 0.03em; text-transform: uppercase; }

.welcome-intro {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  padding: 0 2px;
}
.welcome-intro strong { color: var(--text); font-weight: 600; }

.chips-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
  padding: 0 2px;
}

.chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.chip {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 11.5px;
  text-align: left;
  padding: 9px 11px;
  border-radius: 11px;
  cursor: pointer;
  line-height: 1.45;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
  backdrop-filter: blur(4px);
}
.chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(255,255,255,0.9);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ═══ Packaging analysis score card ══════════════════════════════════════ */

.score-card {
  /* Aligns with the vera bubble: row-av (26px) + gap (8px) = 34px */
  margin-left: 34px;
  max-width: 320px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: fade-up 0.3s ease-out;
}

.score-card-header {
  background: #374151;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 9px 14px;
}

.score-card-body {
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-label {
  width: 136px;
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

.score-bar-track {
  flex: 1;
  height: 10px;
  background: #e5e7eb;
  border-radius: 5px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.75s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-value {
  width: 28px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ═══ Message rows ═══════════════════════════════════════════════════════ */

.row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: fade-up 0.22s ease-out;
}
.row.user { flex-direction: row-reverse; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.row-av {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.bubble {
  max-width: 86%;
  padding: 9px 13px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.row.vera .bubble {
  background: var(--vera-bg);
  border: 1px solid var(--vera-bdr);
  border-left: 2px solid var(--accent);
  border-radius: var(--r) var(--r) var(--r) 4px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(4px);
}
.row.user .bubble {
  background: var(--user-bg);
  color: #fff;
  border-radius: var(--r) var(--r) 4px var(--r);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

/* Image inside message bubbles */
.bubble .msg-image {
  display: block;
  max-width: 200px;
  max-height: 160px;
  border-radius: 10px;
  object-fit: cover;
  margin-bottom: 6px;
}
.row.user .bubble .msg-image { border: 1px solid rgba(255,255,255,0.12); }
.row.vera .bubble .msg-image { border: 1px solid var(--border); }

/* Typing dots */
.typing-dots { display: flex; gap: 4px; padding: 3px 2px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-faint);
  animation: dot-bounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.35; }
  40%            { transform: scale(1.1); opacity: 1; }
}

/* Streaming cursor */
.streaming::after {
  content: '▋';
  font-size: 11px;
  color: var(--accent);
  animation: blink 0.8s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ═══ Composer area (floating pill) ══════════════════════════════════════ */

.composer-area {
  position: fixed;
  bottom: var(--composer-bottom);
  left:  var(--composer-side);
  right: calc(var(--chat-w) + var(--composer-side));
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Smooth right-edge transition when chat panel opens/closes */
  transition: right var(--chat-transition), left var(--chat-transition);
}

/* When chat panel is hidden, expand composer to full width */
.app.chat-hidden .composer-area {
  right: var(--composer-side);
}

/* ── Image preview strip ─────────────────────────────────────────────────── */

.image-preview-strip {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(155,194,10,0.25);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  animation: fade-up 0.2s ease-out;
}
.image-preview-strip.visible { display: flex; }

.image-preview-thumb {
  width: 48px; height: 48px;
  border-radius: 8px;
  object-fit: cover;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}

.image-remove-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text-muted);
  border: none;
  color: #fff;
  font-size: 14px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.image-remove-btn:hover { background: #ef4444; }

.image-preview-label {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}

/* ── Composer pill ────────────────────────────────────────────────────────── */

.composer-pill {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1.5px solid rgba(155,194,10,0.3);
  border-radius: 22px;
  padding: 9px 9px 9px 14px;
  box-shadow: var(--shadow-float), 0 0 0 1px rgba(155,194,10,0.08);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.composer-pill:focus-within {
  border-color: rgba(155,194,10,0.6);
  box-shadow: var(--shadow-float), 0 0 0 3px rgba(155,194,10,0.12);
}

/* Icon buttons inside the composer */
.composer-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 7px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.composer-icon-btn:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-hi);
  border-color: var(--border);
}
.composer-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.mic-btn.active {
  color: #dc2626 !important;
  background: rgba(220,38,38,0.08) !important;
  border-color: rgba(220,38,38,0.25) !important;
}

.image-btn.has-image {
  color: var(--accent) !important;
  background: rgba(155,194,10,0.1) !important;
  border-color: rgba(155,194,10,0.3) !important;
}

textarea#input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
  max-height: 120px;
  overflow-y: auto;
  padding: 3px 2px;
}
textarea#input::placeholder { color: var(--text-faint); }
textarea#input:disabled { cursor: not-allowed; }

.send-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 9px;
  border-radius: 14px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 2px 10px rgba(155,194,10,0.4);
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); transform: scale(1.06); }
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; box-shadow: none; }

.composer-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  text-align: center;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ═══ Responsive — mobile (≤ 860px) ═════════════════════════════════════ */

@media (max-width: 860px) {
  /* Sur mobile : l'avatar occupe tout l'écran (le chat est un drawer bas) */
  .avatar-bg,
  .app.chat-hidden .avatar-bg {
    right: 0;
  }

  /* Chat panel becomes a bottom drawer */
  .chat-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    /* Height: visible area minus a bit, so avatar peeks above */
    height: clamp(260px, 58vh, 520px);
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.4);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.18);
    /* Drawer slides up from bottom */
    transform: translateY(0);
    /* Extra bottom padding so messages aren't hidden under the composer */
    padding-bottom: 72px;
  }

  .chat-panel.hidden {
    transform: translateY(110%);
    opacity: 0;
  }

  /* Show the drag handle on mobile */
  .drawer-handle { display: block; }

  /* Mobile backdrop is shown/hidden by JS */
  .chat-backdrop { display: block; }

  /* Composer: full-width, pinned to bottom, no float */
  .composer-area {
    left: 0;
    right: 0;
    bottom: 0;
    transition: none;
  }
  .app.chat-hidden .composer-area { right: 0; }

  .composer-pill {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    /* Safe area inset for notch phones */
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    background: rgba(255,255,255,0.92);
    box-shadow: 0 -1px 0 rgba(0,0,0,0.06);
  }

  .image-preview-strip {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .composer-hint { display: none; }

  /* Header: hide some elements to save space */
  .header-sub      { display: none; }
  .header-loop-logo { display: none; }
  .header-sep      { display: none; }

  /* Messages: bottom padding for the fixed composer */
  .messages {
    padding-bottom: 16px;
  }
}

/* ═══ App root — tracks chat-hidden state ════════════════════════════════ */

.app {
  /* Needed so .app.chat-hidden works for the composer positioning */
}
