/* ═══════════════════════════════════════════════
   Kvill — Glassmorphism Design System
   Light/Dark themes, blur panels, gradient depth
   ═══════════════════════════════════════════════ */

/* ─── Light Theme (default) ──────────────────── */

:root,
[data-theme="light"] {
  --canvas: #f0f2f7;
  --bg-glass: rgba(255, 255, 255, 0.45);
  --bg-glass-strong: rgba(255, 255, 255, 0.65);
  --bg-glass-subtle: rgba(255, 255, 255, 0.25);
  --glass-blur: 24px;
  --glass-saturate: saturate(180%);
  --bg-solid: #ffffff;
  --bg-input: rgba(0, 0, 0, 0.04);
  --bg-input-hover: rgba(0, 0, 0, 0.06);

  --dot-color: rgba(0, 0, 0, 0.07);
  --dot-size: 1px;
  --dot-gap: 24px;

  --text-0: #1a1d2e;
  --text-1: #4a4e69;
  --text-2: #8b8fa3;
  --text-3: #b0b4c4;

  --accent: #1a1a1a;
  --accent-hover: #000000;
  --accent-subtle: rgba(0, 0, 0, 0.06);
  --accent-glow: rgba(0, 0, 0, 0.12);
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --secondary: #555555;
  --secondary-subtle: rgba(0, 0, 0, 0.05);

  --border-glass: rgba(255, 255, 255, 0.5);
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.14);

  --success: #3daa5c;
  --success-bg: rgba(61, 170, 92, 0.1);
  --error: #dc4545;
  --error-bg: rgba(220, 69, 69, 0.08);
  --warning: #d09620;
  --warning-bg: rgba(208, 150, 32, 0.08);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.1);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.06);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  --specular: rgba(255, 255, 255, 0.5);

  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);

  /* ─── Sidebar (flat) ─── */
  --sidebar-bg: var(--bg-solid);
  --sidebar-bg-hover: rgba(0, 0, 0, 0.06);
  --sidebar-bg-active: rgba(0, 0, 0, 0.08);
  --sidebar-bg-selected: rgba(0, 0, 0, 0.10);
  --sidebar-bg-hover-solid: #f0f0f0;
  --sidebar-bg-selected-solid: #e6e6e6;
  --sidebar-text-primary: #1a1d2e;
  --sidebar-text-secondary: #4a4e69;
  --sidebar-text-muted: #8b8fa3;
  --sidebar-border: rgba(0, 0, 0, 0.06);
  --sidebar-divider: rgba(0, 0, 0, 0.04);
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 48px;
  --sidebar-item-height: 30px;
  --sidebar-item-radius: 6px;
  --sidebar-indent: 24px;
  --sidebar-section-gap: 2px;
}

/* ─── Dark Theme ─────────────────────────────── */

[data-theme="dark"] {
  --canvas: #111113;
  --bg-glass: rgba(24, 24, 27, 0.6);
  --bg-glass-strong: rgba(30, 30, 34, 0.75);
  --bg-glass-subtle: rgba(24, 24, 27, 0.4);
  --glass-blur: 28px;
  --glass-saturate: saturate(140%);
  --bg-solid: #18181b;
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-input-hover: rgba(255, 255, 255, 0.09);

  --dot-color: rgba(255, 255, 255, 0.04);
  --dot-size: 1px;
  --dot-gap: 24px;

  --text-0: #ececef;
  --text-1: #a1a1a8;
  --text-2: #62626a;
  --text-3: #3f3f44;

  --accent: #ffffff;
  --accent-hover: #e0e0e0;
  --accent-subtle: rgba(255, 255, 255, 0.08);
  --accent-glow: rgba(255, 255, 255, 0.14);
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --secondary: #a0a0a0;
  --secondary-subtle: rgba(255, 255, 255, 0.06);

  --border-glass: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  --success: #6dba7a;
  --success-bg: rgba(109, 186, 122, 0.12);
  --error: #e06060;
  --error-bg: rgba(224, 96, 96, 0.1);
  --warning: #e0a83a;
  --warning-bg: rgba(224, 168, 58, 0.1);

  --specular: rgba(255, 255, 255, 0.04);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.45);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.3);

  /* ─── Sidebar (flat) ─── */
  --sidebar-bg: var(--bg-solid);
  --sidebar-bg-hover: rgba(255, 255, 255, 0.08);
  --sidebar-bg-active: rgba(255, 255, 255, 0.10);
  --sidebar-bg-selected: rgba(255, 255, 255, 0.13);
  --sidebar-bg-hover-solid: #2a2a2d;
  --sidebar-bg-selected-solid: #343438;
  --sidebar-text-primary: #e4e4e7;
  --sidebar-text-secondary: #8c8c91;
  --sidebar-text-muted: #5a5a5f;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-divider: rgba(255, 255, 255, 0.04);
}

/* ─── Reset ──────────────────────────────────── */

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

html {
  background: var(--canvas);
  overflow: hidden;
  overscroll-behavior: none;
  width: 100%;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--text-1);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Dot Grid Background ────────────────────── */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--dot-color) var(--dot-size), transparent var(--dot-size));
  background-size: var(--dot-gap) var(--dot-gap);
  z-index: -1;
}

/* ─── Glass Mixin Pattern ────────────────────── */
/* Usage: apply these properties to glass panels:
   background: var(--bg-glass);
   backdrop-filter: blur(var(--glass-blur));
   -webkit-backdrop-filter: blur(var(--glass-blur));
   border: 1px solid var(--border-glass);
*/

/* Fallback for browsers without backdrop-filter */
@supports not (backdrop-filter: blur(1px)) {
  :root, [data-theme="light"] {
    --bg-glass: rgba(255, 255, 255, 0.92);
    --bg-glass-strong: rgba(255, 255, 255, 0.96);
    --glass-saturate: ;
  }
  [data-theme="dark"] {
    --bg-glass: rgba(25, 27, 45, 0.95);
    --bg-glass-strong: rgba(30, 32, 55, 0.97);
    --glass-saturate: ;
  }
}

/* ─── App Layout ─────────────────────────────── */

.app {
  display: flex;
  position: fixed;
  inset: 0;
  padding: 0;
  gap: 0;
}

/* ─── Preview Panel ──────────────────────────── */

.panel-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding: 28px;
  margin: 10px 0;
}

.preview-empty {
  text-align: center;
  position: relative;
  z-index: 1;
}

.preview-empty-icon {
  position: relative;
  width: 72px;
  height: 62px;
  margin: 0 auto 20px;
  opacity: 0.35;
  animation: float 4s ease-in-out infinite;
}

.preview-empty-icon svg { display: none; }

.preview-empty-icon::before,
.preview-empty-icon::after {
  content: '';
  position: absolute;
  width: 52px;
  height: 40px;
  border-radius: 12px;
  border: 2.5px solid var(--text-2);
}

.preview-empty-icon::before {
  top: 0;
  left: 0;
  background: var(--accent-subtle);
}

.preview-empty-icon::after {
  bottom: 0;
  right: 0;
  background: var(--accent-subtle);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.preview-empty-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-0);
  letter-spacing: 0;
  margin-bottom: 8px;
  opacity: 0.2;
}

.preview-empty-text {
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
}

/* ─── Generation Shimmer Slide ───────────────── */

.generation-shimmer {
  position: absolute;
  inset: 0;
  margin: auto;
  z-index: 2;
  overflow: hidden;
  animation: shimmer-appear 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes shimmer-appear {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.generation-shimmer.fade-out {
  animation: shimmer-disappear 0.5s ease forwards;
}

@keyframes shimmer-disappear {
  to { opacity: 0; transform: scale(0.97); }
}

.shimmer-slide {
  width: 1920px;
  height: 1080px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform-origin: 0 0;
  position: relative;
}

[data-theme="dark"] .shimmer-slide {
  background: #1a1a2e;
}

/* Layer 1: Rotating aurora gradient */
.shimmer-gradient-bg {
  position: absolute;
  inset: -40%;
  background: conic-gradient(
    from 0deg at 50% 50%,
    #667eea, #764ba2, #f093fb, #4facfe,
    #00f2fe, #43e97b, #fa709a, #fee140, #667eea
  );
  filter: blur(140px);
  opacity: 0.3;
  animation: aurora-rotate 10s linear infinite;
}

[data-theme="dark"] .shimmer-gradient-bg {
  opacity: 0.2;
}

@keyframes aurora-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Layer 2: Moving gradient for extra depth */
.shimmer-gradient-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    -45deg,
    rgba(102, 126, 234, 0.06),
    rgba(240, 147, 251, 0.08),
    rgba(79, 172, 254, 0.06),
    rgba(67, 233, 123, 0.08),
    rgba(250, 112, 154, 0.06),
    rgba(254, 225, 64, 0.04),
    rgba(102, 126, 234, 0.06)
  );
  background-size: 400% 400%;
  animation: gradient-flow 6s ease infinite;
}

@keyframes gradient-flow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Layer 3: Sweeping light band */
.shimmer-sweep {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 70%
  );
  animation: sweep-move 3s ease-in-out infinite;
}

[data-theme="dark"] .shimmer-sweep {
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
}

@keyframes sweep-move {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(130%); }
}

/* Placeholder content shapes */
.shimmer-placeholders {
  position: absolute;
  inset: 0;
  padding: 100px 140px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.shimmer-ph {
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.035);
}

[data-theme="dark"] .shimmer-ph {
  background: rgba(255, 255, 255, 0.04);
}

.shimmer-ph-title {
  width: 50%;
  height: 68px;
  border-radius: 16px;
}

.shimmer-ph-subtitle {
  width: 32%;
  height: 36px;
  border-radius: 10px;
}

.shimmer-ph-body {
  display: flex;
  gap: 48px;
  flex: 1;
  margin-top: 16px;
}

.shimmer-ph-text-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 8px;
}

.shimmer-ph-line {
  height: 22px;
  border-radius: 8px;
}

.shimmer-ph-line:nth-child(1) { width: 92%; }
.shimmer-ph-line:nth-child(2) { width: 78%; }
.shimmer-ph-line:nth-child(3) { width: 86%; }
.shimmer-ph-line:nth-child(4) { width: 64%; }
.shimmer-ph-line:nth-child(5) { width: 72%; }

.shimmer-ph-image {
  flex: 0 0 42%;
  border-radius: 16px;
}

.preview-wrapper {
  position: relative;
  z-index: 1;
  overflow: hidden;
}

#preview-shadow-host {
  display: none;
}
.mobile-preview-actions {
  display: none;
}

.preview-frame {
  border: none;
  background: var(--canvas);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  width: 1920px;
  height: 1080px;
  transform-origin: 0 0;
  overflow: hidden;
}

/* ─── Slide Navigation ───────────────────────── */

.slide-nav {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 8px 14px;
  backdrop-filter: blur(var(--glass-blur)) var(--glass-saturate);
  -webkit-backdrop-filter: blur(var(--glass-blur)) var(--glass-saturate);
  box-shadow: var(--shadow-glass), inset 0 1px 0 0 var(--specular);
  z-index: 2;
}

.slide-dots {
  display: flex;
  gap: 4px;
  max-width: 280px;
  overflow-x: auto;
  scrollbar-width: none;
}
.slide-dots::-webkit-scrollbar { display: none; }

.slide-dot {
  width: 22px;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-input);
  border: none;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
  padding: 0;
}
.slide-dot:hover { background: var(--border-hover); }
.slide-dot.active {
  background: var(--accent);
  width: 30px;
  box-shadow: 0 0 10px var(--accent-glow);
}

.chat-toolbar {
  display: flex;
  gap: 4px;
  padding: 0 12px 6px;
}

.btn-history {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
}

.btn-history:hover {
  background: var(--border-hover);
  color: var(--text-0);
}

.slide-nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slide-nav-controls button,
.btn-fullscreen {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-1);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
}

.slide-nav-controls button:hover:not(:disabled),
.btn-fullscreen:hover,
.btn-text-edit:hover {
  background: var(--border-hover);
  color: var(--text-0);
}

.btn-text-edit {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-1);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
}

.btn-text-edit.active {
  background: rgba(41, 151, 255, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.slide-nav-controls button:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.slide-info {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-2);
  font-weight: 600;
  min-width: 50px;
  text-align: center;
  letter-spacing: 0.5px;
}

/* ─── Chat Panel ─────────────────────────────── */

.panel-chat {
  width: 400px;
  min-width: 400px;
  background: var(--bg-solid);
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-chat-header {
  padding: 18px 20px 0;
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: space-between;
}

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

.logo-mark {
  display: block;
  position: relative;
  width: 28px;
  height: 24px;
  flex-shrink: 0;
}


.logo-mark::before,
.logo-mark::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--text-1);
}

.logo-mark::before {
  top: 0;
  left: 0;
  background: var(--accent-subtle);
}

.logo-mark::after {
  bottom: 0;
  right: 0;
  background: var(--accent-subtle);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--text-0);
}

/* ─── Input Screen ───────────────────────────── */

.input-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 0 20px 20px;
}

.input-screen > * {
  animation: reveal 0.5s var(--ease-spring) backwards;
}
.input-screen > :nth-child(1) { animation-delay: 0.04s; }
.input-screen > :nth-child(2) { animation-delay: 0.08s; }
.input-screen > :nth-child(3) { animation-delay: 0.12s; }
.input-screen > :nth-child(4) { animation-delay: 0.16s; }
.input-screen > :nth-child(5) { animation-delay: 0.2s; }

@keyframes reveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Starter Hero ──────────────────────────── */

.starter-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  gap: 6px;
  text-align: center;
  padding: 24px 0 8px;
  min-height: 0;
}

/* no ::before spacer — max space for demo-chat */

.starter-hero h2 {
  font-family: var(--font-display);
  font-size: clamp(17px, 5.5vw, 24px);
  font-weight: 800;
  color: var(--text-0);
  letter-spacing: 0;
  margin: 0;
  flex-shrink: 0;
  white-space: nowrap;
}

.starter-subtitle {
  font-family: var(--font-body);
  font-size: clamp(12px, 3.5vw, 13px);
  color: var(--text-2);
  margin: 0 0 4px;
  flex-shrink: 0;
  max-width: min(300px, 88vw);
  line-height: 1.4;
}


.starter-hero.hidden {
  display: none;
}

/* ═══ Demo Chat Animation ══════════════════════ */

.demo-chat {
  width: 100%;
  max-width: min(340px, 92vw);
  margin: 8px auto 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  container-type: inline-size;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.04), 0 1px 4px rgba(0,0,0,0.03);
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  text-align: left;
}

@container (max-width: 260px) {
  .demo-bubble { padding: 6px 10px; font-size: 11px; }
  .demo-bubble-ai { padding-left: 22px; }
  .demo-bubble-ai::before { left: 7px; top: 10px; width: 7px; height: 7px; }
  .demo-chip { padding: 2px 6px; font-size: 9.5px; }
  .demo-mini-slide { width: 42px; height: 28px; }
  .demo-typed-wrap { font-size: 11px; }
}

/* --- Chat Bubbles --- */

.demo-bubble {
  border-radius: 12px;
  padding: 8px 12px;
  opacity: 0;
  transform: translateY(10px);
  transition: none;
  max-width: 92%;
  font-size: 12.5px;
  line-height: 1.4;
  text-align: left;
}

.demo-bubble.show {
  animation: demoBubbleIn 0.4s var(--ease-spring) both;
}

.demo-bubble-user {
  align-self: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.demo-bubble-ai {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  position: relative;
  padding-left: 26px;
}

[data-theme="dark"] .demo-bubble-ai {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* AI avatar dot */
.demo-bubble-ai::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 13px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), #8b5cf6);
  box-shadow: 0 0 6px rgba(59,130,246,0.3);
}

@keyframes demoBubbleIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- File Chips (attachments) --- */

.demo-files {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin-bottom: 6px;
  overflow: hidden;
}

.demo-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--canvas);
  border: 1px solid var(--border);
  font-size: 10.5px;
  color: var(--text-1);
  opacity: 0;
  transform: translateY(6px) scale(0.92);
}

.demo-chip.show {
  animation: demoChipIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--i) * 0.13s);
}

.demo-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.demo-chip-name {
  font-family: var(--font-body);
  white-space: nowrap;
  font-weight: 500;
}

@keyframes demoChipIn {
  from { opacity: 0; transform: translateY(6px) scale(0.92); }
  65%  { opacity: 1; transform: translateY(-2px) scale(1.02); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Typewriter Text --- */

.demo-typed-wrap {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-0);
  line-height: 1.4;
  min-height: 16px;
}

.demo-typed {
  white-space: pre-wrap;
}

.demo-caret {
  display: inline-block;
  width: 1.5px;
  height: 14px;
  background: var(--accent-blue);
  margin-left: 1px;
  vertical-align: text-bottom;
  opacity: 0;
}

.demo-caret.blink {
  animation: demoBlink 0.55s step-end infinite;
}

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

/* --- AI Thinking Dots --- */

.demo-thinking {
  display: none;
  gap: 4px;
  padding: 2px 0;
}

.demo-thinking.show {
  display: flex;
}

.demo-think-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-2);
  opacity: 0;
}

.demo-thinking.show .demo-think-dot {
  animation: demoDotPulse 1.2s ease-in-out infinite;
  animation-delay: calc(var(--d) * 0.15s);
}

@keyframes demoDotPulse {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.2; }
  40% { transform: scale(1); opacity: 1; }
}

/* --- Mini Slides (result) --- */

.demo-slides-row {
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(4px);
  margin-top: 8px;
}

.demo-slides-row.show {
  animation: demoSlidesIn 0.4s var(--ease-spring) both;
}

.demo-mini-slide {
  width: 50px;
  height: 34px;
  border-radius: 5px;
  background: var(--canvas);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  opacity: 0;
  transform: scale(0.9);
}

.demo-slides-row.show .demo-mini-slide {
  animation: demoCardPop 0.35s var(--ease-spring) both;
  animation-delay: calc(var(--s) * 0.1s);
}

.demo-ms-bar {
  width: 55%;
  height: 4px;
  border-radius: 2px;
  background: var(--text-3);
  opacity: 0.45;
}

.demo-ms-line {
  height: 3px;
  border-radius: 1.5px;
  background: var(--border);
}

.demo-ms-chart {
  flex: 1;
  border-radius: 3px;
  background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(139,92,246,0.06));
  border: 1px solid rgba(59,130,246,0.08);
}

@keyframes demoSlidesIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes demoCardPop {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* --- Fade-out entire chat --- */

.demo-chat.fade-out {
  animation: demoFadeOut 0.5s var(--ease) forwards;
}

@keyframes demoFadeOut {
  to { opacity: 0; transform: translateY(-4px) scale(0.98); }
}

/* --- Paused state --- */

.starter-hero.hidden .demo-chat {
  display: none;
}

/* --- Accessibility --- */

@media (prefers-reduced-motion: reduce) {
  .demo-bubble.show,
  .demo-chip.show,
  .demo-slides-row.show,
  .demo-slides-row.show .demo-mini-slide {
    animation-duration: 0.15s;
    animation-timing-function: ease;
  }
  .demo-thinking.show .demo-think-dot {
    animation: none;
    opacity: 0.6;
  }
  .demo-caret.blink {
    animation: none;
    opacity: 1;
  }
  .demo-chat.fade-out {
    animation-duration: 0.15s;
  }
}

/* ─── Textarea (source + chat) ───────────────── */

textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.65;
  resize: none;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
  min-height: 100px;
}
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  background: var(--bg-input-hover);
}
textarea::placeholder { color: var(--text-2); }

/* ─── Primary Button ─────────────────────────── */

.btn-primary {
  margin-top: 10px;
  padding: 13px 20px;
  background: var(--accent);
  color: var(--canvas);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
  letter-spacing: 0;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 24px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─── Generation Progress ────────────────────── */

.gen-progress {
  margin-top: 10px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  animation: reveal 0.3s var(--ease-spring);
}

.gen-progress-bar {
  height: 3px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}

.gen-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.4s ease;
  box-shadow: 0 0 12px var(--accent-glow);
  animation: progress-glow 2s ease-in-out infinite;
}

@keyframes progress-glow {
  0%, 100% { box-shadow: 0 0 8px var(--accent-glow); }
  50% { box-shadow: 0 0 24px var(--accent-glow); }
}

.gen-progress-text {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gen-progress-text::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

.gen-timer {
  font-size: 11px;
  color: var(--text-2);
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  margin-left: 2px;
}

.shimmer-msg {
  position: relative;
  overflow: hidden;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: rgba(245, 245, 248, 0.92) !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  display: flex !important;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Mini progress bar inside shimmer-msg */
.shimmer-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
  border-radius: 2px 2px 0 0;
  overflow: hidden;
}
.shimmer-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.6s ease;
  border-radius: 2px;
}
/* Phase: done — fill progress green */
.shimmer-progress-fill.done {
  background: var(--success, #22c55e);
  width: 100% !important;
}
[data-theme="dark"] .shimmer-msg {
  background: rgba(38, 38, 44, 0.92) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.shimmer-timer {
  font-size: 12px;
  color: var(--text-2);
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.shimmer-trail {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  margin-top: 4px;
}
.trail-step {
  font-size: 11px;
  color: var(--text-3);
  opacity: 0;
  line-height: 1.3;
  animation: trail-fade-in 0.3s ease-out forwards;
}

@keyframes trail-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 0.5; transform: translateY(0); }
}

/* ─── Text Shimmer Animation ────────────────────── */

.text-shimmer {
  display: block;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.5;
  background: linear-gradient(
    90deg,
    #7b7f94 0%,
    #7b7f94 35%,
    var(--text-0) 50%,
    #7b7f94 65%,
    #7b7f94 100%
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: text-shimmer 2s ease-in-out infinite;
}
[data-theme="dark"] .text-shimmer {
  background: linear-gradient(
    90deg,
    #8e8e96 0%,
    #8e8e96 35%,
    #f0f0f3 50%,
    #8e8e96 65%,
    #8e8e96 100%
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

@keyframes text-shimmer {
  0% { background-position: 100% center; }
  100% { background-position: 0% center; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.btn-cancel {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  align-self: flex-start;
}
.btn-cancel:hover {
  border-color: var(--error);
  color: var(--error);
}

/* Access restriction banner */
.access-banner {
  margin-top: 16px;
  padding: 14px 20px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

/* ─── Chat Screen ────────────────────────────── */

#chat-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 20px 20px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 8px 8px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ─── Chat Messages ──────────────────────────── */

.chat-msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.45;
  max-width: 80%;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: msg-in 0.3s var(--ease-spring);
  position: relative;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
  background: var(--bg-input);
  color: var(--text-0);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  font-weight: 500;
  white-space: pre-wrap;
  border: 1px solid var(--border);
}

.chat-msg.ai {
  background: var(--bg-glass-strong);
  color: var(--text-0);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

:root .chat-msg.ai,
[data-theme="light"] .chat-msg.ai {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .chat-msg.ai {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.chat-msg.ai p { margin: 0 0 3px 0; }
.chat-msg.ai p:last-child { margin-bottom: 0; }
.chat-msg.ai strong { font-weight: 600; }
.chat-msg.ai em { font-style: italic; }
.chat-msg.ai code { background: rgba(0,0,0,0.1); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.chat-msg.ai ul, .chat-msg.ai ol { margin: 2px 0; padding-left: 18px; }
.chat-msg.ai li { margin-bottom: 1px; }
.chat-msg.ai h1, .chat-msg.ai h2, .chat-msg.ai h3, .chat-msg.ai h4 { margin: 4px 0 2px 0; font-size: 13px; font-weight: 600; }

.chat-msg.system {
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  text-align: center;
  align-self: center;
  padding: 4px 0;
}

.confirm-generate-wrapper {
  display: flex;
  align-self: flex-start;
  padding: 0 0 4px;
}
.confirm-generate-btn {
  background: var(--text-1);
  color: var(--canvas);
  border: none;
  border-radius: 12px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.confirm-generate-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.03);
}
.confirm-generate-btn:active {
  transform: scale(0.97);
}

/* ─── Queue Status Badges ────────────────────── */

.queue-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 500;
}

.queue-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.queue-status.pending {
  color: var(--text-2);
}
.queue-status.pending .queue-status-dot {
  background: var(--text-3);
}

.queue-status.processing {
  color: var(--accent);
}
.queue-status.processing .queue-status-dot {
  background: var(--accent);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.queue-status.done {
  color: var(--success);
}
.queue-status.done .queue-status-dot {
  background: var(--success);
}

.queue-status.error {
  color: var(--error);
}
.queue-status.error .queue-status-dot {
  background: var(--error);
}

.queue-status.cancelled {
  color: var(--text-3);
  text-decoration: line-through;
}

/* Queue status inside user bubble — light bg in both themes */
.chat-msg.user .queue-status {
  display: inline-flex;
  width: fit-content;
  padding: 4px 10px;
  margin-top: 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-input);
}

.chat-msg.user .queue-status.pending {
  color: var(--text-2);
}
.chat-msg.user .queue-status.pending .queue-status-dot {
  background: var(--text-3);
}

.chat-msg.user .queue-status.processing {
  color: var(--accent-blue);
}
.chat-msg.user .queue-status.processing .queue-status-dot {
  background: var(--accent-blue);
}

.chat-msg.user .queue-status.done {
  color: #16a34a;
}
.chat-msg.user .queue-status.done .queue-status-dot {
  background: #16a34a;
}

.chat-msg.user .queue-status.error {
  color: #dc2626;
}
.chat-msg.user .queue-status.error .queue-status-dot {
  background: #dc2626;
}

/* Queue action buttons */
.queue-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.queue-action-btn {
  padding: 2px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.queue-action-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-1);
  background: var(--bg-input);
}
.queue-action-btn.cancel:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ─── Typing Indicator ───────────────────────── */

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  align-self: flex-start;
  background: var(--bg-glass-strong);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  animation: msg-in 0.3s var(--ease-spring);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-2);
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.32s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-7px); opacity: 1; }
}

/* ─── Quick Actions ──────────────────────────── */

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.action-chip {
  padding: 5px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.action-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

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

.composer {
  display: flex;
  flex-direction: column;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}

/* Drag & drop highlight (global — full page) */
body.drag-over-global::after {
  content: 'Перетащите файл сюда';
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  pointer-events: none;
  border: 3px dashed rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  margin: 12px;
}

/* Push composer to bottom in input screen */
.input-screen > .composer {
  margin-top: auto;
}

/* Plan mode toggle button */
/* Plan mode temporarily disabled */
#plan-mode-btn {
  display: none !important;
}

.plan-mode-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

#plan-mode-btn.active,
.plan-mode-btn-sync.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.plan-mode-btn-sync {
  display: none !important;
}

/* Plan content inside chat message */
.plan-in-chat {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.plan-in-chat .plan-line {
  padding: 2px 0;
  animation: reveal 0.3s var(--ease-spring) backwards;
}

.plan-actions-inline {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.plan-actions-inline .btn-primary {
  margin-top: 0;
  padding: 10px 20px;
  font-size: 13px;
}

.plan-actions-inline .btn-cancel {
  padding: 10px 14px;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  background: var(--bg-input-hover);
}

.composer-textarea {
  flex: none;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 14px 16px 0;
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.65;
  resize: none;
  outline: none;
  min-height: 44px;
  max-height: 200px;
  transition: none;
}
.composer-textarea:focus {
  border-color: transparent;
  box-shadow: none;
  background: transparent;
}
.composer-textarea::placeholder {
  color: var(--text-2);
  transition: opacity 0.3s ease;
}
.composer-textarea.placeholder-fade::placeholder {
  opacity: 0;
}

.chat-composer-textarea {
  min-height: 36px;
  max-height: 120px;
  padding: 10px 16px 0;
}

/* Composer toolbar */
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 6px 8px;
  gap: 4px;
}

.composer-toolbar-left {
  display: flex;
  align-items: center;
  gap: 2px;
}

.composer-tool-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
}
.composer-tool-btn:hover {
  background: var(--accent-subtle);
  color: var(--text-0);
}
.composer-tool-btn.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.composer-tool-btn:has(.composer-tool-label) {
  width: auto;
  padding: 0 8px;
  gap: 4px;
}

.composer-tool-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}

.composer-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Model button label (SVG dots indicator or text) */
.model-btn-label {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
/* Auto-width for text model labels */
#model-btn-start, #model-btn-chat {
  width: auto;
  padding: 0 8px;
}

.model-btn-label svg {
  width: 16px;
  height: 16px;
}

.model-btn-wrapper {
  position: relative;
}

/* Model picker — compact, centered above the button */
.picker-dropdown.model-picker {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: 220px;
  min-width: 220px;
  padding: 10px;
  animation: reveal-centered 0.2s var(--ease-spring);
}

@keyframes reveal-centered {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.composer-send-btn {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: var(--canvas);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.composer-send-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}
.composer-send-btn:active { transform: translateY(0); }
.composer-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.composer-send-btn.uploading-in-progress {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.composer-send-btn.is-stop {
  /* Same black style, just icon changes to stop square */
}

/* File chips */
.composer-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px 0;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  background: var(--accent-subtle);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-1);
  animation: reveal 0.2s var(--ease-spring);
}

.file-chip-icon {
  display: flex;
  color: var(--text-2);
}

.file-chip-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip-remove {
  width: 18px;
  height: 18px;
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  transition: all 0.15s var(--ease);
  padding: 0;
}
.file-chip-remove:hover {
  background: var(--error-bg);
  color: var(--error);
}

/* File chips inside sent messages */
.msg-file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
/* Light theme: user msg bg is dark (#1a1a1a) → chip uses white-based colors */
.msg-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  max-width: 100%;
  transition: all 0.25s var(--ease);
}
.msg-file-chip-icon {
  flex-shrink: 0;
  display: flex;
  opacity: 0.5;
}
.msg-file-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.msg-file-chip-ext {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 5px;
  border-radius: 4px;
}
.msg-file-chip-info {
  font-size: 9px;
  opacity: 0.45;
  white-space: nowrap;
}
.msg-file-chip-download {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  opacity: 0.4;
  margin-left: 2px;
  transition: opacity 0.25s var(--ease);
}
/* Downloadable chip — single unified hover */
.msg-file-chip.downloadable {
  cursor: pointer;
}
.msg-file-chip.downloadable:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.3);
}
.msg-file-chip.downloadable:hover .msg-file-chip-icon { opacity: 0.8; }
.msg-file-chip.downloadable:hover .msg-file-chip-download { opacity: 0.9; }
.msg-file-chip.downloadable:active {
  background: rgba(255,255,255,0.25);
  transform: scale(0.97);
}
/* Extension badges — light theme (user msg bg dark) */
.file-ext-pdf { background: rgba(239, 68, 68, 0.3); color: #fca5a5; }
.file-ext-xlsx, .file-ext-xls, .file-ext-csv { background: rgba(34, 197, 94, 0.3); color: #86efac; }
.file-ext-pptx { background: rgba(249, 115, 22, 0.3); color: #fdba74; }
.file-ext-docx, .file-ext-doc { background: rgba(59, 130, 246, 0.3); color: #93c5fd; }
.file-ext-png, .file-ext-jpg, .file-ext-jpeg, .file-ext-gif, .file-ext-webp { background: rgba(168, 85, 247, 0.3); color: #d8b4fe; }
.file-ext-txt, .file-ext-md, .file-ext-json { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.65); }

/* Light theme: user msg bg is light → chip needs dark-based colors */
:root .msg-file-chip,
[data-theme="light"] .msg-file-chip {
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.12);
}
:root .msg-file-chip.downloadable:hover,
[data-theme="light"] .msg-file-chip.downloadable:hover {
  background: rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.18);
}
:root .msg-file-chip.downloadable:active,
[data-theme="light"] .msg-file-chip.downloadable:active {
  background: rgba(0,0,0,0.12);
}
:root .file-ext-pdf,
[data-theme="light"] .file-ext-pdf { background: rgba(239, 68, 68, 0.15); color: #dc2626; }
:root .file-ext-xlsx, :root .file-ext-xls, :root .file-ext-csv,
[data-theme="light"] .file-ext-xlsx, [data-theme="light"] .file-ext-xls, [data-theme="light"] .file-ext-csv { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
:root .file-ext-pptx,
[data-theme="light"] .file-ext-pptx { background: rgba(249, 115, 22, 0.15); color: #ea580c; }
:root .file-ext-docx, :root .file-ext-doc,
[data-theme="light"] .file-ext-docx, [data-theme="light"] .file-ext-doc { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
:root .file-ext-png, :root .file-ext-jpg, :root .file-ext-jpeg, :root .file-ext-gif, :root .file-ext-webp,
[data-theme="light"] .file-ext-png, [data-theme="light"] .file-ext-jpg, [data-theme="light"] .file-ext-jpeg, [data-theme="light"] .file-ext-gif, [data-theme="light"] .file-ext-webp { background: rgba(168, 85, 247, 0.15); color: #9333ea; }
:root .file-ext-txt, :root .file-ext-md, :root .file-ext-json,
[data-theme="light"] .file-ext-txt, [data-theme="light"] .file-ext-md, [data-theme="light"] .file-ext-json { background: rgba(0,0,0,0.06); color: rgba(0,0,0,0.5); }

/* Recording indicator */
.recording-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--error-bg);
  border: 1px solid rgba(220, 69, 69, 0.2);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  animation: reveal 0.2s var(--ease-spring);
}

.recording-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--error);
  animation: rec-pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.recording-time {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
  min-width: 36px;
}

.recording-stop-btn {
  margin-left: auto;
  padding: 4px 12px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: var(--radius-xs);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.recording-stop-btn:hover {
  filter: brightness(0.9);
}

.recording-waveform {
  flex: 1;
  height: 28px;
  min-width: 60px;
  border-radius: var(--radius-xs);
}

.recording-cancel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid rgba(220, 69, 69, 0.3);
  border-radius: var(--radius-xs);
  color: var(--error);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
}
.recording-cancel-btn:hover {
  background: rgba(220, 69, 69, 0.15);
}

.composer-tool-btn.transcribing {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}
.composer-tool-btn.transcribing::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .recording-cancel-btn { width: 44px; height: 44px; }
  .recording-stop-btn { padding: 8px 16px; font-size: 13px; }
}

/* Picker dropdowns */
.picker-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 8px;
  right: 8px;
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  animation: reveal 0.2s var(--ease-spring);
}

.picker-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.picker-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  color: var(--text-1);
  font-size: 13px;
}
.picker-list-item:hover {
  background: var(--bg-input);
  color: var(--text-0);
}
.picker-list-item.selected {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}
.picker-list-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-2);
}
.picker-list-item.selected svg {
  color: var(--accent);
}

/* (old plan-phase styles removed — plans now render inside chat messages) */

/* ─── Chat Actions ───────────────────────────── */

.chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  flex-shrink: 0;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-input);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.btn-action:hover {
  background: var(--border-hover);
  border-color: var(--border-hover);
}
.btn-action-icon { font-size: 14px; }
.btn-action-disabled, .btn-action-disabled:hover {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* ─── Input-actions: unified disabled look ─── */
.input-actions {
  gap: 8px;
}
/* All three elements: same bg, border, radius */
.input-actions .btn-action,
.input-actions .pres-cost-badge {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
/* Undo/redo group: opacity on the group container, not individual buttons */
.input-actions .btn-action-group {
  opacity: 0.35;
  pointer-events: none;
}
/* Ghost buttons inside input-actions: no extra opacity (parent handles it) */
.input-actions .btn-action-group .btn-action-disabled {
  opacity: 1;
}
.input-actions .pres-cost-badge.cost-zero {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}

.btn-action-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-action-ghost:hover {
  color: var(--text-1);
  background: var(--bg-input);
  border-color: var(--border);
}
.btn-action-icon-only {
  padding: 8px 10px;
  min-width: 0;
}
.btn-action-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.btn-action-group .btn-action-icon-only {
  padding: 6px 8px;
  border-radius: calc(var(--radius-sm) - 2px);
}

/* ─── Download Dropdown ──────────────────────── */

.btn-action-dropdown {
  position: relative;
}
.btn-action-dropdown .dropdown-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 160px;
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.btn-action-dropdown .dropdown-menu.open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s var(--ease);
  white-space: nowrap;
}
.dropdown-item:hover {
  background: var(--border-hover);
}
.dropdown-item-disabled {
  opacity: 0.4;
  cursor: not-allowed !important;
  pointer-events: none;
}
.dropdown-hint {
  margin-left: auto;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-3);
}

/* File type icons */
.file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 20px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
}
.file-icon-pdf {
  background: #e53935;
}
.file-icon-pptx {
  background: #d14424;
}

/* ─── Toast Notifications ────────────────────── */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid;
  pointer-events: auto;
  animation: toast-in 0.4s var(--ease-spring);
  max-width: 360px;
  line-height: 1.4;
  box-shadow: var(--shadow-md);
}

.toast.info {
  background: var(--bg-glass-strong);
  border-color: var(--border-glass);
  color: var(--text-1);
}

.toast.success {
  background: var(--success-bg);
  border-color: rgba(61, 170, 92, 0.2);
  color: var(--success);
}

.toast.error {
  background: var(--error-bg);
  border-color: rgba(220, 69, 69, 0.2);
  color: var(--error);
}

.toast.warning {
  background: var(--warning-bg);
  border-color: rgba(208, 150, 32, 0.2);
  color: var(--warning);
}

@keyframes toast-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
  to { transform: translateX(40px); opacity: 0; }
}

/* ─── Fullscreen Overlay ─────────────────────── */

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9000;
  overflow: hidden;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fullscreen-frame {
  position: absolute;
  border: none;
  width: 1920px;
  height: 1080px;
  transform-origin: 0 0;
  background: #000;
  overflow: hidden;
}

.fullscreen-close {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s var(--ease);
}
.fullscreen-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.fullscreen-nav {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 10px 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.fullscreen-nav button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
}
.fullscreen-nav button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.fullscreen-nav button:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

#fullscreen-slide-info {
  font-family: var(--font-display);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 600;
  min-width: 50px;
  text-align: center;
}

/* Auto-hide nav/close in native fullscreen */
.fullscreen-overlay .fullscreen-close,
.fullscreen-overlay .fullscreen-nav {
  transition: opacity 0.4s ease;
}
.fullscreen-overlay.fs-autohide .fullscreen-close,
.fullscreen-overlay.fs-autohide .fullscreen-nav {
  opacity: 0;
  pointer-events: none;
}

/* ─── Auth Overlay ───────────────────────────── */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: var(--canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.3s ease;
}

.auth-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--dot-color) var(--dot-size), transparent var(--dot-size));
  background-size: var(--dot-gap) var(--dot-gap);
  pointer-events: none;
}

.auth-card {
  position: relative;
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  width: 400px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(var(--glass-blur)) var(--glass-saturate);
  -webkit-backdrop-filter: blur(var(--glass-blur)) var(--glass-saturate);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
}

.auth-logo .logo-mark {
  width: 32px;
  height: 28px;
}

.auth-logo .logo-mark::before,
.auth-logo .logo-mark::after {
  width: 23px;
  height: 18px;
}

.auth-logo .logo-text {
  font-size: 20px;
}

.auth-email-badge {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 13px;
  text-align: center;
}

.auth-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 4px;
}

.auth-links a {
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s var(--ease);
  text-decoration: none;
}

.auth-links a:hover {
  color: var(--text-0);
}

.auth-confirm-icon {
  font-size: 36px;
  text-align: center;
  margin-bottom: 4px;
}

.auth-confirm-text {
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.auth-confirm-text strong {
  color: var(--text-0);
}

.auth-error {
  background: var(--error-bg);
  border: 1px solid rgba(220, 69, 69, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--error);
  font-size: 13px;
  margin-bottom: 16px;
  animation: reveal 0.2s ease;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.auth-form input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.auth-form input::placeholder { color: var(--text-2); }

.auth-form .btn-primary {
  margin-top: 4px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--text-2);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  margin-bottom: 12px;
}

.btn-google:hover {
  background: var(--bg-input-hover);
  border-color: var(--border-hover);
  color: var(--text-0);
}

.auth-forgot {
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s var(--ease);
  text-decoration: none;
}

.auth-forgot:hover { color: var(--text-0); }

.auth-forgot:hover { color: var(--accent); }

/* ─── Auth Consent Checkboxes ─────────────────── */

.auth-implicit-consent {
  text-align: center;
  font-size: 10px;
  color: var(--text-3);
  margin-top: 8px;
  opacity: 0.7;
}

.auth-implicit-consent a {
  color: var(--text-3);
  text-decoration: underline;
  text-decoration-style: dotted;
}

.auth-implicit-consent a:hover {
  color: var(--text-2);
}

.auth-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.auth-footer-links {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 6px;
}
.auth-footer-links a {
  font-size: 10px;
  color: var(--text-3);
  text-decoration: none;
}
.auth-footer-links a:hover {
  color: var(--text-2);
  text-decoration: underline;
}
.auth-footer-requisites {
  font-size: 9px;
  color: var(--text-3);
  opacity: 0.6;
}

.auth-consent {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  padding: 0 4px;
}

.auth-consent-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  cursor: pointer;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--text-3);
}

.auth-consent-item input[type="checkbox"] {
  margin-top: 1px;
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  accent-color: var(--text-3);
  cursor: pointer;
  opacity: 0.6;
}

.auth-consent-item a {
  color: var(--text-3);
  text-decoration: underline;
  text-decoration-style: dotted;
}

.auth-consent-item a:hover {
  color: var(--text-2);
}

.auth-consent-item.consent-error {
  color: var(--error);
}

.auth-consent-item.consent-error input[type="checkbox"] {
  outline: 1.5px solid var(--error);
  outline-offset: 1px;
  opacity: 1;
}

.auth-consent-item.consent-error a {
  color: var(--error);
}

.auth-consent.shake {
  animation: consent-shake 0.4s ease;
}

@keyframes consent-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ─── Auth Legal Footer ─────────────────────── */

.auth-legal {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.auth-legal a {
  color: var(--text-2);
  font-size: 11px;
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.auth-legal a:hover {
  color: var(--text-0);
}

/* ─── Sidebar ────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width-collapsed);
  min-width: var(--sidebar-width-collapsed);
  overflow: hidden;
  background: var(--sidebar-bg);
  border: none;
  border-right: 1px solid var(--sidebar-border);
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  transition: width 0.25s var(--ease-spring), min-width 0.25s var(--ease-spring);
  flex-shrink: 0;
  position: relative;
}

.sidebar.open {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
}

/* Collapsed strip */
.sidebar-collapsed {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  width: var(--sidebar-width-collapsed);
  position: absolute;
  inset: 0;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.15s var(--ease);
}

.sidebar.open .sidebar-collapsed {
  opacity: 0;
  pointer-events: none;
}

.sidebar-collapsed-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.sidebar-collapsed-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar-collapsed-icon {
  position: relative;
  width: 32px;
  height: 32px;
  cursor: pointer;
  margin-bottom: 6px;
}

.sidebar-collapsed-icon .logo-mark {
  margin: 2px auto;
  transition: opacity 0.15s var(--ease);
}

.sidebar-expand-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  color: var(--sidebar-text-secondary);
  transition: opacity 0.15s var(--ease);
}

.sidebar-collapsed-icon:hover .logo-mark {
  opacity: 0;
}

.sidebar-collapsed-icon:hover .sidebar-expand-icon {
  opacity: 1;
}

.sidebar-collapsed-btn {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--sidebar-item-radius);
  color: var(--sidebar-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
  padding: 0;
}

.sidebar-collapsed-btn:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-primary);
}

/* Sidebar full content */
.sidebar-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: var(--sidebar-width);
  flex: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease) 0.05s;
}

.sidebar.open .sidebar-content {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.15s var(--ease) 0.1s;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--sidebar-text-primary);
  letter-spacing: 0;
}

.sidebar-header-actions {
  display: flex;
  gap: 4px;
}

.sidebar-action-btn {
  height: 28px;
  padding: 0 10px;
  background: var(--sidebar-bg-hover);
  border: none;
  border-radius: var(--sidebar-item-radius);
  color: var(--sidebar-text-secondary);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}

.sidebar-action-btn:hover {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-primary);
}

.sidebar-action-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 2px;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.sidebar-list:hover {
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.sidebar-list::-webkit-scrollbar { width: 6px; }
.sidebar-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-list::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}
.sidebar-list:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
}

:root .sidebar-list:hover,
[data-theme="light"] .sidebar-list:hover {
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}
:root .sidebar-list:hover::-webkit-scrollbar-thumb,
[data-theme="light"] .sidebar-list:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
}

.sidebar-empty {
  text-align: center;
  color: var(--sidebar-text-muted);
  font-size: 13px;
  padding: 32px 16px;
  white-space: nowrap;
}

/* ─── Sidebar Rows — Unified Visual System ──── */
/*
 * Everything is a row: sections, folders, items, date groups.
 * Same height, same font, same horizontal rhythm.
 * Differentiated by: indent + icon + font-weight.
 */

.folder-item {}

.folder-header {
  height: var(--sidebar-item-height);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 8px;
  margin: 0 4px;
  border-radius: var(--sidebar-item-radius);
  cursor: pointer;
  transition: background 0.1s ease;
  position: relative;
  user-select: none;
}

.folder-header:hover {
  background: var(--sidebar-bg-hover);
}

.folder-chevron {
  width: 16px;
  height: 16px;
  color: var(--sidebar-text-muted);
  transition: transform 0.15s var(--ease), opacity 0.12s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.folder-header:hover .folder-chevron {
  opacity: 1;
}

.folder-chevron.expanded {
  transform: rotate(90deg);
}

.folder-icon {
  width: 16px;
  height: 16px;
  color: var(--sidebar-text-muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.folder-icon svg {
  width: 16px;
  height: 16px;
}

.folder-name {
  font-size: 13px;
  font-weight: 400;
  color: var(--sidebar-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  line-height: 1;
}

.folder-name-input {
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text-primary);
  background: var(--sidebar-bg-hover);
  border: 1px solid var(--sidebar-border);
  border-radius: 4px;
  padding: 1px 6px;
  outline: none;
  font-family: var(--font-body);
  flex: 1;
  min-width: 0;
}

/* ─── Inline Folder Create ─────────────────────── */

.folder-inline-create {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin: 1px 4px;
  border-radius: var(--sidebar-item-radius);
  background: var(--sidebar-bg-hover);
  border: 1px solid var(--sidebar-border);
  animation: inline-create-in 0.15s var(--ease);
}

.folder-inline-create.saving {
  opacity: 0.5;
  pointer-events: none;
}

@keyframes inline-create-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.folder-inline-input {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--sidebar-text-primary);
  background: transparent;
  border: none;
  outline: none;
  padding: 2px 0;
}

.folder-inline-input::placeholder {
  color: var(--sidebar-text-muted);
}

.folder-inline-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.15s var(--ease);
}

.folder-inline-btn.confirm {
  background: var(--accent);
  color: var(--canvas);
}

.folder-inline-btn.confirm:hover {
  background: var(--accent-hover);
}

.folder-inline-btn.cancel {
  background: transparent;
  color: var(--text-2);
}

.folder-inline-btn.cancel:hover {
  background: var(--bg-input-hover);
  color: var(--text-1);
}

/* ─── Inline Folder Delete Confirm ──────────────── */

.folder-delete-confirm {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  animation: inline-create-in 0.12s var(--ease);
}

.folder-delete-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--error);
  white-space: nowrap;
}

.folder-inline-btn.confirm-delete {
  background: var(--error);
  color: white;
}

.folder-inline-btn.confirm-delete:hover {
  filter: brightness(0.9);
}

/* ─── Folder Actions ────────────────────────────── */

.folder-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
  margin-left: auto;
}

.folder-header:hover .folder-actions {
  opacity: 1;
}

.folder-action-btn {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--sidebar-text-secondary);
  cursor: pointer;
  border-radius: var(--sidebar-item-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  padding: 0;
}

.folder-action-btn:hover {
  background: var(--sidebar-bg-selected);
  color: var(--sidebar-text-primary);
}

.folder-action-btn.delete:hover {
  background: var(--error-bg);
  color: var(--error);
}

.folder-children {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.25s ease;
  position: relative;
}

/* Vertical indent guide line */
.folder-children::before {
  content: '';
  position: absolute;
  left: calc(4px + 16px); /* margin + center under parent chevron */
  top: 0;
  bottom: 4px;
  width: 1px;
  background: var(--sidebar-divider);
  z-index: 1;
  pointer-events: none;
}

.folder-children-inner {
  overflow: hidden;
  min-height: 0;
  padding-left: var(--sidebar-indent);
}

.folder-children.collapsed {
  grid-template-rows: 0fr;
}

/* Nested indent guides shift right */
.folder-children .folder-children::before {
  left: calc(4px + 12px);
}

/* ─── Sidebar Presentation Items ─────────────── */

.sidebar-item {
  height: var(--sidebar-item-height);
  padding: 0 8px;
  margin: 0 4px;
  border-radius: var(--sidebar-item-radius);
  cursor: pointer;
  transition: background 0.1s ease;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-item:hover {
  background: var(--sidebar-bg-hover);
}

.sidebar-item.active {
  background: var(--sidebar-bg-selected);
}

/* Item icon — matches folder-icon size */
.sidebar-item-icon {
  width: 16px;
  height: 16px;
  color: var(--sidebar-text-muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.sidebar-item.active .sidebar-item-icon {
  color: var(--sidebar-text-primary);
}

.sidebar-item-title {
  font-size: 13px;
  font-weight: 400;
  color: var(--sidebar-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  line-height: 1;
}

.sidebar-item.active .sidebar-item-title {
  color: var(--sidebar-text-primary);
  font-weight: 500;
}

.sidebar-item:hover .sidebar-item-title {
  color: var(--sidebar-text-primary);
}

.sidebar-item-title[contenteditable="true"] {
  background: var(--sidebar-bg-hover);
  border-radius: 4px;
  padding: 2px 6px;
  margin: -2px -6px;
  outline: 1px solid var(--sidebar-border);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  cursor: text;
  line-height: 1.4;
}

.sidebar-item-date {
  display: none;
}

/* Admin: two-line items (title + meta) */
.sidebar-item[data-admin-view] {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  height: auto;
  min-height: var(--sidebar-item-height);
  padding: 6px 8px;
  gap: 2px;
}
.sidebar-item[data-admin-view] .sidebar-item-title {
  width: 100%;
}
.sidebar-item[data-admin-view] .sidebar-item-meta {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  line-height: 1;
}

.sidebar-item-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px 0 20px;
  background: linear-gradient(to right, transparent, var(--sidebar-bg-hover-solid) 16px);
  border-radius: var(--sidebar-item-radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.sidebar-item:hover .sidebar-item-actions {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-item.active .sidebar-item-actions {
  background: linear-gradient(to right, transparent, var(--sidebar-bg-selected-solid) 16px);
}

.sidebar-item-action {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--sidebar-text-secondary);
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--sidebar-item-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  padding: 0;
}

.sidebar-item-action:hover {
  background: var(--sidebar-bg-selected);
  color: var(--sidebar-text-primary);
}

.sidebar-item-action.sidebar-item-delete:hover {
  background: var(--error-bg);
  color: var(--error);
}

/* ─── Sidebar Move Menu ──────────────────────── */

.move-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  padding: 4px;
  min-width: 180px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: reveal 0.2s var(--ease-spring);
}

.move-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--sidebar-text-primary);
  transition: background 0.1s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.move-menu-item:hover {
  background: var(--sidebar-bg-hover);
}

.move-menu-item svg {
  width: 14px;
  height: 14px;
  color: var(--sidebar-text-secondary);
  flex-shrink: 0;
}

/* ─── Sidebar Footer ─────────────────────────── */

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--sidebar-divider);
  flex-shrink: 0;
  white-space: nowrap;
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--sidebar-bg);
}

.sidebar-profile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--sidebar-item-radius);
  cursor: pointer;
  transition: background 0.12s ease;
  flex-shrink: 0;
}

.sidebar-profile-btn:hover {
  background: var(--sidebar-bg-hover);
}

.sidebar-avatar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text-secondary);
}

.sidebar-email {
  display: none;
}

.sidebar-theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--sidebar-item-radius);
  color: var(--sidebar-text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.12s ease;
}

.sidebar-theme-btn:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-primary);
}

/* ─── Sidebar Sections ───────────────────────── */

.sidebar-section {
  margin-bottom: var(--sidebar-section-gap);
}

.sidebar-section + .sidebar-section {
  margin-top: 16px;
}

/* Section headers — same row height as items, just subtler typography */
.sidebar-section-header {
  height: 26px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--sidebar-text-muted);
  padding: 12px 12px 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
  cursor: pointer;
  border-radius: 0;
}
.sidebar-section-header:hover { color: var(--sidebar-text-secondary); }

.section-chevron {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s var(--ease), opacity 0.12s ease;
  transform: rotate(90deg);
  color: var(--sidebar-text-muted);
  opacity: 0;
}
.sidebar-section-header:hover .section-chevron {
  opacity: 1;
}
.sidebar-section.collapsed .section-chevron {
  transform: rotate(0deg);
}

.section-label { }


.section-badge {
  display: none;
}

.sidebar-section-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.25s ease;
}
.sidebar-section-inner {
  overflow: hidden;
  min-height: 0;
}
.sidebar-section.collapsed .sidebar-section-body {
  grid-template-rows: 0fr;
}

.sidebar-section-empty {
  font-size: 12px;
  color: var(--sidebar-text-muted);
  padding: 6px 12px 8px;
  font-style: italic;
}

/* Date groups — minimal separator, same rhythm */
.sidebar-date-group-wrapper {
  margin-top: 2px;
}

.sidebar-date-group {
  height: 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--sidebar-text-muted);
  padding: 8px 12px 0;
  user-select: none;
  cursor: pointer;
}
.sidebar-date-group:hover { color: var(--sidebar-text-secondary); }

.date-group-chevron {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s var(--ease), opacity 0.12s ease;
  transform: rotate(90deg);
  opacity: 0;
}
.sidebar-date-group:hover .date-group-chevron {
  opacity: 1;
}
.sidebar-date-group-wrapper.collapsed .date-group-chevron {
  transform: rotate(0deg);
}

.date-group-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.25s ease;
}
.date-group-inner {
  overflow: hidden;
  min-height: 0;
}
.sidebar-date-group-wrapper.collapsed .date-group-body {
  grid-template-rows: 0fr;
}

/* ─── Sidebar Resize Handle ─────────────────── */

.sidebar-resize-handle {
  width: 4px;
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: background 0.15s ease;
  display: none;
}

.sidebar.open ~ .sidebar-resize-handle {
  display: block;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.active {
  background: var(--accent-blue);
}

body.sidebar-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.sidebar-resizing * {
  cursor: col-resize !important;
  pointer-events: none !important;
}

body.sidebar-resizing .sidebar-resize-handle {
  pointer-events: auto !important;
}

/* ─── Chat Resize Handle ──────────────────── */

.chat-resize-handle {
  width: 4px;
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: background 0.15s ease;
}

.chat-resize-handle:hover,
.chat-resize-handle.active {
  background: var(--accent-blue);
}

body.chat-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.chat-resizing * {
  cursor: col-resize !important;
  pointer-events: none !important;
}

body.chat-resizing .chat-resize-handle {
  pointer-events: auto !important;
}

/* ─── Context Menu ──────────────────────────── */

.context-menu {
  position: fixed;
  z-index: 9999;
  min-width: 180px;
  padding: 4px;
  border-radius: 8px;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}

.context-menu.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--sidebar-text-primary);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.1s ease;
}

.context-menu-item:hover {
  background: var(--sidebar-bg-hover);
}

.context-menu-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--sidebar-text-secondary);
}

.context-menu-item.danger {
  color: #ff5a5a;
}

.context-menu-item.danger:hover {
  background: rgba(255, 90, 90, 0.12);
}

.context-menu-item.danger svg {
  color: #ff5a5a;
}

.context-menu-separator {
  height: 1px;
  margin: 4px 8px;
  background: var(--sidebar-divider);
}

/* Prevent text selection during drag */
body.dragging,
body.dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: grabbing !important;
}

/* ─── Pin Button ─────────────────────────────── */

.sidebar-item .pin-btn {
  opacity: 0;
  transition: opacity 0.12s ease;
  color: var(--sidebar-text-secondary);
}

.sidebar-item:hover .pin-btn {
  opacity: 1;
}

.sidebar-item.pinned .pin-btn {
  opacity: 1;
  color: var(--sidebar-text-primary);
}

/* ─── Project Settings Modal ─────────────────── */

.project-settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 9600;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in 0.2s ease;
}

[data-theme="dark"] .project-settings-overlay {
  background: rgba(0, 0, 0, 0.55);
}

.project-settings-card {
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0;
  width: 480px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: reveal 0.3s var(--ease-spring);
}

.project-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.project-settings-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-0);
}

.project-settings-close {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
}

.project-settings-close:hover {
  background: var(--bg-input);
  color: var(--text-0);
}

.project-settings-body {
  padding: 20px 24px;
}

.project-settings-field {
  margin-bottom: 20px;
}

.project-settings-field:last-child {
  margin-bottom: 0;
}

.project-settings-label {
  display: block;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
  margin-bottom: 4px;
}

.project-settings-hint {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-2);
  margin: 0 0 8px;
}

.project-settings-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s var(--ease);
  box-sizing: border-box;
}

.project-settings-input:focus {
  border-color: var(--accent);
}

.project-settings-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.15s var(--ease);
  box-sizing: border-box;
}

.project-settings-textarea:focus {
  border-color: var(--accent);
}

/* Project files list */
.project-files-list {
  margin-bottom: 10px;
}

.project-files-empty {
  font-size: 13px;
  color: var(--text-2);
  padding: 12px 0;
  text-align: center;
}

.project-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  transition: all 0.15s var(--ease);
}

.project-file-item:hover {
  border-color: var(--text-2);
}

.project-file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.project-file-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.project-file-name {
  font-size: 13px;
  color: var(--text-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.project-file-meta {
  font-size: 11px;
  color: var(--text-2);
  flex-shrink: 0;
}

.project-file-delete {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-2);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s var(--ease);
  opacity: 0;
}

.project-file-item:hover .project-file-delete {
  opacity: 1;
}

.project-file-delete:hover {
  background: var(--danger-subtle, rgba(220, 38, 38, 0.1));
  color: var(--danger, #dc2626);
}

/* File action buttons */
.project-files-actions {
  display: flex;
  gap: 8px;
}

.project-files-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.project-files-btn:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

/* Paste text form */
.project-paste-form {
  margin-top: 12px;
  padding: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.project-paste-form .project-settings-input {
  margin-bottom: 8px;
}

.project-paste-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.project-paste-cancel,
.project-paste-add {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.project-paste-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-1);
}

.project-paste-cancel:hover {
  background: var(--bg-input);
}

.project-paste-add {
  background: var(--text-0);
  border: none;
  color: var(--bg-solid);
}

.project-paste-add:hover {
  opacity: 0.85;
}

/* Footer: save + delete */
.project-settings-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-save-btn {
  width: 100%;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--bg-solid);
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s var(--ease);
}

.project-save-btn:hover {
  opacity: 0.85;
}

.project-delete-btn {
  background: none;
  border: none;
  color: var(--danger, #dc2626);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 0;
  transition: opacity 0.15s var(--ease);
}

.project-delete-btn:hover {
  opacity: 0.7;
}

.project-delete-btn.confirm {
  color: var(--danger, #dc2626);
  font-weight: 600;
}

/* ─── Drag & Drop ────────────────────────────── */

.drag-ghost {
  position: fixed;
  opacity: 0.75;
  z-index: 99999;
  pointer-events: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-width: 260px;
}

.drop-indicator {
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  margin: 0 8px;
  pointer-events: none;
}

.drag-source {
  opacity: 0.3;
}

.folder-header.drop-target,
.folder-item.drop-target > .folder-header {
  background: var(--accent-subtle);
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
  border-radius: var(--radius-sm);
}

/* ─── Profile Overlay ────────────────────────── */

.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 9600;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in 0.2s ease;
}

[data-theme="dark"] .profile-overlay {
  background: rgba(0, 0, 0, 0.55);
}

.profile-card {
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 28px 20px;
  width: 380px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: reveal 0.3s var(--ease-spring);
}

.profile-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.profile-card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-0);
  letter-spacing: 0;
}

.profile-card-close {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 22px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s var(--ease);
}

.profile-card-close:hover {
  background: var(--bg-input);
  color: var(--text-0);
}

.profile-info {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding: 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.profile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  flex-shrink: 0;
}

.profile-email {
  font-size: 14px;
  color: var(--text-0);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.profile-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.profile-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: 0;
}

.profile-section input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.profile-section input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.profile-section input::placeholder { color: var(--text-2); }

.profile-save-btn {
  margin-top: 2px;
}

.profile-accounts {
  margin-bottom: 16px;
}

.profile-accounts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.profile-account-row:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover, var(--border));
}

.profile-account-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--text-2);
}

.profile-account-email {
  color: var(--text-1);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.profile-account-btn.remove {
  background: none;
  color: var(--text-2);
  border: none;
  padding: 4px 6px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s var(--ease);
}

.profile-account-btn.remove:hover {
  color: var(--error);
}

.profile-add-account-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  margin-bottom: 16px;
}

.profile-add-account-btn:hover {
  border-color: var(--text-2);
  color: var(--text-1);
}

.profile-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 16px;
}

.profile-logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.profile-logout-btn:hover {
  background: var(--error-bg);
  border-color: rgba(220, 69, 69, 0.2);
  color: var(--error);
}

/* ─── Chat Header ────────────────────────────── */

/* Sidebar toggle in chat header — mobile only */
.sidebar-toggle {
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-2);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
  padding: 0;
}

.sidebar-toggle:hover {
  background: var(--accent-subtle);
  color: var(--text-0);
}

/* ─── Scrollbar ──────────────────────────────── */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ─── Mobile nav & backdrop (desktop: hidden) ─ */

.mobile-nav { display: none; }
.sidebar-backdrop { display: none; }

/* ─── Touch Device Fallbacks ─────────────────── */

@media (hover: none) {
  /* Navigation controls always visible on touch (chevrons, close buttons) */
  .folder-chevron,
  .folder-actions,
  .reassurance-close,
  .share-invite-remove,
  .section-chevron,
  .date-group-chevron {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* Pin/delete/actions — accessible via long-press context menu, NOT always visible */
  /* .sidebar-item-actions, .pin-btn, .project-file-delete stay hidden */

  .reassurance-close {
    transform: scale(1) !important;
  }

  /* Active states for touch feedback */
  .btn-primary:active,
  .btn-secondary:active,
  .sidebar-item:active,
  .folder-header:active,
  .mobile-nav-btn:active {
    opacity: 0.7;
    transition: opacity 0.1s;
  }
}

/* ─── Responsive ─────────────────────────────── */

@media (max-width: 900px) {
  /* iOS: prevent bounce scroll by fixing body */
  html, body {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-solid);
  }

  /* Hide resize handles on mobile */
  .sidebar-resize-handle,
  .chat-resize-handle {
    display: none !important;
  }

  /* Layout: slides top, chat bottom */
  .app {
    flex-direction: column;
    padding: 0;
    gap: 0;
    height: 100dvh;
    overflow: hidden;
    width: 100%;
    background: var(--bg-solid);
  }

  /* Mobile nav bar — compact */
  .mobile-nav {
    display: flex;
    order: -1;
    align-items: center;
    padding: 6px 6px 4px;
    padding-top: calc(6px + env(safe-area-inset-top));
    background: var(--bg-glass-strong);
    backdrop-filter: blur(var(--glass-blur)) var(--glass-saturate);
    -webkit-backdrop-filter: blur(var(--glass-blur)) var(--glass-saturate);
    border-bottom: 1px solid var(--border-glass);
    z-index: 6000;
    flex-shrink: 0;
    gap: 2px;
  }
  .mobile-nav-btn {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--text-1);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s var(--ease);
    flex-shrink: 0;
  }
  .mobile-nav-btn:active { background: var(--accent-subtle); }
  .mobile-nav-title {
    flex: 1;
    text-align: center;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-0);
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
  }

  /* Hide old chat header on mobile */
  .panel-chat-header { display: none !important; }

  /* Preview panel — slide centered vertically, controls below */
  .panel-preview {
    flex: 1;
    max-height: none;
    padding: 0 12px;
    background: var(--canvas);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 0;
  }
  .panel-preview:not(.has-preview) { display: none; }
  .preview-wrapper {
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius-md);
    flex-shrink: 0;
  }

  /* Mobile preview actions — single row below slide nav */
  .mobile-preview-actions {
    display: flex;
    gap: 8px;
    padding: 4px 0 0;
    flex-shrink: 0;
  }
  .mobile-preview-actions .preview-action-row {
    display: contents;
  }
  .mobile-preview-actions .preview-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    background: var(--bg-solid);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s var(--ease);
    white-space: nowrap;
  }
  .mobile-preview-actions .preview-action-btn:active {
    background: var(--accent-subtle);
    color: var(--text-0);
  }
  .mobile-preview-actions .preview-action-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
  }

  /* Slide nav — full-width bar below preview */
  .slide-nav {
    position: static;
    transform: none;
    width: 100%;
    padding: 10px 4px;
    gap: 16px;
    flex-shrink: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    justify-content: center;
  }
  /* Hide edit/fullscreen from nav (available in action buttons below) */
  .slide-nav .btn-text-edit,
  .slide-nav .btn-fullscreen { display: none !important; }
  .slide-dots { max-width: 100px; }
  .slide-dot { width: 10px; height: 3px; border-radius: 2px; }
  .slide-dot.active { width: 20px; }
  /* Nav buttons */
  .slide-nav .slide-nav-controls button {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    border-radius: 8px;
    font-size: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-glass);
  }
  .slide-nav .slide-nav-controls { gap: 10px; }
  .slide-nav .slide-info {
    font-size: 12px;
    min-width: 40px;
    color: var(--text-2);
  }

  /* Chat panel */
  .panel-chat {
    width: 100%;
    min-width: unset;
    flex: 1;
    min-height: 0;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border-glass);
    box-shadow: none;
  }

  /* Chat panel mobile tuning — compact */
  #chat-screen { padding: 0 10px 0; }
  .input-screen { padding: 0 10px 0; }
  .input-screen > .composer { margin-bottom: max(6px, env(safe-area-inset-bottom)); }
  .chat-actions {
    flex-wrap: wrap;
    gap: 3px;
    padding: 2px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .chat-actions .action-chip { padding: 5px 10px; font-size: 11px; }
  .composer { padding-bottom: env(safe-area-inset-bottom); }
  .starter-hero {
    flex: 1 1 0;
    min-height: 0;
    padding: max(20px, env(safe-area-inset-top)) 0 12px;
  }
  .starter-hero h2 { font-size: clamp(17px, 5.5vw, 20px); }

  /* Demo chat responsive — content-driven height, no collapse */
  .demo-chat {
    max-width: min(300px, 88vw);
    flex: 0 0 auto;
    min-height: 180px;
    height: auto;
    overflow: hidden;
    margin-top: 6px;
    padding: 12px;
    border-radius: 12px;
  }
  .demo-chip-name { font-size: 10px; }
  .demo-mini-slide { width: 52px; height: 36px; padding: 3px; }
  .demo-typed-wrap { font-size: 12px; }
  .demo-bubble-ai::before { top: 10px; }
  .demo-slides-row { margin-top: 6px; }

  /* Chat messages compact */
  .chat-msg { padding: 6px 10px; font-size: 12px; max-width: 60%; border-radius: var(--radius-sm); }

  /* Composer compact */
  .composer { border-radius: var(--radius-sm); }
  .composer-textarea { padding: 8px 10px 0; min-height: 32px; font-size: 13px; }
  .chat-composer-textarea { min-height: 26px; padding: 6px 10px 0; font-size: 13px; }
  .composer-toolbar { padding: 2px 4px 2px 6px; }
  .composer-tool-btn svg, .composer-send-btn svg { width: 16px; height: 16px; }

  /* Sidebar overlay */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 7000;
    width: 0;
    min-width: 0;
    opacity: 0;
    border-radius: 0;
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.3);
    transition: width 0.2s var(--ease-spring), min-width 0.2s var(--ease-spring), opacity 0.15s var(--ease);
    padding-top: env(safe-area-inset-top);
  }

  .sidebar.open {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    opacity: 1;
  }

  .sidebar-collapsed {
    display: none !important;
  }

  .sidebar.open .sidebar-content {
    min-width: 0;
  }

  /* Sidebar backdrop */
  .sidebar.open ~ .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 6999;
  }
  [data-theme="dark"] .sidebar.open ~ .sidebar-backdrop {
    background: rgba(0, 0, 0, 0.4);
  }

  /* Touch targets — compact but usable */
  .sidebar-item { min-height: 40px; padding: 10px 12px; }
  .folder-header { padding: 10px 8px; min-height: 40px; }
  .action-chip { padding: 6px 12px; font-size: 11px; }
  .file-chip-remove { width: 28px; height: 28px; font-size: 16px; }
  .composer-send-btn { width: 38px; height: 38px; }
  .composer-tool-btn { width: 36px; height: 36px; }
  .slide-nav-controls button,
  .btn-fullscreen { width: 36px; height: 36px; }
  .slide-info { font-size: 11px; min-width: 40px; }
  .picker-dropdown { left: 4px; right: 4px; }

  /* Fullscreen close button mobile enhance */
  .fullscreen-close {
    min-height: 44px;
    padding: 12px 20px;
    z-index: 9001;
    top: calc(12px + env(safe-area-inset-top));
    font-size: 15px;
  }

  /* ─── Touch Targets 44px ─── */
  .composer-send-btn { min-width: 44px; min-height: 44px; }
  .composer-tool-btn { min-width: 44px; min-height: 44px; }
  .slide-nav-controls button,
  .btn-fullscreen { min-width: 44px; min-height: 44px; }
  .file-chip-remove { min-width: 44px; min-height: 44px; }
  .sidebar-item { min-height: 44px; }
  .folder-header { min-height: 44px; }
  .mobile-nav-btn { min-width: 44px; min-height: 44px; }

  /* ─── Safe-area Gaps ─── */
  .sidebar-footer { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .fullscreen-nav { padding-bottom: env(safe-area-inset-bottom); }

  /* ─── Toast mobile reposition ─── */
  .toast-container {
    top: auto;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
  }

  /* ─── Reassurance card mobile ─── */
  .reassurance-card {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .reassurance-close {
    min-width: 44px;
    min-height: 44px;
  }

  /* ─── Performance: disable heavy backdrop-filter ─── */
  .chat-msg.ai {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .mobile-nav {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  /* ─── Dot grid: hidden on mobile (saves GPU layer) ─── */
  body::before { display: none; }

  /* ─── Mobile Tab Bar ──────────────────────────── */

  .mobile-tab-bar {
    display: flex;
    flex-shrink: 0;
    order: 99; /* always last in flex column */
    background: var(--bg-solid, #1a1a2e);
    border-top: 1px solid var(--border, rgba(255,255,255,0.1));
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    z-index: 100;
    gap: 0;
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-2, #888);
    font-size: 11px;
    cursor: pointer;
    min-height: 44px;
    transition: color 0.2s;
    font-family: var(--font-body);
  }

  .mobile-tab.active {
    color: var(--accent, #6c5ce7);
  }

  .mobile-tab svg {
    width: 20px;
    height: 20px;
  }

  /* === Chat + Keyboard Mobile === */
  .app {
    height: var(--vvh, 100dvh);
  }

  /* iOS zoom prevented via maximum-scale=1 in viewport meta */

  .chat-msg pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: calc(100% - 20px);
  }

  /* Simplified shimmer on mobile */
  @keyframes shimmer-mobile {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
  }
  .shimmer-line {
    animation: shimmer-mobile 2s infinite linear;
    background-size: 200% 100%;
  }

  /* === Preview Mobile === */
  #preview-shadow-host {
    display: none;
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: var(--bg-solid);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  }

  .slide-counter {
    font-size: 14px;
    color: var(--text-secondary, var(--text-2));
    padding: 4px 12px;
    white-space: nowrap;
  }

  .preview-wrapper {
    touch-action: pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
  }
}

/* ═══════════════════════════════════════════════
   Billing & Topup Components
   ═══════════════════════════════════════════════ */

/* ─── Sidebar Balance Badge ──────────────────── */

.sidebar-balance {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 8px;
  background: none;
  border: none;
  border-radius: var(--sidebar-item-radius);
  color: var(--sidebar-text-secondary);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-balance:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-primary);
}

/* ─── Topup Overlay ──────────────────────────── */

.topup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9600;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in 0.2s ease;
}

[data-theme="dark"] .topup-overlay {
  background: rgba(0, 0, 0, 0.55);
}

.topup-card {
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 28px 20px;
  width: 400px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: reveal 0.3s var(--ease-spring);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topup-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topup-card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-0);
  letter-spacing: 0;
}

.topup-card-close {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 22px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s var(--ease);
}

.topup-card-close:hover {
  background: var(--bg-input);
  color: var(--text-0);
}

.topup-current {
  font-size: 14px;
  color: var(--text-1);
  text-align: center;
  padding: 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.topup-current strong {
  color: var(--text-0);
  font-weight: 700;
}

.topup-amounts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.topup-amount-btn {
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.topup-amount-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.topup-amount-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--canvas);
}

.topup-custom-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.topup-custom-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.topup-custom-input::placeholder { color: var(--text-2); }

.topup-pay-btn {
  margin-top: 0;
}

.topup-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
}

/* Wide card for tabbed panel */
.topup-card--wide {
  width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}

/* ─── Topup Tabs ────────────────────────────── */

.topup-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 3px;
}

.topup-tab {
  padding: 6px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.topup-tab:hover {
  color: var(--text-0);
}

.topup-tab.active {
  background: var(--bg-solid);
  color: var(--text-0);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.topup-tab-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Usage Summary Cards ───────────────────── */

.usage-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 10px;
}

.usage-summary-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

[data-theme="dark"] .usage-summary-card {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}

.usage-summary-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.usage-summary-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-0);
  letter-spacing: 0;
}

/* ─── Usage Sections ────────────────────────── */

.usage-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.usage-section-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.usage-empty {
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  padding: 16px;
}

/* ─── Usage Presentations List ──────────────── */

.usage-presentations {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
}

.usage-pres-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid transparent;
  transition: all 0.15s var(--ease);
  gap: 12px;
}

.usage-pres-item.clickable {
  cursor: pointer;
}

.usage-pres-item.clickable:hover {
  border-color: var(--border);
  background: var(--bg-solid);
}

.usage-pres-item.muted {
  opacity: 0.6;
}

.usage-pres-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.usage-pres-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.usage-pres-cost {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-0);
}

.usage-pres-count {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}

/* ─── Usage Breakdown ──────────────────────── */

.usage-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 2px;
}

.breakdown-chip {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* ─── Presentation Cost Badge ──────────────── */

.pres-cost-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}

.pres-cost-badge:hover {
  border-color: var(--text-2);
  background: var(--bg-solid);
}

.pres-cost-badge strong {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-0);
}

/* ─── Usage Transaction Log ─────────────────── */

.usage-log {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--border);
}

.usage-log-row {
  display: grid;
  grid-template-columns: 52px 1fr 64px 72px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-solid);
  font-size: 12px;
  gap: 6px;
}

.usage-log-row:first-child {
  border-radius: 9px 9px 0 0;
}

.usage-log-row:last-child {
  border-radius: 0 0 9px 9px;
}

.usage-log-row.header {
  font-weight: 600;
  color: var(--text-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-input);
}

.usage-log-time {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.usage-log-desc {
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.usage-log-model {
  color: var(--text-2);
  font-size: 11px;
}

.usage-log-amount {
  font-family: var(--font-display);
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.usage-log-amount.negative {
  color: var(--text-0);
}

.usage-log-amount.positive {
  color: #22c55e;
}

/* ─── Responsive: Usage Panel ───────────────── */

@media (max-width: 560px) {
  .topup-card--wide {
    width: 100%;
  }
  .usage-summary {
    grid-template-columns: 1fr 1fr;
  }
  .usage-log-row {
    grid-template-columns: 48px 1fr 56px;
  }
  .usage-log-model,
  .usage-log-row.header .usage-log-model {
    display: none;
  }
}

/* ─── Paywall Banner ─────────────────────────── */

.paywall-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 0 4px 4px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06) 0%, rgba(59, 130, 246, 0.04) 100%);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 12px;
  font-size: 13px;
  animation: reveal 0.3s var(--ease-spring);
  flex-shrink: 0;
}

.paywall-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0071e3, #2997ff);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.paywall-icon svg {
  width: 16px;
  height: 16px;
  color: #fff;
}

.paywall-body {
  flex: 1;
  min-width: 0;
}

.paywall-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-0);
  line-height: 1.3;
}

.paywall-sub {
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: 1px;
}

.paywall-banner button {
  padding: 6px 16px;
  background: var(--accent);
  color: var(--canvas, white);
  border: none;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s var(--ease);
}

.paywall-banner button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.paywall-banner button:active {
  transform: scale(0.96);
}

/* ─── Billing Toast ──────────────────────────── */

.toast.billing {
  background: var(--bg-glass-strong);
  border-color: var(--border-glass);
  color: var(--text-1);
}

/* ─── Reassurance Card ──────────────────────── */

.reassurance-card {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10001;
  width: 340px;
  padding: 20px 20px 16px;
  border-radius: var(--radius);
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  animation: reassurance-in 0.4s var(--ease-spring);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reassurance-card.fade-out {
  animation: reassurance-out 0.3s ease forwards;
}

.reassurance-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.reassurance-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
}

.reassurance-close {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass-strong);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s, transform 0.15s, background 0.15s, color 0.15s;
}

.reassurance-card:hover .reassurance-close {
  opacity: 1;
  transform: scale(1);
}

.reassurance-close:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}

.reassurance-body {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
}

.reassurance-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 4px;
}

.reassurance-mute {
  padding: 5px 12px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-3);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.reassurance-mute:hover {
  background: var(--bg-hover);
  color: var(--text-2);
  border-color: var(--text-3);
}

@keyframes reassurance-in {
  from { transform: translateX(40px) scale(0.95); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes reassurance-out {
  to { transform: translateX(40px) scale(0.95); opacity: 0; }
}

/* ─── Share & Publish Modal ─────────────────── */

.share-overlay {
  position: fixed;
  inset: 0;
  z-index: 9600;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in 0.2s ease;
}

[data-theme="dark"] .share-overlay {
  background: rgba(0, 0, 0, 0.55);
}

.share-card {
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0;
  width: 480px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: reveal 0.3s var(--ease-spring);
}

/* Header */
.share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.share-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-0);
}

.share-close {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
}

.share-close:hover {
  background: var(--bg-input);
  color: var(--text-0);
}

/* Body */
.share-body {
  padding: 12px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Section groups */
.share-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.share-group-label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
}

/* Tooltip trigger (?) */
.share-tooltip-trigger {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  font-style: normal;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-2);
  cursor: help;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s var(--ease);
}

.share-tooltip-trigger:hover {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

.share-tooltip-trigger:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  padding: 10px 12px;
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-1);
  z-index: 10;
  text-transform: none;
  letter-spacing: 0;
  pointer-events: none;
}

/* Access hint text */
.share-access-hint {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
  margin: 0;
}

/* Invite form */
.share-invite-form {
  display: flex;
  gap: 6px;
}

.share-invite-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  font-size: 13px;
  color: var(--text-0);
  font-family: var(--font-body);
  min-width: 0;
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.share-invite-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.share-invite-input::placeholder {
  color: var(--text-3);
}

.share-invite-level {
  padding: 10px 30px 10px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  font-size: 12px;
  color: var(--text-0);
  font-family: var(--font-body);
  flex-shrink: 0;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.15s var(--ease);
}

.share-invite-level:focus {
  border-color: var(--accent-blue);
}

.share-invite-btn {
  padding: 10px 16px;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm, 8px);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s var(--ease);
}

.share-invite-btn:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.share-invite-btn:active {
  transform: translateY(0);
}

/* Invites list */
.share-invites-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.share-invites-list:empty {
  display: none;
}

.share-invite-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.15s var(--ease);
}

.share-invite-row:hover {
  background: var(--bg-input);
}

.share-invite-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.share-invite-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.share-invite-email {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-invite-level-select {
  padding: 5px 24px 5px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-2);
  font-family: var(--font-body);
  flex-shrink: 0;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: all 0.15s var(--ease);
}

.share-invite-level-select:hover {
  background-color: var(--bg-input);
  border-color: var(--border);
}

.share-invite-level-select:focus {
  border-color: var(--accent-blue);
}

.share-invite-remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  border-radius: 8px;
  flex-shrink: 0;
  opacity: 0;
  transition: all 0.15s var(--ease);
}

.share-invite-row:hover .share-invite-remove {
  opacity: 1;
}

.share-invite-remove:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* General access card */
.share-access-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.share-access-card-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.share-access-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle);
  border-radius: 8px;
  color: var(--text-2);
  flex-shrink: 0;
}

.share-access-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.share-access-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-0);
}

.share-access-select-inline {
  padding: 2px 20px 2px 0;
  background: transparent;
  border: none;
  font-size: 12px;
  color: var(--text-2);
  font-family: var(--font-body);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
}

/* Copy link button (inside access card) */
.share-copy-link-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  font-family: var(--font-body);
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: all 0.15s var(--ease);
}

.share-copy-link-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-0);
}

/* Publish card — visually distinct section */
.share-publish-card {
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
}

.share-publish-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.share-publish-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.share-publish-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-0);
}

.share-publish-desc {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
}

/* Toggle switch */
.share-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.share-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.share-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-input);
  border-radius: 24px;
  border: 1px solid var(--border);
  transition: all 0.25s var(--ease);
}

.share-toggle-slider:before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: #9ca3af;
  border-radius: 50%;
  transition: all 0.25s var(--ease);
}

[data-theme="dark"] .share-toggle-slider:before {
  background: #6b7280;
}

.share-toggle input:checked + .share-toggle-slider {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.share-toggle input:checked + .share-toggle-slider:before {
  transform: translateX(20px);
  background: #fff;
}

/* Publish URL */
.share-publish-url {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  animation: reveal 0.2s var(--ease-spring);
}

.share-link-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  font-size: 12px;
  color: var(--text-1);
  font-family: var(--font-mono, monospace);
  min-width: 0;
  outline: none;
  transition: border-color 0.15s var(--ease);
}

.share-link-input:focus {
  border-color: var(--accent-blue);
}

.share-copy-btn {
  padding: 10px 12px;
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  color: var(--text-2);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: all 0.15s var(--ease);
}

.share-copy-btn:hover {
  background: var(--bg-input-hover);
  color: var(--text-0);
  border-color: var(--border-hover);
}

/* Mobile responsive */
@media (max-width: 600px) {
  .share-card {
    border-radius: 16px;
    margin: 8px;
  }
  .share-invite-form {
    flex-wrap: wrap;
  }
  .share-invite-input {
    flex: 1 1 100%;
  }
  .share-invite-level {
    flex: 1;
  }
  .share-invite-btn {
    flex: 0;
  }
}

/* ═══════════════════════════════════════════════
   Pasted Text Attachment — Composer Chip
   ═══════════════════════════════════════════════ */

.pasted-text-chip {
  background: var(--accent-subtle, rgba(0,0,0,0.04)) !important;
  border: 1px solid var(--border, rgba(0,0,0,0.08)) !important;
  gap: 6px;
}

.pasted-text-chip-info {
  font-size: 10px;
  color: var(--text-2);
  white-space: nowrap;
}

.pasted-text-chip-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  transition: all 0.15s var(--ease);
}
.pasted-text-chip-preview:hover {
  background: var(--bg-input);
  color: var(--text-0);
}

/* ═══════════════════════════════════════════════
   Pasted Text Attachment — Message Chip
   ═══════════════════════════════════════════════ */

.msg-pasted-text-chip {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  max-width: 100%;
}
.msg-pasted-text-chip:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.2);
}
.msg-pasted-text-chip:active {
  transform: scale(0.98);
}

.msg-pasted-text-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.msg-pasted-text-icon {
  flex-shrink: 0;
  display: flex;
  opacity: 0.5;
}

.msg-pasted-text-title {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
}

.msg-pasted-text-info {
  font-size: 10px;
  opacity: 0.45;
  margin-left: auto;
  white-space: nowrap;
}

.msg-pasted-text-preview {
  font-size: 11px;
  opacity: 0.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  font-style: italic;
}

/* User msg pasted text chips inherit theme colors naturally */

/* AI message pasted text chip */
.chat-msg.ai .msg-pasted-text-chip {
  background: var(--bg-input, rgba(0,0,0,0.04));
  border-color: var(--border, rgba(0,0,0,0.08));
}
.chat-msg.ai .msg-pasted-text-chip:hover {
  background: var(--bg-input-hover, rgba(0,0,0,0.06));
  border-color: var(--border-hover, rgba(0,0,0,0.12));
}
.chat-msg.ai .msg-pasted-text-icon { color: var(--text-2); }
.chat-msg.ai .msg-pasted-text-title { color: var(--text-0); }
.chat-msg.ai .msg-pasted-text-info { color: var(--text-2); }
.chat-msg.ai .msg-pasted-text-preview { color: var(--text-1); }

/* ═══════════════════════════════════════════════
   Text Viewer Modal
   ═══════════════════════════════════════════════ */

.text-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.text-viewer-overlay.open {
  opacity: 1;
}

.text-viewer-card {
  width: 90%;
  max-width: 680px;
  max-height: 80vh;
  background: var(--bg-solid);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.25s var(--ease-spring);
}
.text-viewer-overlay.open .text-viewer-card {
  transform: translateY(0) scale(1);
}

.text-viewer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.text-viewer-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-0);
}

.text-viewer-title {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
}

.text-viewer-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-2);
  font-family: var(--font-body);
}

.text-viewer-meta-dot {
  opacity: 0.4;
}

.text-viewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.text-viewer-copy-btn {
  padding: 5px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-1);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}
.text-viewer-copy-btn:hover {
  background: var(--bg-input-hover);
  color: var(--text-0);
  border-color: var(--border-hover);
}

.text-viewer-close-btn {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.15s var(--ease);
}
.text-viewer-close-btn:hover {
  background: var(--bg-input);
  color: var(--text-0);
}

.text-viewer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-0);
  font-family: var(--font-body);
  white-space: pre-wrap;
  word-wrap: break-word;
  tab-size: 4;
}

/* ═══════════════════════════════════════════════
   Brand Picker
   ═══════════════════════════════════════════════ */

@keyframes brandFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes brandSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.brand-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: brandFadeIn 0.18s ease;
}

.brand-picker-modal {
  /* Gray background so white cards visually pop */
  background: #eef0f5;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 22px;
  width: min(720px, 100%);
  max-height: min(600px, 92vh);
  display: flex;
  flex-direction: column;
  box-shadow:
    0 2px 4px rgba(0,0,0,0.05),
    0 8px 24px rgba(0,0,0,0.1),
    0 32px 64px rgba(0,0,0,0.16);
  animation: brandSlideUp 0.24s var(--ease-spring);
  overflow: hidden;
}

[data-theme="dark"] .brand-picker-modal {
  background: rgba(22, 22, 26, 0.92);
  border-color: rgba(255, 255, 255, 0.07);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.3),
    0 8px 24px rgba(0,0,0,0.4),
    0 32px 64px rgba(0,0,0,0.5);
}

/* ─── Header ─────────────────────────────────── */

.brand-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 0;
  flex-shrink: 0;
  gap: 12px;
}

.brand-picker-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-0);
  margin: 0 0 3px;
  letter-spacing: 0;
}

.brand-picker-subtitle {
  font-size: 12.5px;
  color: var(--text-2);
  margin: 0;
  line-height: 1.4;
}

.brand-picker-close {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  flex-shrink: 0;
  transition: all 0.15s var(--ease);
}

.brand-picker-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-0);
}

[data-theme="dark"] .brand-picker-close {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .brand-picker-close:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* ─── Search ─────────────────────────────────── */

.brand-search-wrap {
  position: relative;
  padding: 12px 22px 0;
  flex-shrink: 0;
}

.brand-search-icon {
  position: absolute;
  left: 34px;
  top: calc(12px + 19px); /* padding-top + half input height */
  transform: translateY(-50%);
  color: #aaa;
  pointer-events: none;
}

[data-theme="dark"] .brand-search-icon {
  color: rgba(255, 255, 255, 0.3);
}

.brand-search-input {
  width: 100%;
  box-sizing: border-box;
  height: 38px;
  padding: 0 14px 0 36px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  font-family: var(--font-body);
  color: #1a1a1a;
  outline: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.brand-search-input::placeholder {
  color: #bbb;
}

[data-theme="dark"] .brand-search-input {
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.85);
}

[data-theme="dark"] .brand-search-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.brand-search-input:focus {
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 0 0 3px rgba(0,0,0,0.05);
}

[data-theme="dark"] .brand-search-input:focus {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

/* ─── Industry Tabs ──────────────────────────── */

.brand-industry-tabs {
  display: flex;
  gap: 5px;
  padding: 14px 22px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.brand-industry-tabs::-webkit-scrollbar { display: none; }

.brand-industry-tab {
  white-space: nowrap;
  padding: 5px 13px;
  border-radius: 20px;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-display);
  color: #888;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
  line-height: 1.2;
}

[data-theme="dark"] .brand-industry-tab {
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.4);
}

.brand-industry-tab:hover {
  border-color: rgba(0, 0, 0, 0.2);
  color: #444;
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .brand-industry-tab:hover {
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.05);
}

.brand-industry-tab.active {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: #fff;
}

[data-theme="dark"] .brand-industry-tab.active {
  background: #fff;
  border-color: #fff;
  color: #111;
}

/* ─── Cards Grid ─────────────────────────────── */

.brand-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  grid-auto-rows: min-content;
  gap: 8px;
  padding: 4px 22px 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* critical: lets flex child shrink so overflow-y actually scrolls */
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.12) transparent;
}

[data-theme="dark"] .brand-cards-grid {
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.brand-cards-grid::-webkit-scrollbar { width: 4px; }
.brand-cards-grid::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
  border-radius: 4px;
}

[data-theme="dark"] .brand-cards-grid::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
}

/* ─── Section Headers (grouped by industry) ──── */

.brand-section-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0 6px;
}

.brand-section-header:first-child {
  padding-top: 2px;
}

.brand-section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.05);
  color: #666;
  flex-shrink: 0;
}

.brand-section-icon svg {
  width: 14px;
  height: 14px;
}

.brand-section-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #333;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

.brand-section-count {
  font-size: 11px;
  color: #aaa;
  font-weight: 500;
}

.brand-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .brand-section-icon {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.45);
}

[data-theme="dark"] .brand-section-label {
  color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .brand-section-count {
  color: rgba(255, 255, 255, 0.25);
}

[data-theme="dark"] .brand-section-header::after {
  background: rgba(255, 255, 255, 0.06);
}

/* ─── Card ───────────────────────────────────── */

.brand-card {
  position: relative;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-top: 3px solid var(--brand-color, #3b82f6);
  border-radius: 14px;
  cursor: pointer;
  transition: box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.05);
}

[data-theme="dark"] .brand-card {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
  border-top-color: var(--brand-color, #3b82f6);
  box-shadow: none;
}

.brand-card:hover {
  border-color: var(--brand-color, #3b82f6);
  box-shadow:
    0 0 0 2px var(--brand-color, #3b82f6),
    0 4px 14px rgba(0,0,0,0.1);
}

[data-theme="dark"] .brand-card:hover {
  box-shadow: 0 0 0 2px var(--brand-color, #3b82f6), 0 4px 16px rgba(0,0,0,0.4);
}

.brand-card.selected {
  border-color: var(--brand-color, #3b82f6);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--brand-color, #3b82f6) 22%, transparent),
    0 2px 8px rgba(0,0,0,0.06);
}

[data-theme="dark"] .brand-card.selected {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-color, #3b82f6) 30%, transparent);
}

/* Logo area */
.brand-card-logo {
  padding: 14px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 52px;
  overflow: hidden;
  background: color-mix(in srgb, var(--brand-color, #3b82f6) 5%, transparent);
  border-radius: 13px 13px 0 0;
}

[data-theme="dark"] .brand-card-logo {
  background: color-mix(in srgb, var(--brand-color, #3b82f6) 8%, transparent);
}

.brand-card-logo img {
  max-width: 80%;
  max-height: 28px;
  object-fit: contain;
}

/* Monogram fallback */
.brand-card-logo--monogram {
  background: transparent;
}

.brand-card-logo--monogram .brand-monogram {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-color, #3b82f6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.brand-card-body {
  padding: 8px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

[data-theme="dark"] .brand-card-body {
  background: transparent;
}

.brand-card-name {
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
  font-family: var(--font-display);
  line-height: 1.25;
  word-break: break-word;
}

[data-theme="dark"] .brand-card-name {
  color: rgba(255, 255, 255, 0.9);
}

/* ─── Coming Soon state ────────────────────── */

.brand-card--soon {
  cursor: default;
  pointer-events: none;
  opacity: 0.38;
  border-top-color: rgba(0, 0, 0, 0.08) !important;
}

.brand-card--soon .brand-card-soon-label {
  font-size: 9px;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #aaa;
  margin-top: 1px;
}

[data-theme="dark"] .brand-card--soon {
  opacity: 0.3;
  border-top-color: rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] .brand-card--soon .brand-card-soon-label {
  color: rgba(255, 255, 255, 0.4);
}

.brand-card-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  z-index: 2;
}

.brand-card-check svg {
  stroke: var(--brand-color, #3b82f6);
}

.brand-card.selected .brand-card-check {
  display: flex;
}

/* ─── Footer ─────────────────────────────────── */

.brand-picker-footer {
  padding: 10px 22px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(0, 0, 0, 0.09);
  flex-shrink: 0;
  gap: 10px;
  margin-top: 4px;
}

[data-theme="dark"] .brand-picker-footer {
  border-top-color: rgba(255, 255, 255, 0.06);
}

.brand-selected-label {
  font-size: 12px;
  color: #999;
  font-family: var(--font-display);
}

[data-theme="dark"] .brand-selected-label {
  color: rgba(255, 255, 255, 0.35);
}

.brand-selected-name {
  font-weight: 600;
  color: #333;
}

[data-theme="dark"] .brand-selected-name {
  color: rgba(255, 255, 255, 0.8);
}

.brand-clear-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  background: transparent;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-display);
  color: #999;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

[data-theme="dark"] .brand-clear-btn {
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.35);
}

.brand-clear-btn:hover {
  border-color: rgba(0, 0, 0, 0.2);
  color: #555;
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .brand-clear-btn:hover {
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.06);
}

/* ─── Toolbar Button ─────────────────────────── */

.brand-btn-wrapper {
  position: relative;
}

.brand-btn {
  position: relative;
}

.brand-btn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  position: absolute;
  bottom: 4px;
  right: 4px;
  border: 1.5px solid var(--canvas);
  pointer-events: none;
}

/* ─── Bottom Sheets & Mobile Modals (≤768px) ──── */
@media (max-width: 768px) {
  /* Bottom sheet pattern for all modals */
  .profile-overlay,
  .project-settings-overlay,
  .share-overlay,
  .topup-overlay,
  .text-viewer-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .profile-card,
  .project-settings-card,
  .share-card,
  .topup-card,
  .text-viewer-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 85vh;
    border-radius: 20px 20px 0 0 !important;
    animation: slideUpSheet 0.3s ease-out;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Brand picker — full screen bottom sheet */
  .brand-picker-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .brand-picker-modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90vh;
    border-radius: 20px 20px 0 0 !important;
    animation: slideUpSheet 0.3s ease-out;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
  }

  .brand-cards-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 12px !important;
  }

  /* Auth mobile */
  .auth-card {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
    min-height: 100dvh;
    padding: 24px 20px calc(20px + env(safe-area-inset-bottom)) !important;
  }

  .auth-card input[type="email"],
  .auth-card input[type="password"],
  .auth-card input[type="text"] {
    font-size: 16px !important; /* Prevent iOS zoom */
    min-height: 44px;
  }

  .auth-card .checkbox-label {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Share invite — stack vertically */
  .share-invite-form {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .share-invite-form input {
    font-size: 16px !important;
    min-height: 44px;
  }

  .share-invite-form button {
    width: 100% !important;
    min-height: 44px;
  }
}

/* ─── Touch: Context Menu → Action Sheet ───────── */
@media (hover: none) {
  .context-menu {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    animation: slideUpSheet 0.3s ease-out;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
  }

  .context-menu-item {
    min-height: 48px !important;
    padding: 12px 20px !important;
    font-size: 16px !important;
  }
}

/* ─── Intermediate breakpoint (≤600px) ────────── */
/* Bridges gap between ≤480px and ≤900px — typical phones, iPhone SE landscape */
@media (max-width: 600px) {
  .starter-hero { padding: 14px 0 8px; gap: 4px; }
  .demo-chat { max-width: min(280px, 88vw); padding: 11px; }
  .demo-mini-slide { width: 48px; height: 33px; }
  .demo-chip-name { font-size: 10px; }
}

/* Mobile */
@media (max-width: 480px) {
  .brand-picker-modal {
    border-radius: 18px;
    max-height: 90vh;
  }
  .brand-picker-header { padding: 18px 16px 0; }
  .brand-industry-tabs { padding: 12px 16px 14px; }
  .brand-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
    padding: 0 16px 4px;
  }
  .brand-picker-footer { padding: 10px 16px 14px; }
  .brand-card-header { height: 48px; }

  /* Demo chat small mobile */
  .demo-chat { max-width: min(260px, 88vw); min-height: 150px; padding: 10px; border-radius: 10px; }
  .demo-bubble { padding: 6px 10px; font-size: 12px; }
  .demo-bubble-ai { padding-left: 24px; }
  .demo-bubble-ai::before { left: 8px; top: 10px; width: 7px; height: 7px; }
  .demo-chip { padding: 2px 6px; font-size: 10px; }
  .demo-mini-slide { width: 46px; height: 32px; }
  .demo-slides-row { margin-top: 5px; gap: 5px; }
  .demo-typed-wrap { font-size: 11px; }
  .starter-hero { padding: 12px 0 8px; }
}

/* ─── Very small screens (≤360px) ─────────────── */
@media (max-width: 360px) {
  .demo-chat {
    max-width: min(240px, 90vw);
    padding: 8px;
    gap: 5px;
  }
  .demo-files { flex-wrap: wrap; }
  .demo-bubble { font-size: 11px; padding: 5px 8px; }
  .demo-bubble-ai { padding-left: 20px; }
  .demo-bubble-ai::before { left: 7px; top: 9px; width: 7px; height: 7px; }
  .demo-chip { padding: 2px 5px; font-size: 9.5px; }
  .demo-mini-slide { width: 40px; height: 27px; padding: 2px; }
  .demo-slides-row { gap: 4px; margin-top: 4px; }
  .demo-typed-wrap { font-size: 10.5px; }
  .demo-chip-name { font-size: 9.5px; }
  .starter-hero h2 { font-size: 16px; }
  .starter-subtitle { font-size: 11.5px; }
}

/* ─── Mobile landscape (short viewport) ───────── */
/* Mobile landscape has ~320px viewport height; starter-hero + composer won't fit */
@media (orientation: landscape) and (max-height: 500px) {
  .starter-hero {
    padding: 8px 0 4px;
    gap: 4px;
    flex: 0 0 auto;
  }
  /* Hide subtitle to reclaim vertical space */
  .starter-subtitle { display: none; }
  .starter-hero h2 { font-size: 16px; }
  .demo-chat {
    max-width: 260px;
    max-height: 150px;
    min-height: 0;
    padding: 8px 10px;
    gap: 5px;
    margin-top: 4px;
    overflow: hidden;
  }
  .demo-bubble { font-size: 11px; padding: 5px 8px; line-height: 1.3; }
  .demo-bubble-ai { padding-left: 20px; }
  .demo-bubble-ai::before { left: 7px; top: 9px; width: 7px; height: 7px; }
  .demo-chip { padding: 2px 5px; font-size: 9.5px; }
  .demo-mini-slide { width: 42px; height: 27px; padding: 2px; }
  .demo-typed-wrap { font-size: 10.5px; }
}

/* ─── Absolute minimum (≤320px) ───────────────── */
/* Very old/small Android devices; also covers narrow split-screen */
@media (max-width: 320px) {
  .demo-chat {
    max-width: min(176px, 92vw);
    padding: 6px;
    gap: 4px;
    border-radius: 10px;
  }
  .demo-bubble { font-size: 10.5px; padding: 4px 7px; }
  .demo-bubble-ai { padding-left: 18px; }
  .demo-bubble-ai::before { left: 6px; top: 8px; width: 6px; height: 6px; }
  .demo-chip { padding: 1px 4px; font-size: 9px; }
  .demo-chip-name { font-size: 9px; }
  .demo-mini-slide { width: 36px; height: 24px; padding: 1px; }
  .demo-typed-wrap { font-size: 10px; }
  .starter-hero h2 { font-size: 15px; }
  .starter-subtitle { display: none; }
}

/* ─── Dark theme: demo-chat on mobile ─────────── */
@media (max-width: 900px) {
  [data-theme="dark"] .demo-chat {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.10);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.15);
  }
  [data-theme="dark"] .demo-bubble-user {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.10);
  }
}

/* ═══════════════════════════════════════════════
   Brand Persistence — Indicator & Sidebar Dots
   ═══════════════════════════════════════════════ */

.brand-active-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  cursor: default;
  margin-left: 8px;
  transition: opacity 0.15s var(--ease);
}

[data-theme="dark"] .brand-active-indicator {
  background: rgba(255, 255, 255, 0.06);
}

.brand-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.brand-indicator-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  font-family: var(--font-body);
}

.sidebar-brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 4px;
  opacity: 0.7;
}

.brand-set-default-link {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 11.5px;
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  padding: 0;
  margin-left: 6px;
  transition: color 0.15s var(--ease);
}

.brand-set-default-link:hover {
  color: var(--text-0);
}

[data-theme="dark"] .brand-set-default-link {
  color: rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] .brand-set-default-link:hover {
  color: rgba(255, 255, 255, 0.7);
}

.brand-default-badge {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-2);
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 6px;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
}

[data-theme="dark"] .brand-default-badge {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.45);
}

/* ─── Landscape mode adjustments ────────────── */
@media (orientation: landscape) and (max-width: 900px) {
  .mobile-nav { height: 36px; }
  .mobile-tab-bar { padding: 4px 0 max(4px, env(safe-area-inset-bottom)); }
  .mobile-tab { min-height: 36px; padding: 4px; }
}
