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

:root {
  --bg:            #F8FAFC;
  --sidebar-bg:    #FFFFFF;
  --surface:       #F1F5F9;
  --surface-2:     #E8EDF5;
  --border:        #E5E7EB;
  --border-light:  #F3F4F6;
  --text:          #111827;
  --text-muted:    #6B7280;
  --text-light:    #9CA3AF;
  --primary:       #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --primary-fg:    #FFFFFF;
  --accent:        #4F46E5;
  --accent-hover:  #4338CA;
  --accent-fg:     #FFFFFF;
  --gradient:      linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
  --danger:        #EF4444;
  --radius:        14px;
  --sidebar-w:     280px;
  --topbar-h:      72px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:     0 4px 16px rgba(15,23,42,0.08);
  --shadow-lg:     0 10px 30px rgba(15,23,42,0.10);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html, body { height: 100%; }
body { background: var(--bg); color: var(--text); overflow: hidden; }
.hidden { display: none !important; }

/* ─── Auth ────────────────────────────────────────────────────────────── */
.auth-view {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 50%, #F0FEFF 100%);
  padding: 24px;
}

.auth-card {
  width: 100%; max-width: 380px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 44px 40px 40px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 8px 40px rgba(79,70,229,0.10), 0 1px 4px rgba(0,0,0,0.05);
}

.auth-logo {
  font-size: 24px; font-weight: 800; text-align: center; margin-bottom: 4px;
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-title {
  font-size: 20px; font-weight: 700; text-align: center;
  color: var(--text); letter-spacing: -0.3px;
}

.auth-card input {
  width: 100%; height: 46px; padding: 0 16px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 12px; color: var(--text); font: inherit; font-size: 14px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.auth-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

.auth-error { font-size: 13px; color: var(--danger); min-height: 18px; }

.btn-primary {
  height: 46px; background: var(--gradient); color: #fff; border: none;
  border-radius: 12px; font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity .15s, box-shadow .15s, transform .1s;
}
.btn-primary:hover {
  opacity: .92; transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79,70,229,0.30);
}
.btn-full { width: 100%; }

.auth-switch { text-align: center; font-size: 13px; color: var(--text-muted); }
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

/* ─── Layout ──────────────────────────────────────────────────────────── */
.chat-layout {
  display: flex; height: 100vh; height: 100dvh; overflow: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; transition: transform .25s ease;
}

.sidebar-top {
  padding: 22px 16px 16px;
  display: flex; flex-direction: column; gap: 14px;
}

.brand {
  font-size: 19px; font-weight: 800; letter-spacing: -0.4px;
  padding: 2px 6px;
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn-new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 43px; padding: 0 16px;
  background: var(--gradient);
  border: none; border-radius: 16px;
  color: #fff; font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(79,70,229,0.28);
  transition: opacity .15s, transform .12s, box-shadow .15s;
}
.btn-new-chat:hover {
  opacity: .91; transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(79,70,229,0.38);
}

.sidebar-section-label {
  padding: 16px 20px 5px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--text-light);
}

.conversations-list {
  flex: 1; overflow-y: auto; padding: 4px 10px 8px;
}
.conversations-list::-webkit-scrollbar { width: 3px; }
.conversations-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.conv-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 11px;
  cursor: pointer; font-size: 13px; color: var(--text-muted);
  transition: background .12s, color .12s;
}
.conv-item:hover { background: var(--surface); color: var(--text); }
.conv-item.active {
  background: var(--primary-light); color: var(--primary); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}
.conv-item svg { flex-shrink: 0; opacity: 0.45; }
.conv-item.active svg { opacity: 1; }
.conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conv-del {
  flex-shrink: 0; display: none; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  padding: 3px; border-radius: 6px; color: var(--text-muted);
}
.conv-item:hover .conv-del { display: inline-flex; }
.conv-del:hover { background: rgba(239,68,68,0.10); color: #ef4444; }
.conv-del svg { opacity: 1; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 9px;
}

.sidebar-user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  transition: background .15s;
}
.sidebar-user-card:hover { background: var(--surface-2); }

.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}

.user-details { display: flex; flex-direction: column; overflow: hidden; gap: 2px; flex: 1; }
.user-email { font-size: 12px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-hc { font-size: 11px; color: var(--text-muted); }
.user-meta-row { display: flex; align-items: center; gap: 6px; }

.user-tier {
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 5px; border: 1px solid;
}
.user-tier.tier-1 { color: #6B7280; border-color: #D1D5DB; background: #F9FAFB; }
.user-tier.tier-2 { color: #059669; border-color: #A7F3D0; background: #ECFDF5; }
.user-tier.tier-3 { color: #2563EB; border-color: #BFDBFE; background: #EFF6FF; }
.user-tier.tier-4 { color: #7C3AED; border-color: #DDD6FE; background: #F5F3FF; }
.user-tier.tier-5 { color: #D97706; border-color: #FDE68A; background: #FFFBEB; }

.sidebar-footer-actions {
  display: flex; gap: 6px;
}

.btn-sidebar-action {
  flex: 1; height: 32px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-muted); font: inherit;
  font-size: 11.5px; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
}
.btn-sidebar-action:hover { color: var(--primary); border-color: rgba(79,70,229,.25); background: var(--primary-light); }
.btn-sidebar-action.danger:hover { color: #ef4444; border-color: rgba(239,68,68,.25); background: rgba(239,68,68,.05); }

/* Legacy aliases so JS-referenced IDs still work */
.btn-admin  { /* handled by .btn-sidebar-action */ }
.btn-logout { /* handled by .btn-sidebar-action */ }

/* ─── Chat main ───────────────────────────────────────────────────────── */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg);
}

/* Topbar */
.chat-topbar {
  height: var(--topbar-h); min-height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 22px; gap: 16px;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  position: relative; z-index: 20;
}

.btn-menu-mobile {
  display: none; background: transparent; border: none;
  color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 9px;
  flex-shrink: 0;
}
.btn-menu-mobile:hover { background: var(--surface); }

.topbar-title-block {
  flex: 1; display: flex; flex-direction: column; gap: 1px; overflow: hidden; min-width: 0;
}
.chat-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.2px;
}
.chat-subtitle { font-size: 11.5px; color: var(--text-light); font-weight: 400; }

.topbar-controls {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}

/* Mode pills */
.mode-pills {
  display: flex; align-items: center; gap: 3px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; padding: 4px;
}
.mode-pill {
  height: 30px; padding: 0 13px; background: transparent; border: none;
  border-radius: 10px; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
  display: inline-flex; align-items: center; text-decoration: none;
}
.mode-pill:hover { color: var(--text); background: rgba(79,70,229,0.06); }
.mode-pill.active {
  background: #fff; color: var(--primary); font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* Balance chip */
.topbar-balance {
  display: inline-flex; align-items: center;
  height: 32px; padding: 0 12px;
  background: var(--primary-light);
  border: 1px solid rgba(79,70,229,0.18);
  border-radius: 10px;
  font-size: 12.5px; font-weight: 700; color: var(--primary);
  white-space: nowrap; letter-spacing: -0.1px;
}

/* Max tokens input */
#max-tokens {
  height: 32px; width: 80px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font: inherit; font-size: 12.5px;
  outline: none; transition: border-color .15s;
}
#max-tokens:focus { border-color: var(--primary); }

/* Profile button & dropdown */
.topbar-profile { position: relative; }

.profile-btn {
  width: 38px; height: 38px;
  background: var(--gradient); border: none; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  box-shadow: 0 2px 10px rgba(79,70,229,0.28);
  transition: box-shadow .15s, transform .12s;
  flex-shrink: 0;
}
.profile-btn:hover { box-shadow: 0 4px 16px rgba(79,70,229,0.40); transform: scale(1.06); }

.profile-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  min-width: 224px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(15,23,42,0.13), 0 2px 6px rgba(0,0,0,0.06);
  padding: 8px; z-index: 300;
  display: none; animation: ddIn .14s ease;
}
@keyframes ddIn {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.profile-dropdown.open { display: block; }

.profile-dd-header {
  padding: 10px 14px 10px; border-bottom: 1px solid var(--border-light);
  margin-bottom: 4px;
}
.profile-dd-email { font-size: 12.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-dd-tier  { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: 12px;
  font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer; text-decoration: none;
  background: transparent; border: none; width: 100%;
  text-align: left; font-family: inherit;
  transition: background .12s;
}
.dd-item:hover { background: var(--surface); }
.dd-item svg { opacity: 0.5; flex-shrink: 0; }
.dd-item.danger { color: var(--danger); }
.dd-item.danger:hover { background: rgba(239,68,68,0.06); }
.dd-item.danger svg { opacity: 0.8; }
.dd-item.accent { color: var(--primary); }
.dd-item.accent svg { opacity: 0.85; }
.dd-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

/* ─── Messages ────────────────────────────────────────────────────────── */
.messages-area {
  flex: 1; overflow-y: auto;
  padding: 28px 0 12px;
  display: flex; flex-direction: column;
}
.messages-area::-webkit-scrollbar { width: 4px; }
.messages-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Welcome */
.welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 40px 24px; text-align: center; gap: 10px; color: var(--text-muted);
}
.welcome-icon { font-size: 50px; margin-bottom: 6px; }
.welcome h2 {
  font-size: 27px; font-weight: 800; color: var(--text); letter-spacing: -0.5px;
}
.welcome p { font-size: 14px; color: var(--text-muted); }

.onboard-cards {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 14px; margin-top: 20px; width: 100%; max-width: 780px; text-align: left;
}
.onboard-card {
  background: #fff; border: 1.5px solid var(--border); border-radius: 18px;
  padding: 22px 20px; cursor: pointer;
  transition: border-color .18s, transform .15s, box-shadow .18s;
  display: flex; flex-direction: column; gap: 10px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow-sm);
}
.onboard-card:hover {
  border-color: var(--primary); transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(79,70,229,0.13);
}
.onboard-card-icon { font-size: 28px; }
.onboard-card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.onboard-card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.onboard-card-cta { font-size: 12px; font-weight: 700; color: var(--primary); margin-top: 4px; }

@media (max-width: 640px) { .onboard-cards { grid-template-columns: 1fr; } }

/* Message rows */
.msg-row {
  padding: 3px 0;
  display: flex; justify-content: center;
}

.msg-inner {
  width: 100%; max-width: 880px;
  padding: 0 28px;
  display: flex; gap: 14px; align-items: flex-start;
}

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; margin-top: 4px;
}
.msg-avatar.user-av { background: var(--gradient); color: #fff; }
.msg-avatar.ai-av {
  background: #DCFCE7; color: #15803D;
  border: 1.5px solid #BBF7D0; font-size: 15px;
}

.msg-bubble {
  flex: 1; font-size: 14px; line-height: 1.72; color: var(--text); min-width: 0;
}

/* User bubble */
.msg-row.user .msg-bubble {
  background: #F4F3FF;
  border: 1px solid rgba(79,70,229,0.14);
  border-radius: 4px 18px 18px 18px;
  padding: 12px 18px;
}

/* AI bubble */
.msg-row.assistant .msg-bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  padding: 14px 20px;
  box-shadow: 0 2px 12px rgba(15,23,42,0.05);
}

/* Image in chat */
.msg-bubble img { max-width: 100%; border-radius: 12px; margin: 8px 0; display: block; }

/* Thinking */
.thinking { display: flex; gap: 5px; align-items: center; padding: 2px 0; }
.thinking span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary); animation: bounce 1.2s infinite; opacity: 0.4;
}
.thinking span:nth-child(2) { animation-delay: .2s; }
.thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

.msg-status { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }
.msg-status.error { color: var(--danger); }

/* Markdown */
.msg-bubble p { margin-bottom: 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble pre {
  background: #F8FAFC; border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px;
  overflow-x: auto; margin: 10px 0; font-size: 13px; position: relative;
}
.msg-bubble code { font-family: "JetBrains Mono","Fira Code",monospace; font-size: 13px; }
.msg-bubble p code {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; font-size: 12px; color: var(--primary);
}
.msg-bubble ul, .msg-bubble ol { margin: 8px 0 8px 22px; line-height: 1.75; }
.msg-bubble blockquote {
  border-left: 3px solid var(--primary); padding-left: 14px;
  color: var(--text-muted); margin: 8px 0; font-style: italic;
}
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { margin: 16px 0 8px; font-weight: 700; }

.copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 7px; color: var(--text-muted);
  font-size: 11px; padding: 3px 9px; cursor: pointer; transition: color .15s;
}
.copy-btn:hover { color: var(--primary); }

/* Message action bar */
.msg-actions {
  width: 100%; max-width: 880px; margin: 0 auto;
  padding: 3px 28px 10px;
  /* indent to align with bubble text (avatar 32px + gap 14px = 46px + outer 28px) */
  padding-left: calc(28px + 32px + 14px);
  display: flex; align-items: center; gap: 4px;
  opacity: 0; transition: opacity .18s;
}
.msg-row:hover + .msg-actions,
.msg-actions:hover { opacity: 1; }
/* Alternative: show on row hover using a wrapper trick */
.msg-row:hover ~ .msg-actions { opacity: 1; }

.msg-action-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 27px; padding: 0 10px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); font: inherit; font-size: 11.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: color .14s, border-color .14s, background .14s;
}
.msg-action-btn:hover { color: var(--primary); border-color: rgba(79,70,229,.28); background: var(--primary-light); }
.msg-action-btn.active-like  { color: #16a34a; border-color: #bbf7d0; background: #f0fdf4; }
.msg-action-btn.active-dislike { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.msg-action-btn.copied { color: #16a34a; border-color: #bbf7d0; }

.btn-report {
  display: inline-flex; align-items: center; gap: 4px;
  height: 27px; padding: 0 10px; border-radius: 8px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-light); font: inherit; font-size: 11.5px; font-weight: 500;
  cursor: pointer; transition: color .14s, border-color .14s;
}
.btn-report:hover { color: var(--danger); border-color: rgba(239,68,68,.25); }
.btn-report.reported { color: #059669; border-color: rgba(16,185,129,.28); cursor: default; }
.btn-report:disabled { cursor: default; }

/* ─── Input zone ──────────────────────────────────────────────────────── */
.input-zone {
  padding: 14px 24px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--bg); border-top: 1px solid var(--border);
}

.input-box {
  width: 100%; max-width: 880px;
  display: flex; align-items: flex-end; gap: 10px;
  background: #fff; border: 1.5px solid var(--border);
  border-radius: 18px; padding: 12px 12px 12px 20px;
  box-shadow: 0 2px 14px rgba(15,23,42,0.05);
  transition: border-color .15s, box-shadow .15s;
}
.input-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.10), 0 2px 14px rgba(15,23,42,0.05);
}

.input-box textarea {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font: inherit; font-size: 14px;
  line-height: 1.55; resize: none; max-height: 200px; overflow-y: auto;
}
.input-box textarea::placeholder { color: var(--text-light); }

#btn-send {
  width: 38px; height: 38px; flex-shrink: 0;
  background: var(--gradient); border: none; border-radius: 12px;
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 12px rgba(79,70,229,0.30);
  transition: opacity .15s, transform .12s;
}
#btn-send:disabled { opacity: 0.28; cursor: default; box-shadow: none; }
#btn-send:not(:disabled):hover { opacity: .9; transform: scale(1.06); }

.input-hint { font-size: 11.5px; color: var(--text-light); text-align: center; }

/* ─── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.22);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px; backdrop-filter: blur(5px);
}
.modal {
  background: #fff; border: 1px solid var(--border);
  border-radius: 22px; padding: 28px; width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.12);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer; width: 30px; height: 30px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-close:hover { background: var(--surface); }
.modal label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.modal input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--text); font: inherit; font-size: 13px;
  outline: none; transition: border-color .15s;
}
.modal input:focus { border-color: var(--primary); }

/* ─── Sidebar backdrop ────────────────────────────────────────────────── */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.22); z-index: 49;
}
.sidebar-backdrop.visible { display: block; }

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 50; transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 6px 0 32px rgba(0,0,0,0.14); }
  .btn-menu-mobile { display: flex; }
  #max-tokens, .topbar-balance { display: none; }
  .auth-card input, .modal input, .input-box textarea { font-size: 16px; }
  .mode-pills { gap: 2px; }
  .mode-pill { padding: 0 9px; font-size: 12px; }
  .auth-card { padding: 32px 24px 28px; }
  .input-zone { padding: 8px 12px max(12px, env(safe-area-inset-bottom)); }
  .msg-inner { padding: 0 14px; }
  .msg-actions { padding-left: calc(14px + 32px + 14px); }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-height: 85vh; overflow-y: auto; padding-bottom: max(28px, env(safe-area-inset-bottom)); }
  .chat-topbar { padding: 0 14px; gap: 10px; }
  .topbar-controls { gap: 7px; }
  .onboard-cards { grid-template-columns: 1fr; }
  .profile-dropdown { right: -4px; }
}

/* ─── Scrollbar global ────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
