@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-dark: #212121;
  --bg-panel: #171717;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 255, 255, 0.16);
  --color-accent: #6366f1;
  --color-success: #10b981;
  --text-primary: #ececec;
  --text-secondary: #b4b4b4;
  --text-muted: #676767;
  --font-main: 'Plus Jakarta Sans', sans-serif;
  --font-code: 'Fira Code', monospace;
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  display: flex;
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px;
  z-index: 10;
  transition: all 0.2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.brand-logo i {
  color: var(--color-accent);
  font-size: 16px;
}

.brand-info h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.brand-info span {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
}

.btn-new-chat {
  width: 100%;
  padding: 10px 14px;
  background: #18181b;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  margin-bottom: 24px;
}

.btn-new-chat:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border-focus);
}

.history-section {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 20px;
}

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

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 32px 8px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}

.history-item.active {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.history-item-delete {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.15s ease;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

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

.history-item-delete:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.support-section {
  margin-top: 16px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.support-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.support-item:hover {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}

.support-item i {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.support-item:hover i {
  color: var(--text-primary);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 32px;
  height: 32px;
  background: var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border-focus);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
}

.user-status {
  font-size: 10px;
  color: var(--color-success);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

.top-header {
  height: 56px;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 9;
}

@media (min-width: 769px) {
  .top-header {
    display: none;
  }
}

.mobile-toggle {
  display: none;
  font-size: 20px;
  cursor: pointer;
}

.chat-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  width: 100%;
  padding: 80px 24px 40px 24px;
  overflow-y: auto;
}

.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  max-width: 840px;
  width: 100%;
  text-align: center;
}

.welcome-logo {
  width: 64px;
  height: 64px;
  background: #18181b;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  position: relative;
  margin-bottom: 8px;
}

.welcome-logo i {
  position: relative;
  z-index: 2;
  width: 24px;
  height: 24px;
  color: var(--text-primary);
}

.glowing-ring {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 2px solid transparent;
  background: linear-gradient(135deg, #6366f1, #f97316, #3b82f6) border-box;
  -webkit-mask:
    linear-gradient(#fff 0 0) padding-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask-composite: exclude;
  filter: blur(2px);
  animation: spin-glowing 8s linear infinite;
}

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

.welcome-title h2 {
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.8px;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
}

.message-bubble {
  width: 100%;
  line-height: 1.6;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

.message-bubble.user {
  background: #18181b;
  border-radius: 16px 16px 4px 16px;
  padding: 12px 18px;
  max-width: 80%;
  align-self: flex-end;
  border: 1px solid var(--border-color);
}

.message-bubble.assistant {
  background: transparent;
  max-width: 100%;
  align-self: flex-start;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.message-bubble.user .message-meta {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 4px;
}

.message-bubble .actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s ease;
}

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

.chat-input-wrapper {
  padding: 16px 24px 32px 24px;
  display: flex;
  justify-content: center;
  background: linear-gradient(to top, var(--bg-dark) 70%, transparent);
  width: 100%;
}

#welcome-input-placeholder .chat-input-wrapper {
  padding: 0;
  background: transparent;
  width: 100%;
  margin-top: 12px;
}

.chat-input-container {
  max-width: 720px;
  width: 100%;
  display: flex;
  background: #2a2a2a;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 10px 18px;
  align-items: center;
  transition: all 0.2s ease;
}

.chat-input-container:focus-within {
  border-color: var(--border-focus);
  background: #2d2d2d;
}

.chat-input-container textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  resize: none;
  height: 32px;
  padding: 6px 0;
  line-height: 1.4;
  margin-left: 12px;
  margin-right: 12px;
}

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

.btn-send {
  width: 32px;
  height: 32px;
  background: var(--text-primary);
  border: none;
  border-radius: 50%;
  color: var(--bg-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-send:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: scale(1.05);
}

.markdown-body {
  word-wrap: break-word;
  color: #e4e4e7;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin-top: 20px;
  margin-bottom: 10px;
  font-weight: 700;
  color: var(--text-primary);
}

.markdown-body h1 {
  font-size: 18px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.markdown-body h2 {
  font-size: 15px;
}

.markdown-body h3 {
  font-size: 14px;
}

.markdown-body p {
  margin-bottom: 12px;
}

.markdown-body ul, .markdown-body ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.markdown-body li {
  margin-bottom: 6px;
}

.markdown-body code {
  font-family: var(--font-code);
  font-size: 12px;
  background: #27272a;
  padding: 2px 6px;
  border-radius: 4px;
  color: #f43f5e;
}

.markdown-body pre {
  background: #09090b !important;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: var(--text-primary);
  font-size: 12px;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  font-size: 13px;
}

.markdown-body th {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  color: var(--text-primary);
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0;
}

.synthesis-tabs-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: #18181b;
  margin-top: 12px;
  overflow: hidden;
}

.synthesis-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: #09090b;
  padding: 0 12px;
  overflow-x: auto;
}

.synthesis-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 12px 18px;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.synthesis-tab:hover {
  color: var(--text-primary);
}

.synthesis-tab.active[data-tab="omni"] {
  color: #818cf8;
  border-bottom-color: #6366f1;
}

.synthesis-tab.active[data-tab="gpt"] {
  color: #34d399;
  border-bottom-color: #10b981;
}

.synthesis-tab.active[data-tab="claude"] {
  color: #fb923c;
  border-bottom-color: #f97316;
}

.synthesis-tab.active[data-tab="gemini"] {
  color: #60a5fa;
  border-bottom-color: #3b82f6;
}

.synthesis-tab-panel {
  display: none;
  padding: 20px;
  min-height: 60px;
}

.synthesis-tab-panel.active {
  display: block;
}

.model-header-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  align-self: flex-start;
}

.model-header-badge.omni {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.model-header-badge.gpt {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.model-header-badge.claude {
  background: rgba(249, 115, 22, 0.15);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.model-header-badge.gemini {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

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

.input-action-btn:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.input-action-btn.recording {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.input-main-area {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.attachment-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 6px;
}

.attachment-preview-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #27272a;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-preview-card img {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: cover;
}

.attachment-preview-card .btn-remove-attachment {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 50%;
  transition: all 0.15s ease;
}

.attachment-preview-card .btn-remove-attachment:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.msg-attached-img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.msg-attached-file {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #27272a;
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 12px;
  transition: background 0.15s ease;
}

.msg-attached-file:hover {
  background: #3f3f46;
}

.msg-attached-file i {
  width: 16px;
  height: 16px;
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    height: 100vh;
    height: 100dvh;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    z-index: 100;
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .sidebar-backdrop.show {
    display: block;
  }
  
  .top-header {
    padding: 0 16px;
  }
  
  .mobile-toggle {
    display: block;
  }
  
  .welcome-container {
    padding: 16px;
  }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99;
}

.support-dropdown {
  position: relative;
  width: 100%;
}
.support-dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #18181b;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}
.support-dropdown-trigger:hover {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  border-color: var(--border-focus);
}
.support-dropdown-trigger .chevron-icon {
  margin-left: auto;
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}
.support-dropdown-trigger .chevron-icon.rotate {
  transform: rotate(180deg);
}
.support-dropdown-menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding-left: 12px;
  border-left: 1px solid var(--border-color);
}
.support-dropdown-menu.open {
  display: flex;
}
.support-submenu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.support-submenu-item:hover {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}
.support-submenu-item i {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}
.support-submenu-item:hover i {
  color: var(--text-primary);
}

.welcome-suggestions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 720px;
  margin-top: 16px;
}
.suggestion-pill {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.suggestion-pill:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.24);
  color: var(--text-primary);
}
.suggestion-pill i {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}
.suggestion-pill:hover i {
  color: var(--text-primary);
}

/* Premium API Limit Error Card */
.api-limit-error-card {
  display: flex;
  gap: 16px;
  background: rgba(245, 158, 11, 0.03);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 12px;
  padding: 18px 20px;
  margin-top: 12px;
  align-self: flex-start;
  max-width: 100%;
  animation: fadeInError 0.3s ease-out;
}

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

.error-card-icon {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  color: #f59e0b;
  font-size: 20px;
  padding-top: 2px;
}

.error-card-icon i {
  width: 20px;
  height: 20px;
  animation: pulseWarning 2s infinite ease-in-out;
}

@keyframes pulseWarning {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(245, 158, 11, 0)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.4)); }
}

.error-card-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.error-card-content h4 {
  font-size: 14px;
  font-weight: 700;
  color: #fbbf24;
  margin: 0;
}

.error-card-content p {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
}

.error-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  flex-wrap: wrap;
  gap: 12px;
}

.error-card-code {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.btn-retry-error {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 6px;
  color: #fbbf24;
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-retry-error:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.4);
  color: #f59e0b;
}

.btn-retry-error i {
  width: 13px;
  height: 13px;
}
