/* ═══════════════════════════════════════════════════════
   CYBERCHAT — Premium Light UI
   cyberchat.in
   ChatGPT-inspired · Cybersecurity Edition
═══════════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────────── */
:root {
  /* Brand */
  --brand: #4f6ef7;
  --brand-dark: #3451d1;
  --brand-light: #7b93fb;
  --brand-subtle: #eef1fe;
  --brand-muted: #c7d0fc;

  /* Cyber Accent */
  --accent: #06b6d4;
  --accent-subtle: #ecfeff;

  /* Surfaces */
  --bg: #f5f7ff;
  --surface: #ffffff;
  --surface-2: #f0f2fa;
  --surface-3: #e8eaf8;

  /* Sidebar */
  --sidebar-bg: #ffffff;
  --sidebar-width: 262px;

  /* Text */
  --text-1: #0e1524;
  --text-2: #3d4663;
  --text-3: #7880a1;
  --text-4: #a8aec8;
  --text-inv: #ffffff;

  /* Borders */
  --border: #e3e7f5;
  --border-strong: #c8ceea;

  /* Status */
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06),0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08),0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.10),0 4px 8px rgba(0,0,0,.06);
  --shadow-brand: 0 4px 20px rgba(79,110,247,.28);

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 28px;
  --r-full: 9999px;

  /* Type */
  --font: 'Inter', system-ui, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Motion */
  --ease: cubic-bezier(.4,0,.2,1);
  --fast: 140ms var(--ease);
  --base: 240ms var(--ease);
  --slow: 380ms var(--ease);
}

/* ─── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  display: flex;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Sidebar ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  z-index: 200;
  transition: transform var(--base);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Logo row */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
}

.logo-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.025em;
  flex: 1;
}

.sidebar-close-btn {
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: all var(--fast);
}
.sidebar-close-btn:hover { background: var(--surface-2); color: var(--text-1); }

/* New Chat */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 12px 6px;
  padding: 9px 14px;
  background: var(--brand-subtle);
  color: var(--brand);
  border: 1px solid var(--brand-muted);
  border-radius: var(--r-md);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--fast);
  letter-spacing: 0.01em;
}
.new-chat-btn:hover {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  box-shadow: var(--shadow-brand);
  transform: translateY(-1px);
}
.new-chat-btn:active { transform: translateY(0); }

/* History */
.history-zone {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}
.history-zone::-webkit-scrollbar { width: 3px; }
.history-zone::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); }

.history-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-4);
  padding: 8px 8px 4px;
}

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

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  color: var(--text-2);
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: all var(--fast);
  max-width: 100%;
}
.history-item .hi-icon { flex-shrink: 0; color: var(--text-4); }
.history-item .hi-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item:hover { background: var(--surface-2); color: var(--text-1); }
.history-item.active { background: var(--brand-subtle); color: var(--brand); font-weight: 500; }
.history-item.active .hi-icon { color: var(--brand-light); }

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 12px;
  color: var(--text-4);
  text-align: center;
  font-size: 0.78rem;
  opacity: 0.8;
}

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

/* Token meter */
.token-meter {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
}

.token-meter-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
}

.token-meter-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
}

.token-meter-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-2);
  font-family: var(--font-mono);
}

.token-bar-track {
  width: 100%;
  height: 5px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.token-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: var(--r-full);
  transition: width .5s var(--ease);
}

.token-bar-fill.warning { background: linear-gradient(90deg, var(--amber), #f97316); }
.token-bar-fill.danger  { background: linear-gradient(90deg, var(--red), #dc2626); }

.upgrade-link {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
  transition: opacity var(--fast);
  text-align: left;
  padding: 0;
  width: 100%;
}
.upgrade-link:hover { opacity: .75; }

/* Sidebar actions row (settings) */
.sidebar-bottom-actions {
  display: flex;
  align-items: center;
}

.settings-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  transition: all var(--fast);
  width: 100%;
  text-align: left;
}
.settings-btn:hover { background: var(--surface-2); color: var(--text-1); }

/* User profile */
.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-plan {
  font-size: 0.68rem;
  color: var(--text-4);
  font-weight: 500;
}

.user-plan.plan-basic { color: var(--brand); }
.user-plan.plan-pro   { color: #7c3aed; font-weight: 700; }

.logout-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-4);
  transition: all var(--fast);
  flex-shrink: 0;
}
.logout-btn:hover { background: #fff0f0; color: var(--red); }

/* ─── Upgrade Modal ─────────────────────────────────── */
.upgrade-modal { max-width: 640px; }

.upgrade-subtitle {
  font-size: 0.88rem;
  color: var(--text-3);
  margin-bottom: 20px;
  line-height: 1.55;
}

.plan-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.plan-card {
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  background: var(--surface);
  transition: border-color var(--fast);
}

.plan-card-highlight {
  border-color: var(--brand);
  background: var(--brand-subtle);
  box-shadow: 0 0 0 3px rgba(79,110,247,.1);
}

.plan-popular-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--r-full);
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.plan-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.plan-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
}

.plan-price {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-1);
}

.plan-price small {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-3);
}

.plan-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.plan-features li {
  font-size: 0.76rem;
  color: var(--text-2);
  line-height: 1.4;
}

.plan-current-badge {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-4);
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.plan-cta-btn {
  width: 100%;
  padding: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--fast);
  box-shadow: var(--shadow-brand);
}
.plan-cta-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(79,110,247,.35); }

.plan-cta-pro {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  box-shadow: 0 4px 16px rgba(124,58,237,.3);
}
.plan-cta-pro:hover { box-shadow: 0 8px 20px rgba(124,58,237,.4); }

.upgrade-note {
  font-size: 0.74rem;
  color: var(--text-4);
  text-align: center;
  line-height: 1.5;
}

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



/* ─── Mobile Overlay ────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 21, 36, 0.35);
  z-index: 150;
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity var(--base);
}
.overlay.active { display: block; opacity: 1; }

/* ─── Main Area ──────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* ─── Topbar ─────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
  gap: 12px;
}

.menu-btn {
  width: 34px;
  height: 34px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
  flex-shrink: 0;
  transition: all var(--fast);
}
.menu-btn:hover { background: var(--surface-2); color: var(--text-1); }

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.topbar-logo-mark {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.topbar-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* Model pill */
.model-pill-wrap { position: relative; }

.model-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--fast);
  white-space: nowrap;
}
.model-pill:hover { background: var(--brand-subtle); border-color: var(--brand-muted); color: var(--brand); }

.model-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  overflow: hidden;
  animation: popIn var(--fast) both;
}
.model-dropdown.open { display: block; }

@keyframes popIn {
  from { opacity:0; transform: translateY(-6px) scale(.98); }
  to { opacity:1; transform: translateY(0) scale(1); }
}

.model-dropdown-header {
  padding: 11px 14px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-4);
}

.model-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background var(--fast);
  gap: 10px;
}
.model-option:hover { background: var(--surface-2); }
.model-option.active { background: var(--brand-subtle); }
.model-option-name { font-size: 0.83rem; font-weight: 500; color: var(--text-1); }
.model-option.active .model-option-name { color: var(--brand); font-weight: 600; }
.model-option-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-4);
  background: var(--surface-3);
  padding: 2px 7px;
  border-radius: var(--r-full);
  white-space: nowrap;
}
.model-option.active .model-option-tag { background: var(--brand-muted); color: var(--brand-dark); }

/* Topbar right */
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.status-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 4px 10px;
  font-size: 0.71rem;
  font-weight: 600;
  color: var(--text-3);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: breathe 2.5s infinite;
}
.status-dot.loading { background: var(--amber); animation: flicker .7s infinite; }
.status-dot.error { background: var(--red); animation: none; }

@keyframes breathe { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(.8)} }
@keyframes flicker { 0%,100%{opacity:1} 50%{opacity:.3} }

.icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: all var(--fast);
}
.icon-btn:hover { background: #fff0f0; color: var(--red); }

/* ─── Chat Scroll ─────────────────────────────────────── */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px 12px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}
.chat-scroll::-webkit-scrollbar { width: 5px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); }

/* ─── Welcome Screen ──────────────────────────────────── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  text-align: center;
  gap: 0;
  animation: fadeUp var(--slow) both;
  position: relative;
}

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

.welcome-glow {
  position: absolute;
  width: 500px;
  height: 300px;
  background: radial-gradient(ellipse at center, rgba(79,110,247,.1) 0%, transparent 70%);
  pointer-events: none;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
}

.welcome-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--brand-subtle), #dde5fe);
  border-radius: var(--r-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  margin-bottom: 22px;
  border: 1.5px solid var(--brand-muted);
  box-shadow: 0 8px 30px rgba(79,110,247,.14);
}

.welcome-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 12px;
}
.welcome-title span {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-sub {
  font-size: 0.93rem;
  color: var(--text-3);
  max-width: 480px;
  line-height: 1.65;
  margin-bottom: 36px;
}

/* Prompt cards */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 720px;
  width: 100%;
}

.prompt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: all var(--fast);
  box-shadow: var(--shadow-xs);
}
.prompt-card:hover {
  border-color: var(--brand-muted);
  background: var(--brand-subtle);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.prompt-icon { font-size: 1.3rem; line-height: 1; }
.prompt-card p { font-size: 0.78rem; font-weight: 500; color: var(--text-2); line-height: 1.4; }
.prompt-card:hover p { color: var(--brand); }

/* ─── Messages ────────────────────────────────────────── */
.messages {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.msg {
  display: flex;
  gap: 14px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  animation: msgIn 0.28s var(--ease) both;
}
.msg:last-child { border-bottom: none; }
.msg.user { flex-direction: row-reverse; }

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

/* Avatar */
.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  flex-shrink: 0;
  margin-top: 2px;
}
.msg.user .msg-avatar {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white;
}
.msg.assistant .msg-avatar {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
}

/* Content */
.msg-content { flex: 1; min-width: 0; }
.msg.user .msg-content { display: flex; flex-direction: column; align-items: flex-end; }

.msg-name {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text-3);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.msg-bubble {
  padding: 13px 17px;
  border-radius: var(--r-lg);
  font-size: 0.9rem;
  line-height: 1.72;
  max-width: 100%;
  word-break: break-word;
}

/* User bubble */
.msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  border-bottom-right-radius: 5px;
  box-shadow: var(--shadow-brand);
  max-width: 85%;
}

/* Assistant bubble */
.msg.assistant .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  color: var(--text-1);
  box-shadow: var(--shadow-xs);
}

/* Markdown in assistant */
.msg.assistant .msg-bubble h1,
.msg.assistant .msg-bubble h2,
.msg.assistant .msg-bubble h3 {
  font-family: var(--font-display);
  color: var(--text-1);
  margin: 16px 0 6px;
}
.msg.assistant .msg-bubble h1 { font-size: 1.1rem; font-weight: 700; }
.msg.assistant .msg-bubble h2 { font-size: 1rem; font-weight: 600; }
.msg.assistant .msg-bubble h3 { font-size: 0.92rem; font-weight: 600; }

.msg.assistant .msg-bubble p { margin-bottom: 10px; }
.msg.assistant .msg-bubble p:last-child { margin-bottom: 0; }

.msg.assistant .msg-bubble ul,
.msg.assistant .msg-bubble ol {
  margin: 8px 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.msg.assistant .msg-bubble li { font-size: 0.88rem; line-height: 1.62; }

.msg.assistant .msg-bubble strong { font-weight: 700; color: var(--text-1); }
.msg.assistant .msg-bubble em { font-style: italic; color: var(--text-2); }

.msg.assistant .msg-bubble code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--brand-dark);
}

.msg.assistant .msg-bubble pre {
  background: #0e1524;
  color: #e2e8f0;
  padding: 16px;
  border-radius: var(--r-md);
  overflow-x: auto;
  margin: 12px 0;
  font-family: var(--font-mono);
  font-size: 0.81rem;
  line-height: 1.65;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.3);
}
.msg.assistant .msg-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.msg.assistant .msg-bubble blockquote {
  border-left: 3px solid var(--brand);
  padding: 6px 12px;
  margin: 10px 0;
  color: var(--text-2);
  font-style: italic;
  background: var(--brand-subtle);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* Message footer */
.msg-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}
.msg.user .msg-footer { justify-content: flex-end; }

.msg-time { font-size: 0.67rem; color: var(--text-4); }

.copy-btn {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--fast);
}
.copy-btn:hover { background: var(--brand-subtle); color: var(--brand); border-color: var(--brand-muted); }
.copy-btn.copied { background: #dcfce7; color: var(--green); border-color: #a7f3d0; }

/* Typing indicator */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  border-bottom-left-radius: 5px;
  width: fit-content;
  box-shadow: var(--shadow-xs);
}
.t-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  animation: typeBounce 1.1s infinite;
}
.t-dot:nth-child(2) { animation-delay: .18s; }
.t-dot:nth-child(3) { animation-delay: .36s; }
@keyframes typeBounce {
  0%,80%,100% { transform:translateY(0); opacity:.4; }
  40% { transform:translateY(-6px); opacity:1; }
}

/* ─── Input Dock ──────────────────────────────────────── */
.input-dock {
  padding: 14px 24px 18px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-box {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 10px 12px 10px 18px;
  box-shadow: var(--shadow-md);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.input-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79,110,247,.12), var(--shadow-md);
}

.input-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.92rem;
  color: var(--text-1);
  resize: none;
  min-height: 26px;
  max-height: 180px;
  line-height: 1.55;
  overflow-y: auto;
}
.input-textarea::placeholder { color: var(--text-4); }
.input-textarea::-webkit-scrollbar { width: 4px; }
.input-textarea::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); }

.send-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--fast);
  box-shadow: var(--shadow-brand);
  flex-shrink: 0;
}
.send-btn:disabled {
  background: var(--surface-3);
  color: var(--text-4);
  box-shadow: none;
  cursor: not-allowed;
}
.send-btn:not(:disabled):hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 8px 24px rgba(79,110,247,.38);
}
.send-btn:not(:disabled):active { transform: none; }

.input-note {
  max-width: 760px;
  margin: 8px auto 0;
  text-align: center;
  font-size: 0.69rem;
  color: var(--text-4);
}

/* ─── Settings Modal ──────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 21, 36, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
  animation: fadeIn var(--fast) both;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.modal {
  background: var(--surface);
  border-radius: var(--r-2xl);
  width: calc(100% - 48px);
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: popIn var(--base) both;
  overflow: hidden;
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-1);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: all var(--fast);
}
.modal-close:hover { background: var(--surface-2); color: var(--text-1); }

.modal-body { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 0; }

.modal-section { padding: 16px 0; }
.modal-section:first-child { padding-top: 0; }

.modal-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 4px;
}
.modal-section-desc {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-bottom: 12px;
  line-height: 1.5;
}

.modal-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: 0.85rem;
  color: var(--text-1);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237880a1' stroke-width='2.5' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  transition: border-color var(--fast);
}
.modal-select:focus { border-color: var(--brand); outline: none; }

.modal-divider { height: 1px; background: var(--border); margin: 4px 0; }

.modal-about { display: flex; flex-direction: column; gap: 8px; }
.about-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.about-row span:first-child { color: var(--text-3); }
.about-row span:last-child { font-weight: 600; color: var(--text-1); }

.danger-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--red);
  cursor: pointer;
  transition: all var(--fast);
}
.danger-btn:hover { background: var(--red); color: white; border-color: var(--red); }

/* ─── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--text-1);
  color: white;
  padding: 10px 20px;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all var(--base);
  z-index: 999;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--brand); }

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 900px) {
  .prompt-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: flex; }
  .menu-btn { display: flex; }
  .chat-scroll { padding: 16px 12px 8px; }
  .input-dock { padding: 10px 12px 14px; }
  .welcome-title { font-size: 1.6rem; }
  .prompt-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .msg { gap: 10px; padding: 16px 0; }
}

@media (max-width: 500px) {
  .prompt-grid { grid-template-columns: 1fr; }
  .status-chip { display: none; }
  .topbar-name { font-size: 0.92rem; }
}

/* ─── Utility animation ───────────────────────────────── */
.fade-in { animation: fadeUp var(--base) both; }

/* ─── Edit Message ───────────────────────────────────── */
.edit-msg-btn {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255,255,255,.5);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  transition: all var(--fast);
  cursor: pointer;
  background: rgba(255,255,255,.08);
}
.edit-msg-btn:hover {
  background: rgba(255,255,255,.18);
  color: rgba(255,255,255,.9);
}

.edit-textarea {
  width: 100%;
  min-height: 72px;
  background: rgba(255,255,255,.1);
  border: 1.5px solid rgba(255,255,255,.3);
  border-radius: var(--r-sm);
  color: white;
  font-size: 0.9rem;
  font-family: var(--font);
  padding: 10px 12px;
  resize: none;
  outline: none;
  line-height: 1.6;
  transition: border-color var(--fast);
  box-sizing: border-box;
}
.edit-textarea:focus { border-color: rgba(255,255,255,.6); }

.edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.edit-send-btn {
  padding: 6px 16px;
  background: rgba(255,255,255,.9);
  color: #1a1f3c;
  border-radius: var(--r-sm);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--fast);
}
.edit-send-btn:hover { background: white; transform: translateY(-1px); }

.edit-cancel-btn {
  padding: 6px 12px;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.7);
  border-radius: var(--r-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--fast);
}
.edit-cancel-btn:hover { background: rgba(255,255,255,.22); }

