/* ═══════════════════════════════════════════
   AXIOM AI — Main Stylesheet
   styles/main.css
═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Syne:wght@400;500;600;700;800&family=Fira+Code:wght@300;400;500&display=swap');

/* ── CSS VARIABLES / THEMES ── */
:root,
[data-theme="dark"] {
  --bg:           #050810;
  --bg2:          #080c18;
  --surface:      #0b0f1a;
  --panel:        #0f1525;
  --panel2:       #141b30;
  --border:       rgba(99,179,237,0.10);
  --border2:      rgba(99,179,237,0.18);
  --accent:       #63b3ed;
  --accent-rgb:   99,179,237;
  --accent2:      #76e4b0;
  --accent2-rgb:  118,228,176;
  --accent3:      #f6ad55;
  --danger:       #fc8181;
  --warn:         #f6e05e;
  --text:         #e2e8f0;
  --text2:        #a0aec0;
  --muted:        #4a5568;
  --muted2:       #2d3748;
  --shadow:       0 8px 32px rgba(0,0,0,0.6);
  --glow:         0 0 40px rgba(99,179,237,0.12);
  --glow-strong:  0 0 60px rgba(99,179,237,0.25);
}

[data-theme="midnight"] {
  --bg:           #000008;
  --bg2:          #05050f;
  --surface:      #08080f;
  --panel:        #0c0c18;
  --panel2:       #101020;
  --border:       rgba(150,120,255,0.10);
  --border2:      rgba(150,120,255,0.20);
  --accent:       #9678ff;
  --accent-rgb:   150,120,255;
  --accent2:      #c084fc;
  --accent2-rgb:  192,132,252;
  --accent3:      #67e8f9;
  --danger:       #f87171;
  --text:         #e2e8f0;
  --text2:        #94a3b8;
  --muted:        #475569;
  --muted2:       #1e293b;
  --glow:         0 0 40px rgba(150,120,255,0.12);
}

[data-theme="forest"] {
  --bg:           #030a05;
  --bg2:          #050f07;
  --surface:      #071209;
  --panel:        #0a1a0d;
  --panel2:       #0d2010;
  --border:       rgba(52,211,153,0.10);
  --border2:      rgba(52,211,153,0.20);
  --accent:       #34d399;
  --accent-rgb:   52,211,153;
  --accent2:      #86efac;
  --accent2-rgb:  134,239,172;
  --accent3:      #fde68a;
  --danger:       #f87171;
  --text:         #ecfdf5;
  --text2:        #a7f3d0;
  --muted:        #374151;
  --muted2:       #1f2937;
  --glow:         0 0 40px rgba(52,211,153,0.12);
}

[data-theme="ember"] {
  --bg:           #0c0500;
  --bg2:          #120700;
  --surface:      #150800;
  --panel:        #1c0c00;
  --panel2:       #231000;
  --border:       rgba(251,146,60,0.10);
  --border2:      rgba(251,146,60,0.20);
  --accent:       #fb923c;
  --accent-rgb:   251,146,60;
  --accent2:      #fcd34d;
  --accent2-rgb:  252,211,77;
  --accent3:      #f472b6;
  --danger:       #ef4444;
  --text:         #fef3c7;
  --text2:        #fde68a;
  --muted:        #4b3621;
  --muted2:       #2c1f12;
  --glow:         0 0 40px rgba(251,146,60,0.12);
}

[data-theme="light"] {
  --bg:           #f0f4f8;
  --bg2:          #e8eef5;
  --surface:      #ffffff;
  --panel:        #f7f9fc;
  --panel2:       #edf2f7;
  --border:       rgba(49,130,206,0.15);
  --border2:      rgba(49,130,206,0.30);
  --accent:       #2b6cb0;
  --accent-rgb:   43,108,176;
  --accent2:      #276749;
  --accent2-rgb:  39,103,73;
  --accent3:      #c05621;
  --danger:       #c53030;
  --text:         #1a202c;
  --text2:        #4a5568;
  --muted:        #a0aec0;
  --muted2:       #e2e8f0;
  --glow:         0 4px 20px rgba(43,108,176,0.10);
}

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

html { height: 100%; scroll-behavior: smooth; }

body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  transition: background 0.4s, color 0.4s;
}

/* Animated background */
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(var(--accent-rgb),0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb),0.025) 1px, transparent 1px);
  background-size: 52px 52px;
}

.bg-glow {
  position: fixed; pointer-events: none; z-index: 0;
  border-radius: 50%;
  filter: blur(80px);
  animation: bgDrift 25s ease-in-out infinite alternate;
}

.bg-glow-1 {
  width: 600px; height: 400px;
  top: -100px; left: -100px;
  background: radial-gradient(ellipse, rgba(var(--accent-rgb),0.06) 0%, transparent 70%);
}

.bg-glow-2 {
  width: 400px; height: 400px;
  bottom: -50px; right: -50px;
  background: radial-gradient(ellipse, rgba(var(--accent2-rgb),0.05) 0%, transparent 70%);
  animation-delay: -12s;
}

@keyframes bgDrift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(5%, 8%) scale(1.1); }
}

/* ── LAYOUT ── */
#app {
  position: relative; z-index: 1;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
#sidebar {
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.3s cubic-bezier(.4,0,.2,1), opacity 0.3s;
  overflow: hidden;
}

#sidebar.collapsed {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.logo-mark {
  width: 34px; height: 34px;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  display: grid; place-items: center;
  box-shadow: 0 0 20px rgba(var(--accent-rgb),0.3), inset 0 0 10px rgba(var(--accent-rgb),0.05);
  position: relative; overflow: hidden; flex-shrink: 0;
}

.logo-mark::before {
  content: '';
  position: absolute; inset: -50%;
  background: conic-gradient(transparent, rgba(var(--accent-rgb),0.5) 90deg, transparent 180deg);
  animation: spinGlow 4s linear infinite;
}

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

.logo-mark svg { position: relative; z-index: 1; }

.logo-name { font-size: 18px; font-weight: 800; letter-spacing: 0.15em; color: var(--accent); }
.logo-ver  { font-family: 'Fira Code', monospace; font-size: 9px; color: var(--muted); letter-spacing: 0.15em; }

.btn-new-chat {
  width: 100%;
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.15), rgba(var(--accent-rgb),0.05));
  border: 1px solid rgba(var(--accent-rgb),0.3);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--accent);
  font-family: 'Syne', sans-serif;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}

.btn-new-chat:hover {
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.25), rgba(var(--accent-rgb),0.1));
  box-shadow: 0 0 20px rgba(var(--accent-rgb),0.2);
  transform: translateY(-1px);
}

.sidebar-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color 0.2s;
}

.search-input-wrap:focus-within { border-color: var(--border2); }

.search-input-wrap svg { color: var(--muted); flex-shrink: 0; }

.search-input-wrap input {
  background: none; border: none; outline: none;
  color: var(--text); font-family: 'Syne', sans-serif; font-size: 12px;
  width: 100%;
}

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

.sidebar-history {
  flex: 1; overflow-y: auto;
  padding: 8px 0;
}

.sidebar-history::-webkit-scrollbar { width: 3px; }
.sidebar-history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.history-section-label {
  font-family: 'Fira Code', monospace;
  font-size: 9px; letter-spacing: 0.15em;
  color: var(--muted); padding: 10px 16px 4px;
}

.history-item {
  display: flex; align-items: center;
  gap: 8px; padding: 8px 16px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s;
  border-left: 2px solid transparent;
  position: relative;
}

.history-item:hover { background: var(--panel); }
.history-item.active {
  background: rgba(var(--accent-rgb),0.08);
  border-left-color: var(--accent);
}

.history-item-icon { font-size: 13px; flex-shrink: 0; }

.history-item-body { flex: 1; min-width: 0; }
.history-item-title {
  font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text2);
}

.history-item.active .history-item-title { color: var(--text); }
.history-item-time { font-family: 'Fira Code', monospace; font-size: 9px; color: var(--muted); }

.history-item-del {
  opacity: 0; background: none; border: none;
  color: var(--muted); cursor: pointer; padding: 2px; border-radius: 4px;
  transition: all 0.15s;
}

.history-item:hover .history-item-del { opacity: 1; }
.history-item-del:hover { color: var(--danger); background: rgba(252,129,129,0.1); }

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

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

.sf-btn {
  flex: 1; padding: 8px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; color: var(--muted); cursor: pointer;
  font-size: 11px; font-family: 'Syne', sans-serif; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: all 0.2s; letter-spacing: 0.03em;
}

.sf-btn:hover { color: var(--text); border-color: var(--border2); background: var(--panel2); }

/* ── MAIN AREA ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── TOPBAR ── */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.topbar-toggle {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent; color: var(--muted);
  display: grid; place-items: center;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}

.topbar-toggle:hover { color: var(--text); border-color: var(--border2); }

.topbar-title {
  font-size: 13px; font-weight: 600;
  color: var(--text2); flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

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

.status-pill {
  display: flex; align-items: center; gap: 6px;
  background: rgba(var(--accent2-rgb),0.08);
  border: 1px solid rgba(var(--accent2-rgb),0.2);
  border-radius: 100px; padding: 5px 12px;
  font-family: 'Fira Code', monospace;
  font-size: 10px; color: var(--accent2);
  transition: all 0.3s;
}

.status-pill.loading {
  background: rgba(var(--accent-rgb),0.08);
  border-color: rgba(var(--accent-rgb),0.2);
  color: var(--accent);
}

.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 6px var(--accent2);
  animation: pulseDot 2s ease-in-out infinite;
}

.status-pill.loading .status-dot {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: spinDot 0.8s linear infinite;
}

@keyframes pulseDot { 0%,100%{opacity:1} 50%{opacity:.3} }
@keyframes spinDot  { to { transform: rotate(360deg); } }

.model-selector {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 28px 6px 10px;
  color: var(--text2); font-family: 'Fira Code', monospace; font-size: 10px;
  cursor: pointer; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  transition: border-color 0.2s;
}

.model-selector:focus { border-color: var(--border2); }
.model-selector option { background: var(--surface); font-family: 'Fira Code', monospace; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); display: grid; place-items: center;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}

.icon-btn:hover { color: var(--text); border-color: var(--border2); background: var(--panel); }
.icon-btn.active { color: var(--accent); border-color: rgba(var(--accent-rgb),0.3); background: rgba(var(--accent-rgb),0.08); }

/* ── CHAT AREA ── */
#chat-scroll {
  flex: 1; overflow-y: auto;
  padding: 24px 20px;
  display: flex; flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}

#chat-scroll::-webkit-scrollbar { width: 4px; }
#chat-scroll::-webkit-scrollbar-track { background: transparent; }
#chat-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── EMPTY STATE ── */
#empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; gap: 28px; padding: 40px 20px; text-align: center;
}

.empty-orb {
  width: 90px; height: 90px;
  border: 1px solid var(--border);
  border-radius: 24px;
  display: grid; place-items: center;
  background: var(--panel);
  box-shadow: var(--glow);
  font-size: 42px;
  animation: orbFloat 5s ease-in-out infinite;
  position: relative;
}

.empty-orb::before {
  content: '';
  position: absolute; inset: -1px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.3), transparent 60%);
  pointer-events: none;
}

@keyframes orbFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }

.empty-title { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.empty-sub   { color: var(--text2); font-size: 13px; max-width: 380px; line-height: 1.7; }

.starters-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; max-width: 560px; width: 100%;
}

.starter-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
  cursor: pointer; text-align: left;
  transition: all 0.2s;
}

.starter-card:hover {
  border-color: var(--border2);
  background: var(--panel2);
  transform: translateY(-2px);
  box-shadow: var(--glow);
}

.starter-card-icon { font-size: 18px; margin-bottom: 6px; }
.starter-card-title { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.starter-card-desc  { font-size: 11px; color: var(--muted); line-height: 1.4; }

/* ── MESSAGES ── */
.msg {
  display: flex; gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  animation: msgIn 0.3s cubic-bezier(.4,0,.2,1) both;
  max-width: 100%;
}

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

.msg.user {
  background: rgba(var(--accent-rgb),0.06);
  border: 1px solid rgba(var(--accent-rgb),0.12);
  flex-direction: row-reverse;
}

.msg.assistant {
  background: var(--panel);
  border: 1px solid var(--border);
}

.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0; font-size: 13px; font-weight: 700;
}

.msg.user .msg-avatar {
  background: rgba(var(--accent-rgb),0.15);
  border: 1px solid rgba(var(--accent-rgb),0.3);
  color: var(--accent);
  font-family: 'Fira Code', monospace;
}

.msg.assistant .msg-avatar {
  background: rgba(var(--accent2-rgb),0.1);
  border: 1px solid rgba(var(--accent2-rgb),0.25);
  color: var(--accent2);
}

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

.msg-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}

.msg.user .msg-meta { flex-direction: row-reverse; }

.msg-role { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; }
.msg.user      .msg-role { color: var(--accent); }
.msg.assistant .msg-role { color: var(--accent2); }

.msg-time {
  font-family: 'Fira Code', monospace;
  font-size: 9px; color: var(--muted);
}

.msg-actions {
  margin-left: auto; display: flex; gap: 4px;
  opacity: 0; transition: opacity 0.2s;
}

.msg.user .msg-actions { margin-left: 0; margin-right: auto; }
.msg:hover .msg-actions { opacity: 1; }

.msg-action-btn {
  width: 22px; height: 22px; border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  display: grid; place-items: center;
  cursor: pointer; transition: all 0.15s; font-size: 10px;
}

.msg-action-btn:hover { color: var(--text); border-color: var(--border2); }

.msg-content {
  font-size: 14px; line-height: 1.8;
  color: var(--text);
  word-break: break-word;
}

.msg.user .msg-content { text-align: right; }

/* Markdown rendering */
.msg-content h1 { font-size: 20px; font-weight: 800; margin: 12px 0 8px; color: var(--accent); }
.msg-content h2 { font-size: 17px; font-weight: 700; margin: 10px 0 6px; color: var(--accent); }
.msg-content h3 { font-size: 14px; font-weight: 700; margin: 8px 0 4px; color: var(--text); letter-spacing: 0.05em; }
.msg-content p  { margin-bottom: 10px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { font-weight: 700; color: var(--text); }
.msg-content em { font-style: italic; color: var(--text2); }
.msg-content ul, .msg-content ol { padding-left: 20px; margin-bottom: 10px; }
.msg-content li { margin-bottom: 4px; }
.msg-content a  { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.msg-content code {
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border2);
  border-radius: 4px; padding: 1px 6px;
  color: var(--accent3);
}

.msg-content pre {
  background: #000;
  border: 1px solid var(--border2);
  border-radius: 12px;
  overflow: hidden; margin: 12px 0;
  position: relative;
}

.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border);
}

.code-lang {
  font-family: 'Fira Code', monospace;
  font-size: 10px; color: var(--muted);
  letter-spacing: 0.1em;
}

.code-copy {
  font-family: 'Fira Code', monospace;
  font-size: 9px; color: var(--muted);
  background: none; border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 8px;
  cursor: pointer; transition: all 0.2s;
}

.code-copy:hover { color: var(--accent); border-color: rgba(var(--accent-rgb),0.3); }

.msg-content pre code {
  display: block; padding: 16px;
  background: none; border: none; border-radius: 0;
  color: var(--accent2); font-size: 12.5px;
  line-height: 1.7; overflow-x: auto;
  padding-top: 0;
}

.msg-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  background: rgba(var(--accent-rgb),0.05);
  border-radius: 0 8px 8px 0;
  margin: 10px 0; color: var(--text2);
}

.msg-content table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.msg-content th, .msg-content td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; }
.msg-content th { background: var(--panel2); font-weight: 700; color: var(--accent); }
.msg-content tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

/* Stats bar */
.msg-stats {
  display: flex; gap: 14px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}

.stat-item {
  display: flex; align-items: center; gap: 5px;
  font-family: 'Fira Code', monospace; font-size: 9px; color: var(--muted);
}

.stat-item span { color: var(--accent2); }

/* ── THINKING ── */
.thinking-msg {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px;
  display: flex; gap: 12px;
  animation: msgIn 0.3s ease both;
}

.thinking-body { flex: 1; }

.thinking-label {
  font-family: 'Fira Code', monospace; font-size: 9px;
  color: var(--accent2); letter-spacing: 0.15em; margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}

.thinking-progress {
  height: 2px; background: rgba(var(--accent2-rgb),0.1);
  border-radius: 2px; overflow: hidden;
}

.thinking-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent));
  animation: thinkFill 1.8s ease-in-out infinite;
}

@keyframes thinkFill {
  0%   { width: 0%; margin-left: 0%; }
  50%  { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

.typing-dots { display: flex; gap: 4px; align-items: center; margin-top: 8px; }
.typing-dot  {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent2); opacity: 0.4;
  animation: dotBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce { 0%,60%,100%{transform:translateY(0);opacity:0.4} 30%{transform:translateY(-5px);opacity:1} }

/* ── INPUT AREA ── */
#input-area {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.input-outer {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-outer:focus-within {
  border-color: rgba(var(--accent-rgb),0.3);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.07);
}

.input-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.toolbar-btn {
  padding: 4px 8px;
  background: none; border: 1px solid transparent;
  border-radius: 6px; color: var(--muted);
  font-family: 'Fira Code', monospace; font-size: 10px;
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; gap: 4px;
}

.toolbar-btn:hover {
  color: var(--text); border-color: var(--border);
  background: var(--panel2);
}

.toolbar-sep { width: 1px; height: 16px; background: var(--border); margin: 0 2px; }

.input-row {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 12px;
}

#msg-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-family: 'Syne', sans-serif;
  font-size: 14px; line-height: 1.6;
  resize: none; max-height: 200px; min-height: 24px;
}

#msg-input::placeholder { color: var(--muted); }

.send-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid rgba(var(--accent-rgb),0.35);
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.2), rgba(var(--accent-rgb),0.05));
  color: var(--accent);
  display: grid; place-items: center;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.35), rgba(var(--accent-rgb),0.15));
  box-shadow: 0 0 20px rgba(var(--accent-rgb),0.3);
  transform: scale(1.05);
}

.send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

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

.input-hint { font-family: 'Fira Code', monospace; font-size: 9px; color: var(--muted); }
.char-count { font-family: 'Fira Code', monospace; font-size: 9px; color: var(--muted); }

/* ── SETTINGS MODAL ── */
#settings-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}

#settings-modal.open { opacity: 1; pointer-events: all; }

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  width: min(600px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 40px 80px rgba(0,0,0,0.6);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
}

#settings-modal.open .modal-panel { transform: translateY(0) scale(1); }

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

.modal-title { font-size: 16px; font-weight: 800; letter-spacing: 0.05em; }
.modal-close {
  width: 28px; height: 28px; border-radius: 7px;
  border: 1px solid var(--border);
  background: none; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; transition: all 0.2s;
}
.modal-close:hover { color: var(--text); border-color: var(--border2); }

.modal-body { overflow-y: auto; flex: 1; }
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.settings-tabs {
  display: flex; gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
}

.settings-tab {
  padding: 12px 16px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-family: 'Fira Code', monospace;
  font-size: 10px; letter-spacing: 0.1em;
  cursor: pointer; transition: all 0.2s;
  margin-bottom: -1px;
}

.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-tab:hover:not(.active) { color: var(--text2); }

.tab-pane { display: none; padding: 24px; }
.tab-pane.active { display: block; }

.setting-group { margin-bottom: 28px; }

.setting-group-title {
  font-family: 'Fira Code', monospace;
  font-size: 9px; letter-spacing: 0.2em;
  color: var(--accent); margin-bottom: 14px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

.setting-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; padding: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px;
}

.setting-info { flex: 1; }
.setting-label { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.setting-desc  { font-size: 11px; color: var(--muted); line-height: 1.4; }

.setting-control { flex-shrink: 0; }

/* Toggle switch */
.toggle {
  width: 42px; height: 24px;
  background: var(--muted2);
  border-radius: 100px;
  position: relative; cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.2s;
}

.toggle.on { background: rgba(var(--accent-rgb),0.3); border-color: rgba(var(--accent-rgb),0.4); }

.toggle-knob {
  width: 18px; height: 18px;
  background: var(--muted);
  border-radius: 50%; position: absolute;
  top: 2px; left: 2px;
  transition: all 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.toggle.on .toggle-knob { left: 20px; background: var(--accent); }

/* Select */
.setting-select {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 28px 7px 10px;
  color: var(--text); font-family: 'Fira Code', monospace; font-size: 11px;
  cursor: pointer; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  min-width: 130px;
}

.setting-select:focus { border-color: var(--border2); }
.setting-select option { background: var(--surface); }

/* Range slider */
.setting-range { width: 130px; }
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--muted2); border-radius: 2px; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb),0.5);
  cursor: pointer;
}

/* Text inputs in settings */
.setting-input {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px;
  color: var(--text); font-family: 'Fira Code', monospace; font-size: 11px;
  outline: none; width: 100%;
  transition: border-color 0.2s;
}
.setting-input:focus { border-color: var(--border2); }

.setting-textarea {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  color: var(--text); font-family: 'Fira Code', monospace; font-size: 11px;
  outline: none; width: 100%; resize: vertical;
  min-height: 100px; line-height: 1.6;
  transition: border-color 0.2s;
}
.setting-textarea:focus { border-color: var(--border2); }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-ghost {
  padding: 9px 18px;
  background: none; border: 1px solid var(--border);
  border-radius: 8px; color: var(--muted);
  font-family: 'Syne', sans-serif; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}

.btn-ghost:hover { color: var(--text); border-color: var(--border2); }

.btn-save {
  padding: 9px 20px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.25), rgba(var(--accent-rgb),0.1));
  border: 1px solid rgba(var(--accent-rgb),0.4);
  border-radius: 8px; color: var(--accent);
  font-family: 'Syne', sans-serif; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: all 0.2s; letter-spacing: 0.03em;
}

.btn-save:hover {
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.35), rgba(var(--accent-rgb),0.2));
  box-shadow: 0 0 16px rgba(var(--accent-rgb),0.2);
}

/* ── TOAST ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200; pointer-events: none;
}

.toast {
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: 10px; padding: 12px 16px;
  font-size: 13px; display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s cubic-bezier(.4,0,.2,1) both;
  max-width: 320px;
}

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

.toast.fadeout {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

.toast.success { border-color: rgba(var(--accent2-rgb),0.3); }
.toast.error   { border-color: rgba(252,129,129,0.3); color: var(--danger); }
.toast.info    { border-color: rgba(var(--accent-rgb),0.3); color: var(--accent); }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  #sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; }
  .starters-grid { grid-template-columns: 1fr; }
  .topbar-right .model-selector { display: none; }
}

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

/* ── UTILITY ── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); }
