/* Cloudflare AI Chat Design System */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;

  /* Theme: Dark (Default) */
  --bg-primary: #0a0d14;
  --bg-secondary: #111622;
  --bg-tertiary: #182030;
  --bg-elevated: #1f293d;
  --bg-input: #151b2a;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-focus: #f6821f;

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-inverse: #0a0d14;

  --accent-orange: #f6821f;
  --accent-orange-hover: #faad3f;
  --accent-gradient: linear-gradient(135deg, #f6821f 0%, #faad3f 100%);
  --accent-glow: rgba(246, 130, 31, 0.25);

  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  --sidebar-width: 280px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-elevated: #ffffff;
  --bg-input: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;

  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #f6821f;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

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

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea {
  font-family: inherit;
  color: inherit;
}

/* Layout */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar Backdrop for Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 90;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

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

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 2px 6px var(--accent-glow));
}

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

.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 11px;
  color: var(--accent-orange);
  font-weight: 600;
}

.sidebar-close-btn {
  display: none;
}

.sidebar-actions {
  padding: 14px 16px 8px;
}

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-gradient);
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: opacity 0.2s, transform 0.1s;
}

.new-chat-btn:hover {
  opacity: 0.94;
  transform: translateY(-1px);
}

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

.search-box {
  margin: 8px 16px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--border-focus);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

/* Conversations List */
.conversations-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.conversations-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 40px;
}

.history-group-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 4px 8px;
}

.history-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

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

.chat-item.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.chat-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent-orange);
  border-radius: 0 2px 2px 0;
}

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

.chat-item-actions {
  display: none;
  align-items: center;
  gap: 4px;
}

.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions {
  display: flex;
}

.chat-item-btn {
  padding: 3px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}

.chat-item-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.chat-item-btn.delete:hover {
  color: var(--danger);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.status-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Buttons */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: color 0.15s, background 0.15s;
}

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

.theme-icon-light {
  display: none;
}

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

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

/* Main Workspace */
.chat-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  position: relative;
}

/* Topbar Header */
.chat-header {
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.mobile-menu-btn {
  display: none;
}

.title-container {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

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

.chat-title-input {
  font-size: 15px;
  font-weight: 600;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  color: var(--text-primary);
  outline: none;
}

.edit-title-btn {
  padding: 4px;
}

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

/* Dropdown */
.dropdown-wrapper {
  position: relative;
}

.selector-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  transition: border-color 0.15s, background 0.15s;
}

.selector-btn:hover {
  border-color: var(--border-medium);
  background: var(--bg-elevated);
}

.model-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-orange);
}

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(246, 130, 31, 0.15);
  color: var(--accent-orange);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 250px;
  z-index: 100;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: dropdownFadeIn 0.15s ease;
}

.dropdown-menu.show {
  display: flex;
}

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

.dropdown-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.dropdown-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.dropdown-item {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: var(--bg-tertiary);
}

.dropdown-item.active {
  background: rgba(246, 130, 31, 0.1);
}

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

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

.dropdown-item-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.action-menu {
  min-width: 170px;
}

.action-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
  transition: background 0.15s;
}

.action-item:hover {
  background: var(--bg-tertiary);
}

.action-item.danger {
  color: var(--danger);
}

.action-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Messages Feed */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.empty-state {
  max-width: 760px;
  margin: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 40px 16px;
}

.empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.hero-icon-glow {
  padding: 12px;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle, rgba(246, 130, 31, 0.25) 0%, rgba(246, 130, 31, 0) 70%);
}

.empty-hero h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.empty-hero p {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 480px;
}

.starters-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.starter-card {
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
}

.starter-card:hover {
  border-color: var(--accent-orange);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.starter-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

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

/* Messages List */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.message-row {
  display: flex;
  gap: 14px;
  width: 100%;
  animation: messageFadeIn 0.2s ease;
}

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

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

.message-avatar.user-avatar {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.message-avatar.ai-avatar {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.message-content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.message-author {
  font-weight: 600;
  font-size: 13px;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.message-action-btn {
  padding: 4px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}

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

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

.message-row.user-row .message-body {
  white-space: pre-wrap;
}

/* Markdown Rendering */
.message-body p {
  margin-bottom: 12px;
}

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

.message-body h1, .message-body h2, .message-body h3, .message-body h4 {
  font-weight: 700;
  margin: 18px 0 8px;
  line-height: 1.3;
}

.message-body h1 { font-size: 20px; }
.message-body h2 { font-size: 17px; }
.message-body h3 { font-size: 15px; }

.message-body ul, .message-body ol {
  margin: 8px 0 12px 24px;
}

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

.message-body blockquote {
  border-left: 3px solid var(--accent-orange);
  padding: 6px 12px;
  margin: 10px 0;
  color: var(--text-secondary);
  background: rgba(246, 130, 31, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.message-body code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: #fca5a5;
}

[data-theme="light"] .message-body code:not(pre code) {
  color: #b91c1c;
}

/* Reasoning & Thought Process Box */
.thought-process {
  margin: 8px 0 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 13px;
}

.thought-process summary {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  user-select: none;
  list-style: none;
}

.thought-process summary::-webkit-details-marker {
  display: none;
}

.thought-process summary:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.thought-process[open] summary {
  border-bottom: 1px solid var(--border-subtle);
}

.thought-content {
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.15);
  max-height: 320px;
  overflow-y: auto;
}

.code-block-wrapper {
  margin: 12px 0;
  background: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.copy-code-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.copy-code-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.code-block-wrapper pre {
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: #e5e7eb;
}

/* Streaming cursor */
.streaming-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--accent-orange);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Input Section */
.input-section {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
}

.input-card {
  max-width: 820px;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-card:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-glow), var(--shadow-md);
}

#chatInput {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  max-height: 180px;
  min-height: 24px;
  font-size: 14.5px;
  line-height: 1.5;
}

#chatInput::placeholder {
  color: var(--text-muted);
}

.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
}

kbd {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: inherit;
  font-size: 10px;
}

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

.btn-send {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-send:not(:disabled):hover {
  transform: scale(1.05);
}

.btn-stop {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  font-size: 12px;
  font-weight: 500;
  color: var(--danger);
  transition: background 0.15s;
}

.btn-stop:hover {
  background: rgba(239, 68, 68, 0.1);
}

.input-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 13px;
  pointer-events: auto;
  animation: toastIn 0.2s ease, toastOut 0.2s ease 2.8s forwards;
}

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

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

/* Responsive Media Queries */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .sidebar-close-btn {
    display: inline-flex;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .desktop-only {
    display: none !important;
  }

  .starters-grid {
    grid-template-columns: 1fr;
  }

  .chat-title {
    max-width: 160px;
  }

  .messages-container {
    padding: 16px 12px;
  }

  .input-section {
    padding: 0 12px 12px;
  }
}

/* Sidebar User Profile */
.sidebar-user {
  margin: 0 12px 8px;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px var(--accent-glow);
}

.user-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

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

.logout-btn {
  padding: 5px;
  color: var(--text-muted);
}

.logout-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* Auth Modal Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: authOverlayIn 0.2s ease;
}

@keyframes authOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: authCardIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.auth-logo {
  border-radius: var(--radius-md);
  filter: drop-shadow(0 2px 8px var(--accent-glow));
}

.auth-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-header p {
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-tabs {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  border: 1px solid var(--border-subtle);
}

.auth-tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.auth-error {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 13px;
  line-height: 1.4;
  animation: errorShake 0.3s ease;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

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

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

.toggle-pwd-btn {
  position: absolute;
  right: 8px;
  padding: 6px;
  color: var(--text-muted);
  transition: color 0.15s;
}

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

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.auth-submit-btn {
  margin-top: 4px;
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 2px 10px var(--accent-glow);
  transition: opacity 0.2s, transform 0.1s;
}

.auth-submit-btn:hover {
  opacity: 0.94;
  transform: translateY(-1px);
}

.auth-submit-btn:active {
  transform: translateY(0);
}

.auth-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch-btn {
  color: var(--accent-orange);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.15s;
}

.auth-switch-btn:hover {
  opacity: 0.85;
}

/* API & OpenCode Modal Styles */
.api-modal-card {
  max-width: 480px;
}

.api-modal-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(246, 130, 31, 0.15);
  color: var(--accent-orange);
  display: flex;
  align-items: center;
  justify-content: center;
}

.api-info-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.api-info-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.copy-input-row {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px 4px 2px 10px;
  gap: 4px;
}

.copy-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-primary);
  outline: none;
}

.api-snippet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.api-snippet {
  background: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #e5e7eb;
  overflow-x: auto;
  line-height: 1.5;
  margin: 0;
}


