/* ===========================
   VARIABLES & RESET
   =========================== */
:root {
  /* Theme primitives (light defaults) */
  --bg-primary: #f5f7fb;
  --bg-secondary: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --button-bg: #f3f4f6;

  /* Accent and semantic colors remain shared */
  --accent: #6d5dfc;
  --accent-hover: #7d6dff;
  --success: #10b981;
  --danger: #ef4444;

  /* Derived (kept for backward compatibility with existing selectors) */
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-light: var(--button-bg);
  --card: var(--bg-secondary);
  --border: var(--border-color);
  --border-light: rgba(0,0,0,0.06);
  --text: var(--text-primary);
  --text-tertiary: var(--text-secondary);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 280px;
  --sidebar-width-mobile: 0;
}

/* Dark theme overrides */
body.dark-mode {
  --bg-primary: #080c14;
  --bg-secondary: #0d1120;
  --text-primary: #f1f5fb;
  --text-secondary: #8899bb;
  --border-color: #1e2a42;
  --button-bg: #131927;

  /* keep derived variables in sync */
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-light: var(--button-bg);
  --card: var(--bg-secondary);
  --border: var(--border-color);
  --border-light: rgba(255,255,255,0.05);
  --text: var(--text-primary);
  --text-tertiary: var(--text-secondary);
}

body.light-mode {
  /* explicit for clarity */
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --text: var(--text-primary);
  --border: var(--border-color);
}

/* === MIDNIGHT theme === */
body.midnight-mode {
  --bg-primary: #050508;
  --bg-secondary: #0d0d14;
  --text-primary: #e2e0ff;
  --text-secondary: #7c7a9e;
  --border-color: #1e1c33;
  --button-bg: #14121f;
  --accent: #9d88ff;
  --accent-hover: #b3a0ff;
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-light: var(--button-bg);
  --card: var(--bg-secondary);
  --border: var(--border-color);
  --border-light: rgba(157,136,255,0.08);
  --text: var(--text-primary);
  --text-tertiary: var(--text-secondary);
}

/* === OCEAN theme === */
body.ocean-mode {
  --bg-primary: #020e18;
  --bg-secondary: #061724;
  --text-primary: #cef0ff;
  --text-secondary: #5b8fa8;
  --border-color: #0e2d40;
  --button-bg: #091e2e;
  --accent: #00c8ff;
  --accent-hover: #33d6ff;
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-light: var(--button-bg);
  --card: var(--bg-secondary);
  --border: var(--border-color);
  --border-light: rgba(0,200,255,0.08);
  --text: var(--text-primary);
  --text-tertiary: var(--text-secondary);
}

/* === FOREST theme === */
body.forest-mode {
  --bg-primary: #030d07;
  --bg-secondary: #071810;
  --text-primary: #d4f5d8;
  --text-secondary: #4e8a5c;
  --border-color: #0f2e18;
  --button-bg: #0b1f10;
  --accent: #22c55e;
  --accent-hover: #4ade80;
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-light: var(--button-bg);
  --card: var(--bg-secondary);
  --border: var(--border-color);
  --border-light: rgba(34,197,94,0.08);
  --text: var(--text-primary);
  --text-tertiary: var(--text-secondary);
}

/* === ROSE theme === */
body.rose-mode {
  --bg-primary: #120810;
  --bg-secondary: #1e0f19;
  --text-primary: #ffe4f0;
  --text-secondary: #a0607a;
  --border-color: #3a1628;
  --button-bg: #280f1e;
  --accent: #f43f8e;
  --accent-hover: #f97ab5;
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-light: var(--button-bg);
  --card: var(--bg-secondary);
  --border: var(--border-color);
  --border-light: rgba(244,63,142,0.08);
  --text: var(--text-primary);
  --text-tertiary: var(--text-secondary);
}

/* === AURORA theme === */
body.aurora-mode {
  --bg-primary: #080d12;
  --bg-secondary: #0d1620;
  --text-primary: #d0ffe8;
  --text-secondary: #4a8a70;
  --border-color: #112234;
  --button-bg: #0e1c2a;
  --accent: #00e5a0;
  --accent-hover: #33edba;
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-light: var(--button-bg);
  --card: var(--bg-secondary);
  --border: var(--border-color);
  --border-light: rgba(0,229,160,0.08);
  --text: var(--text-primary);
  --text-tertiary: var(--text-secondary);
}

/* === COFFEE theme === */
body.coffee-mode {
  --bg-primary: #0d0906;
  --bg-secondary: #1a120c;
  --text-primary: #f5e6d3;
  --text-secondary: #8a6448;
  --border-color: #2e1e10;
  --button-bg: #221610;
  --accent: #c8860a;
  --accent-hover: #e09c1a;
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-light: var(--button-bg);
  --card: var(--bg-secondary);
  --border: var(--border-color);
  --border-light: rgba(200,134,10,0.08);
  --text: var(--text-primary);
  --text-tertiary: var(--text-secondary);
}

/* === NORD theme === */
body.nord-mode {
  --bg-primary: #1a1f2e;
  --bg-secondary: #212737;
  --text-primary: #d8dee9;
  --text-secondary: #6c7a96;
  --border-color: #2e3548;
  --button-bg: #282e3e;
  --accent: #88c0d0;
  --accent-hover: #a3d4e0;
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-light: var(--button-bg);
  --card: var(--bg-secondary);
  --border: var(--border-color);
  --border-light: rgba(136,192,208,0.08);
  --text: var(--text-primary);
  --text-tertiary: var(--text-secondary);
}

/* === SUNSET theme === */
body.sunset-mode {
  --bg-primary: #0f0805;
  --bg-secondary: #1a100a;
  --text-primary: #ffe8d6;
  --text-secondary: #9a6a50;
  --border-color: #2e1810;
  --button-bg: #211208;
  --accent: #f97316;
  --accent-hover: #fb923c;
  --bg: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-light: var(--button-bg);
  --card: var(--bg-secondary);
  --border: var(--border-color);
  --border-light: rgba(249,115,22,0.08);
  --text: var(--text-primary);
  --text-tertiary: var(--text-secondary);
}

/* Smooth transitions when switching theme */
body {
  transition: background 0.3s ease, color 0.3s ease;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  font-feature-settings: "cv11", "ss01";
}

/* ===========================
   SCROLLBAR
   =========================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.25);
  border-radius: 4px;
  transition: background var(--transition);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(128, 128, 128, 0.4);
}

/* Scrollbar mais escura nos temas dark */
body.dark-mode ::-webkit-scrollbar-thumb,
body.midnight-mode ::-webkit-scrollbar-thumb,
body.ocean-mode ::-webkit-scrollbar-thumb,
body.forest-mode ::-webkit-scrollbar-thumb,
body.sunset-mode ::-webkit-scrollbar-thumb,
body.rose-mode ::-webkit-scrollbar-thumb,
body.aurora-mode ::-webkit-scrollbar-thumb,
body.coffee-mode ::-webkit-scrollbar-thumb,
body.nord-mode ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
}

body.dark-mode ::-webkit-scrollbar-thumb:hover,
body.midnight-mode ::-webkit-scrollbar-thumb:hover,
body.ocean-mode ::-webkit-scrollbar-thumb:hover,
body.forest-mode ::-webkit-scrollbar-thumb:hover,
body.sunset-mode ::-webkit-scrollbar-thumb:hover,
body.rose-mode ::-webkit-scrollbar-thumb:hover,
body.aurora-mode ::-webkit-scrollbar-thumb:hover,
body.coffee-mode ::-webkit-scrollbar-thumb:hover,
body.nord-mode ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ===========================
   APP WRAPPER
   =========================== */
.app-wrapper {
  display: flex;
  height: 100vh;
  width: 100%;
  position: relative;
}

/* ===========================
   SIDEBAR
   =========================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  color: var(--text);
}

.logo-icon {
  font-size: 22px;
  animation: rotate 20s linear infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all var(--transition);
}

.sidebar-close-btn:hover {
  background: var(--card);
  color: var(--text);
}

/* Model Selector */
.model-selector {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.model-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
}

/* Custom Dropdown Wrapper */
.model-dropdown-wrapper {
  position: relative;
  width: 100%;
}

/* Model Trigger Button (Dropdown Header) */
.model-trigger {
  width: 100%;
  padding: 10px 12px;
  background: linear-gradient(
    135deg,
    rgba(22, 27, 40, 0.5),
    rgba(28, 33, 48, 0.3)
  );
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  outline: none;
  backdrop-filter: blur(10px);
}

.model-trigger:hover {
  background: linear-gradient(
    135deg,
    rgba(22, 27, 40, 0.6),
    rgba(28, 33, 48, 0.4)
  );
  border-color: rgba(255, 255, 255, 0.12);
}

.model-trigger:focus {
  border-color: rgba(109, 93, 252, 0.4);
  box-shadow: 0 0 0 3px rgba(109, 93, 252, 0.1);
}

.model-trigger.open {
  border-color: rgba(109, 93, 252, 0.4);
  background: linear-gradient(
    135deg,
    rgba(22, 27, 40, 0.7),
    rgba(28, 33, 48, 0.5)
  );
}

.model-trigger-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.model-trigger-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.model-trigger-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.model-trigger-provider {
  font-size: 11px;
  color: var(--text-tertiary);
}

.model-trigger-status {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: none;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
  }
  50% {
    opacity: 0.7;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
  }
}

.model-trigger-arrow {
  flex-shrink: 0;
  transition: transform var(--transition);
  color: var(--text-secondary);
}

.model-trigger.open .model-trigger-arrow {
  transform: rotate(180deg);
}

/* Model Dropdown Menu */
.model-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: linear-gradient(
    135deg,
    rgba(16, 19, 30, 0.9),
    rgba(22, 27, 40, 0.85)
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: all var(--transition-slow);
}

.model-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Model Group */
.model-group {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.model-group:last-child {
  border-bottom: none;
}

.model-group-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-tertiary);
}

.group-icon {
  font-size: 14px;
}

.group-name {
  flex: 1;
}

.group-badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(109, 93, 252, 0.15);
  color: var(--accent);
  font-weight: 600;
}

.group-badge.fast {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.group-badge.pro {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}

/* Model Items */
.model-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 4px;
}

.model-item {
  padding: 8px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  text-align: left;
  outline: none;
}

.model-item:hover {
  background: rgba(109, 93, 252, 0.1);
  border-color: rgba(109, 93, 252, 0.2);
  color: var(--text);
}

.model-item.active {
  background: rgba(109, 93, 252, 0.2);
  border-color: rgba(109, 93, 252, 0.4);
  color: var(--accent);
  font-weight: 600;
}

.item-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.item-name {
  flex: 1;
  font-weight: 500;
}

.item-spec {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: auto;
}

.item-status {
  display: flex;
  align-items: center;
  margin-left: 4px;
}

/* Hidden select for compatibility */
.model-select-hidden {
  display: none;
}

/* New Chat Button styles removed (button removed from UI) */

/* Conversations Section */
.conversations-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  min-height: 0;
  overflow: hidden;
}

/* ===========================
   MESSAGE ACTIONS
   =========================== */
.message-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  flex-wrap: wrap;
}

.message:hover .message-actions,
.message-actions:focus-within {
  opacity: 1;
  transform: translateY(0);
}

.msg-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--text-secondary);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.msg-action:hover {
  background: var(--surface-light);
  border-color: var(--border);
  transform: translateY(-2px);
  color: var(--text);
}

.msg-action:active {
  transform: scale(0.9);
}

.msg-action.copied {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--success);
}

.msg-action.liked {
  background: rgba(109, 93, 252, 0.15);
  border-color: rgba(109, 93, 252, 0.3);
  color: var(--accent);
}

.msg-action.disliked {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

/* Tooltip for message actions */
.tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 999;
  transition: opacity 200ms ease, transform 200ms ease;
}

body.dark-mode .tooltip {
  background: #1e2535;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* Message footer / metadata */
.message-footer {
  display: block;
  font-size: 12px;
  opacity: 0.65;
  margin-top: 6px;
  font-weight: 400;
  letter-spacing: 0.3px;
  color: var(--text-tertiary);
}

@media (max-width: 768px) {
  .message-footer { font-size: 11px; }
}

/* Toasts (bottom-right) */
#toast-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Dark mode compatibility */
body.dark-mode .toast {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

.conversations-title {
  padding: 12px 16px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  margin: 0;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 8px;
}

.conversation-item {
  padding: 10px 12px;
  margin: 0 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all var(--transition);
  color: var(--text-secondary);
  font-size: 13px;
  position: relative;
  overflow: hidden;
}

.conversation-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--card);
  opacity: 0;
  transition: opacity var(--transition);
  z-index: -1;
}

.conversation-item:hover {
  color: var(--text);
  border-color: var(--border);
}

.conversation-item:hover::before {
  opacity: 1;
}

.conversation-item.active {
  background: var(--card);
  color: var(--accent);
  border-color: var(--accent);
}

.conversation-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.conversation-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-menu {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0;
  transition: all var(--transition);
  font-size: 14px;
}

.conversation-item:hover .conversation-menu {
  opacity: 1;
}

.conversation-menu:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-footer-btn {
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
}

.sidebar-footer-btn:hover {
  background: var(--card);
  color: var(--text);
  border-color: var(--border-light);
}

/* Theme toggle button (criado dinamicamente via JS) */
#theme-toggle-btn {
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  width: 100%;
}

#theme-toggle-btn:hover {
  background: var(--card);
  color: var(--text);
  border-color: var(--accent);
}

/* Theme swatch active highlight */
.theme-swatch.active {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0,0,0,0.4) !important;
  transform: scale(1.05);
}

.theme-swatch:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
}

/* ===========================
   SIDEBAR MOBILE & OVERLAY
   =========================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 101;
  width: 40px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}

.mobile-menu-btn:hover {
  background: var(--card);
}

/* ===========================
   SIDEBAR TOGGLE BUTTON (Desktop)
   =========================== */
.sidebar-toggle-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 98;
  width: 40px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  opacity: 0;
  pointer-events: none;
}

.sidebar-toggle-btn:hover {
  background: var(--card);
  border-color: var(--accent);
  color: var(--accent);
}

/* Mostrar botão quando sidebar está colapsada */
.sidebar.collapsed ~ .sidebar-toggle-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Desktop: mostrar botão de toggle */
@media (min-width: 769px) {
  .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ===========================
   MAIN CONTENT
   =========================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* Premium layered background */
.main-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(109,93,252,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(109,93,252,0.04) 0%, transparent 55%),
    radial-gradient(ellipse 40% 60% at 50% 50%, rgba(0,0,0,0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Subtle noise texture */
.main-content::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  z-index: 1;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 48px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chat-container::-webkit-scrollbar-track {
  margin: 40px 0;
}

/* ===========================
   MESSAGES — Premium WhatsApp Style
   =========================== */

/* Date separator */
.message-date-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0 8px;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.4px;
  opacity: 0.6;
}
.message-date-sep::before,
.message-date-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  opacity: 0.5;
  max-width: 80px;
}

/* Message row */
.message {
  display: flex;
  padding: 3px 24px;
  animation: msgFadeIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes msgFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Space between groups (different senders get more gap) */
.message { margin-bottom: 2px; }
.message.user + .message.ai,
.message.ai + .message.user { margin-top: 10px; }

.message.user  { justify-content: flex-end; }
.message.ai    { justify-content: flex-start; }

/* ---- bubble wrapper ---- */
.message-content {
  display: flex;
  flex-direction: column;
  max-width: 68%;
  position: relative;
}

.message.user .message-content { align-items: flex-end; }
.message.ai  .message-content  { align-items: flex-start; }

/* ---- bubble ---- */
.bubble {
  position: relative;
  padding: 10px 14px 24px 14px;
  border-radius: 20px;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.01em;
  max-width: 100%;
  transition: box-shadow 0.2s ease;
}

/* ──── USER bubble ──────────────────────────────── */
.user .bubble {
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow:
    0 2px 8px rgba(109, 93, 252, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.user .bubble:hover {
  box-shadow:
    0 4px 16px rgba(109, 93, 252, 0.45),
    0 2px 4px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Tail — user */
.user .bubble::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 10px 10px;
  border-color: transparent transparent transparent var(--accent-hover);
  filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.15));
}

/* ──── ASSISTANT bubble ──────────────────────────── */
.ai .bubble {
  background: linear-gradient(
    145deg,
    rgba(255,255,255,0.06) 0%,
    rgba(255,255,255,0.03) 100%
  );
  background-color: var(--surface-light);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 5px;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
}

.ai .bubble:hover {
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Tail — assistant */
.ai .bubble::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 10px 10px 0;
  border-color: transparent var(--surface-light) transparent transparent;
  filter: drop-shadow(-1px 1px 1px rgba(0,0,0,0.1));
}

/* ---- timestamp inside bubble ---- */
.bubble-meta {
  position: absolute;
  bottom: 5px;
  right: 10px;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.3px;
  opacity: 0.5;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  color: inherit;
}

/* ---- typing indicator ---- */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  background: var(--surface-light);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 20px;
  border-bottom-left-radius: 5px;
  min-width: 68px;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30%           { transform: translateY(-7px); opacity: 1; }
}

/* Message Sources */
.message-sources {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.message-sources span:first-child {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-sources a {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  transition: opacity var(--transition);
}

.message-sources a:hover { opacity: 0.75; }

/* ===========================
   INPUT AREA - GLASSMORPHISM
   =========================== */
.input-container {
  padding: 20px 20px 32px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(10, 14, 24, 0.4) 50%,
    var(--bg) 100%
  );
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  backdrop-filter: blur(12px);
}

/* Quick Tags Section */
.quick-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  opacity: 0;
  animation: fadeInDown 0.5s ease-out 0.2s forwards;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.quick-tag-btn {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(109, 93, 252, 0.2);
  border-radius: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  white-space: nowrap;
}

.quick-tag-btn:hover {
  background: rgba(109, 93, 252, 0.15);
  border-color: rgba(109, 93, 252, 0.4);
  color: var(--text);
  transform: translateY(-2px);
}

.quick-tag-btn:active {
  transform: translateY(0);
}

.tag-icon {
  font-size: 14px;
}

.tag-text {
  display: none;
}

@media (min-width: 600px) {
  .tag-text {
    display: inline;
  }
}

/* Glass Input Box */
.glass-input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
  max-width: 760px;
  padding: 12px 14px;
  background: linear-gradient(
    135deg,
    rgba(22, 27, 40, 0.6),
    rgba(28, 33, 48, 0.4)
  );
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  backdrop-filter: blur(20px);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 40px rgba(109, 93, 252, 0.08);
  transition: all var(--transition-slow);
  position: relative;
  overflow: hidden;
  animation: slideUpFade 0.4s ease-out;
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.glass-input-box::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 0%,
    rgba(109, 93, 252, 0.1),
    transparent 70%
  );
  opacity: 0;
  transition: opacity var(--transition-slow);
  pointer-events: none;
  border-radius: inherit;
}

.glass-input-box:focus-within::before {
  opacity: 1;
}

.glass-input-box:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 60px rgba(109, 93, 252, 0.12);
  background: linear-gradient(
    135deg,
    rgba(22, 27, 40, 0.7),
    rgba(28, 33, 48, 0.5)
  );
}

.glass-input-box:focus-within {
  border-color: rgba(109, 93, 252, 0.4);
  box-shadow: 
    0 16px 48px rgba(109, 93, 252, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 0 80px rgba(109, 93, 252, 0.2);
  background: linear-gradient(
    135deg,
    rgba(22, 27, 40, 0.8),
    rgba(28, 33, 48, 0.6)
  );
}

/* Left Action Buttons */
.input-actions-left,
.input-actions-right {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.action-btn {
  width: 36px;
  height: 36px;
  background: rgba(109, 93, 252, 0.1);
  border: 1px solid rgba(109, 93, 252, 0.2);
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.action-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at center,
    rgba(109, 93, 252, 0.2),
    transparent 70%
  );
  opacity: 0;
  transition: opacity var(--transition);
}

.action-btn:hover {
  background: rgba(109, 93, 252, 0.2);
  border-color: rgba(109, 93, 252, 0.4);
  color: var(--text);
  transform: translateY(-2px);
}

.action-btn:hover::before {
  opacity: 1;
}

.action-btn:active {
  transform: scale(0.92);
}

/* Web Mode Toggle Button */
.web-mode-btn {
  position: relative;
}

.web-mode-icon {
  font-size: 18px;
  transition: transform var(--transition);
}

.web-mode-btn[data-active="true"] .web-mode-icon {
  transform: rotate(-12deg) scale(1.1);
}

.web-mode-indicator {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  bottom: 2px;
  right: 2px;
  opacity: 0;
  transform: scale(0);
  transition: all var(--transition);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.web-mode-btn[data-active="true"] {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--success);
}

.web-mode-btn[data-active="true"] .web-mode-indicator {
  opacity: 1;
  transform: scale(1);
}

/* Textarea Container */
.textarea-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  min-height: 36px;
}

.input-focus-ring {
  position: absolute;
  inset: -4px;
  border: 2px solid rgba(109, 93, 252, 0);
  border-radius: 12px;
  pointer-events: none;
  transition: all var(--transition);
  box-shadow: inset 0 0 0 0 transparent;
}

.chat-input-glass:focus ~ .input-focus-ring {
  border-color: rgba(109, 93, 252, 0.3);
  box-shadow: inset 0 0 12px rgba(109, 93, 252, 0.05);
}

/* Glass Textarea */
.chat-input-glass {
  flex: 1;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 120px;
  transition: all var(--transition);
  field-sizing: content;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  z-index: 1;
}

.chat-input-glass::placeholder {
  color: var(--text-tertiary);
}

.chat-input-glass::-webkit-scrollbar {
  width: 6px;
}

.chat-input-glass::-webkit-scrollbar-track {
  background: transparent;
}

.chat-input-glass::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.chat-input-glass::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Send Button - Glass Style */
.send-btn-glass {
  width: 40px;
  height: 40px;
  min-width: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: 
    0 4px 16px rgba(109, 93, 252, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.send-btn-glass::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.3),
    transparent 70%
  );
  opacity: 0;
  transition: opacity var(--transition);
}

.send-btn-glass:hover::before {
  opacity: 1;
}

.send-btn-glass::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.send-btn-glass:hover {
  transform: translateY(-4px);
  box-shadow: 
    0 8px 32px rgba(109, 93, 252, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.send-btn-glass:active {
  transform: translateY(-1px) scale(0.95);
  box-shadow: 
    0 4px 16px rgba(109, 93, 252, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.send-btn-glass:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.send-icon {
  transition: all var(--transition);
}

.send-btn-glass:hover .send-icon {
  transform: translateX(2px);
}

/* Send Loader */
.send-loader {
  position: absolute;
  display: flex;
  gap: 3px;
  opacity: 0;
  transform: scale(0.8);
  transition: all var(--transition);
}

.send-btn-glass.loading .send-icon {
  opacity: 0;
  transform: scale(0.5);
}

.send-btn-glass.loading .send-loader {
  opacity: 1;
  transform: scale(1);
}

.loader-dot {
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: dotBounce 1.2s ease-in-out infinite;
}

.loader-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loader-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotBounce {
  0%, 100% {
    opacity: 0.6;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-6px);
  }
}

/* Input Hint */
.input-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.input-hint:hover {
  opacity: 1;
}

.hint-icon {
  font-size: 11px;
  font-weight: 600;
}

/* ===========================
   KEYFRAME ANIMATIONS
   =========================== */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */
@media (max-width: 768px) {
  :root {
    --sidebar-width-mobile: 280px;
  }

  .app-wrapper {
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 102;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.3);
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .main-content {
    width: 100%;
  }

  .chat-container {
    padding: 16px 16px 100px;
    max-width: 100%;
  }

  .message-content {
    max-width: 85%;
  }

  .glass-input-box {
    max-width: 100%;
  }

  .input-container {
    padding: 12px 16px 24px;
  }

  .chat-input-glass {
    font-size: 16px;
  }

  .model-dropdown {
    max-height: 300px;
  }

  .quick-tags {
    gap: 6px;
  }

  .quick-tag-btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .input-actions-left,
  .input-actions-right {
    gap: 6px;
  }

  .action-btn {
    width: 32px;
    height: 32px;
  }

  .send-btn-glass {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 480px) {
  :root {
    --radius-lg: 12px;
    --radius-md: 10px;
  }

  .sidebar {
    width: 100%;
  }

  .chat-container {
    padding: 12px 12px 100px;
  }

  .message-content {
    max-width: 90%;
  }

  .bubble {
    padding: 10px 14px;
    font-size: 13px;
  }

  .glass-input-box {
    padding: 10px 10px;
    gap: 8px;
    border-radius: 16px;
  }

  .action-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .send-btn-glass {
    width: 36px;
    height: 36px;
  }

  .input-hint {
    font-size: 11px;
    display: none;
  }

  .sidebar-header {
    padding: 16px 12px;
  }

  .logo {
    font-size: 16px;
  }

  .quick-tags {
    display: none;
  }

  .input-actions-left {
    display: none;
  }
}


/* ===========================
   SETTINGS MODAL
   =========================== */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.settings-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: min(520px, 95vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.45);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.settings-overlay.open .settings-panel {
  transform: translateY(0) scale(1);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-close-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.settings-close-btn:hover {
  background: var(--surface-light);
  color: var(--text);
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-section {
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--accent);
  margin-bottom: 14px;
}

.settings-field {
  margin-bottom: 14px;
}

.settings-field:last-child {
  margin-bottom: 0;
}

.settings-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.settings-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.settings-textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
  box-sizing: border-box;
}

.settings-textarea:focus {
  border-color: var(--accent);
}

/* Slider */
.settings-slider {
  width: 100%;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  transition: background var(--transition);
}

.settings-slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(109,93,252,0.4);
  transition: transform var(--transition);
}

.settings-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.settings-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.settings-value-badge {
  font-size: 11px;
  font-weight: 700;
  background: rgba(109,93,252,0.15);
  color: var(--accent);
  border-radius: 6px;
  padding: 2px 7px;
  font-family: monospace;
}

/* Button group (font size) */
.settings-btn-group {
  display: flex;
  gap: 6px;
}

.settings-size-btn {
  flex: 1;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.settings-size-btn:hover {
  background: var(--surface-light);
  color: var(--text);
}

.settings-size-btn.active {
  background: rgba(109,93,252,0.15);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

/* Toggle row */
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-toggle {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}

.settings-toggle input {
  display: none;
}

.settings-toggle-track {
  display: block;
  width: 42px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: background 0.2s ease;
}

.settings-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: transform 0.2s ease;
}

.settings-toggle input:checked + .settings-toggle-track {
  background: var(--accent);
}

.settings-toggle input:checked + .settings-toggle-track::after {
  transform: translateX(18px);
}

/* Data section */
.settings-data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-badge {
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-light);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 4px 10px;
}

.settings-action-btn {
  padding: 7px 12px;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.settings-action-btn:hover {
  background: var(--card);
  border-color: var(--accent);
  color: var(--accent);
}

.settings-action-btn--new {
  border-color: rgba(16,185,129,0.3);
  color: var(--success);
}

.settings-action-btn--new:hover {
  background: rgba(16,185,129,0.1);
  border-color: var(--success);
  color: var(--success);
}

.settings-action-btn--danger {
  border-color: rgba(239,68,68,0.3);
  color: var(--danger);
}

.settings-action-btn--danger:hover {
  background: rgba(239,68,68,0.1);
  border-color: var(--danger);
}

.settings-danger-btn {
  width: 100%;
  padding: 10px 14px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.settings-danger-btn:hover {
  background: rgba(239,68,68,0.15);
  border-color: var(--danger);
}

.settings-version {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 10px;
  opacity: 0.6;
}

.settings-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-save-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(109,93,252,0.25);
}

.settings-save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(109,93,252,0.35);
}

.settings-save-btn:active {
  transform: translateY(0);
}

/* Font size overrides */
body[data-font="small"] .bubble  { font-size: 12px; }
body[data-font="medium"] .bubble { font-size: 14px; }
body[data-font="large"] .bubble  { font-size: 16px; }

body[data-show-footer="false"] .message-footer { display: none; }

/* ===========================
   MARKDOWN RENDER (AI bubble)
   =========================== */
.ai .bubble {
  white-space: normal;
}

.md-p {
  margin: 0 0 10px 0;
  line-height: 1.7;
}
.md-p:last-child { margin-bottom: 0; }

.md-h2 { font-size: 16px; font-weight: 700; margin: 14px 0 6px; color: var(--text); }
.md-h3 { font-size: 15px; font-weight: 700; margin: 12px 0 5px; color: var(--text); }
.md-h4 { font-size: 14px; font-weight: 600; margin: 10px 0 4px; color: var(--text); }

.md-list {
  margin: 6px 0 10px 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.md-list li { line-height: 1.6; }

.md-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* Inline code */
.inline-code {
  font-family: 'Courier New', Consolas, monospace;
  font-size: 12.5px;
  background: rgba(109,93,252,0.12);
  color: var(--accent);
  border: 1px solid rgba(109,93,252,0.2);
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* Code block */
.code-block {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 10px 0;
  overflow-x: auto;
  position: relative;
}

.code-block code {
  font-family: 'Courier New', Consolas, monospace;
  font-size: 12.5px;
  color: #e2e8f0;
  white-space: pre;
  display: block;
  line-height: 1.6;
}

/* Copy button on code blocks */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.code-block:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover {
  background: rgba(109,93,252,0.2);
  border-color: rgba(109,93,252,0.4);
  color: var(--accent);
}

/* Light theme adjustments */
body.light-mode .code-block {
  background: #f1f3f9;
  border-color: var(--border);
}
body.light-mode .code-block code { color: #1e293b; }
body.light-mode .inline-code {
  background: rgba(109,93,252,0.08);
  border-color: rgba(109,93,252,0.15);
}

/* ===========================
   CONVERSATION SEARCH
   =========================== */
.conversation-search {
  padding: 0 16px 8px;
}

.conversation-search-input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
  position: relative;
}

.conversation-search-input::placeholder { color: var(--text-tertiary); }
.conversation-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109,93,252,0.1);
}

.conversation-search-wrapper {
  position: relative;
}

.conversation-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-tertiary);
  pointer-events: none;
  line-height: 1;
}

.conversation-item.hidden { display: none; }

/* ===========================
   CHAR COUNTER
   =========================== */
.char-counter {
  font-size: 11px;
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity var(--transition);
  user-select: none;
  white-space: nowrap;
  align-self: flex-end;
  padding-bottom: 2px;
  flex-shrink: 0;
}

.char-counter.visible { opacity: 0.7; }
.char-counter.warn    { color: #f59e0b; opacity: 1; }
.char-counter.danger  { color: var(--danger); opacity: 1; }

/* ===========================
   UTILITY CLASSES
   =========================== */
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ===========================
   PREMIUM REFINEMENTS
   =========================== */

/* Scrollbar mais fino e elegante */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { border-radius: 2px; }
.chat-input-glass::-webkit-scrollbar { width: 3px; }

/* Logo: ícone com brilho accent + texto com gradiente sutil */
.logo-icon {
  color: var(--accent);
  text-shadow: 0 0 16px rgba(109,93,252,0.55), 0 0 32px rgba(109,93,252,0.2);
  filter: drop-shadow(0 0 6px rgba(109,93,252,0.4));
}
.logo-text {
  background: linear-gradient(95deg, var(--text-primary) 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1.5px;
}

/* Sidebar: gradiente sutil top→bottom */
.sidebar {
  background: linear-gradient(
    180deg,
    var(--bg-secondary) 0%,
    color-mix(in srgb, var(--bg-secondary) 97%, var(--accent) 3%) 100%
  );
}

/* Sidebar header: linha accent no topo */
.sidebar-header {
  background: linear-gradient(
    180deg,
    rgba(109,93,252,0.04) 0%,
    transparent 100%
  );
  padding: 22px 18px;
}

/* Conversation active: border-left accent + glow sutil */
.conversation-item.active {
  background: linear-gradient(
    90deg,
    rgba(109,93,252,0.12) 0%,
    rgba(109,93,252,0.05) 100%
  );
  border-color: rgba(109,93,252,0.25);
  border-left: 2px solid var(--accent);
  color: var(--text);
  font-weight: 500;
  padding-left: 10px;
}

/* Conversation item hover: left-border sutil */
.conversation-item:hover:not(.active) {
  border-left: 2px solid rgba(109,93,252,0.2);
  padding-left: 10px;
}

/* Model trigger: borda mais definida e fundo mais profundo */
.model-trigger {
  background: linear-gradient(
    135deg,
    rgba(109,93,252,0.08) 0%,
    rgba(16,19,30,0.6) 100%
  );
  border-color: rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 11px 12px;
}
.model-trigger:hover {
  background: linear-gradient(
    135deg,
    rgba(109,93,252,0.12) 0%,
    rgba(16,19,30,0.7) 100%
  );
  border-color: rgba(109,93,252,0.25);
}
.model-trigger-name { font-weight: 600; font-size: 13px; }

/* Model dropdown mais refinado */
.model-dropdown {
  border-radius: 16px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.5),
    0 8px 20px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.1);
}
.model-item {
  border-radius: 10px;
  padding: 9px 12px;
}
.model-item:hover {
  transform: translateX(2px);
}
.model-item.active {
  background: linear-gradient(90deg, rgba(109,93,252,0.18) 0%, rgba(109,93,252,0.08) 100%);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

/* Bubbles: raio ainda mais suave no desktop */
@media (min-width: 769px) {
  .bubble {
    border-radius: 22px;
    padding: 12px 16px 26px 16px;
    font-size: 14.5px;
    line-height: 1.65;
  }
  .user .bubble { border-bottom-right-radius: 6px; }
  .ai  .bubble  { border-bottom-left-radius: 6px; }
}

/* User bubble: shimmer sutil no hover */
.user .bubble::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    120deg,
    transparent 0%,
    rgba(255,255,255,0.06) 50%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.user .bubble:hover::before { opacity: 1; }

/* AI bubble: borda top-left accent muito sutil */
.ai .bubble {
  border-top: 1px solid rgba(109,93,252,0.12);
}

/* Typing bubble premium */
.typing-bubble {
  background: linear-gradient(135deg, var(--surface-light), rgba(109,93,252,0.05));
  border: 1px solid rgba(109,93,252,0.1);
  border-bottom-left-radius: 6px;
  border-radius: 22px;
}

/* Input container: sem border top, apenas fade */
.input-container {
  border-top: none;
  padding-top: 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--bg-primary) 55%
  );
}

/* Glass input box: mais alto e espaçoso */
.glass-input-box {
  padding: 14px 16px;
  border-radius: 24px;
  max-width: 800px;
  box-shadow:
    0 12px 40px rgba(0,0,0,0.3),
    0 2px 8px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 0 1px rgba(255,255,255,0.04);
}
.glass-input-box:focus-within {
  border-radius: 24px;
  box-shadow:
    0 20px 60px rgba(109,93,252,0.18),
    0 4px 12px rgba(109,93,252,0.12),
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 0 0 1px rgba(109,93,252,0.15);
}

/* Chat input: ligeiramente maior */
.chat-input-glass { font-size: 14.5px; }

/* Send button: mais premium */
.send-btn-glass {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 14px;
  box-shadow:
    0 6px 20px rgba(109,93,252,0.35),
    inset 0 1px 0 rgba(255,255,255,0.25),
    inset 0 -1px 0 rgba(0,0,0,0.15);
}
.send-btn-glass:hover {
  box-shadow:
    0 10px 32px rgba(109,93,252,0.5),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -1px 0 rgba(0,0,0,0.15);
}

/* Action buttons input */
.action-btn {
  border-radius: 12px;
  width: 38px;
  height: 38px;
}

/* Quick tags premium */
.quick-tag-btn {
  border-radius: 24px;
  padding: 7px 14px;
  font-size: 12.5px;
  letter-spacing: 0.1px;
  backdrop-filter: blur(8px);
}
.quick-tag-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 12px rgba(109,93,252,0.2);
}

/* Toasts: glassmorphism premium */
.toast {
  background: color-mix(in srgb, var(--bg-secondary) 90%, transparent);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.1px;
  backdrop-filter: blur(20px);
  box-shadow:
    0 16px 40px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.1);
}

/* Settings modal mais premium */
.settings-panel {
  border-radius: 24px;
  box-shadow:
    0 32px 80px rgba(0,0,0,0.5),
    0 8px 24px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.08);
}
.settings-save-btn {
  border-radius: 14px;
  padding: 13px;
  font-size: 14.5px;
  letter-spacing: 0.2px;
  box-shadow:
    0 6px 20px rgba(109,93,252,0.3),
    inset 0 1px 0 rgba(255,255,255,0.2);
}
.settings-save-btn:hover {
  box-shadow:
    0 10px 32px rgba(109,93,252,0.45),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

/* Code block premium */
.code-block {
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 16px 18px;
}
.code-block::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(109,93,252,0.3), transparent);
  border-radius: 14px 14px 0 0;
}

/* Sidebar footer buttons premium */
.sidebar-footer-btn,
#theme-toggle-btn {
  border-radius: 12px;
  font-size: 12.5px;
  letter-spacing: 0.1px;
}
.sidebar-footer-btn:hover {
  border-color: rgba(109,93,252,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Conversation search input premium */
.conversation-search-input {
  border-radius: 10px;
  font-size: 12.5px;
}

/* Msg action buttons: mais arredondados */
.msg-action { border-radius: 9px; }

/* Hint de teclado premium */
.input-hint {
  font-size: 11.5px;
  letter-spacing: 0.1px;
}

/* ===========================
   NEXT-LEVEL PREMIUM
   =========================== */

/* Background animado: orbs flutuantes */
.main-content::before {
  background:
    radial-gradient(ellipse 70% 45% at 15% 8%,  rgba(109,93,252,0.09) 0%, transparent 65%),
    radial-gradient(ellipse 55% 35% at 85% 85%, rgba(109,93,252,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 45% 55% at 60% 30%, rgba(100,200,255,0.03) 0%, transparent 55%);
  animation: orbs 18s ease-in-out infinite alternate;
}
@keyframes orbs {
  0%   { transform: scale(1)    rotate(0deg); }
  50%  { transform: scale(1.03) rotate(1deg); }
  100% { transform: scale(1)    rotate(0deg); }
}

/* Chat: padding lateral generoso, sem max-width na row */
/* Mensagens ancoradas na base — spacer empurra conteúdo p/ baixo */
.chat-container {
  padding: 32px 32px 24px;
  align-items: stretch;
}

/* Spacer invisível no topo — ocupa o espaço vazio e empurra msgs para baixo */
/* Quando há overflow (muitas msgs), flex-shrink deixa encolher para 0 */
.chat-container::before {
  content: '';
  flex: 1 1 auto;
  min-height: 0;
}

.message {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  padding: 4px 8px;
}

/* Mais espaço entre grupos */
.message.user + .message.ai,
.message.ai  + .message.user { margin-top: 16px; }

/* AI message: flex row com wrap — avatar + bubble na mesma linha, ações abaixo */
.message.ai .message-content {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0;
  max-width: 60%; /* compacto no canto esquerdo */
  position: relative;
}

/* Avatar da IA — esquerda, não participa do wrap */
.message.ai .message-content::before {
  content: '◆';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border-radius: 10px;
  font-size: 13px;
  color: white;
  box-shadow:
    0 4px 12px rgba(109,93,252,0.35),
    inset 0 1px 0 rgba(255,255,255,0.2);
  margin-top: 4px;
  margin-right: 10px;
  flex-shrink: 0;
  align-self: flex-start;
}

/* Bubble — ocupa apenas o espaço necessário, sem overflow */
.message.ai .bubble {
  flex: 0 1 auto;
  min-width: 0;
  max-width: calc(100% - 52px); /* 100% - (avatar 32px + gap 10px + margem 10px) */
  border-radius: 18px;
  border-bottom-left-radius: 6px;
}
.ai .bubble::after { display: none; }

/* Actions — nova linha, indentado para alinhar com o bubble */
.message.ai .message-actions {
  flex-basis: 100%;
  padding-left: 42px;
  margin-top: 6px;
  justify-content: flex-end; /* ações no canto direito */
}

/* Meta/footer — nova linha, indentado + canto direito */
.message.ai .message-meta {
  flex-basis: 100%;
  padding-left: 42px;
  text-align: right;
}

/* User: full width sem avatar */
.message.user .message-content {
  max-width: 72%;
}

/* Bubbles sem tail no user também — mais moderno */
.user .bubble::after { display: none; }

/* Bubble user: margem left auto */
.user .message-content { margin-left: auto; }

/* Separador entre grupos de mensagens — linha sutil */
.message.user + .message.ai::before {
  content: '';
  display: block;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
  margin-bottom: 8px;
  width: 100%;
}

/* Sidebar: border mais sutil com gradient */
.sidebar {
  border-right: 1px solid transparent;
  background:
    linear-gradient(var(--bg-secondary), var(--bg-secondary)) padding-box,
    linear-gradient(180deg, rgba(109,93,252,0.15) 0%, var(--border-color) 40%, transparent 100%) border-box;
}

/* Logo: padding ajustado + ícone maior */
.logo-icon {
  font-size: 20px;
  animation: none;
  transition: filter 0.3s ease;
}
.logo:hover .logo-icon {
  filter: drop-shadow(0 0 10px rgba(109,93,252,0.8));
}

/* Model label: com linha decorativa */
.model-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.model-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

/* Conversations: botão nova conversa no topo */
.conversations-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 16px;
}

/* Conversa item: mais rounded */
.conversation-item {
  border-radius: 14px;
  font-size: 13px;
  letter-spacing: 0.05px;
}
.conversation-item.active {
  border-radius: 14px;
}

/* Status dot: maior e mais visível */
.status-dot.online {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 2px rgba(16,185,129,0.2), 0 0 10px rgba(16,185,129,0.5);
}

/* Typing bubble: mais refinado */
.typing-bubble { padding: 16px 20px; border-radius: 22px; }

/* Input area: sem border top mesmo na light */
body.light-mode .input-container {
  background: linear-gradient(180deg, transparent 0%, var(--bg-primary) 55%);
}

/* Glass box: shimmer no topo */
.glass-input-box::after {
  content: '';
  position: absolute;
  top: 0; left: 16px; right: 16px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  pointer-events: none;
}

/* Placeholder mais suave */
.chat-input-glass::placeholder {
  font-size: 14px;
  letter-spacing: 0.1px;
}

/* Quick tags: gap menor no desktop */
.quick-tags { gap: 6px; }

/* Group badge: border-radius maior */
.group-badge { border-radius: 6px; letter-spacing: 0.3px; }

/* Message actions: gap ligeiramente maior */
.message-actions { gap: 3px; margin-top: 8px; }

/* Message footer: mais elegante */
.message-footer {
  font-size: 11px;
  opacity: 0.5;
  letter-spacing: 0.4px;
}

/* Tooltip: mais premium */
.tooltip {
  border-radius: 8px;
  font-size: 11.5px;
  padding: 5px 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

/* Code block: header label */
.code-block { padding-top: 42px; }
.code-block::after {
  content: 'CODE';
  position: absolute;
  top: 10px; left: 18px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.2);
  font-family: 'Courier New', monospace;
}

/* Botão copiar: sempre visível, mas mais sutil */
.code-copy-btn {
  opacity: 0.5;
  font-size: 10.5px;
  padding: 4px 9px;
  border-radius: 7px;
}
.code-block:hover .code-copy-btn { opacity: 1; }

/* Settings sections: mais espaçado */
.settings-section { border-radius: 16px; }
.settings-header {
  background: linear-gradient(180deg, rgba(109,93,252,0.04) 0%, transparent 100%);
}

/* Mobile: chat sem padding lateral excessivo */
@media (max-width: 768px) {
  .message { padding: 3px 4px; max-width: 100%; }
  .message.ai .message-content {
    display: flex;
    flex-direction: column;
  }
  .message.ai .message-content::before { display: none; }
  .message.ai .message-actions,
  .message.ai .message-meta { grid-column: unset; grid-row: unset; }
  .user .message-content { max-width: 88%; }
  .ai .bubble { max-width: 100%; }
}

/* ===========================
   SIDEBAR COLLAPSE (DESKTOP)
   =========================== */
.sidebar {
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.28s ease;
}

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

/* Botão fechar: sempre flex em desktop */
@media (min-width: 769px) {
  .sidebar-close-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    opacity: 0.6;
    transition: opacity var(--transition), background var(--transition);
  }
  .sidebar-close-btn:hover { opacity: 1; background: var(--surface-light); }
}

/* ===========================
   NOVA CONVERSA BUTTON
   =========================== */
.conversations-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px 16px;
}

.conversations-title-row .conversations-title {
  padding: 0;
  margin: 0;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(109,93,252,0.12);
  border: 1px solid rgba(109,93,252,0.25);
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.new-chat-btn:hover {
  background: rgba(109,93,252,0.22);
  border-color: rgba(109,93,252,0.5);
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(109,93,252,0.25);
}

.new-chat-btn:active { transform: scale(0.94); }

/* ===========================
   STOP BUTTON
   =========================== */
.stop-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow:
    0 6px 20px rgba(239,68,68,0.35),
    inset 0 1px 0 rgba(255,255,255,0.25);
  animation: stopPulse 1.5s ease-in-out infinite;
}

@keyframes stopPulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(239,68,68,0.35), inset 0 1px 0 rgba(255,255,255,0.25); }
  50%       { box-shadow: 0 8px 28px rgba(239,68,68,0.55), inset 0 1px 0 rgba(255,255,255,0.25); }
}

.stop-btn:hover {
  background: linear-gradient(135deg, #f87171, #ef4444);
  transform: translateY(-2px);
}

.stop-btn:active { transform: scale(0.95); }

/* Favorito destacado */
.msg-action.favorited {
  background: rgba(234,179,8,0.15);
  border-color: rgba(234,179,8,0.35);
  color: #eab308;
}

/* ===========================
   CUSTOM THEME COLOR PICKER
   =========================== */
.settings-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.settings-color-input {
  width: 44px;
  height: 36px;
  padding: 2px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface-light);
  cursor: pointer;
  transition: border-color var(--transition);
  flex-shrink: 0;
}

.settings-color-input:hover { border-color: var(--accent); }

.settings-color-preview {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  flex: 1;
  min-width: 80px;
  transition: color 0.2s ease;
}

/* ===========================
   ULTRA PREMIUM OVERHAUL
   =========================== */

/* ── Root: fontes e variáveis adicionais ── */
:root {
  --font-size-base: 14.5px;
  --shadow-glow-accent: 0 0 40px rgba(109,93,252,0.18);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1);
  --shadow-card-hover: 0 16px 48px rgba(0,0,0,0.28), 0 4px 12px rgba(0,0,0,0.14);
  --blur-glass: blur(24px) saturate(1.4);
}

/* ── Body base ── */
body {
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
}

/* ── APP SHELL: grid mais moderno ── */
.app-wrapper {
  background: var(--bg-primary);
}

/* ── SIDEBAR redesenhada ── */
.sidebar {
  width: 270px;
  background:
    linear-gradient(var(--bg-secondary), var(--bg-secondary)) padding-box,
    linear-gradient(180deg,
      rgba(109,93,252,0.18) 0%,
      rgba(109,93,252,0.04) 35%,
      transparent 100%
    ) border-box;
  border-right: 1px solid transparent;
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  backdrop-filter: var(--blur-glass);
}

/* ── LOGO ultra premium ── */
.logo {
  gap: 12px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.logo-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: 10px;
  font-size: 16px;
  color: white;
  box-shadow:
    0 4px 14px rgba(109,93,252,0.45),
    inset 0 1px 0 rgba(255,255,255,0.25);
  animation: none !important;
  filter: none !important;
  text-shadow: none !important;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  flex-shrink: 0;
}

.logo:hover .logo-icon {
  box-shadow:
    0 6px 22px rgba(109,93,252,0.65),
    inset 0 1px 0 rgba(255,255,255,0.3);
  transform: rotate(15deg) scale(1.08);
}

.logo-text {
  background: linear-gradient(
    110deg,
    var(--text-primary) 0%,
    rgba(109,93,252,0.9) 60%,
    var(--accent-hover) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
  font-weight: 800;
}

/* ── SIDEBAR HEADER ── */
.sidebar-header {
  padding: 20px 18px;
  background: linear-gradient(
    180deg,
    rgba(109,93,252,0.06) 0%,
    transparent 100%
  );
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* ── MODEL SELECTOR premium ── */
.model-selector {
  padding: 14px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  gap: 10px;
}

.model-label {
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--text-tertiary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06), transparent);
}

.model-trigger {
  background: linear-gradient(
    135deg,
    rgba(109,93,252,0.1) 0%,
    rgba(8,12,20,0.7) 100%
  );
  border: 1px solid rgba(109,93,252,0.15);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow:
    0 2px 12px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.06);
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

.model-trigger:hover {
  background: linear-gradient(
    135deg,
    rgba(109,93,252,0.15) 0%,
    rgba(8,12,20,0.8) 100%
  );
  border-color: rgba(109,93,252,0.3);
  box-shadow:
    0 4px 16px rgba(0,0,0,0.25),
    0 0 0 1px rgba(109,93,252,0.1),
    inset 0 1px 0 rgba(255,255,255,0.08);
  transform: translateY(-1px);
}

.model-trigger.open {
  border-color: rgba(109,93,252,0.45);
  box-shadow:
    0 4px 20px rgba(109,93,252,0.2),
    inset 0 1px 0 rgba(255,255,255,0.1);
}

.model-trigger-name {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.1px;
}

.model-trigger-provider {
  font-size: 10.5px;
  letter-spacing: 0.3px;
  font-weight: 500;
}

/* ── MODEL DROPDOWN ultra glass ── */
.model-dropdown {
  background: linear-gradient(
    145deg,
    rgba(12,15,26,0.96) 0%,
    rgba(16,20,36,0.94) 100%
  );
  border: 1px solid rgba(109,93,252,0.15);
  border-radius: 18px;
  backdrop-filter: blur(32px) saturate(1.5);
  box-shadow:
    0 24px 64px rgba(0,0,0,0.6),
    0 8px 24px rgba(0,0,0,0.3),
    0 0 0 1px rgba(255,255,255,0.04),
    inset 0 1px 0 rgba(255,255,255,0.1);
}

.model-group-header {
  padding: 10px 14px 6px;
  font-size: 10px;
  letter-spacing: 1px;
}

.model-item {
  border-radius: 12px;
  padding: 10px 14px;
  gap: 10px;
}

.model-item:hover {
  background: rgba(109,93,252,0.12);
  border-color: rgba(109,93,252,0.2);
  color: var(--text-primary);
  transform: translateX(3px);
}

.model-item.active {
  background: linear-gradient(
    90deg,
    rgba(109,93,252,0.2) 0%,
    rgba(109,93,252,0.08) 100%
  );
  border-left: 2px solid var(--accent);
  padding-left: 12px;
  color: var(--accent);
  box-shadow: inset 0 0 20px rgba(109,93,252,0.05);
}

/* ── CONVERSATIONS LIST premium ── */
.conversations-section {
  padding: 10px 0;
}

.conversations-title-row {
  padding: 10px 16px 6px;
}

.conversations-title {
  font-size: 10px;
  letter-spacing: 1.2px;
  font-weight: 700;
  color: var(--text-tertiary);
}

.new-chat-btn {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(109,93,252,0.1);
  border: 1px solid rgba(109,93,252,0.2);
  box-shadow: 0 2px 8px rgba(109,93,252,0.1);
}

.new-chat-btn:hover {
  background: rgba(109,93,252,0.2);
  border-color: rgba(109,93,252,0.45);
  box-shadow: 0 4px 16px rgba(109,93,252,0.3);
  transform: scale(1.1) rotate(5deg);
}

.conversations-list {
  padding: 0 6px;
  gap: 2px;
}

.conversation-item {
  margin: 0 2px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  letter-spacing: 0.1px;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.conversation-item:hover:not(.active) {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.06);
  border-left: 2px solid rgba(109,93,252,0.25);
  padding-left: 10px;
  color: var(--text-primary);
  transform: translateX(2px);
}

.conversation-item.active {
  background: linear-gradient(
    90deg,
    rgba(109,93,252,0.16) 0%,
    rgba(109,93,252,0.06) 100%
  );
  border-color: rgba(109,93,252,0.28);
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  color: var(--text-primary);
  font-weight: 600;
  box-shadow:
    0 2px 12px rgba(109,93,252,0.12),
    inset 0 0 0 1px rgba(109,93,252,0.08);
}

/* ── SIDEBAR FOOTER premium ── */
.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.04);
  gap: 6px;
}

.sidebar-footer-btn {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12.5px;
  letter-spacing: 0.1px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  transition: all 0.2s ease;
}

.sidebar-footer-btn:hover {
  background: rgba(109,93,252,0.1);
  border-color: rgba(109,93,252,0.2);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

#theme-toggle-btn {
  border-radius: 12px;
  font-size: 12.5px;
  letter-spacing: 0.1px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

#theme-toggle-btn:hover {
  background: rgba(109,93,252,0.1);
  border-color: rgba(109,93,252,0.3);
  color: var(--accent);
}

/* ── MAIN CONTENT: fundo ultra premium ── */
.main-content {
  background: var(--bg-primary);
}

.main-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 60% at 10% 0%,   rgba(109,93,252,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 95%,  rgba(109,93,252,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 70% at 55% 40%,  rgba(60,180,255,0.04) 0%, transparent 55%),
    radial-gradient(ellipse 40% 40% at 80% 10%,  rgba(109,93,252,0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
  animation: orbs 22s ease-in-out infinite alternate;
}

@keyframes orbs {
  0%   { transform: scale(1) rotate(0deg) translateY(0px); }
  33%  { transform: scale(1.02) rotate(0.5deg) translateY(-4px); }
  66%  { transform: scale(0.99) rotate(-0.5deg) translateY(4px); }
  100% { transform: scale(1.01) rotate(0deg) translateY(-2px); }
}

/* ── CHAT CONTAINER ── */
.chat-container {
  padding: 40px 48px 20px;
  scroll-behavior: smooth;
}

@media (max-width: 1024px) {
  .chat-container { padding: 32px 28px 20px; }
}

/* ── MENSAGENS ultra premium ── */
.message {
  padding: 3px 0;
  animation: msgFadeIn 0.32s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* User: alinhado à direita, max-width generoso */
.message.user .message-content {
  max-width: 65%;
}

/* AI: com avatar, max-width */
.message.ai .message-content {
  max-width: 68%;
}

/* ── BUBBLE USER: ultra premium ── */
.user .bubble {
  background: linear-gradient(
    150deg,
    color-mix(in srgb, var(--accent) 90%, white 10%) 0%,
    var(--accent-hover) 100%
  );
  border-bottom-right-radius: 6px;
  font-size: 14.5px;
  line-height: 1.65;
  padding: 13px 17px 28px 17px;
  box-shadow:
    0 4px 20px rgba(109,93,252,0.4),
    0 1px 4px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -1px 0 rgba(0,0,0,0.08);
  border: none;
  letter-spacing: 0.01em;
}

.user .bubble::after { display: none; }
.user .bubble::before { display: none; }

/* ── BUBBLE AI: ultra premium glassmorphism ── */
.ai .bubble {
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-top: 1px solid var(--accent);
  backdrop-filter: blur(16px);
  font-size: 14.5px;
  line-height: 1.7;
  padding: 13px 17px 28px 17px;
  border-radius: 20px;
  border-bottom-left-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.22);
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.ai .bubble::after  { display: none; }

/* ── AVATAR IA ── */
.message.ai .message-content::before {
  content: '◆';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: 11px;
  font-size: 13px;
  color: white;
  box-shadow:
    0 4px 16px rgba(109,93,252,0.45),
    inset 0 1px 0 rgba(255,255,255,0.25),
    inset 0 -1px 0 rgba(0,0,0,0.1);
  margin-top: 3px;
  margin-right: 10px;
  flex-shrink: 0;
  align-self: flex-start;
  letter-spacing: 0;
}

/* ── TYPING INDICATOR premium ── */
.typing-bubble {
  background: linear-gradient(
    145deg,
    rgba(255,255,255,0.065) 0%,
    rgba(109,93,252,0.06) 100%
  );
  border: 1px solid rgba(109,93,252,0.12);
  border-radius: 20px;
  border-bottom-left-radius: 6px;
  padding: 16px 22px;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.22),
    inset 0 1px 0 rgba(255,255,255,0.07);
  backdrop-filter: blur(16px);
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(109,93,252,0.5);
}

/* ── INPUT AREA ultra premium — fixo no bottom ── */
.input-container {
  position: fixed !important;
  bottom: 24px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: 760px !important;
  max-width: calc(100vw - 48px) !important;
  z-index: 100 !important;
  padding: 0 !important;
  background: transparent !important;
  border-top: none !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 10px !important;
  backdrop-filter: none !important;
}

/* ── QUICK TAGS ultra ── */
.quick-tags {
  gap: 6px;
  margin-bottom: 2px;
}

.quick-tag-btn {
  padding: 7px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(109,93,252,0.18);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.1px;
  gap: 7px;
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

.quick-tag-btn:hover {
  background: rgba(109,93,252,0.14);
  border-color: rgba(109,93,252,0.38);
  color: var(--text-primary);
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 6px 20px rgba(109,93,252,0.2),
    0 2px 6px rgba(0,0,0,0.1);
}

/* ── GLASS INPUT BOX ultra ── */
.glass-input-box {
  max-width: 820px;
  padding: 12px 14px;
  border-radius: 26px;
  background: linear-gradient(
    135deg,
    rgba(255,255,255,0.055) 0%,
    rgba(255,255,255,0.02) 100%
  );
  border: 1px solid rgba(255,255,255,0.09);
  backdrop-filter: blur(28px) saturate(1.4);
  box-shadow:
    0 12px 40px rgba(0,0,0,0.28),
    0 4px 12px rgba(0,0,0,0.16),
    0 0 0 1px rgba(255,255,255,0.03),
    inset 0 1px 0 rgba(255,255,255,0.1),
    var(--shadow-glow-accent);
  transition: all 0.28s cubic-bezier(0.4,0,0.2,1);
  gap: 10px;
}

.glass-input-box::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    ellipse 80% 40% at 50% 0%,
    rgba(109,93,252,0.1),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

.glass-input-box:focus-within::before { opacity: 1; }

.glass-input-box::after {
  content: '';
  position: absolute;
  top: 0; left: 20px; right: 20px; height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255,255,255,0.18),
    transparent
  );
  pointer-events: none;
  border-radius: 999px;
}

.glass-input-box:hover {
  border-color: rgba(255,255,255,0.13);
  box-shadow:
    0 16px 48px rgba(0,0,0,0.32),
    0 4px 16px rgba(0,0,0,0.18),
    0 0 0 1px rgba(255,255,255,0.04),
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 0 60px rgba(109,93,252,0.1);
  transform: translateY(-1px);
}

.glass-input-box:focus-within {
  border-color: rgba(109,93,252,0.38);
  box-shadow:
    0 20px 60px rgba(109,93,252,0.2),
    0 8px 24px rgba(109,93,252,0.12),
    0 0 0 1px rgba(109,93,252,0.12),
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 0 80px rgba(109,93,252,0.15);
  transform: translateY(-1px);
}

/* ── TEXTAREA premium ── */
.chat-input-glass {
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}

.chat-input-glass::placeholder {
  font-size: 14.5px;
  color: var(--text-tertiary);
  letter-spacing: 0.05px;
  font-weight: 400;
}

/* ── ACTION BUTTONS premium ── */
.action-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.action-btn:hover {
  background: rgba(109,93,252,0.16);
  border-color: rgba(109,93,252,0.32);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow:
    0 6px 18px rgba(109,93,252,0.2),
    0 2px 6px rgba(0,0,0,0.1);
}

/* ── SEND BUTTON ultra premium ── */
.send-btn-glass {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 16px;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--accent) 80%, white 20%) 0%,
    var(--accent) 50%,
    var(--accent-hover) 100%
  );
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow:
    0 6px 24px rgba(109,93,252,0.45),
    0 2px 8px rgba(109,93,252,0.2),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -1px 0 rgba(0,0,0,0.12);
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

.send-btn-glass:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 10px 36px rgba(109,93,252,0.6),
    0 4px 12px rgba(109,93,252,0.3),
    inset 0 1px 0 rgba(255,255,255,0.35),
    inset 0 -1px 0 rgba(0,0,0,0.12);
}

.send-btn-glass:active {
  transform: translateY(0) scale(0.96);
  box-shadow:
    0 4px 16px rgba(109,93,252,0.3),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

.send-btn-glass:hover .send-icon {
  transform: translateX(2px) translateY(-1px);
}

/* ── STOP BUTTON ── */
.stop-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 16px;
}

/* ── INPUT HINT premium ── */
.input-hint {
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--text-tertiary);
  opacity: 0.55;
}

/* ── BUBBLE META (timestamp) ── */
.bubble-meta {
  font-size: 9.5px;
  letter-spacing: 0.2px;
  font-weight: 500;
  opacity: 0.45;
  bottom: 6px;
  right: 12px;
}

/* ── MESSAGE ACTIONS premium ── */
.message-actions {
  margin-top: 6px;
  gap: 3px;
  opacity: 0;
  transform: translateY(4px);
}

.message:hover .message-actions,
.message-actions:focus-within {
  opacity: 1;
  transform: translateY(0);
}

.msg-action {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 13px;
  transition: all 0.15s cubic-bezier(0.4,0,0.2,1);
}

.msg-action:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-2px) scale(1.1);
  color: var(--text-primary);
}

/* ── TOAST ultra glass ── */
.toast {
  background: linear-gradient(
    135deg,
    rgba(20,26,46,0.92) 0%,
    rgba(16,20,36,0.88) 100%
  );
  border: 1px solid rgba(255,255,255,0.1);
  border-top: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  padding: 13px 20px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.1px;
  backdrop-filter: blur(32px) saturate(1.5);
  box-shadow:
    0 20px 48px rgba(0,0,0,0.45),
    0 4px 12px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.12);
  color: var(--text-primary);
  min-width: 200px;
  max-width: 340px;
}

/* ── SETTINGS MODAL ultra premium ── */
.settings-overlay {
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(10px) saturate(1.2);
}

.settings-panel {
  background: linear-gradient(
    145deg,
    var(--bg-secondary) 0%,
    color-mix(in srgb, var(--bg-secondary) 95%, var(--accent) 5%) 100%
  );
  border: 1px solid rgba(255,255,255,0.08);
  border-top: 1px solid rgba(109,93,252,0.2);
  border-radius: 26px;
  box-shadow:
    0 40px 100px rgba(0,0,0,0.6),
    0 12px 36px rgba(0,0,0,0.3),
    0 0 0 1px rgba(255,255,255,0.04),
    inset 0 1px 0 rgba(255,255,255,0.1);
}

.settings-header {
  background: linear-gradient(
    180deg,
    rgba(109,93,252,0.07) 0%,
    transparent 100%
  );
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 22px 26px 18px;
}

.settings-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.settings-section {
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.02);
  padding: 18px;
  margin-bottom: 10px;
}

.settings-section-title {
  font-size: 10.5px;
  letter-spacing: 1px;
  font-weight: 800;
  margin-bottom: 16px;
}

.settings-save-btn {
  border-radius: 16px;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 85%, white 15%) 0%,
    var(--accent-hover) 100%
  );
  box-shadow:
    0 8px 28px rgba(109,93,252,0.4),
    inset 0 1px 0 rgba(255,255,255,0.25),
    inset 0 -1px 0 rgba(0,0,0,0.1);
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

.settings-save-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 12px 36px rgba(109,93,252,0.55),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -1px 0 rgba(0,0,0,0.1);
}

/* ── CODE BLOCK ultra ── */
.code-block {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.06);
  border-top: 1px solid rgba(109,93,252,0.15);
  border-radius: 16px;
  padding: 44px 18px 18px 18px;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.04);
}

.code-block::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(
    90deg,
    transparent 5%,
    rgba(109,93,252,0.4) 30%,
    rgba(109,93,252,0.6) 50%,
    rgba(109,93,252,0.4) 70%,
    transparent 95%
  );
}

.code-block::after {
  content: '{ CODE }';
  position: absolute;
  top: 12px; left: 18px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(109,93,252,0.4);
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
}

.code-copy-btn {
  top: 9px;
  right: 12px;
  opacity: 0.55;
  font-size: 10.5px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(109,93,252,0.1);
  border: 1px solid rgba(109,93,252,0.2);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: all 0.18s ease;
}

.code-block:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover {
  background: rgba(109,93,252,0.22);
  border-color: rgba(109,93,252,0.45);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(109,93,252,0.2);
}

/* ── INLINE CODE premium ── */
.inline-code {
  font-size: 13px;
  background: rgba(109,93,252,0.1);
  border: 1px solid rgba(109,93,252,0.18);
  border-radius: 6px;
  padding: 2px 7px;
  color: color-mix(in srgb, var(--accent) 80%, white 20%);
  font-weight: 500;
}

/* ── STATUS DOT premium ── */
.status-dot.online {
  width: 7px;
  height: 7px;
  box-shadow:
    0 0 0 2px rgba(16,185,129,0.15),
    0 0 10px rgba(16,185,129,0.55);
}

/* ===========================
   CHAT — LAYOUT IDEAL REFACTORED
   =========================== */

/* Chat wrapper: container principal com flex column */
.chat-wrapper {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  height: 100vh !important;
  position: relative !important;
  z-index: 1 !important;
}

/* Container principal do chat: flex-1, scrollável */
.chat-container {
  flex: 1 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 20px 24px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0 !important;
  background: transparent !important;
  /* Centralizar mensagens horizontalmente */
  max-width: 800px !important;
  margin: 0 auto !important;
  width: 100% !important;
}

/* Scrollbar mínima */
.chat-container::-webkit-scrollbar { width: 3px; }
.chat-container::-webkit-scrollbar-thumb {
  background: rgba(109,93,252,0.25);
  border-radius: 2px;
}

/* Remove spacer flex que empurrava mensagens */
.chat-container::before {
  display: none !important;
  flex: none !important;
}

/* ── Linha de mensagem ── */
.message {
  display: flex !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 3px 0 !important;
  margin: 0 !important;
  animation: msgFadeIn 0.28s cubic-bezier(0.22,1,0.36,1) both !important;
}

/* Usuário: à direita */
.message.user {
  justify-content: flex-end !important;
}

/* IA: à esquerda */
.message.ai {
  justify-content: flex-start !important;
}

/* Espaço extra entre trocas de sender */
.message.user + .message.ai,
.message.ai  + .message.user {
  margin-top: 10px !important;
}

/* ── Wrapper de conteúdo ── */
.message-content {
  display: flex !important;
  flex-direction: column !important;
  max-width: 80% !important;
  position: relative !important;
}

.message.user .message-content {
  align-items: flex-end !important;
}

.message.ai .message-content {
  align-items: flex-start !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  max-width: 85% !important;
}

/* ── Avatar da IA ── */
.message.ai .message-content::before {
  content: '◆' !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover)) !important;
  border-radius: 10px !important;
  font-size: 13px !important;
  color: white !important;
  box-shadow: 0 4px 14px rgba(109,93,252,0.4) !important;
  margin-top: 3px !important;
  margin-right: 10px !important;
  flex-shrink: 0 !important;
  align-self: flex-start !important;
  letter-spacing: 0 !important;
}

/* ── Bubble base ── */
.bubble {
  border-radius: 16px !important;
  padding: 12px 16px 26px 16px !important;
  font-size: 14px !important;
  line-height: 1.65 !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
  position: relative !important;
  max-width: 100% !important;
  letter-spacing: 0.01em !important;
}

/* ── Bubble do usuário ── */
.user .bubble {
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-hover) 100%) !important;
  color: #fff !important;
  border-bottom-right-radius: 5px !important;
  border: none !important;
  box-shadow:
    0 4px 20px rgba(109,93,252,0.4),
    inset 0 1px 0 rgba(255,255,255,0.18) !important;
  white-space: pre-wrap !important;
}

/* ── Bubble da IA ── */
.ai .bubble {
  background: rgba(13,17,32,0.88) !important;
  border: 1px solid rgba(109,93,252,0.15) !important;
  border-top: 1px solid rgba(109,93,252,0.22) !important;
  color: var(--text-primary) !important;
  border-radius: 16px !important;
  border-bottom-left-radius: 5px !important;
  backdrop-filter: blur(20px) !important;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.06) !important;
  flex: 0 1 auto !important;
  min-width: 0 !important;
  max-width: calc(100% - 44px) !important;
  white-space: normal !important;
}

/* Remove tails */
.user .bubble::after,
.ai  .bubble::after { display: none !important; }
.user .bubble::before { display: none !important; }

/* ── Timestamp ── */
.bubble-meta {
  position: absolute !important;
  bottom: 6px !important;
  right: 12px !important;
  font-size: 9.5px !important;
  opacity: 0.4 !important;
  pointer-events: none !important;
  user-select: none !important;
  white-space: nowrap !important;
}

/* ── Ações da mensagem IA ── */
.message.ai .message-actions {
  flex-basis: 100% !important;
  padding-left: 40px !important;
  margin-top: 4px !important;
}

/* ── Meta/footer IA ── */
.message.ai .message-meta {
  flex-basis: 100% !important;
  padding-left: 40px !important;
}

/* Separador entre grupos */
.message.user + .message.ai::before {
  display: none !important;
}

/* ── Typing bubble ── */
.typing-bubble {
  background: rgba(13,17,32,0.88) !important;
  border: 1px solid rgba(109,93,252,0.15) !important;
  border-radius: 16px !important;
  border-bottom-left-radius: 5px !important;
  padding: 14px 20px !important;
  backdrop-filter: blur(20px) !important;
}

/* ── Responsivo ── */
@media (max-width: 768px) {
  .chat-container {
    width: auto !important;
    left: 16px !important;
    right: 16px !important;
    transform: none !important;
    bottom: 140px !important;
    max-width: none !important;
  }
  .message.ai .message-content::before { display: none !important; }
  .ai .bubble { max-width: 100% !important; }
  .message.ai .message-content { flex-direction: column !important; }
  .message.ai .message-actions { padding-left: 0 !important; }
  .message.ai .message-meta { padding-left: 0 !important; }
  .message-content { max-width: 86% !important; }
}

@media (max-width: 480px) {
  .chat-container { bottom: 120px !important; }
  .bubble { font-size: 13.5px !important; padding: 10px 14px 24px !important; }
}

/* ── SCROLLBAR ultra thin ── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-thumb {
  background: rgba(109,93,252,0.25);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(109,93,252,0.45);
}

/* ── SELECTION color ── */
::selection {
  background: rgba(109,93,252,0.3);
  color: var(--text-primary);
}

/* ── LIGHT MODE overrides para manter premium ── */
body.light-mode .glass-input-box {
  background: linear-gradient(
    135deg,
    rgba(255,255,255,0.9) 0%,
    rgba(248,249,255,0.8) 100%
  );
  border-color: rgba(109,93,252,0.12);
  box-shadow:
    0 8px 32px rgba(109,93,252,0.08),
    0 2px 8px rgba(0,0,0,0.06),
    inset 0 1px 0 rgba(255,255,255,0.9);
}

body.light-mode .glass-input-box:focus-within {
  border-color: rgba(109,93,252,0.35);
  box-shadow:
    0 12px 40px rgba(109,93,252,0.14),
    0 4px 12px rgba(109,93,252,0.08),
    inset 0 1px 0 white;
}

body.light-mode .user .bubble {
  box-shadow:
    0 4px 20px rgba(109,93,252,0.35),
    0 1px 4px rgba(0,0,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

body.light-mode .ai .bubble {
  background: rgba(248,249,255,0.95);
  border-color: rgba(109,93,252,0.1);
  color: var(--text-primary);
  box-shadow:
    0 4px 20px rgba(0,0,0,0.08),
    0 1px 4px rgba(0,0,0,0.05);
  backdrop-filter: none;
}

body.light-mode .model-trigger {
  background: linear-gradient(
    135deg,
    rgba(109,93,252,0.06) 0%,
    rgba(248,249,255,0.8) 100%
  );
  border-color: rgba(109,93,252,0.14);
}

body.light-mode .model-dropdown {
  background: rgba(255,255,255,0.96);
  border-color: rgba(109,93,252,0.12);
}

body.light-mode .model-item:hover {
  background: rgba(109,93,252,0.06);
  color: var(--accent);
}

body.light-mode .toast {
  background: rgba(255,255,255,0.96);
  border-color: rgba(109,93,252,0.12);
  color: var(--text-primary);
  box-shadow:
    0 16px 48px rgba(0,0,0,0.14),
    0 4px 12px rgba(0,0,0,0.08),
    inset 0 1px 0 white;
}

body.light-mode .settings-panel {
  background: white;
  border-color: rgba(109,93,252,0.1);
}

body.light-mode .conversation-item.active {
  background: linear-gradient(90deg, rgba(109,93,252,0.1) 0%, rgba(109,93,252,0.03) 100%);
  border-left-color: var(--accent);
}

body.light-mode .sidebar {
  background: white;
  box-shadow: 4px 0 24px rgba(0,0,0,0.06);
}

/* ── RESPONSIVE FINAL ── */
@media (max-width: 768px) {
  .chat-container { padding: 16px 12px 20px; }
  .input-container { padding: 0 12px 28px; }
  .glass-input-box { border-radius: 22px; max-width: 100%; }
  .send-btn-glass, .stop-btn { width: 40px; height: 40px; min-width: 40px; }
  .action-btn { width: 34px; height: 34px; }
  .message.ai .message-content { max-width: 92%; }
  .message.user .message-content { max-width: 86%; }
  .toast { max-width: 280px; font-size: 13px; }
}

@media (max-width: 480px) {
  .glass-input-box { border-radius: 18px; padding: 10px 12px; gap: 8px; }
  .send-btn-glass, .stop-btn { width: 38px; height: 38px; min-width: 38px; border-radius: 12px; }
  .quick-tags { display: none; }
  .input-actions-left { display: none; }
}

/* ===========================
   CHAT SCROLL NAVIGATION
   Botões de navegação para subir/descer no chat
   =========================== */

/* Container dos botões de scroll */
.chat-scroll-nav {
  position: fixed;
  bottom: 180px;
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.chat-scroll-nav.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* Botão individual de scroll */
.scroll-nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    rgba(255,255,255,0.08) 0%,
    rgba(255,255,255,0.03) 100%
  );
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.scroll-nav-btn:hover {
  background: rgba(109,93,252,0.15);
  border-color: rgba(109,93,252,0.3);
  color: var(--accent);
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(109,93,252,0.2);
}

.scroll-nav-btn:active {
  transform: scale(0.95);
}

.scroll-nav-btn svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.scroll-nav-btn:hover svg {
  transform: translateY(-2px);
}

.scroll-nav-btn.scroll-down:hover svg {
  transform: translateY(2px);
}

/* Badge de novas mensagens */
.new-messages-badge {
  position: fixed;
  bottom: 230px;
  right: 32px;
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: none;
  border-radius: 20px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 20px rgba(109,93,252,0.4);
  z-index: 91;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.new-messages-badge.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.new-messages-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(109,93,252,0.5);
}

.new-messages-badge svg {
  width: 14px;
  height: 14px;
}

/* ===========================
   INPUT FIXO NO BOTTOM — LAYOUT IDEAL
   Padrão: flex column com input fixo no bottom
   =========================== */

/* Chat wrapper: container principal com flex column */
.chat-wrapper {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  min-height: 0 !important;
  position: relative !important;
  z-index: 1 !important;
}

/* Chat container: flex-1, min-height: 0, overflow-y: auto */
.chat-container {
  flex: 1 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 20px 24px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0 !important;
  background: transparent !important;
  max-width: 800px !important;
  margin: 0 auto !important;
  width: 100% !important;
  position: relative !important;
  /* Remove position fixed e justify-content flex-end */
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  max-height: none !important;
  z-index: auto !important;
}

/* Input container: flex-shrink: 0, fixo no bottom do flex container */
.input-container {
  flex-shrink: 0 !important;
  padding: 16px 20px 24px !important;
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--bg-primary) 40%
  ) !important;
  border-top: none !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 10px !important;
  position: relative !important;
  /* Remove position fixed */
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  width: 100% !important;
  max-width: none !important;
  z-index: auto !important;
  backdrop-filter: none !important;
}

/* Glass input box centralizado */
.input-container .glass-input-box {
  max-width: 760px !important;
  width: 100% !important;
}

/* Quick tags centralizadas */
.input-container .quick-tags {
  max-width: 760px !important;
}

/* MOBILE: ajustes para telas menores */
@media (max-width: 768px) {
  .chat-container {
    padding: 16px !important;
    max-width: none !important;
  }

  .input-container {
    padding: 12px 16px 20px !important;
  }

  .input-container .glass-input-box {
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  .chat-container {
    padding: 12px !important;
  }

  .input-container {
    padding: 10px 12px 16px !important;
  }
}
