/* ==========================================================================
   ESCANOR AI - Claude.ai Design Language Interface Stylesheet
   Recreating the exact Anthropic Claude.ai aesthetic:
   - Editorial, warm, literary atmosphere (warm olive-charcoal & parchment)
   - Terracotta / coral orange accent color (#c96442)
   - Clean non-bubble typography-first chat stream
   - Floating pill input area with subtle ring shadow
   - Refined typography pairing Inter with Playfair Display
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Typography & Web Font Imports
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300..700;1,14..32,300..700&family=Playfair+Display:ital,wght@0,400..700;1,400..700&family=JetBrains+Mono:ital,wght@0,400..600;1,400..600&display=swap');

/* --------------------------------------------------------------------------
   2. Design Tokens & CSS Custom Properties
   -------------------------------------------------------------------------- */

:root,
html[data-theme="dark"],
html.dark {
  /* Color Palette - Claude.ai Dark Theme (Default) */
  --bg-canvas: #2b2a27;               /* Warm olive-charcoal canvas */
  --bg-sidebar: #1f1f1d;              /* Slightly darker warm tone */
  --bg-surface: #343330;              /* Warm dark surface */
  --bg-surface-hover: #3d3c38;        /* Subtle hover state */
  --bg-surface-active: #464540;       /* Active state */
  --bg-input-container: #2b2a27;      /* Match canvas background */
  --bg-input-field: #343330;          /* Warm dark input wrapper */
  --bg-input-focus: #383733;          /* Focus state */
  --bg-card: #343330;                 /* Card background */
  --bg-card-hover: #3d3c38;           /* Card hover */
  --bg-overlay: rgba(20, 20, 18, 0.72); /* Mobile backdrop blur overlay */

  /* Typography Colors */
  --text-primary: #e8e6e0;            /* Warm off-white, NOT pure white */
  --text-secondary: #a8a69e;          /* Warm muted secondary */
  --text-muted: #706f6a;              /* Subdued tertiary */
  --text-placeholder: #706f6a;        /* Input placeholder */
  --text-inverse: #1a1918;            /* Contrast text */

  /* Accent & Brand Colors (Claude Terracotta) */
  --accent: #c96442;                  /* Signature terracotta/coral orange */
  --accent-hover: #b85538;            /* Deepened terracotta on hover */
  --accent-active: #a2462c;           /* Pressed state */
  --accent-light: rgba(201, 100, 66, 0.15); /* Soft terracotta wash */
  --accent-subtle: rgba(201, 100, 66, 0.08); /* Very faint tint */
  --accent-border: rgba(201, 100, 66, 0.35); /* Accent highlight border */

  /* Structural Borders & Dividers */
  --border-color: #3d3d38;            /* Subtle warm borders */
  --border-subtle: #33332e;           /* Hairline separator */
  --border-hover: #4d4d46;            /* Border hover */
  --border-focus: #c96442;            /* Focus ring */

  /* Code Block Tokens */
  --code-bg: #1a1a18;                 /* Deep warm black */
  --code-header-bg: #151513;          /* Slightly darker header */
  --code-border: #333330;             /* Code block border */
  --code-text: #e8e6e0;               /* Code body text */
  --code-inline-bg: rgba(232, 230, 224, 0.08); /* Inline badge */
  --code-inline-text: #f0b19e;         /* Warm coral badge text */

  /* Status Tokens */
  --success: #6d9a5b;                 /* Muted natural olive green */
  --success-light: rgba(109, 154, 91, 0.15);
  --warning: #d99b43;                 /* Warm amber */
  --warning-light: rgba(217, 155, 67, 0.15);
  --error: #c45c5c;                   /* Soft warm crimson */
  --error-light: rgba(196, 92, 92, 0.15);
  --error-border: rgba(196, 92, 92, 0.35);

  /* Typography Fonts */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Playfair Display', Georgia, Cambria, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Sizing, Radius & Shadows */
  --sidebar-width: 260px;
  --header-height: 52px;
  --chat-max-width: 680px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-input: 0 0 0 1px var(--border-color), 0 4px 18px rgba(0, 0, 0, 0.18);
  --shadow-input-focus: 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-light), 0 6px 22px rgba(0, 0, 0, 0.25);

  /* Scrollbar */
  --scrollbar-thumb: #484742;
  --scrollbar-thumb-hover: #5c5b55;
  --scrollbar-track: transparent;

  /* Transitions & Fluid Spring Easing Curves */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-bounce: cubic-bezier(0.34, 1.4, 0.64, 1);
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.38s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   3. Light Theme Tokens (Parchment / Cream)
   -------------------------------------------------------------------------- */

[data-theme="light"],
html.light,
body.light-theme {
  /* Color Palette - Claude.ai Light Theme */
  --bg-canvas: #f5f4ed;               /* Warm parchment/cream */
  --bg-sidebar: #eae8e0;              /* Tonal warm cream sidebar */
  --bg-surface: #ffffff;              /* Crisp clean white surface */
  --bg-surface-hover: #e4e2d8;        /* Hover surface */
  --bg-surface-active: #dad8ce;       /* Active surface */
  --bg-input-container: #f5f4ed;      /* Parchment input background */
  --bg-input-field: #ffffff;          /* White input field */
  --bg-input-focus: #ffffff;          /* Focus state */
  --bg-card: #ffffff;                 /* Pure white card */
  --bg-card-hover: #f9f8f3;           /* Light card hover */
  --bg-overlay: rgba(30, 29, 27, 0.45);/* Backdrop overlay */

  /* Typography Colors */
  --text-primary: #1a1918;            /* Deep warm charcoal */
  --text-secondary: #6b6a65;          /* Warm muted secondary */
  --text-muted: #9a9890;              /* Subdued tertiary */
  --text-placeholder: #9a9890;        /* Input placeholder */
  --text-inverse: #ffffff;            /* Inverse */

  /* Accent & Brand Colors */
  --accent: #c96442;                  /* Signature terracotta */
  --accent-hover: #b85538;            /* Hover terracotta */
  --accent-active: #a2462c;           /* Active terracotta */
  --accent-light: rgba(201, 100, 66, 0.12); /* Subtle wash */
  --accent-subtle: rgba(201, 100, 66, 0.05); /* Faint wash */
  --accent-border: rgba(201, 100, 66, 0.28);

  /* Structural Borders & Dividers */
  --border-color: #e0ddd4;            /* Warm parchment border */
  --border-subtle: #eae7de;           /* Hairline separator */
  --border-hover: #cfccc2;            /* Border hover */
  --border-focus: #c96442;            /* Focus ring */

  /* Code Block Tokens (Dark even in light mode for readability) */
  --code-bg: #1f1e1c;
  --code-header-bg: #171614;
  --code-border: #353430;
  --code-text: #e8e6e0;
  --code-inline-bg: rgba(43, 42, 39, 0.08);
  --code-inline-text: #b85538;

  /* Status Tokens */
  --success: #548243;
  --success-light: rgba(84, 130, 67, 0.12);
  --warning: #b87e28;
  --warning-light: rgba(184, 126, 40, 0.12);
  --error: #b33a3a;
  --error-light: rgba(179, 58, 58, 0.12);
  --error-border: rgba(179, 58, 58, 0.28);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.10);
  --shadow-input: 0 0 0 1px var(--border-color), 0 3px 14px rgba(0, 0, 0, 0.05);
  --shadow-input-focus: 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-light), 0 4px 18px rgba(201, 100, 66, 0.12);

  /* Scrollbar */
  --scrollbar-thumb: #cfccc2;
  --scrollbar-thumb-hover: #b5b2a6;
  --scrollbar-track: transparent;
}

/* --------------------------------------------------------------------------
   4. CSS Reset & Global Base Styles
   -------------------------------------------------------------------------- */

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  border: none;
  background: none;
}

button {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

button:active:not(:disabled) {
  transform: scale(0.96);
  transition: transform 0.08s ease;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
}

/* --------------------------------------------------------------------------
   5. Custom Scrollbar Styling (Minimal, Editorial 6px)
   -------------------------------------------------------------------------- */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* --------------------------------------------------------------------------
   6. Main App Container Layout
   -------------------------------------------------------------------------- */

.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-canvas);
  position: relative;
}

/* --------------------------------------------------------------------------
   7. Sidebar (Collapsible, Tonal Separation, No Hard Line)
   -------------------------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 50;
  border-right: 1px solid var(--border-subtle);
  flex-shrink: 0;
  overflow: hidden;
  transition: margin-left 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: margin-left;
  user-select: none;
}

/* Desktop Collapsed State - Fluid slide behind viewport edge without opacity pop */
.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
  pointer-events: none;
}

/* Sidebar Header Area */
.sidebar-header {
  padding: 16px 14px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

/* Logo Component */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.logo:hover {
  background-color: var(--bg-surface-hover);
}

.logo-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--bg-surface);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.logo-icon img {
  width: 28px;
  height: 28px;
  object-fit: cover;
}

.logo-text {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  line-height: 1.2;
}

/* New Chat Button (Outlined / Ghost Terracotta Style) */
.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all 0.25s var(--ease-spring);
}

.new-chat-btn svg {
  color: var(--accent);
  stroke: var(--accent);
  flex-shrink: 0;
  transition: transform 0.35s var(--ease-bounce);
}

.new-chat-btn:hover {
  background-color: var(--bg-surface);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1.5px);
  box-shadow: 0 4px 14px rgba(201, 100, 66, 0.15);
}

.new-chat-btn:hover svg {
  transform: rotate(90deg) scale(1.15);
}

.new-chat-btn:active {
  transform: scale(0.97) translateY(0);
}

.new-chat-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* --------------------------------------------------------------------------
   8. Conversation History List
   -------------------------------------------------------------------------- */

.conversations-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conversation-item-empty {
  padding: 28px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
}

/* Individual Conversation Item */
.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 450;
  cursor: pointer;
  position: relative;
  transition: all 0.22s var(--ease-spring);
  text-decoration: none;
  outline: none;
}

.conversation-item:hover {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  transform: translateX(4px);
}

.conversation-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* Active Conversation Item (Warm highlighted background + Left terracotta indicator) */
.conversation-item.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 500;
  transform: translateX(3px);
}

.conversation-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background-color: var(--accent);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  box-shadow: 0 0 8px rgba(201, 100, 66, 0.45);
}

/* Conversation Item Elements */
.conversation-item-icon {
  flex-shrink: 0;
  margin-right: 9px;
  color: var(--text-muted);
  opacity: 0.75;
  transition: color 0.2s ease, opacity 0.2s ease, transform 0.25s var(--ease-spring);
}

.conversation-item:hover .conversation-item-icon,
.conversation-item.active .conversation-item-icon {
  color: var(--accent);
  opacity: 1;
  transform: scale(1.08);
}

.conversation-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 6px;
  line-height: 1.3;
}

.conversation-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.2s ease, transform 0.22s var(--ease-spring);
  margin-left: auto;
}

.conversation-item:hover .conversation-item-actions,
.conversation-item:focus-within .conversation-item-actions {
  opacity: 1;
  transform: translateX(0);
}

.delete-conv-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 4px;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  background: transparent;
  transition: all 0.2s var(--ease-bounce);
}

.delete-conv-btn:hover {
  color: var(--error);
  background-color: var(--error-light);
  transform: scale(1.15);
}

.delete-conv-btn:active {
  transform: scale(0.9);
}

.share-conv-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 4px;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  background: transparent;
  transition: all 0.2s var(--ease-bounce);
}

.share-conv-btn:hover {
  color: var(--accent);
  background-color: var(--accent-light);
  transform: scale(1.15);
}

.share-conv-btn:active {
  transform: scale(0.9);
}

.share-conv-btn:focus-visible {
  outline: 2px solid var(--accent);
}

.delete-conv-btn:focus-visible {
  outline: 2px solid var(--error);
}

/* --------------------------------------------------------------------------
   9. Sidebar Footer (Connection Status & Theme Toggle)
   -------------------------------------------------------------------------- */

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background-color: var(--bg-sidebar);
  flex-shrink: 0;
}

/* Settings Button in Sidebar Footer */
.settings-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  user-select: none;
}

.settings-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-hover);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.settings-btn:active {
  transform: translateY(0) scale(0.98);
}

.settings-btn-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-btn .gear-icon {
  color: var(--text-secondary);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s;
}

.settings-btn:hover .gear-icon {
  color: var(--accent);
  transform: rotate(60deg);
}

.settings-btn-text {
  font-weight: 500;
  letter-spacing: -0.01em;
}

.settings-btn .chevron-icon {
  color: var(--text-muted);
  transition: transform 0.2s, color 0.2s;
}

.settings-btn:hover .chevron-icon {
  color: var(--accent);
  transform: translateX(2px);
}

.theme-footer-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   9b. Modern Tactile Theme Switcher (#theme-toggle)
   ========================================================================== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  outline: none;
  border-radius: var(--radius-full);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle-track {
  position: relative;
  display: flex;
  align-items: center;
  width: 52px;
  height: 28px;
  border-radius: 9999px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 2px;
  box-sizing: border-box;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
}

.theme-toggle:hover .theme-toggle-track {
  border-color: var(--accent);
  background-color: var(--bg-surface-hover);
  transform: scale(1.05);
}

.theme-toggle:active .theme-toggle-track {
  transform: scale(0.95);
}

.theme-toggle:focus-visible .theme-toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle-thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease, color 0.3s ease;
}

/* Dark Mode Theme Switch State (Default) */
html[data-theme="dark"] .theme-toggle-track,
html.dark .theme-toggle-track {
  background-color: #1a1917;
  border-color: rgba(255, 255, 255, 0.12);
}

html[data-theme="dark"] .theme-toggle-thumb,
html.dark .theme-toggle-thumb {
  transform: translateX(0);
  background-color: #383733;
  color: #fbbf24; /* Warm golden moon */
}

html[data-theme="dark"] .theme-icon-moon,
html.dark .theme-icon-moon {
  display: block;
}

html[data-theme="dark"] .theme-icon-sun,
html.dark .theme-icon-sun {
  display: none;
}

/* Light Mode Theme Switch State */
html[data-theme="light"] .theme-toggle-track,
html.light .theme-toggle-track {
  background-color: #e2e0d8;
  border-color: rgba(0, 0, 0, 0.15);
}

html[data-theme="light"] .theme-toggle-thumb,
html.light .theme-toggle-thumb {
  transform: translateX(24px);
  background-color: #ffffff;
  color: #ea580c; /* Warm solar amber */
}

html[data-theme="light"] .theme-icon-moon,
html.light .theme-icon-moon {
  display: none;
}

html[data-theme="light"] .theme-icon-sun,
html.light .theme-icon-sun {
  display: block;
}

/* --------------------------------------------------------------------------
   10. Sidebar Mobile Drawer & Overlay
   -------------------------------------------------------------------------- */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   11. Main Content Container
   -------------------------------------------------------------------------- */

.main-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  height: 100%;
  background-color: var(--bg-canvas);
  position: relative;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   12. Minimal Top Chat Header (52px Height)
   -------------------------------------------------------------------------- */

.chat-header {
  height: var(--header-height);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(43, 42, 39, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 20;
  flex-shrink: 0;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

html[data-theme="light"] .chat-header,
html.light .chat-header {
  background: rgba(250, 249, 245, 0.8);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background-color: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.sidebar-toggle svg {
  transition: transform 0.28s var(--ease-spring);
}

.sidebar-toggle:hover {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-subtle);
  transform: scale(1.05);
}

.sidebar-toggle:active {
  transform: scale(0.92);
}

.sidebar-toggle:focus-visible {
  outline: 2px solid var(--accent);
}

/* Chat Header Action Buttons (Share, etc.) */
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.header-action-btn svg {
  color: var(--text-secondary);
  stroke: currentColor;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.header-action-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-action-btn:hover svg {
  color: var(--accent);
  stroke: var(--accent);
}

.header-action-btn:active {
  transform: scale(0.96) translateY(0);
}

/* Hide share button when chat is empty */
.main-content.is-empty .header-action-btn.share-btn {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Model Selector Dropdown - Hidden from top header (handled by composer pill badge) */
.model-selector,
select#model-select {
  display: none !important;
}

/* --------------------------------------------------------------------------
   13. Chat Layout & Messages Container
   -------------------------------------------------------------------------- */

.chat-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  height: calc(100% - var(--header-height));
}

/* Empty Landing State (Centered exactly like modern ChatGPT) */
.main-content.is-empty .chat-layout {
  justify-content: center;
  align-items: center;
  padding: 0 20px 40px 20px;
}

.main-content.is-empty .messages-container {
  display: none !important;
}

.main-content.is-empty .welcome-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 22px;
  animation: heroEntrance 0.6s var(--ease-spring) both;
}

.welcome-title {
  font-family: var(--font-sans);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
  text-align: center;
  transition: transform 0.3s ease;
}

.main-content.is-empty .composer-section {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  animation: heroEntrance 0.6s var(--ease-spring) 0.08s both;
}

.main-content.is-empty .input-area {
  padding: 0;
}

/* Active Chatting State */
.main-content:not(.is-empty) .welcome-header {
  display: none !important;
}

.main-content:not(.is-empty) .welcome-suggestions {
  display: none !important;
}

.main-content:not(.is-empty) .messages-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  margin-bottom: -78px;
  padding-bottom: 180px;

  /* Progressive soft fade mask at bottom & top to prevent abrupt text cutoffs */
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.4) 10px,
    #000 28px,
    #000 calc(100% - 145px),
    rgba(0, 0, 0, 0.8) calc(100% - 95px),
    rgba(0, 0, 0, 0.25) calc(100% - 45px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.4) 10px,
    #000 28px,
    #000 calc(100% - 145px),
    rgba(0, 0, 0, 0.8) calc(100% - 95px),
    rgba(0, 0, 0, 0.25) calc(100% - 45px),
    transparent 100%
  );
}

.main-content:not(.is-empty) .composer-section {
  width: 100%;
  max-width: var(--chat-max-width);
  margin: 0 auto;
  padding: 0 20px 16px 20px;
  position: relative;
  z-index: 25;
  pointer-events: none;
}

.main-content:not(.is-empty) .input-area {
  pointer-events: auto;
}

/* Messages Container (Scrollable Area) */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 20px 32px 20px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}

.messages-container > * {
  max-width: var(--chat-max-width);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* --------------------------------------------------------------------------
   14. Welcome Suggestions List (Positioned right below input in empty state)
   -------------------------------------------------------------------------- */

.welcome-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
  width: 100%;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: transparent;
  border: 1px solid transparent;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  transition: all 0.22s var(--ease-spring);
  width: 100%;
  opacity: 0;
  animation: suggestionFadeUp 0.5s var(--ease-spring) forwards;
}

.suggestion-item:nth-child(1) { animation-delay: 0.12s; }
.suggestion-item:nth-child(2) { animation-delay: 0.2s; }
.suggestion-item:nth-child(3) { animation-delay: 0.28s; }
.suggestion-item:nth-child(4) { animation-delay: 0.36s; }

.suggestion-item:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  transform: translateX(6px);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
}

.suggestion-item:hover .suggestion-icon {
  transform: scale(1.22) rotate(-6deg);
  color: var(--accent);
}

.suggestion-item:active {
  transform: translateX(3px) scale(0.99);
}

.suggestion-item .suggestion-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.25s var(--ease-bounce), color 0.2s ease;
}

.suggestion-item .suggestion-text {
  flex: 1;
  color: inherit;
  font-size: 13.5px;
  line-height: 1.4;
}

/* --------------------------------------------------------------------------
   15. Messages (Claude-Style: Right Pill Bubble for User, Left Clean Text for AI)
   -------------------------------------------------------------------------- */

.message {
  display: flex;
  margin-bottom: 24px;
  position: relative;
  width: 100%;
}

.message.animate-in {
  animation: none;
}

/* User Message: Right-Aligned Pill Bubble with Spring Pop */
.message.user {
  justify-content: flex-end;
}

.message.user.animate-in .user-bubble {
  animation: userMessagePop 0.35s var(--ease-spring) both;
  transform-origin: bottom right;
}

.user-bubble {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  max-width: 75%;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-bubble:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.user-text-content {
  white-space: pre-wrap;
  word-break: break-word;
  width: 100%;
}

/* Assistant Message: Left-Aligned Editorial Text */
.message.assistant {
  justify-content: flex-start;
  flex-direction: column;
}

.message.assistant.animate-in {
  animation: assistantFadeUp 0.4s var(--ease-spring) both;
}

.assistant-body {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.assistant-body .markdown-body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-primary);
  word-break: break-word;
}

/* Assistant Message Actions Toolbar (Copy, Speak, Thumbs, Retry) */
.assistant-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  opacity: 0.85;
  transition: opacity 0.2s ease, transform 0.25s var(--ease-spring);
  animation: actionToolbarPop 0.35s var(--ease-spring) both;
}

.message.assistant:hover .assistant-actions {
  opacity: 1;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: none;
  background-color: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s var(--ease-bounce), color 0.15s ease, background-color 0.15s ease;
}

.action-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  transform: translateY(-2px) scale(1.12);
}

.action-btn:active {
  transform: scale(0.88);
}

.action-btn.active {
  color: var(--accent);
  animation: popCheck 0.3s var(--ease-bounce);
}

.action-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
}

/* Typing Indicator (Claude Style Floating Dots on Left) */
.typing-indicator-row {
  margin-bottom: 20px;
  animation: assistantFadeUp 0.35s var(--ease-spring) both;
}

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  opacity: 0.4;
  animation: typingWave 1.3s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

/* --------------------------------------------------------------------------
   16. Markdown Body (Literary, Editorial Claude Typography)
   -------------------------------------------------------------------------- */

.markdown-body {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-primary);
  word-break: break-word;
}

.markdown-body p {
  margin-bottom: 1.1em;
  line-height: 1.65;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

/* Headings with literary touch */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  color: var(--text-primary);
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-top: 1.5em;
  margin-bottom: 0.6em;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0.2em;
}

.markdown-body h1 {
  font-family: var(--font-serif);
  font-size: 1.75em;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.3em;
}

.markdown-body h2 {
  font-family: var(--font-serif);
  font-size: 1.4em;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.25em;
}

.markdown-body h3 {
  font-size: 1.18em;
}

.markdown-body h4 {
  font-size: 1.05em;
}

.markdown-body h5,
.markdown-body h6 {
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

/* Lists */
.markdown-body ul,
.markdown-body ol {
  padding-left: 1.6em;
  margin-bottom: 1.1em;
}

.markdown-body ul:last-child,
.markdown-body ol:last-child {
  margin-bottom: 0;
}

.markdown-body li {
  margin-bottom: 0.4em;
  line-height: 1.6;
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin-top: 0.3em;
  margin-bottom: 0.3em;
}

/* Blockquotes (Literary accent border) */
.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 1.2em 0;
  background-color: var(--accent-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.markdown-body blockquote p {
  margin-bottom: 0.5em;
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

/* Horizontal Rules */
.markdown-body hr {
  height: 0;
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2em 0;
}

/* Strong, Emphasis & Del */
.markdown-body strong {
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-body em {
  font-style: italic;
}

.markdown-body del {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.3em 0;
  font-size: 14px;
  line-height: 1.5;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.markdown-body th,
.markdown-body td {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.markdown-body th {
  background-color: var(--bg-surface);
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-body tr:nth-child(even) {
  background-color: var(--accent-subtle);
}

/* --------------------------------------------------------------------------
   17. Code Blocks & Inline Code
   -------------------------------------------------------------------------- */

/* Inline Code Badges */
.inline-code,
code.inline-code,
p > code,
li > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background-color: var(--code-inline-bg);
  color: var(--code-inline-text);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  white-space: break-spaces;
}

/* Code Block Wrapper */
.code-block-wrapper {
  position: relative;
  margin: 1.3em 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  box-shadow: var(--shadow-sm);
}

/* Code Block Header */
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background-color: var(--code-header-bg);
  border-bottom: 1px solid var(--code-border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
}

.code-lang {
  text-transform: lowercase;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

/* Copy Code Button */
.copy-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
}

.copy-code-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--accent);
  transform: translateY(-1px) scale(1.04);
}

.copy-code-btn:active {
  transform: scale(0.93);
}

.copy-code-btn.copied {
  border-color: var(--success);
  color: var(--success);
  background-color: var(--success-light);
  animation: popCheck 0.35s var(--ease-bounce);
}

.copy-icon {
  width: 13px;
  height: 13px;
  stroke: currentColor;
}

.copy-text {
  font-size: 11.5px;
  line-height: 1;
}

/* Code Body Pre / Code */
.code-block-wrapper pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  tab-size: 2;
  background-color: transparent;
}

.code-block-wrapper code {
  font-family: var(--font-mono);
  font-size: inherit;
  color: var(--code-text);
  background: transparent;
  padding: 0;
  border: none;
}

/* --------------------------------------------------------------------------
   18. Typing Indicator Row & Dots
   -------------------------------------------------------------------------- */

.typing-indicator-row {
  margin-bottom: 24px;
}

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 4px;
  box-shadow: var(--shadow-sm);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent);
  border-radius: 50%;
  opacity: 0.35;
  animation: escanorBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0s;
}

/* --------------------------------------------------------------------------
   19. System Error Message & Retry Card
   -------------------------------------------------------------------------- */

.system-error-message {
  margin-bottom: 24px;
  width: 100%;
}

.error-card {
  padding: 16px 20px;
  background-color: var(--error-light);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.error-header {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--error);
  font-weight: 600;
  font-size: 14.5px;
  margin-bottom: 8px;
}

.error-header svg {
  stroke: var(--error);
  flex-shrink: 0;
}

.error-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.error-body code {
  background-color: rgba(0, 0, 0, 0.25);
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.error-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

.retry-message-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background-color: var(--accent);
  color: #ffffff;
  border: none;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.retry-message-btn svg {
  stroke: currentColor;
}

.retry-message-btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.retry-message-btn:active {
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   20. Input Area & Claude Floating Pill Container
   -------------------------------------------------------------------------- */

.input-area {
  padding: 12px 20px 20px 20px;
  background-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

/* Modern Frosted Glass Input Wrapper ("Effet vitre / glassmorphism") */
.input-wrapper {
  max-width: var(--chat-max-width);
  width: 100%;
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  
  /* Glass Surface: Translucent, tinted, frosted pane of glass */
  background: linear-gradient(
    135deg, 
    rgba(255, 255, 255, 0.09) 0%, 
    rgba(255, 255, 255, 0.03) 38%, 
    rgba(0, 0, 0, 0.09) 100%
  ), rgba(46, 44, 40, 0.74);
  
  /* Authentic frosted glass blur & light refraction */
  backdrop-filter: blur(24px) saturate(190%) contrast(105%);
  -webkit-backdrop-filter: blur(24px) saturate(190%) contrast(105%);
  
  /* Glass pane specular edge highlight */
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top: 1px solid rgba(255, 255, 255, 0.28);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-xl);
  padding: 8px 10px 8px 18px;
  
  /* Multilayer glass depth & refraction shadow */
  box-shadow: 
    0 0 0 0 rgba(201, 100, 66, 0),
    0 14px 40px -4px rgba(0, 0, 0, 0.44),
    0 2px 8px 0 rgba(0, 0, 0, 0.25),
    inset 0 1px 1.5px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 1px 0 rgba(0, 0, 0, 0.35);
    
  transition: 
    border-color 0.3s ease, 
    box-shadow 0.38s cubic-bezier(0.22, 1, 0.36, 1), 
    background 0.3s ease, 
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    backdrop-filter 0.3s ease;
  will-change: box-shadow, transform;
}

.input-wrapper:hover {
  border-color: rgba(255, 255, 255, 0.26);
  border-top-color: rgba(255, 255, 255, 0.42);
  background: linear-gradient(
    135deg, 
    rgba(255, 255, 255, 0.12) 0%, 
    rgba(255, 255, 255, 0.04) 38%, 
    rgba(0, 0, 0, 0.06) 100%
  ), rgba(50, 48, 44, 0.78);
  box-shadow: 
    0 0 0 0 rgba(201, 100, 66, 0),
    0 18px 48px -4px rgba(0, 0, 0, 0.52),
    0 4px 12px 0 rgba(0, 0, 0, 0.3),
    inset 0 1px 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 1px 0 rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

.input-wrapper:focus-within {
  border-color: rgba(255, 255, 255, 0.28);
  border-top-color: rgba(255, 255, 255, 0.45);
  border-bottom-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(
    135deg, 
    rgba(255, 255, 255, 0.12) 0%, 
    rgba(255, 255, 255, 0.04) 38%, 
    rgba(0, 0, 0, 0.06) 100%
  ), rgba(52, 50, 46, 0.82);
  box-shadow: 
    0 0 30px 4px rgba(201, 100, 66, 0.32),
    0 20px 52px -4px rgba(0, 0, 0, 0.58),
    0 4px 12px 0 rgba(0, 0, 0, 0.3),
    inset 0 1px 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 1px 0 rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
  outline: none;
}

/* Light Theme Glass Effect for Input Wrapper */
html[data-theme="light"] .input-wrapper,
html.light .input-wrapper {
  background: linear-gradient(
    135deg, 
    rgba(255, 255, 255, 0.88) 0%, 
    rgba(255, 255, 255, 0.65) 40%, 
    rgba(242, 240, 234, 0.75) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-top: 1px solid #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 
    0 0 0 0 rgba(201, 100, 66, 0),
    0 14px 40px -4px rgba(40, 30, 20, 0.12),
    0 2px 8px 0 rgba(40, 30, 20, 0.05),
    inset 0 1px 2px 0 #ffffff,
    inset 0 -1px 1px 0 rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .input-wrapper:hover,
html.light .input-wrapper:hover {
  border-color: #ffffff;
  box-shadow: 
    0 0 0 0 rgba(201, 100, 66, 0),
    0 18px 46px -4px rgba(40, 30, 20, 0.15),
    0 2px 8px 0 rgba(40, 30, 20, 0.05),
    inset 0 1px 2px 0 #ffffff,
    inset 0 -1px 1px 0 rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .input-wrapper:focus-within,
html.light .input-wrapper:focus-within {
  border-color: rgba(255, 255, 255, 0.95);
  border-top-color: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.08);
  box-shadow: 
    0 0 26px 4px rgba(201, 100, 66, 0.26),
    0 20px 50px -4px rgba(40, 30, 20, 0.18),
    0 2px 8px 0 rgba(40, 30, 20, 0.05),
    inset 0 1px 2px 0 #ffffff,
    inset 0 -1px 1px 0 rgba(0, 0, 0, 0.04);
  outline: none;
}

/* Auto-expanding Textarea */
.input-wrapper textarea,
textarea#user-input {
  flex: 1;
  min-height: 24px;
  max-height: 200px;
  padding: 6px 6px 6px 0;
  border: none;
  background-color: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  resize: none;
  outline: none;
}

.input-wrapper textarea:focus,
textarea#user-input:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.input-wrapper textarea::placeholder,
textarea#user-input::placeholder {
  color: var(--text-placeholder);
  opacity: 0.85;
}

/* Circular Send Button (36px, Terracotta Accent) */
.send-btn,
button#send-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background-color: var(--accent);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 1px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s var(--ease-spring);
}

.send-btn svg,
.send-icon {
  stroke: #ffffff;
  width: 18px;
  height: 18px;
  margin-left: 2px;
  transition: transform 0.25s var(--ease-bounce);
}

.send-btn:not(:disabled) {
  animation: sendReadyPulse 2s infinite ease-in-out;
}

.send-btn:hover:not(:disabled) {
  background-color: var(--accent-hover);
  transform: scale(1.08) rotate(-3deg);
  box-shadow: 0 4px 18px rgba(201, 100, 66, 0.55);
}

.send-btn:hover:not(:disabled) svg {
  transform: translateX(2px) translateY(-2px) scale(1.1);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.92) rotate(0deg);
}

.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  animation: none;
}

/* Stop Generation Button */
.stop-btn,
.escanor-stop-btn,
button#stop-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-xl);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
  margin-bottom: 1px;
  transition: all 0.2s var(--ease-spring);
  animation: stopPulseRing 1.5s infinite ease-in-out;
}

.stop-btn svg {
  fill: var(--accent);
  color: var(--accent);
  width: 12px;
  height: 12px;
}

.stop-btn:hover {
  background-color: var(--error-light);
  border-color: var(--error);
  color: var(--error);
  transform: scale(1.05);
}

.stop-btn:hover svg {
  fill: var(--error);
  color: var(--error);
}

.stop-btn:active {
  transform: scale(0.94);
}

/* Input Wrapper Extras: Attach button, right actions group, model badge, voice button */
.attach-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 1px;
  transition: all 0.22s var(--ease-spring);
}

.attach-btn svg {
  transition: transform 0.35s var(--ease-bounce);
}

.attach-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  transform: scale(1.1);
}

.attach-btn:hover svg {
  transform: rotate(90deg) scale(1.1);
}

.attach-btn:active {
  transform: scale(0.92);
}

.input-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-bottom: 1px;
}

.model-badge-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  user-select: none;
  height: 28px;
  font-family: var(--font-sans);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.18);
}

.model-badge:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.25);
}

html[data-theme="light"] .model-badge,
html.light .model-badge {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.model-badge:active {
  transform: scale(0.96) translateY(0);
}

.model-badge .badge-text {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  line-height: 1;
}

.model-badge .chevron-icon {
  stroke: currentColor;
  transition: transform 0.28s var(--ease-spring);
}

.model-badge[aria-expanded="true"] .chevron-icon {
  transform: rotate(180deg);
}

/* Model Dropdown Menu Popover (Opens upwards above composer) */
.model-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  min-width: 210px;
  max-width: min(280px, calc(100vw - 32px));
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--border-subtle);
  padding: 6px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform-origin: bottom right;
  transform: translateY(10px) scale(0.95);
  transition: opacity 0.22s var(--ease-spring), transform 0.22s var(--ease-spring), visibility 0.22s;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.model-dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.model-dropdown-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 6px 8px 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}

.model-dropdown-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.model-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 450;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background-color var(--transition-fast), color var(--transition-fast), padding-left var(--transition-fast), transform var(--transition-fast);
}

.model-dropdown-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  padding-left: 13px;
}

.model-dropdown-item:active {
  transform: scale(0.97);
}

.model-dropdown-item.active {
  background-color: var(--accent-light);
  color: var(--accent);
  font-weight: 550;
}

.model-dropdown-item .item-check {
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
}

.voice-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

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

/* Input Disclaimer (Small, Muted Editorial Text) */
.input-disclaimer {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 9px;
  line-height: 1.4;
  letter-spacing: -0.005em;
  max-width: var(--chat-max-width);
}

/* --------------------------------------------------------------------------
   21. Escanor Toast Notifications
   -------------------------------------------------------------------------- */

.escanor-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
}

.escanor-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  font-size: 13.5px;
  line-height: 1.4;
  transition: all var(--transition-normal);
}

.escanor-toast.toast-error {
  border-left-color: var(--error);
}

.escanor-toast.toast-warning {
  border-left-color: var(--warning);
}

.escanor-toast.toast-success {
  border-left-color: var(--success);
}

.escanor-toast.toast-info {
  border-left-color: var(--accent);
}

.toast-message {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0 2px;
  transition: color var(--transition-fast);
}

.toast-close:hover {
  color: var(--text-primary);
}

.animate-toast-in {
  animation: toastIn 0.3s var(--transition-slow) forwards;
}

.animate-toast-out {
  opacity: 0;
  transform: translateY(10px);
}

/* --------------------------------------------------------------------------
   22. Keyframe Animations (Fluid Spring & Micro-Interactions)
   -------------------------------------------------------------------------- */

/* Hero Entrance */
@keyframes heroEntrance {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Staggered Suggestion Entry */
@keyframes suggestionFadeUp {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* User Message Pop In */
@keyframes userMessagePop {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Assistant Message Smooth Slide In */
@keyframes assistantFadeUp {
  0% {
    opacity: 0;
    transform: translateY(14px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Action Toolbar Soft Pop */
@keyframes actionToolbarPop {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  100% {
    opacity: 0.9;
    transform: translateY(0);
  }
}

/* Modern Wave Typing Indicator */
@keyframes typingWave {
  0%, 60%, 100% {
    transform: translateY(0) scale(0.85);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-7px) scale(1.2);
    opacity: 1;
    background-color: var(--accent);
  }
}

/* Ready to Send Button Breathing Aura */
@keyframes sendReadyPulse {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(201, 100, 66, 0.3);
  }
  50% {
    box-shadow: 0 2px 18px rgba(201, 100, 66, 0.65);
  }
}

/* Stop Button Concentric Ripple */
@keyframes stopPulseRing {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(196, 92, 92, 0.5);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 0 7px rgba(196, 92, 92, 0);
  }
}

/* Toast Spring Entrance */
@keyframes toastIn {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.92);
  }
  70% {
    opacity: 1;
    transform: translateY(-3px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Spring Pop for Badges and Checkmarks */
@keyframes popCheck {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Message entry fade & subtle slide up */
@keyframes messageAppear {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 3-dot typing indicator bounce */
@keyframes escanorBounce {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.3;
  }
  40% {
    transform: scale(1);
    opacity: 0.95;
  }
}

/* Generic Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   23. Interactive Action Buttons Hover Transitions
   -------------------------------------------------------------------------- */

.message .message-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
  margin-top: 6px;
}

.message:hover .message-actions,
.message:focus-within .message-actions {
  opacity: 1;
}

.message-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  background-color: transparent;
  color: var(--text-muted);
  font-size: 12px;
  transition: all var(--transition-fast);
}

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

/* --------------------------------------------------------------------------
   24. Responsive Media Queries (Mobile, Tablet, Touch & Safe Area Insets)
   -------------------------------------------------------------------------- */

/* Touch-friendly adjustments (No hover state on smartphones/tablets) */
@media (hover: none) {
  .assistant-actions {
    opacity: 1 !important;
  }

  .action-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .action-btn svg {
    width: 15px;
    height: 15px;
  }

  .conversation-item-actions {
    opacity: 1 !important;
  }
}

@media (max-width: 1024px) {
  /* Sidebar Drawer on Mobile & Tablet (Fluid GPU slide with zero layout reflow) */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100%;
    max-width: 82vw;
    width: 280px;
    margin-left: 0 !important;
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 100;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    opacity: 1 !important;
    pointer-events: auto;
  }

  /* Reset desktop collapsed margin on mobile/tablet so it never conflicts */
  .sidebar.collapsed {
    margin-left: 0 !important;
    opacity: 1 !important;
    pointer-events: auto;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.55);
  }

  .sidebar-overlay {
    display: block;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
  }

  /* Chat Header adjustment with safe area */
  .chat-header {
    padding: max(8px, env(safe-area-inset-top)) 14px 8px 14px;
    height: auto;
    min-height: var(--header-height);
  }

  .sidebar-toggle {
    width: 38px;
    height: 38px;
  }

  /* Messages Container spacing */
  .messages-container {
    padding: 16px 14px 24px 14px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  .message {
    gap: 8px;
    margin-bottom: 20px;
  }

  /* User message bubble on tablet/mobile */
  .user-bubble {
    max-width: 88%;
    font-size: 14.5px;
    padding: 8px 15px;
  }

  /* Assistant text and code blocks on mobile */
  .assistant-actions {
    opacity: 1;
    margin-top: 8px;
  }

  .code-block-wrapper,
  .markdown-body pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .markdown-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Welcome Screen Empty State */
  .welcome-header {
    margin-bottom: 18px;
  }

  .welcome-title {
    font-size: 24px;
    line-height: 1.3;
  }

  .welcome-suggestions {
    margin-top: 14px;
    gap: 6px;
  }

  .suggestion-item {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 13.5px;
  }

  /* Composer Section & Floating Pill Input Mobile */
  .composer-section {
    padding: 0 12px max(14px, env(safe-area-inset-bottom)) 12px;
  }

  .input-area {
    padding: 6px 0 10px 0;
  }

  .input-wrapper {
    padding: 6px 8px 6px 12px;
    border-radius: var(--radius-lg);
    gap: 5px;
  }

  /* CRITICAL: Font-size >= 16px prevents iOS Safari automatic viewport zooming on focus */
  .input-wrapper textarea,
  textarea#user-input {
    font-size: 16px !important;
    line-height: 1.45;
    padding: 5px 4px 5px 0;
  }

  .input-actions-right {
    gap: 4px;
  }

  .attach-btn,
  .voice-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .send-btn,
  button#send-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }

  /* Model Badge inside pill on mobile */
  .model-badge {
    height: 26px;
    padding: 2px 8px;
    font-size: 11.5px;
    gap: 4px;
  }

  .model-badge .badge-text {
    max-width: 76px;
  }

  /* Model Dropdown Menu Popover bounded within mobile viewport */
  .model-dropdown-menu {
    bottom: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    max-width: min(280px, calc(100vw - 28px));
  }

  /* Toast notification on mobile */
  .escanor-toast-container {
    bottom: max(16px, env(safe-area-inset-bottom));
    right: 16px;
    left: 16px;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .logo-text {
    font-size: 17px;
  }

  .welcome-title {
    font-size: 21px;
  }

  .user-bubble {
    max-width: 92%;
    font-size: 14px;
    padding: 8px 13px;
  }

  .composer-section {
    padding: 0 8px max(12px, env(safe-area-inset-bottom)) 8px;
  }

  .input-wrapper {
    padding: 5px 6px 5px 10px;
    gap: 4px;
  }

  .model-badge .badge-text {
    max-width: 62px;
  }

  .suggestion-item {
    padding: 8px 10px;
    font-size: 13px;
    gap: 10px;
  }

  .suggestion-item .suggestion-icon {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 360px) {
  .welcome-title {
    font-size: 19px;
  }

  .model-badge .badge-text {
    max-width: 50px;
  }
}

/* --------------------------------------------------------------------------
   25. Accessibility & Motion Preferences
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus Visible High Contrast Outline */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   26. Print Media Stylesheet
   -------------------------------------------------------------------------- */

@media print {
  .sidebar,
  .sidebar-overlay,
  .chat-header,
  .input-area,
  .copy-code-btn,
  .escanor-toast-container {
    display: none !important;
  }

  .app-container,
  .main-content,
  .messages-container {
    height: auto !important;
    overflow: visible !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  .messages-container > * {
    max-width: 100% !important;
  }

  .message {
    page-break-inside: avoid;
  }
}

/* --------------------------------------------------------------------------
   27. Comprehensive Utility Classes & Semantic Refinements
   -------------------------------------------------------------------------- */

.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;
}

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.spacer-sm {
  height: 8px;
}

.spacer-md {
  height: 16px;
}

.spacer-lg {
  height: 24px;
}

/* --------------------------------------------------------------------------
   28. Share Conversation Modal Component
   -------------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(18, 18, 16, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-spring), visibility 0.25s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-subtle);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  transform: translateY(14px) scale(0.96);
  transition: transform 0.28s var(--ease-spring), opacity 0.28s var(--ease-spring);
  display: flex;
  flex-direction: column;
}

.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 22px 16px 22px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.modal-header-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background-color: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-header-icon svg {
  stroke: var(--accent);
}

.modal-header-text {
  flex: 1;
}

.modal-title {
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
  letter-spacing: -0.01em;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  margin-top: -4px;
  margin-right: -4px;
}

.modal-close-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.modal-close-btn:active {
  transform: scale(0.92);
}

.modal-body {
  padding: 20px 22px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.share-preview-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 3.5px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.share-preview-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.share-preview-meta {
  font-size: 12px;
  color: var(--text-muted);
}

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

.share-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.share-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.share-url-input {
  flex: 1;
  height: 40px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-secondary);
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
  transition: border-color var(--transition-fast);
}

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

.share-copy-btn {
  height: 40px;
  padding: 0 16px;
  background-color: var(--accent);
  color: #ffffff;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(201, 100, 66, 0.3);
}

.share-copy-btn svg {
  stroke: #ffffff;
}

.share-copy-btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(201, 100, 66, 0.45);
}

.share-copy-btn:active {
  transform: scale(0.96) translateY(0);
}

.share-help-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.share-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.share-option-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.share-option-btn svg {
  stroke: currentColor;
  opacity: 0.8;
  transition: opacity var(--transition-fast);
}

.share-option-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-hover);
  color: var(--accent);
  transform: translateY(-1px);
}

.share-option-btn:hover svg {
  opacity: 1;
}

.share-option-btn:active {
  transform: scale(0.96);
}

@media (max-width: 480px) {
  .modal-card {
    border-radius: var(--radius-md);
  }
  
  .modal-header {
    padding: 16px 16px 12px 16px;
  }
  
  .modal-body {
    padding: 14px 16px 20px 16px;
    gap: 14px;
  }
  
  .share-input-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .share-copy-btn {
    justify-content: center;
  }
  
  .share-options-grid {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   29. Settings Modal Component (Tabs: Général, Compte, Privacy, Paiement)
   -------------------------------------------------------------------------- */
.settings-modal-card {
  max-width: 660px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.settings-header-icon {
  background-color: var(--accent-light);
  color: var(--accent);
}

.settings-header-icon svg {
  stroke: var(--accent);
}

/* Tab Navigation Bar */
.settings-nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px 0 18px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}

.settings-nav-tabs::-webkit-scrollbar {
  display: none;
}

.settings-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  user-select: none;
}

.settings-tab-btn svg {
  stroke: currentColor;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.settings-tab-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-hover);
}

.settings-tab-btn:hover svg {
  opacity: 1;
}

.settings-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
  background-color: var(--accent-subtle);
}

.settings-tab-btn.active svg {
  opacity: 1;
  stroke: var(--accent);
}

/* Modal Body & Tab Panes */
.settings-modal-body {
  padding: 20px 22px 24px 22px;
  overflow-y: auto;
  max-height: calc(88vh - 130px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-tab-pane {
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: fadeInPane 0.2s ease forwards;
}

.settings-tab-pane.active {
  display: flex;
}

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

/* Setting Cards */
.setting-item-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setting-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.setting-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.setting-item-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.setting-section-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-top: 4px;
}

/* Segmented Control for Theme */
.theme-segmented-control {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.theme-segment-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-segment-btn:hover {
  color: var(--text-primary);
}

.theme-segment-btn.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  font-weight: 600;
}

.theme-segment-btn.active svg {
  color: var(--accent);
  stroke: var(--accent);
}

/* Dropdown Select */
.settings-select {
  padding: 8px 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  min-width: 190px;
}

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

/* Inputs & Buttons */
.settings-input {
  padding: 8px 12px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.settings-btn-primary {
  padding: 8px 14px;
  background-color: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.settings-btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.settings-btn-primary:active {
  transform: translateY(0);
}

.settings-btn-secondary {
  padding: 7px 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.settings-btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-hover);
  color: var(--accent);
}

.settings-btn-danger {
  padding: 8px 14px;
  background-color: rgba(196, 92, 92, 0.12);
  color: #f87171;
  border: 1px solid rgba(196, 92, 92, 0.3);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.settings-btn-danger:hover {
  background-color: rgba(196, 92, 92, 0.25);
  border-color: rgba(196, 92, 92, 0.5);
  transform: translateY(-1px);
}

.settings-btn-danger:active {
  transform: translateY(0);
}

/* Shortcuts Grid */
.setting-shortcuts-card {
  flex-direction: column;
  align-items: stretch;
}

.shortcuts-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12.5px;
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-label {
  color: var(--text-secondary);
}

.shortcut-keys kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Account Profile Card */
.account-profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: linear-gradient(135deg, var(--bg-card), var(--bg-surface));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.account-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.account-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c96442, #e07a5f);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(201, 100, 66, 0.35);
}

.account-status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background-color: #10b981;
  border: 2px solid var(--bg-card);
  border-radius: 50%;
}

.account-profile-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-name-input {
  flex: 1;
}

.account-badges-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-plan-pro {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: rgba(201, 100, 66, 0.16);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
}

.badge-verified {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 500;
}

.session-token-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-token-code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 10px;
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-xs);
  color: var(--code-inline-text);
  word-break: break-all;
}

/* Account Profile Details */
.account-user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.account-name-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-user-name {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.account-edit-name-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.account-edit-name-btn:hover {
  color: var(--accent);
  background-color: var(--bg-surface-hover);
}

.account-user-email {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--text-secondary);
  word-break: break-all;
}

.account-inline-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.badge-auth-provider {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: rgba(66, 133, 244, 0.12);
  color: #4285f4;
  border: 1px solid rgba(66, 133, 244, 0.25);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 500;
}

.badge-auth-provider.email {
  background-color: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.25);
}

/* Cloud Sync Status Indicator */
.account-sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-full);
}

.sync-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: syncPulse 2s infinite ease-in-out;
}

@keyframes syncPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.sync-status-text {
  font-size: 12px;
  font-weight: 550;
  color: #10b981;
}

/* Auth View: Welcome Banner */
.auth-welcome-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(201, 100, 66, 0.08), rgba(201, 100, 66, 0.02));
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.auth-welcome-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-welcome-text {
  flex: 1;
}

.auth-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 3px 0;
}

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

/* Google Sign-in Box */
.auth-google-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  background-color: #ffffff;
  color: #1f1f1f;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: all var(--transition-fast);
}

.auth-google-btn:hover {
  background-color: #f8f9fa;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
}

.auth-google-btn:active {
  transform: scale(0.98);
}

.auth-token-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.auth-token-toggle-btn:hover {
  color: var(--accent);
  background-color: var(--bg-surface-hover);
}

.auth-token-input-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.auth-token-input-row {
  display: flex;
  gap: 8px;
}

.auth-token-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
}

.auth-help-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Auth Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}

.auth-divider-line {
  flex: 1;
  height: 1px;
  background-color: var(--border-subtle);
}

.auth-divider-text {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Auth Mode Segmented Control (Connexion / Inscription) */
.auth-mode-segmented {
  display: flex;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
  margin-bottom: 16px;
}

.auth-mode-tab {
  flex: 1;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 550;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-mode-tab.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.auth-mode-tab:hover:not(.active) {
  color: var(--text-primary);
}

/* Auth Forms */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field-label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-secondary);
}

.auth-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.auth-forgot-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.auth-forgot-link:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.auth-input {
  width: 100%;
}

.auth-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-password-wrapper .auth-input {
  padding-right: 38px;
}

.auth-toggle-pwd-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.auth-toggle-pwd-btn:hover {
  color: var(--text-primary);
}

.auth-submit-btn {
  width: 100%;
  height: 40px;
  font-size: 14px;
  font-weight: 600;
  justify-content: center;
  margin-top: 4px;
}

/* Privacy Tab */
.privacy-shield-banner {
  display: flex;
  gap: 14px;
  padding: 16px;
  background-color: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-md);
}

.privacy-shield-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.privacy-shield-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.privacy-shield-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.privacy-shield-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.security-checklist {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 6px;
}

.security-check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.check-icon-pill {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.check-green {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.check-blue {
  background-color: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.check-row-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.check-row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.check-row-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.check-badge-active {
  font-size: 11px;
  font-weight: 600;
  color: #10b981;
  background-color: rgba(16, 185, 129, 0.1);
  padding: 3px 7px;
  border-radius: var(--radius-xs);
}

.check-badge-off {
  font-size: 11px;
  font-weight: 600;
  color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.1);
  padding: 3px 7px;
  border-radius: var(--radius-xs);
}

.danger-zone-card {
  border-color: rgba(196, 92, 92, 0.3);
  background-color: rgba(196, 92, 92, 0.04);
}

.text-danger {
  color: #f87171;
}

/* Billing Tab */
.billing-balance-card {
  background: linear-gradient(135deg, rgba(201, 100, 66, 0.12), rgba(201, 100, 66, 0.04));
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.billing-balance-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.billing-balance-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.billing-plan-pill {
  background-color: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

.billing-balance-val-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.billing-balance-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.billing-balance-suffix {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
}

.billing-balance-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Recharge Grid */
.recharge-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.recharge-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.recharge-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.recharge-card.featured {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(201, 100, 66, 0.08) 0%, var(--bg-card) 100%);
  box-shadow: 0 4px 16px rgba(201, 100, 66, 0.15);
}

.recharge-featured-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.recharge-card-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recharge-pack-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.recharge-pack-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.recharge-pack-price small {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.recharge-pack-credits {
  font-size: 12.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.recharge-bonus-pill {
  font-size: 10.5px;
  font-weight: 600;
  color: #10b981;
  background-color: rgba(16, 185, 129, 0.12);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.recharge-pack-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 1;
}

.recharge-pack-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
}

.recharge-action-btn {
  margin-top: 6px;
  padding: 9px 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.recharge-action-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.recharge-action-btn.btn-featured {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.recharge-action-btn.btn-featured:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.billing-guarantees-card {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 12px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 10px;
}

.guarantee-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.guarantee-item svg {
  stroke: #10b981;
}

@media (max-width: 600px) {
  .recharge-grid {
    grid-template-columns: 1fr;
  }
  .setting-item-card {
    flex-direction: column;
    align-items: stretch;
  }
  .account-profile-card {
    flex-direction: column;
    text-align: center;
  }
  .account-name-row {
    flex-direction: column;
  }
  .account-badges-row {
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   30. Multi-Media Attachments System (Video MP4, Audio MP3, Image PNG/JPG, etc.)
   -------------------------------------------------------------------------- */

/* Attachment Preview Tray above Input Bar */
.attachment-preview-tray {
  max-width: var(--chat-max-width);
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  background: rgba(38, 37, 34, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: slideUpFade 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.attachment-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  max-width: 220px;
  position: relative;
  transition: all 0.2s ease;
}

.attachment-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.attachment-thumb {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background-color: #1a1a18;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--accent);
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-thumb.thumb-video {
  background: linear-gradient(135deg, rgba(201, 100, 66, 0.2), rgba(0, 0, 0, 0.6));
  position: relative;
}

.attachment-thumb.thumb-video svg {
  color: #fff;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.attachment-thumb.thumb-audio {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(0, 0, 0, 0.6));
  color: #10b981;
}

.attachment-thumb.thumb-doc {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(0, 0, 0, 0.6));
  color: #3b82f6;
}

.attachment-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.attachment-filename {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-filesize {
  font-size: 10.5px;
  color: var(--text-muted);
}

.attachment-remove-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-left: 2px;
}

.attachment-remove-btn:hover {
  background: rgba(196, 92, 92, 0.8);
  color: #fff;
  transform: scale(1.1);
}

/* Drag & Drop Overlay State */
.input-wrapper.drag-over {
  border-color: var(--accent) !important;
  background: rgba(201, 100, 66, 0.12) !important;
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.3), 0 16px 40px rgba(0,0,0,0.5) !important;
}

/* Media in Chat Messages (.user-bubble) */
.message-media-gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.message-media-gallery:last-child {
  margin-bottom: 0;
}

/* Images Grid */
.media-image-card {
  max-width: 440px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.22s var(--ease-spring), box-shadow 0.22s ease;
  position: relative;
  background: #1a1a18;
}

.media-image-card:hover {
  transform: scale(1.015);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.message-attached-image {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  display: block;
}

/* Video Player Card (MP4, WebM) */
.media-video-card {
  max-width: 480px;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #151513;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

.media-video-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: var(--text-secondary);
}

.media-video-header svg {
  color: var(--accent);
}

.chat-video-player {
  width: 100%;
  max-height: 360px;
  display: block;
  background: #000;
  outline: none;
}

/* Audio Player Card (MP3, WAV) */
.media-audio-card {
  max-width: 400px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)), #242320;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.media-audio-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.media-audio-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.media-audio-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-audio-player {
  width: 100%;
  height: 36px;
  outline: none;
  border-radius: var(--radius-sm);
}

/* Document / Other file Card */
.media-doc-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  max-width: 320px;
  transition: all 0.2s ease;
}

.media-doc-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.media-doc-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Fullscreen Media Lightbox */
.media-lightbox-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(10, 10, 8, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.lightbox-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
}

.lightbox-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.08);
}

.lightbox-content {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content img,
.lightbox-content video {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

/* --------------------------------------------------------------------------
   31. Internationalization & RTL Support (Arabic, etc.)
   -------------------------------------------------------------------------- */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border-color);
}

[dir="rtl"] .sidebar-toggle {
  margin-right: 0;
  margin-left: 12px;
}

[dir="rtl"] .input-actions-right {
  margin-left: 0;
  margin-right: auto;
}

[dir="rtl"] .attach-btn {
  margin-right: 0;
  margin-left: 6px;
}

[dir="rtl"] .chat-header-actions {
  margin-left: 0;
  margin-right: auto;
}

/* Supabase Cloud Configuration Card & Status Badge */
.supabase-config-card {
  border-left: 3px solid #3ecf8e !important;
  background: linear-gradient(135deg, rgba(62, 207, 142, 0.05), rgba(62, 207, 142, 0.01));
}

.badge-supabase-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background-color: rgba(62, 207, 142, 0.15);
  color: #3ecf8e;
  border: 1px solid rgba(62, 207, 142, 0.3);
  transition: all var(--transition-fast);
}

.badge-supabase-status.not-configured {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border-color: var(--border-medium);
}

.badge-supabase-status.connected {
  background-color: rgba(62, 207, 142, 0.2);
  color: #3ecf8e;
  border-color: rgba(62, 207, 142, 0.5);
  box-shadow: 0 0 10px rgba(62, 207, 142, 0.2);
}

/* End of Escanor AI Claude.ai Stylesheet */

