:root {
  /* Podstawowe definicje kolorów (RGB) */
  --color-primary: 30, 64, 175;
  --color-success: 16, 185, 129;
  --color-warning: 245, 158, 11;
  --color-danger: 239, 68, 68;
  --color-neutral: 55, 65, 81;
  
  /* Tła */
  --bg-dark: 15, 23, 42;
  --bg-darker: 17, 24, 39;
  --bg-lighter: 30, 41, 59;
  
  /* Tekst */
  --text-primary: 255, 255, 255;
  --text-secondary: 219, 228, 240;
  --text-muted: 156, 170, 190;
  
  /* Modele AI */
  --color-openai: 14, 165, 233;
  --color-claude: 79, 70, 229;
  --color-gemini: 37, 99, 235;
  --color-grok: 56, 189, 248;

  /* --- NOWE ZMIENNE: Tints, Shades & Gradients --- */
  --primary: rgb(var(--color-primary));
  --primary-shade: rgb(20, 40, 120); /* Ciemniejszy dla głębi */
  --primary-tint: rgba(var(--color-primary), 0.15); /* Subtelny overlay */
  
  --bg-surface-tint: rgba(var(--bg-lighter), 0.6); /* Jaśniejsza powierzchnia */
  --text-primary-shade: rgba(var(--text-primary), 0.95); /* Lekko złamana biel */
  --neutral-soft: rgba(var(--color-neutral), 0.6);

  --gradient-primary: linear-gradient(135deg, rgb(var(--color-primary)) 0%, var(--primary-shade) 100%);
  --gradient-accent: linear-gradient(135deg, rgba(var(--color-primary), 0.9) 0%, rgba(var(--color-gemini), 0.7) 100%);
  --gradient-surface: linear-gradient(to bottom, var(--bg-surface-tint), rgba(var(--bg-lighter), 0.3));

  /* --- FLUID TYPOGRAPHY & SPACING --- */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: clamp(0.6rem, 1.5vw, 0.75rem);
  --space-md: clamp(0.85rem, 2vw, 1rem);
  --space-lg: clamp(1.25rem, 3vw, 1.5rem);
  --space-xl: 2rem;

  --font-size-xs: clamp(0.7rem, 1.5vw + 0.1rem, 0.75rem);
  --font-size-sm: clamp(0.8rem, 1.5vw + 0.2rem, 0.875rem);
  --font-size-md: clamp(0.95rem, 1.5vw + 0.3rem, 1rem);
  --font-size-lg: clamp(1.1rem, 2vw + 0.4rem, 1.25rem);
  
  --line-height-tight: 1.25;
  --line-height-normal: 1.6;
  --line-height-loose: 1.75;
  --letter-spacing-wide: 0.015em;

  /* Cienie i Promienie */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.15), 0 2px 4px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.2), 0 4px 6px -2px rgba(0,0,0,0.1);
  --shadow-inner: inset 0 1px 1px rgba(255,255,255,0.05);

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;

  /* Layout vars */
  --header-height: clamp(50px, 8vh, 60px);
  --input-area-height: 60px;
  --panel-z-index: 400;
  --panel-width: 320px;
  --safe-area-bottom: env(safe-area-inset-bottom, 16px);
  
  /* Pozostałe zmienne */
  --primary-light: rgba(var(--color-primary), 0.8);
  --primary-lighter: rgba(var(--color-primary), 0.3);
  --primary-dark: rgb(17, 24, 90);
  --success: rgb(var(--color-success));
  --warning: rgb(var(--color-warning));
  --danger: rgb(var(--color-danger));
  --bg-base: rgb(var(--bg-dark));
  --bg-surface: rgb(var(--bg-darker));
  --bg-elevated: rgb(var(--bg-lighter));
  --text-default: rgb(var(--text-primary));
  --text-soft: rgb(var(--text-secondary));
  --text-subtle: rgb(var(--text-muted));
  --blur-strength: 12px;
  --glass-opacity: 0.8;
  --transition-smooth: 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.theme-light {
  --bg-dark: 241, 245, 252;
  --bg-darker: 248, 250, 255;
  --bg-lighter: 226, 235, 245;
  --text-primary: 15, 23, 50;
  --text-secondary: 30, 50, 95;
  --text-muted: 76, 94, 138;
  --primary-shade: rgb(20, 50, 140);
  --bg-surface-tint: rgba(255, 255, 255, 0.8);
  --gradient-primary: linear-gradient(135deg, rgb(var(--color-primary)) 0%, rgb(50, 90, 220) 100%);
  --shadow-inner: inset 0 1px 1px rgba(255,255,255,0.4);
}

@media (prefers-contrast: high) {
  :root {
    --primary: rgb(0, 80, 200);
    --glass-opacity: 1;
    --blur-strength: 0;
  }
}

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

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

html, body {
  height: 100%;
  width: 100%;
  font-size: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-default);
  background-color: var(--bg-base);
  /* Dodano noise texture dla efektu premium */
  background-image: 
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.04'/%3E%3C/svg%3E"),
    radial-gradient(at 30% 20%, rgba(var(--color-primary), 0.12) 0, transparent 55%),
    radial-gradient(at 80% 70%, rgba(var(--color-gemini), 0.1) 0, transparent 55%);
  background-attachment: fixed;
  line-height: var(--line-height-normal);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* --- BUTTONY PREMIUM --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  border: none;
  font-weight: 500;
  cursor: pointer;
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), background-color var(--transition-smooth);
  position: relative;
  overflow: hidden;
  color: var(--text-default);
  background-color: rgba(var(--color-neutral), 0.7);
  background-image: linear-gradient(to bottom, rgba(255,255,255,0.05), rgba(255,255,255,0));
  box-shadow: var(--shadow-sm), var(--shadow-inner);
  font-size: var(--font-size-sm);
  min-height: 36px;
  letter-spacing: 0.01em;
}

.btn:hover:not(:disabled) {
  background-color: rgba(var(--color-neutral), 0.9);
  transform: translateY(-1px) scale(1.02);
  box-shadow: var(--shadow-md), var(--shadow-inner);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn:focus-visible {
  outline: 2px solid rgba(var(--color-primary), 0.6);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  border: 1px solid rgba(255,255,255,0.1);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, rgb(var(--color-primary)) 0%, rgb(25, 50, 150) 100%);
  box-shadow: 0 0 15px rgba(var(--color-primary), 0.4), var(--shadow-inner);
}

.btn-danger {
  background: linear-gradient(135deg, rgba(var(--color-danger), 0.9), rgba(var(--color-danger), 1));
}

.btn-danger:hover:not(:disabled) {
  background-color: rgb(var(--color-danger));
  box-shadow: 0 0 10px rgba(var(--color-danger), 0.4);
}

.btn-warning {
  background: linear-gradient(135deg, rgba(var(--color-warning), 0.9), rgba(var(--color-warning), 1));
  color: #1a1a1a;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* Ulepszony Ripple Effect */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.4);
  display: block;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%);
}

.ripple:active::after {
  transform: translate(-50%, -50%) scale(100);
  opacity: 0;
  transition: transform 0.6s ease-out, opacity 0.6s ease-out;
}

.form-control {
  display: block;
  width: 100%;
  padding: var(--space-sm);
  font-size: var(--font-size-sm);
  border: 1px solid rgba(var(--color-neutral), 0.3);
  border-radius: var(--radius-sm);
  background-color: rgba(var(--bg-darker), 0.8);
  color: var(--text-default);
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.form-control:focus {
  outline: none;
  border-color: rgba(var(--color-primary), 0.7);
  box-shadow: 0 0 0 3px rgba(var(--color-primary), 0.15);
  background-color: rgba(var(--bg-darker), 0.95);
}

label {
  display: block;
  margin-bottom: var(--space-2xs);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-soft);
  letter-spacing: 0.01em;
}

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(var(--text-secondary), 0.3);
  border-radius: 50%;
  border-top-color: var(--text-default);
  animation: spin 0.8s ease infinite;
}

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

.btn-group {
  display: flex;
  gap: var(--space-xs);
}

.model-badge, .file-ext-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  background-color: rgba(var(--color-neutral), 0.3);
  border: 1px solid rgba(var(--color-neutral), 0.2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.model-openai {
  background-color: rgba(var(--color-openai), 0.15);
  border-color: rgba(var(--color-openai), 0.3);
  color: rgb(var(--color-openai));
}

.model-claude {
  background-color: rgba(var(--color-claude), 0.15);
  border-color: rgba(var(--color-claude), 0.3);
  color: rgb(120, 115, 245);
}

.model-gemini {
  background-color: rgba(var(--color-gemini), 0.15);
  border-color: rgba(var(--color-gemini), 0.3);
  color: rgb(var(--color-gemini));
}

.model-grok {
  background-color: rgba(var(--color-grok), 0.15);
  border-color: rgba(var(--color-grok), 0.3);
  color: rgb(var(--color-grok));
}

#chat-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  background-color: rgba(var(--bg-darker), 0.85);
  backdrop-filter: blur(var(--blur-strength));
  -webkit-backdrop-filter: blur(var(--blur-strength));
  border-bottom: 1px solid rgba(var(--color-neutral), 0.3);
  position: relative;
  z-index: calc(var(--panel-z-index) + 1);
}

#side-menu-toggle-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background-color: transparent;
  color: var(--text-default);
}

#side-menu-toggle-btn:hover {
  background-color: rgba(var(--color-neutral), 0.2);
}

#menu-toggle-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--gradient-accent);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
}

#chat-info {
  display: flex;
  flex-grow: 1;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  overflow: hidden;
}

#conversation-title {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-default);
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-sm);
  transition: background-color 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  max-width: 250px;
  letter-spacing: 0.02em;
}

#conversation-title:hover:not([contenteditable="false"]) {
  background-color: rgba(var(--color-neutral), 0.2);
}

#conversation-title:focus {
  background-color: rgba(var(--color-neutral), 0.3);
  white-space: normal;
}

#model-select-container {
  display: flex;
  align-items: center;
  position: relative;
  min-width: 100px;
  position: relative;
}

#model-select-container::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  height: 20px;
  width: 1px;
  background-color: rgba(var(--color-neutral), 0.4);
  transform: translateY(-50%);
}

#model-select {
  padding: var(--space-xs) var(--space-sm);
  background-color: rgba(var(--bg-lighter), 0.5);
  border: 1px solid rgba(var(--color-neutral), 0.3);
  border-radius: var(--radius-sm);
  color: var(--text-default);
  font-size: var(--font-size-sm);
  max-width: 150px;
  transition: all 0.2s ease;
  font-weight: 500;
}

#model-select:focus {
  border-color: rgba(var(--color-primary), 0.7);
  box-shadow: 0 0 0 2px rgba(var(--color-primary), 0.25);
  outline: none;
}

#chat-actions {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  flex-shrink: 0;
}

#chat-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: transparent;
  overflow: hidden;
}

#chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: var(--space-md) clamp(1rem, 5vw, 2rem);
  padding-bottom: calc(var(--input-area-height) + 40px + var(--safe-area-bottom));
  scroll-behavior: smooth;
  will-change: transform;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--space-2xs); /* Reduced thanks to gap in flex container */
  will-change: transform, opacity;
}

.message-wrapper.user {
  align-items: flex-end;
}

.message-wrapper.assistant {
  align-items: flex-start;
}

/* Ulepszona animacja wejścia - Spring/Bounce effect */
.message-wrapper.new {
  animation: messageIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

.message {
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  max-width: 85%;
  word-wrap: break-word;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  position: relative;
}

.message:hover:not(.excluded) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  z-index: 2;
}

.message.excluded {
  opacity: 0.6;
}

/* Updated Message Styling - Vibrant & Deep */
.message-wrapper .message.user, 
.message.user-message {
  background: var(--gradient-primary) !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 15px -3px rgba(var(--color-primary), 0.4) !important;
}

.message-wrapper .message.assistant,
.message.assistant-message {
  background: var(--gradient-surface) !important;
  color: var(--text-primary-shade) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: var(--shadow-md) !important;
}

.message-wrapper .message.user:hover:not(.excluded),
.message.user-message:hover:not(.excluded) {
  background: linear-gradient(135deg, rgb(var(--color-primary)) 0%, rgb(15, 30, 100) 100%) !important;
  border-color: rgba(255,255,255,0.3) !important;
}

.message-wrapper .message.assistant:hover:not(.excluded),
.message.assistant-message:hover:not(.excluded) {
  background: linear-gradient(to bottom, rgba(var(--bg-lighter), 0.7), rgba(var(--bg-lighter), 0.4)) !important;
  border-color: rgba(255,255,255,0.15) !important;
}

.message.system-message {
  background-color: rgba(var(--color-warning), 0.15);
  color: rgba(var(--color-warning), 0.9);
  border: 1px solid rgba(var(--color-warning), 0.3);
  font-style: italic;
  font-size: var(--font-size-sm);
  text-align: center;
  max-width: 95%;
  margin: 0 auto var(--space-md) auto;
  box-shadow: none;
}

.message strong {
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.message .message-content {
  flex-grow: 1;
  font-size: var(--font-size-md);
  line-height: var(--line-height-loose);
  letter-spacing: var(--letter-spacing-wide);
}

/* Styling for <think> tags content */
.think-block { margin: var(--space-sm) 0; border-radius: var(--radius-sm); overflow: hidden; background-color: rgba(0, 0, 0, 0.2); border: 1px solid rgba(156, 163, 175, 0.2); }
.think-toggle { display: flex; align-items: center; gap: var(--space-xs); width: 100%; padding: var(--space-xs) var(--space-sm); font-size: 0.75em; font-weight: 500; color: rgba(156, 170, 190, 0.9); background: transparent; border: none; cursor: pointer; text-align: left; transition: background-color 0.2s ease; }
.think-toggle:hover { background-color: rgba(255, 255, 255, 0.05); }
.think-toggle.expanded { background-color: rgba(255, 255, 255, 0.03); }
.think-content { font-size: 0.72em; color: rgba(156, 170, 190, 0.85); line-height: 1.5; padding: var(--space-sm) var(--space-md); background-color: rgba(0, 0, 0, 0.15); border-top: 1px solid rgba(156, 163, 175, 0.15); white-space: pre-wrap; word-wrap: break-word; max-height: 400px; overflow-y: auto; transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease; }
.think-content.collapsed { max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; border-top: none; overflow: hidden; }

.stream-waiting { display: inline-flex; align-items: center; gap: 4px; padding: 8px 0; }
.stream-waiting-dot { width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(135deg, #60a5fa, #818cf8); animation: streamDotPulse 1.4s ease-in-out infinite; opacity: 0.4; }
.stream-waiting-dot:nth-child(1) { animation-delay: 0s; }
.stream-waiting-dot:nth-child(2) { animation-delay: 0.2s; }
.stream-waiting-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes streamDotPulse { 0%, 60%, 100% { transform: scale(1); opacity: 0.4; } 30% { transform: scale(1.3); opacity: 1; } }
.stream-waiting.fade-out { animation: streamWaitingFade 0.3s ease-out forwards; }
@keyframes streamWaitingFade { to { opacity: 0; transform: translateY(-4px); } }

/* XML Action blocks styling */
.xml-action-block { margin: var(--space-md) 0; border-radius: var(--radius-md); overflow: hidden; background-color: rgba(30, 41, 59, 0.6); border: 1px solid rgba(100, 116, 139, 0.3); font-size: 0.82em; }
.xml-action-block.xml-action-error { border-color: rgba(239, 68, 68, 0.4); background-color: rgba(127, 29, 29, 0.2); }
.xml-action-block.xml-action-success { border-color: rgba(34, 197, 94, 0.3); }
.xml-action-header { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-xs) var(--space-sm); background-color: rgba(0, 0, 0, 0.2); border-bottom: 1px solid rgba(100, 116, 139, 0.2); }
.xml-action-icon { font-size: 1.1em; }
.xml-action-label { font-weight: 600; color: var(--color-text-primary); flex: 1; }
.xml-action-status { font-size: 0.85em; color: rgba(34, 197, 94, 0.9); }
.xml-action-error .xml-action-status { color: rgba(239, 68, 68, 0.9); }
.xml-action-toggle { background: transparent; border: none; color: var(--color-text-muted); cursor: pointer; padding: var(--space-2xs) var(--space-xs); font-size: 0.9em; transition: transform 0.2s ease; }
.xml-action-toggle.expanded { transform: rotate(180deg); }
.xml-action-query { padding: var(--space-xs) var(--space-sm); font-size: 0.88em; color: rgba(148, 163, 184, 0.9); background-color: rgba(0, 0, 0, 0.15); font-family: var(--font-mono); white-space: pre-wrap; word-break: break-all; max-height: 120px; overflow-y: auto; border-bottom: 1px solid rgba(100, 116, 139, 0.15); }
.xml-action-result { padding: var(--space-sm); font-size: 0.85em; color: var(--color-text-secondary); background-color: rgba(0, 0, 0, 0.1); white-space: pre-wrap; word-wrap: break-word; max-height: 300px; overflow-y: auto; transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease; }
.xml-action-result.collapsed { max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; overflow: hidden; }
.xml-action-link { color: #60a5fa; text-decoration: none; font-weight: 500; }
.xml-action-link:hover { color: #93c5fd; text-decoration: underline; }

.message .message-token-count {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  text-align: right;
  margin-top: var(--space-xs);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.message-controls {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-sm);
  background-color: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.message-wrapper.user .message-controls {
  justify-content: flex-end;
}

.message-wrapper.assistant .message-controls {
  justify-content: flex-start;
}

.message-checkbox {
  width: 12px;
  height: 12px;
  accent-color: var(--primary);
  cursor: pointer;
  transition: opacity 0.2s;
}

.message-action-btn {
  border: none;
  background: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: var(--space-2xs);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.message-action-btn:hover {
  background-color: rgba(255,255,255, 0.2);
  color: white;
  transform: scale(1.1);
}

.message-action-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2.5;
}

.message .message-content pre {
  position: relative;
  background-color: rgba(10, 15, 30, 0.95);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid rgba(var(--color-neutral), 0.4);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.message .message-content code {
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  font-size: 0.9em;
  tab-size: 2;
  color: #e2e8f0;
}

.message .message-content pre code {
  padding: 0;
  color: var(--text-secondary);
}

.copy-button {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  background-color: rgba(255,255,255, 0.1);
  color: var(--text-default);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0;
}

.message .message-content pre:hover .copy-button {
  opacity: 1;
}

.copy-button:hover {
  background-color: rgba(var(--color-primary), 0.7);
}

.copy-button.copied {
  background-color: rgba(var(--color-success), 0.7);
}

#chat-input-area {
  position: sticky;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background-color: rgba(var(--bg-darker), 0.85);
  backdrop-filter: blur(var(--blur-strength));
  -webkit-backdrop-filter: blur(var(--blur-strength));
  z-index: 100;
  border-top: 1px solid rgba(var(--color-neutral), 0.3);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: var(--space-sm) var(--space-md);
  padding-bottom: calc(var(--space-sm) + var(--safe-area-bottom));
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
}

#user-input {
  flex-grow: 1;
  width: 100%;
  min-height: var(--input-area-height);
  max-height: 288px;
  padding: var(--space-sm) var(--space-md);
  padding-right: 48px;
  border: 1px solid rgba(var(--color-primary), 0.3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  background-color: rgba(var(--bg-darker), 0.6);
  color: var(--text-default);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

#user-input:focus {
  outline: none;
  border-color: rgba(var(--color-primary), 0.8);
  box-shadow: 0 0 0 3px rgba(var(--color-primary), 0.2), inset 0 1px 2px rgba(0,0,0,0.1);
  background-color: rgba(var(--bg-darker), 0.9);
}

#send-button {
  padding: 0 var(--space-lg);
  min-height: var(--input-area-height);
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  color: white;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(var(--color-primary), 0.3);
  border: 1px solid rgba(255,255,255,0.1);
}

/* Microphone button overlay inside chat input area */
#mic-button-wrapper {
 position: absolute;
 right: 9px;
 bottom: 9px;
 width: 19px;
 height: 19px;
 z-index: 10;
}

.mic-button {
 position: absolute;
 right: 0;
 bottom: 0;
 width: 19px;
 height: 19px;
 border-radius: 50%;
 background: rgba(var(--color-primary), 0.7);
 border: 1px solid rgba(var(--color-primary), 0.5);
 display: inline-flex;
 align-items: center;
 justify-content: center;
 cursor: pointer;
 box-shadow: var(--shadow-sm);
 color: rgba(255, 255, 255, 0.9);
 transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), background-color var(--transition-smooth);
}

.mic-button:hover {
 background: rgba(var(--color-primary), 0.85);
 transform: scale(1.15);
 box-shadow: 0 0 8px rgba(var(--color-primary), 0.4);
}

.mic-button.recording {
 background: var(--gradient-primary);
 border-color: rgba(255, 255, 255, 0.2);
 transform: scale(1.1);
 animation: micPulse 1s infinite;
}

.mic-button.processing {
 opacity: 0.6;
 pointer-events: none;
 transform: scale(0.9);
}

@keyframes micPulse {
 0%, 100% { transform: scale(0.9); }
 50% { transform: scale(1.2); }
}

.textarea-wrapper { position: relative; flex-grow: 1; display: flex; }

#send-button.sending::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.3) 50%,
    rgba(255,255,255,0) 100%
  );
  animation: shimmer 1.5s infinite;
}

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

.input-buttons { display: flex; align-items: flex-end; gap: 8px; }
.input-actions-column { display: flex; flex-direction: column; gap: 2px; align-items: stretch; background: rgba(255, 255, 255, 0.03); border: none; border-radius: var(--radius-md); padding: 4px; }
.toggle-buttons-row { display: flex; gap: 2px; }
.send-button-wrapper { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.expand-menu-wrapper { position: relative; }
.btn-expand { background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.06); color: var(--text-soft); padding: 4px 0; cursor: pointer; transition: all 0.2s ease; border-radius: var(--radius-sm); width: 100%; display: flex; justify-content: center; align-items: center; }
.btn-expand:hover { color: var(--text-default); background-color: rgba(var(--color-primary), 0.15); border-color: rgba(var(--color-primary), 0.3); }
.btn-icon-small { background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.06); color: var(--text-soft); padding: 6px; cursor: pointer; transition: all 0.2s ease; border-radius: var(--radius-sm); flex: 1; display: flex; justify-content: center; align-items: center; }
.btn-icon-small:hover { color: var(--text-default); background-color: rgba(var(--color-primary), 0.15); border-color: rgba(var(--color-primary), 0.3); transform: scale(1.05); }
.btn-icon-small.active { color: rgb(var(--color-primary)); background-color: rgba(var(--color-primary), 0.15); border-color: rgba(var(--color-primary), 0.4); }
.btn-icon-small.active:hover { background-color: rgba(var(--color-primary), 0.25); }
.toggle-btn.active { box-shadow: inset 0 0 0 1.5px rgba(var(--color-primary), 0.6); }
.icon-xs { width: 18px; height: 18px; stroke-width: 2; fill: none; stroke: currentColor; }
.input-token-count { font-size: 9px; color: var(--text-subtle); white-space: nowrap; font-weight: 500; text-align: center; }

#thinking-toggle-btn .thinking-toggle-x-line {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  opacity: 0;
  transition: stroke-dashoffset 0.3s ease, opacity 0.25s ease;
}

#thinking-toggle-btn:hover .thinking-toggle-x-line,
#thinking-toggle-btn.active .thinking-toggle-x-line {
  stroke-dashoffset: 0;
  opacity: 1;
}

#thinking-toggle-btn.active .thinking-toggle-x-line--diag1 {
  stroke: #fb7185;
}

#thinking-toggle-btn.active .thinking-toggle-x-line--diag2 {
  stroke: #ef4444;
}

#thinking-toggle-btn .thinking-toggle-x-line--diag2 {
  transition-delay: 0.05s;
}

.expand-context-menu { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 6px; z-index: 3000; background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); overflow: hidden; min-width: 150px; }
.expand-context-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; background: transparent; border: none; color: var(--text-default); font-size: 0.85rem; cursor: pointer; text-align: left; transition: background-color 0.15s ease; }
.expand-context-btn:hover { background: rgba(var(--color-primary), 0.15); }
.expand-context-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.load-more-indicator { text-align: center; padding: 12px 20px; color: var(--text-subtle); font-size: 0.8rem; background: linear-gradient(180deg, rgba(var(--bg-darker), 0.8) 0%, transparent 100%); position: sticky; top: 0; z-index: 10; }

#side-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background-color: rgba(var(--bg-darker), 0.97);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(var(--color-primary), 0.2);
  backdrop-filter: blur(10px);
}

#side-panel.visible {
  transform: translateX(0);
}

.side-panel-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-md) 0 var(--space-md);
  display: flex;
  flex-direction: column;
  margin-top: var(--header-height);
}

.panel-section {
  display: none;
  flex-direction: column;
  flex-grow: 1;
}

.panel-section.active {
  display: flex;
}

.panel-section h3 {
  margin-bottom: var(--space-sm);
  color: var(--text-soft);
  font-size: var(--font-size-md);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

#conversations-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#conversations-list li {
  margin: var(--space-xs) 0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s ease;
  border-radius: var(--radius-sm);
  background-color: rgba(var(--color-neutral), 0.2);
  border: 1px solid rgba(var(--color-neutral), 0.1);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.75rem;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#conversations-list li::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(var(--text-muted), 0.5);
  flex-shrink: 0;
}

#conversations-list li:hover {
  background-color: rgba(var(--color-primary), 0.2);
  transform: translateX(4px);
  border-color: rgba(var(--color-primary), 0.3);
}

#conversations-list li.active {
  background: linear-gradient(90deg, rgba(var(--color-primary), 0.25), rgba(var(--color-primary), 0.05));
  border-left: 3px solid var(--primary);
  font-weight: 500;
  color: white;
}

#conversations-list li.active::before {
  background-color: var(--primary);
  box-shadow: 0 0 5px var(--primary);
}

#conversations-list li.placeholder {
  font-style: italic;
  text-align: center;
  background: none;
  border: 1px dashed rgba(var(--color-neutral), 0.3);
  cursor: default;
}

.file-system-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.folder-item, .file-item {
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s ease;
  margin: 4px 0;
}

.folder-item {
  margin-bottom: 4px;
}

.folder-content {
  margin-left: 12px;
  border-left: 1px dotted rgba(var(--color-neutral), 0.4);
  padding-left: 8px;
  display: none;
}

.folder-open > .folder-content {
  display: block;
}

.folder-label, .file-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  cursor: pointer;
}

.folder-label {
  color: var(--text-soft);
  font-weight: 500;
}

.folder-label:hover, .file-label:hover {
  background-color: rgba(var(--color-primary), 0.15);
  color: var(--text-default);
}

.folder-icon, .file-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.8;
  font-size: 10px;
}

.folder-toggle {
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 8px;
  color: var(--text-subtle);
}

.folder-name, .file-name {
  flex-grow: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--font-size-xs);
}

.file-ext-badge {
  font-size: 9px;
  padding: 2px 5px;
  min-width: 22px;
  text-align: center;
  font-weight: 700;
}

.file-ext-txt {
  background-color: rgba(79, 70, 229, 0.15);
  border-color: rgba(79, 70, 229, 0.3);
  color: rgb(100, 100, 255);
}

.file-ext-pdf {
  background-color: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: rgb(255, 100, 100);
}

.file-ext-img {
  background-color: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: rgb(50, 200, 150);
}

.file-ext-doc {
  background-color: rgba(14, 165, 233, 0.15);
  border-color: rgba(14, 165, 233, 0.3);
  color: rgb(50, 180, 255);
}

.file-ext-csv {
  background-color: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: rgb(255, 180, 50);
}

.file-upload-area {
  margin-top: var(--space-md);
  border: 1px dashed rgba(var(--color-primary), 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  background-color: rgba(var(--color-primary), 0.05);
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-upload-area:hover {
  background-color: rgba(var(--color-primary), 0.1);
  border-color: rgba(var(--color-primary), 0.6);
  transform: scale(1.02);
}

.file-upload-icon {
  color: rgba(var(--color-primary), 0.8);
  margin-bottom: var(--space-xs);
  display: inline-block;
}

.file-upload-text {
  font-size: var(--font-size-xs);
  color: var(--text-soft);
}

#file-upload-input {
  display: none;
}

.side-panel-footer {
  padding: var(--space-md);
  border-top: 1px solid rgba(var(--color-primary), 0.2);
  background-color: rgba(var(--bg-lighter), 0.3);
}

.side-panel-user-info {
  display: flex;
  padding: var(--space-xs) var(--space-md);
  height: 60px;
  background-color: rgba(var(--bg-lighter), 0.4);
  border-top: 1px solid rgba(var(--color-primary), 0.15);
  position: relative;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: var(--space-sm);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.user-details {
  flex-grow: 1;
  overflow: hidden;
}

.user-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-default);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-panel-buttons {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}

.user-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: rgba(var(--color-neutral), 0.3);
  color: var(--text-default);
}

.user-btn:hover {
  background-color: rgba(var(--color-primary), 0.2);
  transform: scale(1.05);
}

.user-btn .icon {
  width: 16px;
  height: 16px;
}

.profile-btn {
  background-color: rgba(var(--color-primary), 0.2);
}

.files-btn {
  background-color: rgba(var(--color-success), 0.2);
  border: 2px solid rgba(var(--color-success), 0.5);
}

.files-btn:hover {
  background-color: rgba(var(--color-success), 0.3);
  border-color: rgba(var(--color-success), 0.7);
}

.switch-vertical {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 42px;
  background-color: rgba(var(--bg-darker), 0.8);
  border-radius: 10px;
  border: 1px solid rgba(var(--color-primary), 0.3);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.switch-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider-vertical {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
}

.switch-option {
  width: 100%;
  height: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-subtle);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 2;
}

.switch-option:hover {
  color: var(--text-soft);
}

.switch-option.active {
  color: var(--text-default);
}

.switch-indicator-vertical {
  position: absolute;
  width: calc(100% - 4px);
  height: 50%;
  border-radius: 8px;
  background-color: rgba(var(--color-primary), 0.8);
  left: 2px;
  top: 2px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1;
}

.switch-input:checked ~ .switch-slider-vertical .switch-indicator-vertical {
  transform: translateY(100%);
}

#header-dropdown-menu {
  position: absolute;
  top: var(--header-height);
  right: 0;
  background-color: rgba(var(--bg-darker), 0.95);
  backdrop-filter: blur(var(--blur-strength));
  -webkit-backdrop-filter: blur(var(--blur-strength));
  color: var(--text-default);
  border: 1px solid rgba(var(--color-primary), 0.2);
  box-shadow: var(--shadow-lg);
  z-index: var(--panel-z-index);
  transform: translateY(-120%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
  visibility: hidden;
  display: flex;
  flex-direction: column;
  width: 240px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
}

#header-dropdown-menu.visible {
  transform: translateY(0);
  visibility: visible;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: none;
  color: var(--text-default);
  cursor: pointer;
  transition: background-color 0.2s;
  font-size: var(--font-size-sm);
  text-align: left;
  width: 100%;
}

.menu-item:hover {
  background-color: rgba(var(--color-primary), 0.2);
}

.model-select-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: var(--space-sm) var(--space-md);
}

.model-select-item label {
  margin-bottom: var(--space-xs);
  color: var(--text-soft);
}

.model-select-item select {
  width: 100%;
}

.slide-down-panel {
  position: absolute;
  top: var(--header-height);
  left: 0;
  right: 0;
  margin: 0 auto;
  width: calc(100% - 40px);
  max-width: var(--panel-width);
  background-color: rgba(var(--bg-darker), 0.95);
  backdrop-filter: blur(var(--blur-strength));
  -webkit-backdrop-filter: blur(var(--blur-strength));
  color: var(--text-default);
  border: 1px solid rgba(var(--color-primary), 0.2);
  border-top: none;
  box-shadow: var(--shadow-lg);
  z-index: var(--panel-z-index);
  transform: translateY(-110%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
  visibility: hidden;
  max-height: calc(80vh - var(--header-height));
  display: flex;
  flex-direction: column;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}

.slide-down-panel.visible {
  transform: translateY(0);
  visibility: visible;
}

.panel-header {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid rgba(var(--color-primary), 0.2);
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  background-color: rgba(var(--bg-lighter), 0.5);
}

.panel-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: var(--space-md);
  overscroll-behavior: contain;
}

.panel-footer {
  padding: var(--space-sm);
  border-top: 1px solid rgba(var(--color-primary), 0.2);
  flex-shrink: 0;
  display: flex;
  gap: var(--space-sm);
  background-color: rgba(var(--bg-lighter), 0.3);
}

#settings-panel .panel-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.settings-group {
  background-color: rgba(var(--bg-lighter), 0.3);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  border: 1px solid rgba(var(--color-primary), 0.15);
}

.settings-group-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.setting-row {
  margin-bottom: var(--space-sm);
}

.temperature-visualization {
  height: 4px;
  background: linear-gradient(to right, var(--primary), rgb(var(--color-danger)));
  border-radius: 2px;
  margin: var(--space-xs) 0;
  position: relative;
}

.temperature-indicator {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: white;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 5px rgba(0,0,0,0.3);
}

.setting-help {
  font-size: var(--font-size-xs);
  color: var(--text-subtle);
  margin-top: var(--space-2xs);
}

.prompt-buttons { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.prompt-btn { font-size: 11px; padding: 4px 8px; background-color: rgba(var(--color-primary), 0.15); color: var(--text-soft); border: 1px solid rgba(var(--color-primary), 0.3); border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s ease; }
.prompt-btn:hover { background-color: rgba(var(--color-primary), 0.25); color: var(--text-default); border-color: rgba(var(--color-primary), 0.5); transform: translateY(-1px); }
.prompt-btn:active { transform: scale(0.95); }

/* Prompt Templates Section */
.prompt-templates-section {
  margin-top: var(--space-md);
}

.prompt-templates-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding: var(--space-xs);
  background-color: rgba(var(--bg-lighter), 0.3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

.prompt-template-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  background-color: rgba(var(--bg-lighter), 0.5);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.prompt-template-item:hover {
  background-color: rgba(var(--color-primary), 0.15);
  border-color: rgba(var(--color-primary), 0.4);
  transform: translateX(2px);
}

.prompt-template-item:active {
  transform: scale(0.99);
}

.prompt-template-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-default);
}

.prompt-template-desc {
  font-size: 10px;
  color: var(--text-subtle);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.prompt-templates-loading,
.prompt-templates-empty,
.prompt-templates-error {
  font-size: 11px;
  color: var(--text-subtle);
  text-align: center;
  padding: var(--space-sm);
}

.prompt-templates-error {
  color: var(--color-danger);
}

.token-count-container {
  padding: var(--space-sm);
  background-color: rgba(var(--bg-lighter), 0.5);
  border-radius: var(--radius-sm);
  text-align: center;
  margin-top: var(--space-sm);
}

#token-count-display {
  font-size: var(--font-size-xs);
  color: var(--text-subtle);
}

.icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-lg {
  width: 24px;
  height: 24px;
}

#messages-selection-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#messages-selection-list li {
  margin: var(--space-xs) 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  background-color: rgba(var(--color-neutral), 0.2);
  border: 1px solid rgba(var(--color-neutral), 0.1);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.5rem;
}

#messages-selection-list li:hover {
  background-color: rgba(var(--color-primary), 0.2);
}

#messages-selection-list li.selected {
  background-color: rgba(var(--color-primary), 0.25);
  border-left: 3px solid var(--primary);
}

#messages-selection-list li.excluded-by-rerank {
  background-color: rgba(var(--color-neutral), 0.08);
  opacity: 0.6;
  border-left: 3px solid transparent;
}

#messages-selection-list li.excluded-by-rerank .msg-preview-role {
  color: var(--color-text-muted);
}

.message.excluded-by-rerank {
  opacity: 0.5;
  border-left: 2px solid var(--color-warning);
}

.msg-preview-checkbox {
  flex-shrink: 0;
}

.msg-preview-role {
  font-weight: 600;
  color: var(--text-subtle);
  flex-shrink: 0;
  font-size: var(--font-size-xs);
  width: 70px;
}

.msg-preview-content {
  flex-grow: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background-color: rgba(var(--bg-darker), 0.95);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(var(--color-primary), 0.3);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

.modal-overlay.visible .modal-container {
  transform: translateY(0);
}

.modal-header {
  padding: var(--space-md);
  border-bottom: 1px solid rgba(var(--color-primary), 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(var(--bg-lighter), 0.3);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-default);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  background-color: rgba(var(--color-danger), 0.2);
  color: rgb(var(--color-danger));
}

.modal-body {
  padding: var(--space-md);
  flex-grow: 1;
  overflow-y: auto;
}

.modal-footer {
  padding: var(--space-md);
  border-top: 1px solid rgba(var(--color-primary), 0.2);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  background: rgba(var(--bg-lighter), 0.3);
}

#edit-message-content {
  width: 100%;
  min-height: 200px;
  padding: var(--space-md);
  background-color: rgba(var(--bg-darker), 0.7);
  border: 1px solid rgba(var(--color-neutral), 0.4);
  border-radius: var(--radius-md);
  color: var(--text-default);
  font-family: inherit;
  font-size: var(--font-size-md);
  line-height: 1.5;
  resize: vertical;
}

#edit-message-content:focus {
  outline: none;
  border-color: rgba(var(--color-primary), 0.7);
  box-shadow: 0 0 0 2px rgba(var(--color-primary), 0.2);
}

@media (max-width: 768px) {
  :root {
    --header-height: 50px;
    --input-area-height: 44px;
    --panel-width: 280px;
  }

  #chat-header {
    padding: 0 var(--space-sm);
  }

  #chat-info {
    gap: var(--space-xs);
  }

  #conversation-title {
    font-size: var(--font-size-md);
    max-width: 140px;
  }

  #model-select-container::before {
    display: none;
  }

  #model-select {
    max-width: 100px;
    font-size: var(--font-size-xs);
  }

  #chat-messages {
    padding: var(--space-sm);
    padding-bottom: calc(var(--input-area-height) + 60px + var(--safe-area-bottom));
  }

  .message {
    padding: var(--space-md);
    max-width: 90%;
  }

  #chat-input-area {
    padding: var(--space-sm);
  }

  #user-input {
    padding: var(--space-xs) var(--space-sm);
    min-height: var(--input-area-height);
    font-size: var(--font-size-sm);
  }

  #send-button {
    padding: 0 var(--space-md);
    min-height: var(--input-area-height);
  }

  .slide-down-panel {
    width: 100%;
    max-width: none;
    border-radius: 0;
  }

  #side-panel {
    width: 85%;
  }

  .switch-vertical {
    width: 18px;
    height: 38px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --header-height: 44px;
    --input-area-height: 40px;
  }

  #chat-messages {
    padding-bottom: calc(var(--input-area-height) + 20px);
  }

  .slide-down-panel {
    max-height: 80vh;
  }
}

@media (pointer: coarse) {
  .message-action-btn svg {
    width: 14px;
    height: 14px;
  }

  .message-checkbox {
    width: 14px;
    height: 14px;
  }
}

/* Image upload and preview styles */
.image-preview-area {
  padding: var(--space-sm);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xs);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.image-preview-item {
  position: relative;
  display: inline-block;
}

.image-preview {
  max-width: 100px;
  max-height: 100px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--bg-elevated);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.image-preview:hover {
  border-color: var(--primary);
}

.image-remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  transition: background-color 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.image-remove-btn:hover {
  background: rgba(var(--color-danger), 0.8);
  transform: scale(1.1);
}

/* Message image display */
.message-image {
  max-width: 300px;
  max-height: 300px;
  border-radius: var(--radius-md);
  margin: var(--space-xs) 0;
  cursor: pointer;
  transition: transform 0.2s ease;
  box-shadow: var(--shadow-md);
}

.message-image:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-lg);
}

.message-content-mixed {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.message-text-part {
  flex: 1;
}

.message-images-part {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

/* Attachments preview styles (images + files combined) */
.attachments-preview-area { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: rgba(0, 0, 0, 0.2); border-radius: var(--radius-sm); margin-bottom: var(--space-xs); padding: 6px 8px; }

.attachment-image-item { position: relative; display: inline-block; flex-shrink: 0; }
.attachment-image-preview { max-width: 48px; max-height: 48px; border-radius: var(--radius-sm); border: 2px solid rgba(100, 116, 139, 0.35); cursor: pointer; transition: border-color 0.2s ease; object-fit: cover; }
.attachment-image-preview:hover { border-color: var(--primary); }
.attachment-remove-btn { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%; background: rgba(239, 68, 68, 0.9); color: white; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: bold; transition: all 0.2s ease; box-shadow: var(--shadow-sm); }
.attachment-remove-btn:hover { background: rgb(239, 68, 68); transform: scale(1.1); }

.uploaded-file-item { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; background: rgba(100, 116, 139, 0.25); border: 1px solid rgba(100, 116, 139, 0.35); border-radius: var(--radius-sm); font-size: 0.75rem; white-space: nowrap; flex-shrink: 0; cursor: pointer; transition: background-color 0.15s ease; }
.uploaded-file-item:hover { background: rgba(100, 116, 139, 0.4); }
.uploaded-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-secondary); max-width: 80px; }
.uploaded-file-remove { background: transparent; border: none; color: rgba(239, 68, 68, 0.7); cursor: pointer; font-size: 12px; padding: 0 2px; line-height: 1; }
.uploaded-file-remove:hover { color: rgb(239, 68, 68); }

.context-menu { position: fixed; z-index: 3000; background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); overflow: hidden; min-width: 140px; }
.file-context-menu { position: fixed; z-index: 3000; background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); overflow: hidden; min-width: 140px; }
.file-context-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; background: transparent; border: none; color: var(--text-default); font-size: 0.85rem; cursor: pointer; text-align: left; transition: background-color 0.15s ease; }
.file-context-btn:hover { background: rgba(var(--color-primary), 0.15); }
.file-context-btn svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.file-preview-modal { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center; }
.file-preview-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.7); }
.file-preview-dialog { position: relative; width: 90%; max-width: 900px; max-height: 85vh; background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); }
.file-preview-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface); border-radius: var(--radius-md) var(--radius-md) 0 0; }
.file-preview-title { font-weight: 600; color: var(--text-default); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-close { background: transparent; border: none; color: var(--text-subtle); font-size: 1.5rem; cursor: pointer; padding: 0 4px; line-height: 1; transition: color 0.15s ease; }
.file-preview-close:hover { color: var(--text-default); }
.file-preview-body { flex: 1; overflow: auto; padding: 16px; }
.file-preview-body pre { margin: 0; padding: 12px; background: rgba(0, 0, 0, 0.2); border-radius: var(--radius-sm); overflow-x: auto; font-size: 0.85rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }

.file-badge { display: inline-flex; align-items: center; gap: var(--space-xs); padding: var(--space-xs) var(--space-sm); background: rgba(var(--color-primary), 0.15); border: 1px solid rgba(var(--color-primary), 0.3); border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--text-default); max-width: 200px; }

.file-badge-icon { width: 16px; height: 16px; color: var(--primary); flex-shrink: 0; }

.file-badge-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-badge-remove { width: 18px; height: 18px; border-radius: 50%; background: rgba(var(--color-danger), 0.2); border: none; color: rgb(var(--color-danger)); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: bold; transition: background-color 0.2s ease; flex-shrink: 0; margin-left: auto; }

.file-badge-remove:hover { background: rgba(var(--color-danger), 0.4); transform: scale(1.1); }

.file-reference { display: inline-flex; align-items: center; gap: var(--space-xs); padding: 2px var(--space-xs); background: rgba(var(--color-primary), 0.1); border-radius: var(--radius-sm); font-size: 0.85em; color: var(--primary); text-decoration: none; cursor: pointer; }

.file-reference:hover { background: rgba(var(--color-primary), 0.2); }

/* Message attached files */
.message-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(var(--color-neutral), 0.2); }

.file-tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; background: rgba(var(--color-primary), 0.1); border: 1px solid rgba(var(--color-primary), 0.25); border-radius: var(--radius-sm); font-size: 0.8rem; color: var(--text-default); }

.file-tag-icon { width: 14px; height: 14px; stroke: var(--primary); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

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

.text-danger { color: rgb(var(--color-danger)); }

.text-success { color: rgb(var(--color-success)); }

.conversation-brief-tooltip { position: fixed; z-index: 5000; max-width: min(400px, calc(100vw - 20px)); max-height: 90vh; overflow-y: auto; padding: 12px 16px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); font-size: 0.72rem; line-height: 1.5; color: var(--text-default); opacity: 0; transition: opacity 0.2s ease; }
.conversation-brief-tooltip p { margin: 0 0 8px 0; }
.conversation-brief-tooltip p:last-child { margin-bottom: 0; }
.conversation-brief-tooltip strong { color: var(--primary); }

.summary-download-container { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.summary-download-container .btn { display: flex; align-items: center; gap: 6px; width: 100%; justify-content: center; }
.summary-download-container .btn .icon { width: 16px; height: 16px; }

.btn-secondary { background: rgba(var(--color-neutral), 0.3); border: 1px solid rgba(var(--color-neutral), 0.5); color: var(--text-default); }
.btn-secondary:hover { background: rgba(var(--color-neutral), 0.5); }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

/* Profile Panel Fullscreen */
.profile-fullscreen { position: absolute !important; top: 0; left: 0; right: 0; bottom: 0; z-index: 100; background: rgba(var(--bg-darker), 0.98); display: none; flex-direction: column; overflow: hidden; }

.profile-fullscreen.active { display: flex; }

.profile-header { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); background: rgba(var(--bg-lighter), 0.3); border-bottom: 1px solid rgba(var(--color-primary), 0.2); flex-shrink: 0; }

.profile-header h3 { margin: 0; font-size: 1rem; font-weight: 600; color: var(--text-default); }

.profile-header .btn-icon { width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center; background: transparent; border: none; color: var(--text-muted); }

.profile-header .btn-icon:hover { color: var(--text-default); background: rgba(var(--color-primary), 0.1); }

.profile-content { flex: 1; overflow-y: auto; padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-md); }

.profile-section { background: rgba(var(--bg-lighter), 0.2); border-radius: var(--radius-md); padding: var(--space-md); }

.profile-section-divider { border-top: 1px solid rgba(var(--color-primary), 0.15); margin-top: var(--space-xs); }

.profile-section-title { font-size: 0.85rem; font-weight: 600; color: var(--primary); margin-bottom: var(--space-sm); text-transform: uppercase; letter-spacing: 0.5px; }

.profile-section-desc { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 var(--space-sm) 0; }

.profile-main-info { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--space-lg) var(--space-md); }

.profile-avatar-large { width: 72px; height: 72px; border-radius: 50%; background: var(--gradient-primary); display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-sm); box-shadow: var(--shadow-md); }

.profile-avatar-large .icon { width: 40px; height: 40px; stroke: white; fill: none; stroke-width: 1.5; }

.profile-username-display { font-size: 1.25rem; font-weight: 700; color: var(--text-default); margin-bottom: var(--space-xs); }

.profile-tier-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

.profile-tier-badge.tier-free { background: rgba(var(--color-neutral), 0.3); color: var(--text-muted); }

.profile-tier-badge.tier-pro { background: linear-gradient(135deg, rgba(var(--color-primary), 0.3), rgba(var(--color-secondary), 0.3)); color: var(--primary); }

.profile-tier-badge.tier-admin { background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 140, 0, 0.3)); color: #ffd700; }

.profile-field { display: flex; justify-content: space-between; align-items: center; padding: var(--space-sm) 0; border-bottom: 1px solid rgba(var(--color-neutral), 0.1); }

.profile-field:last-child { border-bottom: none; }

.profile-label { font-size: 0.85rem; color: var(--text-muted); }

.profile-value { font-size: 0.9rem; color: var(--text-default); font-weight: 500; }

.profile-action-btn { width: 100%; margin-top: var(--space-sm); display: flex; align-items: center; justify-content: center; gap: var(--space-sm); }

.profile-instructions-textarea { resize: vertical; min-height: 80px; max-height: 200px; font-size: 0.85rem; background: rgba(var(--bg-darker), 0.5); border: 1px solid rgba(var(--color-neutral), 0.3); }

.profile-instructions-textarea:focus { border-color: rgba(var(--color-primary), 0.5); outline: none; }

.profile-footer { margin-top: auto; padding-top: var(--space-md); text-align: center; }

.profile-tiny-id { font-size: 0.7rem; color: var(--text-subtle); font-family: monospace; opacity: 0.6; }

.profile-instructions-wrapper { position: relative; }

.instructions-counter { position: absolute; bottom: 8px; right: 10px; font-size: 0.7rem; color: var(--text-subtle); pointer-events: none; }

.instructions-counter.limit-warning { color: rgb(var(--color-warning)); }

.instructions-counter.limit-exceeded { color: rgb(var(--color-danger)); }

/* Change Password Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); z-index: 9999; display: none; align-items: center; justify-content: center; }

.modal-overlay.visible { display: flex; }

.modal-content { background: rgba(var(--bg-darker), 0.98); border: 1px solid rgba(var(--color-primary), 0.2); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); max-width: 90%; animation: modalSlideIn 0.2s ease; }

.modal-sm { width: 380px; }

.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-md); border-bottom: 1px solid rgba(var(--color-neutral), 0.2); }

.modal-header h3 { margin: 0; font-size: 1.1rem; font-weight: 600; color: var(--text-default); }

.modal-close-btn { background: transparent; border: none; color: var(--text-muted); padding: 4px; }

.modal-close-btn:hover { color: var(--text-default); }

.modal-body { padding: var(--space-lg); }

.modal-body .form-group { margin-bottom: var(--space-md); }

.modal-body .form-group:last-child { margin-bottom: 0; }

.modal-body .form-group label { display: block; margin-bottom: var(--space-xs); font-size: 0.85rem; color: var(--text-muted); }

.modal-body .form-group .form-control { width: 100%; }

.modal-footer { display: flex; gap: var(--space-sm); justify-content: flex-end; padding: var(--space-md); border-top: 1px solid rgba(var(--color-neutral), 0.2); }

@keyframes modalSlideIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
