/* ============================================================
   Sylor — Design System
   Corporate Deep Intelligence Interface
   Dark mode first, premium chat interface
   ============================================================ */

/* ---- Design Tokens ---- */
:root {
  --sylor-blue: #3B82F6;
  --sylor-grey: rgba(18, 26, 47, 0.5);
  --sylor-black: #0A0A0C;
  --sylor-white: #F4F4F5;

  --bg-primary: #0A0A0C;
  --bg-secondary: #111113;
  --bg-surface: rgba(255, 255, 255, 0.045);
  --bg-surface-hover: rgba(255, 255, 255, 0.075);
  --bg-surface-active: rgba(255, 255, 255, 0.10);
  --bg-elevated: #161618;

  --text-primary: #F4F4F5;
  --text-secondary: #9CA3AF;
  --text-tertiary: #6B7280;
  --text-inverse: #0A0A0C;

  --accent-primary: #2563EB;
  --accent-secondary: #6366F1;
  --accent-gradient: linear-gradient(135deg, #2563EB 0%, #6366F1 100%);
  --sylor-spark-gradient: linear-gradient(135deg, #2563EB 0%, #6366F1 100%);
  --accent-soft: #93C5FD;
  --accent-dim: rgba(37, 99, 235, 0.12);
  --accent-code: #93C5FD;
  --accent-quote: #6366F1;
  --accent-quote-dim: rgba(99, 102, 241, 0.06);

  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-default: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);

  --bg-input: rgba(30, 31, 32, 0.7);
  --bg-input-focus: rgba(30, 31, 32, 0.95);
  --border-input: rgba(255, 255, 255, 0.08);
  --border-input-focus: rgba(255, 255, 255, 0.2);

  /* Semantic accents */
  --accent-primary-rgb: 37, 99, 235;
  --accent-warning-rgb: 245, 158, 11;
  --danger-critical-rgb: 239, 68, 68;
  --success-primary: #10B981;
  --danger-warning: #F59E0B;
  --danger-critical: #EF4444;
  --button-primary-text: #FFFFFF;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-xl2: 28px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);

  --sidebar-width-collapsed: 68px;
  --sidebar-width-expanded: 280px;
  --sidebar-width: var(--sidebar-width-collapsed);
  --header-height: 64px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  
  --font-main: 'Inter', system-ui, sans-serif;
  --font-display: 'Spectral', serif;

  font-family: var(--font-main);
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.6;
}

/* ---- Light Theme Tokens ---- */
:root[data-theme="light"] {
  --bg-primary: #FAFAFA;
  --bg-secondary: #F3F4F6;
  --bg-surface: #FFFFFF;
  --bg-surface-hover: #F9FAFB;
  --bg-surface-active: #F3F4F6;
  --bg-elevated: #FFFFFF;

  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-tertiary: #9CA3AF;
  --text-inverse: #FFFFFF;

  --border-subtle: rgba(0, 0, 0, 0.05);
  --border-default: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);

  --bg-input: rgba(255, 255, 255, 0.9);
  --bg-input-focus: #FFFFFF;
  --border-input: rgba(0, 0, 0, 0.08);
  --border-input-focus: rgba(0, 0, 0, 0.2);

  /* Semantic accents */
  --accent-primary-rgb: 37, 99, 235;
  --accent-warning-rgb: 245, 158, 11;
  --danger-critical-rgb: 239, 68, 68;
  --success-primary: #10B981;
  --danger-warning: #F59E0B;
  --danger-critical: #EF4444;
  --button-primary-text: #FFFFFF;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1);
}

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

html, body {
  height: 100%;
  background: var(--bg-primary);
  overflow: hidden;
}

a { color: var(--accent-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.app {
  display: flex;
  height: 100vh;
  width: 100%;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* ---- Sidebar — Collapsible, M3 Styling ---- */
.sidebar {
  width: var(--sidebar-width-collapsed);
  background: var(--bg-secondary);
  border-right: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-normal), background-color var(--transition-normal);
  z-index: 100;
  position: relative;
  overflow: hidden;
}

.sidebar.expanded {
  width: var(--sidebar-width-expanded);
}

.sidebar-header {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}

#btn-sidebar-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
}

#btn-sidebar-toggle:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.sidebar.expanded .brand {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.brand-logo {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-display {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

/* Sidebar navigation */
.sidebar-nav {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 40px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
  border-radius: 9999px; /* Pill container */
  position: relative;
  white-space: nowrap;
  outline: none;
}

/* Collapsed nav item defaults */
.sidebar-nav-item svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  opacity: 0.85;
}

.sidebar-nav-item .nav-text {
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.sidebar.expanded .sidebar-nav-item .nav-text {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

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

/* Active navigation item pill */
.sidebar-nav-item.active-pill {
  background: var(--bg-surface-active);
  color: var(--text-primary);
  font-weight: 600;
}

/* Conversations & Notebooks wrap */
.sidebar-conversations-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sidebar.expanded .sidebar-conversations-wrap {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-conversations-wrap::-webkit-scrollbar {
  width: 4px;
}

.sidebar-conversations-wrap::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  padding: 12px 12px 6px;
  white-space: nowrap;
}

.sidebar-conversations {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 36px;
  padding: 0 12px;
  border-radius: 9999px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13.5px;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
}

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

.conv-item.active {
  background: var(--bg-surface-active);
  color: var(--text-primary);
  font-weight: 500;
}

.conv-item .conv-icon {
  flex-shrink: 0;
  opacity: 0.6;
}

.conv-item .conv-title {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  padding-right: 18px;
}

.conv-item .conv-delete {
  position: absolute;
  right: 12px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.conv-item:hover .conv-delete {
  opacity: 1;
}

.conv-item .conv-delete:hover {
  color: var(--danger-critical);
}

.sidebar-footer {
  padding: 12px 14px;
  flex-shrink: 0;
}

/* ---- User info ---- */
.user-info {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 10px;
  border-radius: 9999px;
  transition: background-color var(--transition-fast);
}

.sidebar.expanded .user-info:hover {
  background: var(--bg-surface-hover);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-details {
  flex: 1;
  min-width: 0;
  margin-left: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.sidebar.expanded .user-details {
  opacity: 1;
  pointer-events: auto;
}

.user-name {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#btn-settings-nav {
  display: none; /* Only show settings inside sidebar-footer when expanded */
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar.expanded #btn-settings-nav {
  display: flex;
}

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

/* ---- Buttons ---- */
.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

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

/* ---- Chat main ---- */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}

/* ---- Chat header ---- */
.chat-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  flex-shrink: 0;
}

.chat-header-title {
  flex: 1;
  min-width: 0;
}

.chat-header-title h1 {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.coming-soon-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 4px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* ---- Messages ---- */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 6px;
}

/* Welcome screen */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  min-height: 100%;
}

.welcome-logo {
  margin-bottom: 20px;
  animation: welcome-pulse 3s ease-in-out infinite;
}

@keyframes welcome-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.9; }
}

.welcome-screen h2 {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 44px;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.welcome-screen p {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 460px;
  margin-bottom: 24px;
  font-weight: 400;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 580px;
}

.suggestion-chip {
  padding: 12px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.suggestion-chip:hover {
  background: var(--accent-dim);
  border-color: rgba(var(--accent-primary-rgb), 0.35);
  color: var(--accent-soft);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Message bubble */
.messages {
  padding: 24px 0 8px;
}

.message {
  padding: 8px 24px;
  display: flex;
  gap: 16px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* User messages — minimal pill on the right */
.message.user {
  flex-direction: row-reverse;
  gap: 0;
}

.message.user .message-body {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 18px;
  padding: 10px 16px;
  max-width: 70%;
  color: var(--text-primary);
}

.message.user .message-role {
  display: none;
}

.message.user .message-avatar {
  display: none;
}

/* Assistant messages — clean document view, no bubble */
.message.assistant {
  align-items: flex-start;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.assistant .message-avatar {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
}

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

.message-role {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
}

.message.assistant .message-role {
  color: var(--text-tertiary);
}

.message-content {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text-primary);
  word-break: break-word;
}

/* Assistant message feedback toolbar */
.message-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.message.assistant:hover .message-feedback {
  opacity: 0.7;
}

.message-feedback:hover {
  opacity: 1 !important;
}

.feedback-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

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

.feedback-btn.active {
  color: var(--accent-soft);
  background: var(--bg-surface-active);
}

.message-content p {
  margin-bottom: 12px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content code {
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Fira Code', 'Consolas', monospace;
  color: var(--accent-soft);
  border: 1px solid var(--border-subtle);
}

.message-content pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 12px 0;
  overflow-x: auto;
}

.message-content pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  border: none;
}

.code-block {
  position: relative;
  margin: 12px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-default);
  background: var(--bg-secondary);
}

.code-block .code-lang {
  display: inline-block;
  padding: 7px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-soft);
  font-family: var(--font-main);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  width: 100%;
  box-sizing: border-box;
}

.code-block .btn-copy {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 3px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 11px;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 1;
}

.code-block .btn-copy:hover {
  background: var(--accent-dim);
  border-color: var(--accent-primary);
  color: var(--accent-soft);
}

.code-block pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background: transparent;
  border: none;
}

.code-block pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.6;
  font-family: 'Fira Code', 'Consolas', 'JetBrains Mono', monospace;
}

.message-content ul, .message-content ol {
  padding-left: 20px;
  margin: 8px 0;
}

.message-content li {
  margin-bottom: 4px;
}

.message-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.message-content em {
  color: var(--text-secondary);
}

.message-content blockquote {
  border-left: 3px solid var(--accent-quote);
  padding: 8px 16px;
  margin: 10px 0;
  color: var(--text-secondary);
  background: var(--accent-quote-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Links in responses */
.message-content a,
.rany-link {
  color: var(--accent-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
  transition: color 0.2s, border-color 0.2s;
}

.message-content a:hover,
.rany-link:hover {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* Inline citation badges [1] [2] */
.citation-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65em;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin: 0 1px;
  background: var(--accent-primary);
  color: var(--button-primary-text);
  border-radius: 4px;
  vertical-align: super;
  line-height: 1;
  cursor: default;
}

/* Sources section */
.sources-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-default);
}

.sources-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.sources-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.2s, border-color 0.2s;
  max-width: 280px;
  min-width: 0;
}

.source-card:hover {
  background: var(--accent-dim);
  border-color: rgba(var(--accent-primary-rgb), 0.35);
}

.source-favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

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

.source-title {
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.source-domain {
  font-size: 0.65rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-num {
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--accent-primary);
  color: var(--button-primary-text);
  min-width: 16px;
  height: 16px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
}

/* Streaming dots */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* ---- Chat Image Container + Skeleton + Toolbar ---- */
.chat-img-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.chat-img-watermark {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-default);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  pointer-events: none;
  opacity: 0.85;
  transition: opacity 0.25s ease;
  z-index: 4;
}

.chat-img-container:hover .chat-img-watermark {
  opacity: 0.4;
}

.chat-img-watermark img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  opacity: 0.8;
}

.chat-img-watermark span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  font-family: var(--font-main);
  text-transform: uppercase;
}

.chat-img-skeleton {
  width: 420px;
  max-width: 100%;
  height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg-secondary);
}

.skeleton-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-subtle) 20%,
    var(--border-default) 50%,
    var(--border-subtle) 80%,
    transparent 100%
  );
  animation: shimmer 2s infinite ease-in-out;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton-label {
  position: relative;
  z-index: 1;
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.chat-img {
  display: block;
  max-width: 100%;
  max-height: 500px;
  object-fit: contain;
  border-radius: 0;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.chat-img-loading {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-img-toolbar {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 5;
}

.chat-img-container:hover .chat-img-toolbar {
  opacity: 1;
  transform: translateY(0);
}

.chat-img-toolbar button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  background: var(--bg-elevated);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.chat-img-toolbar button:hover {
  background: var(--bg-surface-hover);
  transform: scale(1.08);
}

/* ---- Lightbox ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-overlay.active {
  opacity: 1;
}

.lightbox-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  z-index: 9010;
  pointer-events: none;
}

.lightbox-title {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
  font-family: var(--font-main);
  pointer-events: auto;
}

.lightbox-actions {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 99px;
  padding: 4px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
}

.lightbox-actions button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.lightbox-actions button:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  transform: scale(1.04);
}

.lightbox-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 88px 32px 32px 32px;
}

.lightbox-img {
  max-width: 95%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-user-drag: none;
}

/* ---- Input area — Minimalist premium ---- */
.input-area {
  padding: 18px 24px 28px;
  flex-shrink: 0;
  position: relative;
  background: linear-gradient(to top, var(--bg-primary) 80%, transparent);
}

.input-container {
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 24px;
  transition: all var(--transition-normal);
  overflow: hidden;
  box-shadow: var(--shadow-sm), 0 8px 24px rgba(0, 0, 0, 0.35);
}

.input-container:focus-within {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 1px var(--border-subtle), var(--shadow-md);
  transform: translateY(-1px);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px 10px 16px;
}

.btn-attach {
  width: 34px;
  height: 34px;
  color: var(--text-tertiary);
  border-radius: 10px;
  transition: all var(--transition-fast);
  margin-bottom: 4px;
}

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

textarea#message-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15.5px;
  padding: 10px 4px;
  resize: none;
  max-height: 200px;
  outline: none;
  line-height: 1.55;
  min-height: 44px;
}

textarea#message-input::placeholder {
  color: var(--text-tertiary);
}

.btn-send {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  opacity: 0.5;
  margin-bottom: 4px;
}

.btn-send:not(:disabled) {
  opacity: 1;
  background: var(--text-primary);
  color: var(--text-inverse);
}

.btn-send:not(:disabled):hover {
  transform: scale(1.04);
  background: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.btn-send:disabled {
  cursor: default;
}

.input-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 10px;
  opacity: 0.75;
}

.input-disclaimer #active-mode-chip {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Image previews */
.image-previews {
  display: flex;
  gap: 8px;
  padding: 10px 12px 0;
  flex-wrap: wrap;
}

.image-preview {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-default);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview .remove-image {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ---- Login screen ---- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

#login-bg-svg {
  width: 100%;
  height: 100%;
  opacity: 0.6;
}

.shape {
  opacity: 0.2;
  animation: float 35s infinite alternate ease-in-out;
  will-change: transform;
}

@media (min-width: 768px) {
  .shape {
    filter: blur(40px);
    opacity: 0.35;
  }
}

.color1 { fill: var(--accent-primary); animation-delay: 0s; }
.color2 { fill: var(--accent-quote); animation-delay: -5s; }
.color3 { fill: var(--accent-soft); animation-delay: -10s; }

@keyframes float {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  33% { transform: translate3d(10%, 15%, 0) scale(1.1); }
  66% { transform: translate3d(-5%, 10%, 0) scale(0.9); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}

.login-container {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 48px;
  width: 440px;
  max-width: 90%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  animation: login-in 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (min-width: 768px) {
  .login-container {
    background: rgba(var(--bg-elevated), 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
  }
}

@keyframes login-in {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  margin-bottom: 24px;
  animation: welcome-pulse 3s ease-in-out infinite;
}

/* ============================================================
   Sylor — Auth Redesign (Hyper-Dynamic)
   ============================================================ */

:root {
  --mood-green-bg: #0b2d1d;
  --mood-green-cursor: #ff80bf;
  --mood-blue-bg: #001f3f;
  --mood-blue-cursor: #00d4ff;
  --mood-purple-bg: #1a0b2e;
  --mood-purple-cursor: #a855f7;
  --current-mood-bg: var(--mood-green-bg);
  --current-mood-cursor: var(--mood-green-cursor);
}

@media (prefers-color-scheme: light) {
  .auth-page {
    --current-mood-bg: var(--bg-secondary);
  }
}

.auth-page {
  background: var(--bg-primary);
  height: 100vh;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-main);
}

.auth-wrapper {
  display: flex;
  width: 100%;
  height: 100%;
}

.hero-section {
  flex: 1;
  background: var(--current-mood-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
  padding-top: calc(40px + env(safe-area-inset-top));
  position: relative;
  transition: background 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-inverse);
}

.skip-btn {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top));
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-inverse);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  z-index: 10;
  transition: all var(--transition-fast);
}

.skip-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 30px;
}

.hero-logo { width: 48px; height: 48px; }
.hero-title { font-family: var(--font-display); font-size: 32px; font-weight: 700; letter-spacing: 0.1em; }
.hero-dynamic-text { font-size: 24px; font-weight: 500; text-align: center; max-width: 400px; min-height: 1.5em; color: var(--text-inverse); opacity: 0.9; }

.typing-cursor {
  color: var(--current-mood-cursor);
  transition: color 1.5s ease;
  animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink { from, to { opacity: 1; } 50% { opacity: 0; } }

.action-panel {
  flex: 1;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  z-index: 5;
}

.panel-content { width: 100%; max-width: 360px; text-align: center; }
.panel-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.panel-subtitle { font-size: 15px; color: var(--text-secondary); margin-bottom: 32px; }

.auth-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.btn-google-pro, .btn-orzatty-pro {
  width: 100% !important;
  height: 52px !important;
  min-height: 52px !important;
  border-radius: var(--radius-lg);
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-default);
  margin-bottom: 0 !important;
  flex-shrink: 0;
  box-sizing: border-box;
}

.btn-google-pro {
  background: var(--text-primary);
  color: var(--text-inverse);
  border: none;
  box-shadow: var(--shadow-sm);
}

.btn-orzatty-pro {
  background: var(--accent-primary);
  color: var(--button-primary-text);
  border: none;
  box-shadow: 0 4px 12px rgba(var(--accent-primary-rgb), 0.25);
}

.btn-orzatty-pro:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(var(--accent-primary-rgb), 0.35);
}

.btn-google-pro:hover {
  background: var(--text-secondary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-auth-pro {
  width: 100%;
  height: 52px;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 12px;
}

.btn-auth-pro.primary { background: var(--text-primary); border: none; color: var(--text-inverse); }
.btn-auth-pro.primary:hover { background: var(--text-secondary); transform: translateY(-1px); }
.btn-auth-pro.secondary { background: transparent; border: 1px solid var(--border-strong); color: var(--text-primary); }
.btn-auth-pro.secondary:hover { background: var(--bg-surface-hover); transform: translateY(-1px); }

/* ---- Classic Auth Form ---- */
.auth-form-pro { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.input-group { position: relative; }
.input-group input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-group input::placeholder { color: var(--text-tertiary); }
.input-group input:focus {
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.password-group {
  position: relative;
}

.password-group input {
  padding-right: 48px !important;
}

.btn-toggle-password {
  position: absolute !important;
  right: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  z-index: 20;
  height: 24px !important;
  width: 24px !important;
}

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

.auth-error {
  color: var(--danger-critical);
  font-size: 13px;
  padding: 8px 12px;
  background: rgba(var(--danger-critical-rgb, 239, 68, 68), 0.08);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--danger-critical-rgb, 239, 68, 68), 0.15);
}

.btn-submit-pro {
  width: 100%;
  height: 52px;
  background: var(--accent-gradient);
  color: var(--button-primary-text);
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-submit-pro:hover { box-shadow: 0 4px 16px rgba(var(--accent-primary-rgb), 0.35); transform: translateY(-1px); }

.btn-back-pro {
  width: 100%;
  height: 44px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  margin-top: 4px;
}
.btn-back-pro:hover { color: var(--text-primary); border-color: var(--border-strong); }

/* ---- Google Tooltip ---- */
.google-wrapper { position: relative; margin-bottom: 4px; }
.google-tooltip {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

/* ---- User Avatar Mini (Google) ---- */
.user-avatar-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border-subtle);
}

/* ---- Verification Panel ---- */
.verify-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-fade-in 300ms ease;
}
.verify-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 24px;
  padding: 40px 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.verify-logo img { width: 48px; height: 48px; margin-bottom: 16px; }
.verify-desc { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
.verify-desc strong { color: var(--text-primary); }

.code-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
}
.code-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.code-digit:focus {
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.verify-resend { font-size: 13px; color: var(--text-tertiary); margin-top: 16px; }
.link-btn {
  background: none;
  border: none;
  color: var(--accent-soft);
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

/* ---- Panel Footer ---- */
.panel-footer { margin-top: 32px; }
.panel-footer p { font-size: 12px; color: var(--text-tertiary); margin-bottom: 8px; }
.footer-links { display: flex; justify-content: center; gap: 16px; }
.footer-links a { font-size: 12px; color: var(--text-tertiary); }
.footer-links a:hover { color: var(--accent-soft); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-fade-in 200ms ease;
}

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

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 380px;
  width: 90%;
  text-align: center;
}

.modal-icon {
  font-size: 40px;
  margin-bottom: 16px;
}

.modal h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.modal-timer {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-soft);
  margin-bottom: 20px;
}

.btn-primary {
  display: inline-block;
  padding: 10px 24px;
  background: var(--accent-gradient);
  color: var(--button-primary-text);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(var(--accent-primary-rgb), 0.35);
}

/* ---- Auth Divider ---- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: var(--text-tertiary);
  font-size: 13px;
}

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

/* ---- Google Sign-In Button ---- */
.btn-google {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 28px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.btn-google:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-google svg {
  flex-shrink: 0;
}

.btn-secondary {
  padding: 8px 16px;
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--bg-surface-active);
  border-color: var(--text-tertiary);
}

/* ---- Settings Modal ---- */
.settings-modal {
  max-width: 500px;
  padding: 0;
  text-align: left;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
}

.modal-body {
  padding: 24px;
}

.settings-section {
  margin-bottom: 32px;
}

.settings-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-soft);
  margin-bottom: 16px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.setting-info {
  flex: 1;
}

.setting-name {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.setting-desc {
  display: block;
  font-size: 13px;
  color: var(--text-tertiary);
}

.setting-select {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

/* ---- Mobile ---- */
.mobile-only { display: none; }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99;
  transition: opacity 0.25s ease;
}

@media (max-width: 768px) {
  .mobile-only { display: flex; }
  .sidebar {
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    background: var(--bg-secondary);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-right: 1px solid var(--border-default);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.active {
    display: block;
  }
  .welcome-screen {
    padding: 30px 16px;
  }
  .welcome-screen h2 {
    font-size: 26px;
    word-break: break-word;
  }
  .welcome-screen p {
    font-size: 14px;
    margin-bottom: 24px;
  }
  .suggestion-chips {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    width: 100%;
    justify-content: flex-start;
    padding: 8px 4px;
    gap: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .suggestion-chips::-webkit-scrollbar {
    display: none;
  }
  .suggestion-chip {
    scroll-snap-align: start;
    white-space: nowrap;
    padding: 8px 14px;
    font-size: 12.5px;
    flex-shrink: 0;
    border-radius: 16px;
  }
  .message {
    padding: 10px 14px;
    gap: 12px;
  }
  .message.user .message-body {
    max-width: 85%;
    padding: 10px 14px;
  }
  .input-area {
    padding: 10px 12px 14px;
  }
  .input-container {
    border-radius: 28px;
  }
  .input-row {
    padding: 6px 8px 6px 12px;
  }
  textarea#message-input {
    font-size: 15px;
  }
  .modes-menu {
    left: 12px;
    width: calc(100% - 24px);
    max-width: 340px;
    bottom: calc(100% + 10px);
  }
  .input-area {
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .input-container {
    border-radius: 20px;
  }
}

@media (max-width: 1023px) {
  .auth-wrapper { flex-direction: column; }
  .hero-section { flex: 0 0 60%; padding: 24px; }
  .action-panel { flex: 1; background: transparent; padding: 0; position: relative; display: block; }
  .panel-content {
    background: var(--bg-primary);
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    padding: 24px 24px calc(16px + env(safe-area-inset-bottom)) 24px;
    border-radius: 32px 32px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    animation: bottom-sheet-up 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow-y: auto;
    max-height: 60vh;
  }
  @keyframes bottom-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .hero-dynamic-text { font-size: 20px; }
  .btn-auth-pro, .btn-google-pro { height: 56px; }
}

.auth-page.mood-green { --current-mood-bg: var(--mood-green-bg); --current-mood-cursor: var(--mood-green-cursor); }
.auth-page.mood-blue { --current-mood-bg: var(--mood-blue-bg); --current-mood-cursor: var(--mood-blue-cursor); }
.auth-page.mood-purple { --current-mood-bg: var(--mood-purple-bg); --current-mood-cursor: var(--mood-purple-cursor); }

/* ---- Toasts ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 14px;
  animation: toast-in 400ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 12px;
}

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

/* ---- Thinking indicator (replaces skeleton) ---- */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  color: var(--text-tertiary);
  font-size: 13px;
  font-style: italic;
}

.thinking-indicator .thinking-logo {
  width: 20px;
  height: 20px;
  animation: thinking-spin 1.8s ease-in-out infinite;
  opacity: 0.7;
  flex-shrink: 0;
}

.thinking-indicator .thinking-dots span {
  display: inline-block;
  animation: thinking-dot 1.4s ease-in-out infinite;
  opacity: 0;
}
.thinking-indicator .thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-indicator .thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-spin {
  0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.5; }
  50% { transform: rotate(180deg) scale(1.1); opacity: 1; }
}

@keyframes thinking-dot {
  0%, 80%, 100% { opacity: 0; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ---- Thinking block ---- */
.thinking-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  margin: 14px 0;
  overflow: hidden;
  width: 100%;
}

.thinking-block summary {
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  user-select: none;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  list-style: none;
}

.thinking-block summary::-webkit-details-marker {
  display: none;
}

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

.thinking-chevron {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  transition: transform 0.25s ease;
}

.thinking-chevron svg {
  display: block;
  width: 100%;
  height: 100%;
}

.thinking-block[open] .thinking-chevron {
  transform: rotate(180deg);
}

.thinking-content {
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-default);
  line-height: 1.65;
  font-style: italic;
  background: var(--bg-surface);
}

/* ---- Skeleton (kept for compatibility) ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-secondary) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
  display: inline-block;
  vertical-align: middle;
}

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

/* ---- Page Specific ---- */
.auth-page .login-screen {
    background: var(--bg-primary);
    min-height: 100vh;
}

.login-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
}

.login-logo img {
    max-width: 80px;
    height: auto;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.settings-page {
    background: var(--bg-primary);
    min-height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.settings-container {
    max-width: 650px;
    width: 90%;
    margin: 40px auto;
    padding: 32px;
    background: var(--bg-surface);
    border-radius: 28px;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-lg);
    animation: login-in 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.settings-header h1 {
    font-size: 24px;
    font-family: var(--font-display);
    letter-spacing: 0.05em;
}

.user-profile-section {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    margin-bottom: 32px;
    border: 1px solid var(--border-default);
}

.profile-avatar-large {
    width: 64px;
    height: 64px;
    background: var(--accent-gradient);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--button-primary-text);
    box-shadow: var(--shadow-sm);
}

.profile-info h3 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.profile-info p { font-size: 14px; color: var(--text-tertiary); }

.credit-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-full);
    color: var(--accent-soft);
    font-size: 13px;
    font-weight: 600;
    margin-top: 10px;
}

.settings-footer {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-logout-pro {
    background: rgba(var(--danger-critical-rgb, 239, 68, 68), 0.1);
    color: var(--danger-critical);
    border: 1px solid rgba(var(--danger-critical-rgb, 239, 68, 68), 0.2);
    padding: 10px 24px;
    border-radius: var(--radius-full);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout-pro:hover {
    background: var(--danger-critical);
    color: var(--button-primary-text);
    box-shadow: 0 4px 12px rgba(var(--danger-critical-rgb, 239, 68, 68), 0.3);
}

@media (max-width: 767px) {
    .settings-container { margin: 20px auto; padding: 24px; border-radius: 0; min-height: 100vh; width: 100%; border: none; }
}

/* ---- Modes Menu & Indicators ---- */
.modes-menu {
  position: absolute;
  bottom: calc(100% + 16px);
  left: calc(50% - 160px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 320px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 100;
}

.modes-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.mode-item-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 8px 12px 4px;
}

.mode-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.18s ease;
  font-size: 14.5px;
  font-weight: 500;
  position: relative;
}

.mode-item-hint {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.mode-item svg {
  color: var(--text-tertiary);
  transition: color 0.2s ease;
  flex-shrink: 0;
}

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

.mode-item:hover svg {
  color: var(--text-primary);
}

.mode-item.active {
  background: var(--bg-surface-active);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.mode-item.active svg {
  color: var(--accent-soft);
}

.mode-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mode-item .lock-icon {
  margin-left: auto;
  color: var(--text-tertiary);
}

.mode-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 6px 0;
}

/* Model Selector Pill inside Input Container */
.model-select-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border-default);
  padding: 5px 12px;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 4px;
}

.model-select-pill:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.model-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.model-pill-dot.model-flash { background: var(--accent-warning); }
.model-pill-dot.model-pro { background: var(--accent-primary); }

.input-right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.active-mode-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 12px 12px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
  animation: slide-up-fade 300ms cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: 0.02em;
}

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

#btn-clear-mode {
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  margin-left: 4px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
#btn-clear-mode svg {
  width: 12px;
  height: 12px;
}
#btn-clear-mode:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  transform: scale(1.1);
}

.input-area {
  position: relative;
}

/* ---- Brand logo to sidebar-toggle transition ---- */
.sidebar-toggle-content {
  position: relative;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toggle-logo-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toggle-hover-icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  opacity: 0;
  transform: scale(0.6) rotate(-90deg);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  color: var(--text-primary);
}
.toggle-hover-icon.open-icon {
  display: block;
}
.toggle-hover-icon.close-icon {
  display: none;
}
.sidebar.expanded .toggle-hover-icon.open-icon {
  display: none;
}
.sidebar.expanded .toggle-hover-icon.close-icon {
  display: block;
}
#btn-sidebar-toggle:hover .toggle-logo-img {
  opacity: 0;
  transform: scale(0.6) rotate(90deg);
}
#btn-sidebar-toggle:hover .toggle-hover-icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* ---- Welcome state: Centered Input & Dynamic Animation ---- */
.chat-main.state-welcome {
  justify-content: center;
  align-items: center;
  position: relative;
}
.chat-main.state-welcome .chat-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-bottom: none;
  background: transparent;
  z-index: 10;
}
.chat-main.state-welcome .chat-header-title {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.chat-header-title {
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}
.chat-main.state-welcome .messages-container {
  flex: none;
  width: 100%;
  overflow: visible;
}
.chat-main.state-welcome .welcome-screen {
  min-height: auto;
  padding: 0;
}
.chat-main.state-welcome .input-area {
  padding-top: 0;
  background: transparent;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}
.input-area {
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), padding 0.6s ease;
}

/* ---- O-Drive Modal (Glassmorphic M3 Card) ---- */
.odrive-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10000;
}
.odrive-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}
.odrive-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 20px;
  width: 480px;
  max-width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.odrive-modal-overlay.active .odrive-modal {
  transform: scale(1) translateY(0);
}
.odrive-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
}
.odrive-modal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
}
.odrive-modal-header-left h3 {
  font-size: 16px;
  font-weight: 600;
}
.odrive-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.odrive-modal-close:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.odrive-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}
.odrive-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
}
.odrive-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: odrive-spin 1s linear infinite;
}
@keyframes odrive-spin {
  to { transform: rotate(360deg); }
}
.odrive-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-tertiary);
  padding: 40px 20px;
  text-align: center;
}
.odrive-files-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.odrive-file-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}
.odrive-file-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.odrive-file-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.odrive-file-item:hover .odrive-file-icon {
  color: var(--accent-soft);
}
.odrive-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.odrive-file-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.odrive-file-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ---- Temporary Chat Incognito Mode styles ---- */
.state-temporary .ambient-glow {
  background: radial-gradient(circle at 50% 100%, rgba(var(--accent-primary-rgb), 0.18) 0%, transparent 65%) !important;
}

.state-temporary .chat-main.state-welcome {
  background: radial-gradient(circle at 50% 92%, rgba(var(--accent-primary-rgb), 0.12) 0%, var(--bg-primary) 65%) !important;
}

.state-temporary .input-container {
  border-color: rgba(var(--accent-primary-rgb), 0.45) !important;
  box-shadow: 0 0 20px rgba(var(--accent-primary-rgb), 0.18) !important;
  background: rgba(var(--accent-primary-rgb), 0.06) !important;
}

.state-temporary .input-container:focus-within {
  border-color: rgba(var(--accent-primary-rgb), 0.8) !important;
  box-shadow: 0 0 30px rgba(var(--accent-primary-rgb), 0.25) !important;
}

.state-temporary .welcome-logo {
  filter: drop-shadow(0 0 25px rgba(var(--accent-primary-rgb), 0.55)) !important;
}

.state-temporary .brand-display {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-soft) 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

.state-temporary .btn-send {
  background: var(--accent-primary) !important;
}

/* ============================================================
   AGENT MODE — Sidebar Toggle, Quota, Badge, Confirmation Modal
   ============================================================ */

/* ---- Agent Mode Toggle (Sidebar) ---- */
.agent-mode-toggle {
  padding: 8px 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar.expanded .agent-mode-toggle {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.agent-toggle-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  cursor: pointer;
  padding: 3px;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  user-select: none;
  overflow: hidden;
}

.agent-toggle-track:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-hover);
}

.agent-toggle-track:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-primary);
}

/* Active (agent mode on) */
.agent-toggle-track.active {
  background: rgba(var(--accent-primary-rgb), 0.12);
  border-color: rgba(var(--accent-primary-rgb), 0.3);
}

.agent-toggle-label {
  position: relative;
  z-index: 1;
  flex: 1;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: color 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.agent-label-chat {
  color: var(--text-primary);
}

.agent-label-agent {
  color: var(--text-tertiary);
}

/* When agent mode is active */
.agent-toggle-track.active .agent-label-chat {
  color: var(--text-tertiary);
}

.agent-toggle-track.active .agent-label-agent {
  color: var(--accent-primary);
}

/* Thumb/slider */
.agent-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.agent-toggle-track.active .agent-toggle-thumb {
  left: calc(50%);
  background: var(--accent-primary);
  box-shadow: 0 2px 12px rgba(var(--accent-primary-rgb), 0.4);
}

/* Collapsed sidebar: show a small icon-only indicator */
.sidebar:not(.expanded) .agent-mode-toggle {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  padding: 8px 0;
  display: flex;
  justify-content: center;
}

.sidebar:not(.expanded) .agent-toggle-track {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  justify-content: center;
  padding: 0;
}

.sidebar:not(.expanded) .agent-toggle-label {
  display: none;
}

.sidebar:not(.expanded) .agent-toggle-thumb {
  display: none;
}

.sidebar:not(.expanded) .agent-toggle-track::after {
  content: 'S';
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.sidebar:not(.expanded) .agent-toggle-track.active::after {
  content: 'A';
  color: var(--accent-primary);
  text-shadow: 0 0 8px rgba(var(--accent-primary-rgb), 0.5);
}

.sidebar:not(.expanded) .agent-toggle-track.active {
  background: rgba(var(--accent-primary-rgb), 0.15);
  border-color: rgba(var(--accent-primary-rgb), 0.35);
  box-shadow: 0 0 12px rgba(var(--accent-primary-rgb), 0.2);
}

/* ---- Agent Quota Bar ---- */
.agent-quota-bar {
  padding: 6px 10px 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar.expanded .agent-quota-bar {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.agent-quota-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-bottom: 5px;
}

.agent-quota-text svg {
  vertical-align: -1px;
  margin-right: 3px;
  color: var(--accent-primary);
}

.agent-quota-track {
  width: 100%;
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  overflow: hidden;
}

.agent-quota-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.agent-quota-fill.warning {
  background: var(--danger-warning);
}

.agent-quota-fill.critical {
  background: var(--danger-critical);
  animation: pulse-critical 1.5s ease-in-out infinite;
}

@keyframes pulse-critical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ---- Agent Mode Badge (Header) ---- */
.agent-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: rgba(var(--accent-primary-rgb), 0.12);
  border: 1px solid rgba(var(--accent-primary-rgb), 0.25);
  color: var(--accent-primary);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  animation: badge-appear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  white-space: nowrap;
}

.agent-mode-badge svg {
  animation: bolt-flash 2s ease-in-out infinite;
}

@keyframes badge-appear {
  0% { opacity: 0; transform: scale(0.8) translateY(4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes bolt-flash {
  0%, 80%, 100% { opacity: 1; }
  40% { opacity: 0.4; }
}

/* ---- Agent Confirmation Modal ---- */
.agent-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.agent-confirm-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: scale(0.92) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.agent-confirm-overlay.active .agent-confirm-modal {
  transform: scale(1) translateY(0);
}

.agent-confirm-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(var(--accent-warning-rgb), 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--accent-warning);
}

.agent-confirm-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.agent-confirm-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.agent-confirm-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.agent-confirm-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: rgba(var(--accent-warning-rgb), 0.1);
  border: 1px solid rgba(var(--accent-warning-rgb), 0.2);
  color: var(--accent-warning);
  font-size: 12px;
  font-weight: 500;
}

.agent-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.agent-confirm-btn {
  padding: 10px 24px;
  border-radius: var(--radius-full);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.agent-confirm-cancel {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.agent-confirm-cancel:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.agent-confirm-approve {
  background: var(--accent-primary);
  color: var(--button-primary-text);
}

.agent-confirm-approve:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(var(--accent-primary-rgb), 0.4);
}

/* ---- Upgrade Prompt Modal ---- */
.upgrade-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.upgrade-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: scale(0.92) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.upgrade-overlay.active .upgrade-modal {
  transform: scale(1) translateY(0);
}

.upgrade-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(var(--accent-primary-rgb), 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--accent-primary);
}

.upgrade-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.upgrade-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.upgrade-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.upgrade-btn {
  padding: 10px 24px;
  border-radius: var(--radius-full);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upgrade-btn-cancel {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

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

.upgrade-btn-primary {
  background: var(--accent-primary);
  color: var(--button-primary-text);
}

.upgrade-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(var(--accent-primary-rgb), 0.4);
}

/* ---- Agent Mode Global State ---- */
.app.state-agent .input-container {
  border-color: rgba(var(--accent-primary-rgb), 0.25) !important;
}

.app.state-agent .input-container:focus-within {
  border-color: rgba(var(--accent-primary-rgb), 0.6) !important;
  box-shadow: 0 0 25px rgba(var(--accent-primary-rgb), 0.15) !important;
}

.app.state-agent .btn-send {
  background: var(--accent-primary) !important;
}

.app.state-agent .btn-send:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(var(--accent-primary-rgb), 0.4) !important;
}

.app.state-agent .welcome-logo {
  filter: drop-shadow(0 0 25px rgba(var(--accent-primary-rgb), 0.5));
}

/* Agent thinking steps indicator */
.agent-steps-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: rgba(var(--accent-primary-rgb), 0.05);
  border: 1px solid rgba(var(--accent-primary-rgb), 0.12);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.agent-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.agent-step-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.agent-step.running {
  color: var(--accent-primary);
}

.agent-step.running .agent-step-icon::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(var(--accent-primary-rgb), 0.3);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.agent-step.done {
  color: var(--success-primary);
}

.agent-step.error {
  color: var(--danger-critical);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Reduced motion / Low-end device overrides ---- */
@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;
  }

  .thinking-chevron,
  .agent-step.running .agent-step-icon::after,
  .typing-dot,
  .thinking-dots span,
  .thinking-indicator .thinking-logo {
    animation: none !important;
    transition: none !important;
  }
}

.low-motion *, .low-motion *::before, .low-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.05s !important;
  scroll-behavior: auto !important;
}

.low-motion .thinking-chevron,
.low-motion .agent-step.running .agent-step-icon::after,
.low-motion .typing-dot,
.low-motion .thinking-dots span,
.low-motion .thinking-indicator .thinking-logo,
.low-motion .skeleton,
.low-motion .shimmer {
  animation: none !important;
}

.low-motion .thinking-block,
.low-motion .thinking-chevron {
  transition: none !important;
}

/* Split menus */
.upload-menu,
.model-mode-menu {
  bottom: calc(100% + 12px);
  left: 14px;
  right: auto;
  min-width: 260px;
}

.model-mode-menu {
  left: auto;
  right: 14px;
}

/* Reasoning level selector */
.reasoning-level-selector {
  display: flex;
  gap: 8px;
  padding: 8px 14px 14px;
}

.reasoning-level-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
  font-weight: 600;
}

.reasoning-level-item small {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.75;
}

.reasoning-level-item:hover {
  background: var(--bg-surface-hover);
}

.reasoning-level-item.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.reasoning-level-item.active small {
  color: rgba(255, 255, 255, 0.85);
}

.usage-subtext {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: -2px;
  margin-bottom: 4px;
}
