:root {
  --bg: #0a0a0b;
  --bg-sidebar: #111113;
  --bg-card: #18181b;
  --bg-elevated: #1f1f23;
  --bg-input: #27272a;
  --fg: #fafafa;
  --fg-dim: #a1a1aa;
  --fg-muted: #52525b;
  --border: #27272a;
  --border-light: #3f3f46;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --warning: #eab308;
  --error: #ef4444;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
}

/* === Loading Overlay === */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* === Landing Page === */
.landing-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, #0f0f12 100%);
}

.landing-content {
  text-align: center;
  padding: 40px;
  max-width: 480px;
}

.landing-logo {
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin: 0 auto 32px;
  box-shadow: 0 20px 60px rgba(99, 102, 241, 0.3);
}

.landing-content h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--fg) 0%, var(--fg-dim) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.landing-content > p {
  color: var(--fg-dim);
  font-size: 1.1rem;
  margin-bottom: 40px;
  line-height: 1.6;
}

.google-signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.google-signin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.google-signin-btn:active {
  transform: translateY(0);
}

/* Free Credits Banner */
.free-credits-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 20px;
  margin-bottom: 24px;
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 500;
}

.gift-icon {
  font-size: 1.1rem;
}

/* Auth Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--fg-muted);
  font-size: 0.85rem;
}

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

/* Email Auth Form */
.email-auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.auth-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.auth-input::placeholder {
  color: var(--fg-muted);
}

.email-signin-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.email-signin-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.email-signin-btn:disabled {
  background: var(--fg-muted);
  cursor: not-allowed;
  transform: none;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.auth-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease;
}

.auth-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Auth Modal */
.auth-modal {
  max-width: 400px;
}

.auth-modal-desc {
  color: var(--fg-dim);
  margin-bottom: 20px;
  text-align: center;
}

.auth-modal .auth-input {
  margin-bottom: 0;
}

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

.auth-error {
  color: var(--error);
  font-size: 0.85rem;
  text-align: center;
  min-height: 20px;
}

.auth-success {
  color: var(--success);
  font-size: 0.85rem;
  text-align: center;
  min-height: 20px;
}

.auth-modal-footer {
  text-align: center;
  margin-top: 16px;
  color: var(--fg-dim);
  font-size: 0.9rem;
}

.modal-google-btn {
  width: 100%;
  justify-content: center;
}

/* Credits Display Styles */
.credits-display {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--fg-dim);
  transition: all 0.2s ease;
}

.credits-display.warning {
  border-color: var(--warning);
  color: var(--warning);
  background: rgba(234, 179, 8, 0.1);
}

.credits-display.danger {
  border-color: var(--error);
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.credits-display.unlimited {
  border-color: var(--success);
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.credits-display.free {
  border-color: var(--success);
  color: var(--success);
}

.get-credits-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.get-credits-btn:hover {
  background: var(--accent-hover);
}

/* Landing Prompts */
.landing-prompts {
  margin-top: 48px;
  text-align: center;
}

.prompts-label {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-bottom: 16px;
}

.prompt-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 520px;
  margin: 0 auto;
}

.prompt-example {
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--fg-dim);
  cursor: pointer;
  transition: all 0.2s ease;
}

.prompt-example:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
  color: var(--fg);
  transform: translateY(-2px);
}

.landing-features {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 48px;
  flex-wrap: wrap;
}

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

.feature-icon {
  font-size: 1.5rem;
}

.feature span:last-child {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

/* === Chat App Container === */
.chat-app {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* === Sidebar === */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.brand-text {
  font-weight: 600;
  font-size: 1.1rem;
}

.sidebar-actions {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.new-chat-btn {
  padding: 12px 16px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.new-chat-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.chat-list-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-list-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-muted);
}

.clear-all-btn {
  padding: 4px 8px;
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}

.clear-all-btn:hover {
  background: var(--bg-card);
  color: var(--error);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.chat-item {
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--fg-dim);
  font-size: 0.9rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.15s;
}

.chat-item:hover {
  background: var(--bg-card);
  color: var(--fg);
}

.chat-item.active {
  background: var(--bg-elevated);
  color: var(--fg);
}

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

.chat-item-delete {
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s;
}

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

.chat-item-delete:hover {
  background: var(--error);
  color: white;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.user-card:hover {
  background: var(--bg-card);
}

.user-avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.signout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

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

/* Header User Avatar */
.header-user {
  display: flex;
  align-items: center;
}

.header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s;
}

.header-avatar:hover {
  border-color: var(--accent);
}

/* === Main === */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.main-title {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

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

.chain-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--success);
}

.chain-badge .dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

/* Message Counter Badge */
.message-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--fg-dim);
}

.message-counter-icon {
  font-size: 0.75rem;
}

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

.settings-btn {
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.settings-btn:hover {
  background: var(--bg-elevated);
  color: var(--fg);
}

/* === Messages === */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
}

.message {
  max-width: 800px;
  margin: 0 auto 24px;
  padding: 0 24px;
  display: flex;
  gap: 16px;
  animation: messageSlideIn 0.3s ease-out;
  opacity: 0;
  animation-fill-mode: forwards;
}

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.message.assistant .message-avatar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.message-avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

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

.message-role {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--fg-dim);
}

.message-content {
  line-height: 1.7;
  font-size: 0.95rem;
}

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

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

.message-content code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

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

.message-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

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

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

/* Response Controls */
.message-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.message:hover .message-footer {
  opacity: 1;
}

.response-actions {
  display: flex;
  gap: 8px;
}

.response-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.response-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  color: var(--fg);
}

.response-btn.copied {
  border-color: var(--success);
  color: var(--success);
}

.response-btn svg {
  width: 14px;
  height: 14px;
}

.feedback-btns {
  display: flex;
  gap: 4px;
}

.feedback-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--fg-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

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

/* Model Badge */
.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--fg-muted);
  margin-left: 8px;
}

.model-badge svg {
  width: 12px;
  height: 12px;
}

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

.welcome-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 24px;
}

.welcome h2 {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.welcome p {
  color: var(--fg-dim);
  max-width: 420px;
  margin-bottom: 32px;
  line-height: 1.6;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 500px;
}

.suggestion {
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--fg-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.suggestion:hover {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  color: var(--fg);
  transform: translateY(-2px);
}

/* === Input === */
.input-area {
  padding: 20px 24px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-container {
  max-width: 800px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 16px;
  transition: border-color 0.15s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
}

.input-field {
  flex: 1;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 200px;
  line-height: 1.5;
}

.input-field::placeholder {
  color: var(--fg-muted);
}

.send-btn {
  width: 42px;
  height: 42px;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: var(--fg-muted);
  cursor: not-allowed;
  transform: none;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding: 0 4px;
}

.input-note {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.disclaimer {
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-align: center;
  margin-top: 8px;
  opacity: 0.7;
}

.trial-note {
  font-size: 0.75rem;
  color: var(--accent);
}

/* === Loading === */
.typing {
  display: flex;
  gap: 6px;
  padding: 8px 0;
  align-items: center;
}

.typing span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-8px) scale(1.1);
    opacity: 1;
  }
}

/* Loading state for input */
.input-wrapper.loading {
  opacity: 0.7;
  pointer-events: none;
}

.send-btn.loading {
  position: relative;
}

.send-btn.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 440px;
  max-height: 90vh;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

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

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

.modal-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--bg-elevated);
  color: var(--fg);
}

.modal-body {
  padding: 24px;
}

.modal-desc {
  color: var(--fg-dim);
  margin-bottom: 20px;
  line-height: 1.6;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.input-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  transition: border-color 0.15s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-help {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--fg-muted);
  font-size: 0.85rem;
}

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

.trial-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.trial-box p {
  color: var(--fg-dim);
  font-size: 0.9rem;
  margin-bottom: 0;
}

.trial-box a {
  color: var(--accent);
  text-decoration: none;
}

.trial-box a:hover {
  text-decoration: underline;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-btn {
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  width: 100%;
  text-align: center;
}

.modal-btn.save {
  background: var(--accent);
  color: white;
}

.modal-btn.save:hover {
  background: var(--accent-hover);
}

.modal-btn.trial {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
}

.modal-btn.trial:hover {
  background: var(--bg-elevated);
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  z-index: 1001;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* === Error Retry === */
.error-message {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.error-text {
  color: var(--error);
}

.retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: fit-content;
}

.retry-btn:hover {
  background: var(--bg-input);
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 100;
    transition: transform 0.3s ease;
  }

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

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .sidebar-overlay.open {
    display: block;
    opacity: 1;
  }

  .menu-btn {
    display: flex;
  }

  .chain-badge {
    display: none;
  }

  /* Improved mobile message layout */
  .message {
    padding: 0 16px;
    gap: 12px;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .message-content {
    font-size: 0.9rem;
  }

  /* Better input area on mobile */
  .input-area {
    padding: 12px 16px 16px;
  }

  .input-wrapper {
    padding: 10px 12px;
    border-radius: 12px;
  }

  .send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  /* Welcome section mobile */
  .welcome {
    padding: 24px 16px;
  }

  .welcome h2 {
    font-size: 1.3rem;
  }

  .welcome p {
    font-size: 0.9rem;
  }

  .suggestions {
    flex-direction: column;
    width: 100%;
  }

  .suggestion {
    width: 100%;
    text-align: center;
  }

  /* Modal mobile */
  .modal {
    width: 95%;
    max-height: 85vh;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .main-header {
    padding: 12px 16px;
  }

  .main-title {
    font-size: 0.85rem;
  }

  .settings-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .input-footer {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
}
