:root {
  --bg:          #050507;
  --sidebar:     #08080B;
  --surface:     #0F0F13;
  --surface-2:   #141419;
  --border:      #1A1A22;
  --border-2:    #242430;
  --text:        #EAEAF0;
  --text-muted:  #707088;
  --text-dim:    #424252;
  --accent:      #C0152A;
  --accent-soft: rgba(192,21,42,0.09);
  --accent-glow: rgba(192,21,42,0.28);
  --accent-hi:   #E8203A;
  --danger:      #EF4444;
  --success:     #22C55E;
  --warning:     #F59E0B;
  --radius:      9px;
  --font-ui:     'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Anti-Lumen palette aliases (the shadow-realm inversion of navy+orange) */
  --primary:     #8b0000;          /* blood red */
  --ember:       #b5300c;          /* smouldering ember */
  --glow:        #6e2dab;          /* necrotic violet — used sparingly */
  --glow-soft:   rgba(110,45,171,0.18);
  --muted:       var(--text-muted);
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Ambient vignette — deep corner shadows */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(192,21,42,0.03) 0%, transparent 65%),
              radial-gradient(ellipse at 100% 100%, rgba(0,0,0,0.4) 0%, transparent 60%),
              radial-gradient(ellipse at 0% 100%,   rgba(0,0,0,0.4) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── App shell ───────────────────────────────────────────── */
.app { display: flex; height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: #0e0508;
  border: 1px solid rgba(192,21,42,0.35);
  box-shadow: 0 0 10px rgba(192,21,42,0.15), inset 0 0 8px rgba(192,21,42,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: var(--accent); flex-shrink: 0;
  letter-spacing: -0.5px;
}

.logo-text {
  font-size: 15px; font-weight: 700; color: var(--text);
  letter-spacing: 0.03em;
  text-shadow: 0 0 18px rgba(192,21,42,0.25);
}

.logo-tagline {
  font-size: 10px; color: var(--text-dim); letter-spacing: 0.08em;
  text-transform: uppercase; font-weight: 500; margin-top: 1px;
}

.sidebar-body { flex: 1; overflow-y: auto; padding: 8px 8px; display: flex; flex-direction: column; gap: 2px; }

.sidebar-section-label {
  padding: 10px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px;
  color: var(--text-muted); font-size: 13.5px; font-weight: 450;
  text-decoration: none; cursor: pointer;
  transition: background 0.12s, color 0.12s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  border-left: 2px solid var(--accent);
  padding-left: 8px;
  box-shadow: inset 1px 0 0 rgba(192,21,42,0.1);
}
.nav-item.active svg { opacity: 1; color: var(--accent); }

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

.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 7px;
  transition: background 0.12s; cursor: default;
}
.user-row:hover { background: var(--surface); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-2); display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 600;
  color: var(--text-muted); flex-shrink: 0; border: 1px solid var(--border-2);
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text); truncate; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sign-out {
  color: var(--text-dim); text-decoration: none; font-size: 12px;
  display: flex; align-items: center; gap: 4px; padding: 4px 0;
  transition: color 0.12s;
}
.sign-out:hover { color: var(--text-muted); }

/* ── Main area ───────────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  height: 49px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px;
  gap: 12px;
}

.topbar-title { font-size: 14px; font-weight: 500; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Page body ───────────────────────────────────────────── */
.page { flex: 1; overflow-y: auto; padding: 32px 24px; }
.page-narrow { max-width: 680px; margin: 0 auto; }
.page-wide { max-width: 900px; margin: 0 auto; }

.page-header { margin-bottom: 28px; }
.page-title { font-size: 18px; font-weight: 600; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-body { padding: 20px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

/* ── Inputs ──────────────────────────────────────────────── */
.input, .select {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--text);
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.input::placeholder { color: var(--text-dim); }
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(192,21,42,0.12);
}

label.field-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 7px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.12s; border: none; font-family: var(--font-ui);
  white-space: nowrap; text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(192,21,42,0.3);
}
.btn-primary:hover {
  background: var(--accent-hi);
  box-shadow: 0 0 18px rgba(232,32,58,0.4);
}
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border-2); }
.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { background: rgba(239,68,68,0.08); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-green { background: rgba(52,211,153,0.1); color: var(--success); border: 1px solid rgba(52,211,153,0.2); }
.badge-red   { background: rgba(239,68,68,0.1);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.2); }
.badge-yellow{ background: rgba(245,158,11,0.1); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.badge-blue  { background: var(--accent-soft);   color: var(--accent);  border: 1px solid var(--accent-glow); }

/* ── Table ───────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-muted); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.015); }
.table td .primary { color: var(--text); font-weight: 500; }
.table td .secondary { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; padding: 24px; width: 100%; max-width: 440px; box-shadow: 0 24px 64px rgba(0,0,0,0.5); }
.modal-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Chat layout ─────────────────────────────────────────── */
.chat-layout { display: flex; flex: 1; overflow: hidden; }

/* Conversation sidebar */
.conv-sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.conv-sidebar-header { padding: 12px 12px 8px; display: flex; align-items: center; gap: 8px; }
.conv-sidebar-header select { flex: 1; }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.conv-item {
  display: flex; align-items: start; gap: 0;
  padding: 9px 10px; border-radius: 7px;
  cursor: pointer; transition: background 0.1s;
  position: relative;
}
.conv-item:hover { background: var(--surface); }
.conv-item.active { background: var(--surface); }
.conv-item-body { flex: 1; min-width: 0; }
.conv-item-title { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 450; line-height: 1.4; }
.conv-item.active .conv-item-title { font-weight: 500; }
.conv-item-snippet { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.conv-del-btn {
  opacity: 0; flex-shrink: 0; color: var(--text-dim);
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  border-radius: 4px; transition: opacity 0.15s, color 0.15s; line-height: 1;
}
.conv-item:hover .conv-del-btn { opacity: 1; }
.conv-del-btn:hover { color: var(--danger); }

/* Chat main panel */
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

/* Messages */
.messages-area { flex: 1; overflow-y: auto; padding: 0 0 8px; }
.messages-inner { max-width: 720px; margin: 0 auto; padding: 24px 24px 0; }

.msg { display: flex; gap: 14px; padding: 8px 0; }
.msg + .msg { padding-top: 4px; }
.msg.msg-user { flex-direction: row-reverse; }

.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; margin-top: 2px;
}
.msg-avatar.ai-avatar  {
  background: rgba(192,21,42,0.07);
  color: var(--accent);
  border: 1px solid rgba(192,21,42,0.25);
  box-shadow: 0 0 8px rgba(192,21,42,0.12);
}
.msg-avatar.usr-avatar { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border-2); }

.msg-content { flex: 1; min-width: 0; max-width: 600px; }
.msg-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }
.msg.msg-user .msg-meta { justify-content: flex-end; }
.msg-meta .model-tag { color: var(--text-dim); font-size: 11px; }

.msg-body { font-size: 14px; line-height: 1.75; color: var(--text); }
.msg-body p { margin: 0.4em 0; }
.msg-body p:first-child { margin-top: 0; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body h1,.msg-body h2,.msg-body h3 { color: var(--text); font-weight: 600; margin: 1.2em 0 0.4em; }
.msg-body h1 { font-size: 1.2em; }
.msg-body h2 { font-size: 1.1em; }
.msg-body h3 { font-size: 1em; }
.msg-body ul,.msg-body ol { padding-left: 1.4em; margin: 0.4em 0; }
.msg-body li { margin: 0.2em 0; }
.msg-body pre { background: #0E0E12; border: 1px solid var(--border-2); border-radius: 8px; padding: 14px 16px; overflow-x: auto; margin: 0.8em 0; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; }
.msg-body code:not(pre code) { font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-2); color: #A78BFA; padding: 1px 5px; border-radius: 4px; }
.msg-body blockquote { border-left: 3px solid var(--border-2); padding-left: 14px; color: var(--text-muted); margin: 0.6em 0; }
.msg-body table { width: 100%; border-collapse: collapse; margin: 0.8em 0; font-size: 13px; }
.msg-body th { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--border-2); color: var(--text-muted); font-size: 12px; }
.msg-body td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.msg-body a { color: var(--accent); text-decoration: none; }
.msg-body a:hover { text-decoration: underline; }
.msg-body strong { color: var(--text); font-weight: 600; }
.msg-body hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }

/* User message: subtly distinguished */
.msg.msg-user .msg-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px 4px 12px 12px;
  padding: 10px 14px;
  display: inline-block;
  max-width: 100%;
}

/* Input bar */
.input-area {
  flex-shrink: 0;
  padding: 12px 24px 20px;
  background: var(--bg);
}
.input-inner {
  max-width: 720px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 10px 10px 10px 16px;
  display: flex; align-items: flex-end; gap: 8px;
  transition: border-color 0.15s;
}
.input-inner:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192,21,42,0.1), 0 0 20px rgba(192,21,42,0.06);
}

#msg-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--font-ui); font-size: 14px; color: var(--text);
  resize: none; line-height: 1.55; max-height: 180px; overflow-y: auto;
}
#msg-input::placeholder { color: var(--text-dim); }

.send-btn {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, box-shadow 0.12s;
  box-shadow: 0 0 10px rgba(192,21,42,0.35);
}
.send-btn:hover {
  background: var(--accent-hi);
  box-shadow: 0 0 18px rgba(232,32,58,0.5);
}
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Status bar */
.status-bar { text-align: center; font-size: 11.5px; color: var(--text-dim); font-family: var(--font-mono); padding: 3px 0 0; max-width: 720px; margin: 0 auto; }

/* Cursor blink for streaming */
.cursor {
  display: inline-block; width: 2px; height: 1em;
  background: var(--accent);
  border-radius: 1px; margin-left: 1px;
  animation: blink 0.9s step-end infinite;
  vertical-align: text-bottom;
  box-shadow: 0 0 6px rgba(192,21,42,0.6);
}
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }

/* Empty state */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--text-dim); padding: 40px;
}
.empty-state-icon { font-size: 32px; opacity: 0.3; margin-bottom: 4px; }
.empty-state p { font-size: 13px; text-align: center; }

/* Login page */
.login-shell { height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.login-shell .login-page { flex: 1; }
.login-page { min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 48px 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .mark {
  width: 48px; height: 48px; border-radius: 12px;
  background: #0a0204;
  border: 1px solid rgba(192,21,42,0.4);
  box-shadow: 0 0 20px rgba(192,21,42,0.2), inset 0 0 12px rgba(192,21,42,0.08);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900; color: var(--accent); margin-bottom: 16px;
  letter-spacing: -0.5px;
}
.login-logo h1 {
  font-size: 24px; font-weight: 800; color: var(--text);
  letter-spacing: 0.04em;
  text-shadow: 0 0 24px rgba(192,21,42,0.3);
}
.login-logo p { font-size: 12px; color: var(--text-dim); margin-top: 5px; letter-spacing: 0.02em; }
.login-form { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.login-form .field + .field { margin-top: 14px; }
.login-form .field:last-child { margin-top: 20px; }
.login-note { font-size: 12px; color: var(--text-dim); text-align: center; margin-top: 16px; }

/* Utilities */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.font-mono { font-family: var(--font-mono); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11.5px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden { display: none !important; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* model select in conv sidebar */
#model-select {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 10px; font-size: 12px; color: var(--text-muted);
  outline: none; cursor: pointer;
}
#model-select:focus { border-color: var(--accent); color: var(--text); }

/* link-style items */
a { color: inherit; text-decoration: none; }

/* ── Institutional header parody (the "anti-Lumen" letterhead) ─── */
.umbral-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px;
  background: linear-gradient(90deg, #050204 0%, #0c0307 60%, #050204 100%);
  border-bottom: 1px solid var(--border);
  font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--text-muted);
}
.umbral-block {
  width: 22px; height: 22px; border-radius: 3px;
  background: #000;
  border: 1px solid rgba(192,21,42,0.5);
  box-shadow: 0 0 8px rgba(192,21,42,0.25), inset 0 0 6px rgba(110,45,171,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 900; color: var(--accent);
  flex-shrink: 0; font-family: var(--font-ui);
}
.umbral-name { font-weight: 600; color: var(--text-muted); }
.umbral-spacer { flex: 1; }
.umbral-bar a {
  color: var(--text-dim); text-decoration: none;
  transition: color 0.12s, text-shadow 0.12s;
}
.umbral-bar a:hover { color: var(--accent); text-shadow: 0 0 8px rgba(192,21,42,0.4); }
.umbral-sep { color: var(--text-dim); opacity: 0.5; }

/* ── Footer parody (the dark CTAs where Lumen's orange ones were) ── */
.shadow-footer {
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent 0%, rgba(110,45,171,0.04) 100%);
  padding: 22px 24px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
}
.shadow-footer .cta-row { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; }
.shadow-footer .cta {
  display: inline-flex; align-items: center;
  padding: 7px 14px; border-radius: 7px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.03em;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-2);
  text-decoration: none;
  transition: all 0.14s;
}
.shadow-footer .cta:hover {
  color: var(--text);
  border-color: rgba(192,21,42,0.45);
  box-shadow: 0 0 14px rgba(192,21,42,0.18), inset 0 0 12px rgba(110,45,171,0.08);
}
.shadow-footer .footer-org {
  font-size: 11px; color: var(--text-dim); letter-spacing: 0.04em;
  text-align: right; line-height: 1.5;
}
.shadow-footer .footer-org .after-dark { color: var(--glow); }
