/* ============================================================
   Saint AI Platform — "Obsidian Luxe" Theme
   Deep surfaces, warm amber accent, glass morphism, grain texture
   Typography: Outfit (display) + DM Sans (body)
   ============================================================ */

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

:root {
  --bg-void:       #050507;
  --bg-deep:       #09090b;
  --bg-primary:    #0c0c0f;
  --bg-base:       #101014;
  --bg-elevated:   #16161b;
  --bg-surface:    #1c1c22;
  --bg-hover:      #22222a;
  --bg-active:     #2a2a33;

  --text-primary:  #e8e6e3;
  --text-secondary:#9a9590;
  --text-tertiary: #5c5750;
  --text-inverse:  #09090b;

  --accent:        #d4a853;
  --accent-hover:  #c49840;
  --accent-dim:    rgba(212,168,83,0.12);
  --accent-glow:   rgba(212,168,83,0.08);

  --success:       #4ade80;
  --success-bg:    rgba(74,222,128,0.08);
  --warning:       #fbbf24;
  --warning-bg:    rgba(251,191,36,0.08);
  --danger:        #f87171;
  --danger-bg:     rgba(248,113,113,0.08);
  --info:          #60a5fa;
  --info-bg:       rgba(96,165,250,0.08);

  --border:        rgba(255,255,255,0.04);
  --border-strong: rgba(255,255,255,0.08);
  --border-accent: rgba(212,168,83,0.2);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --sidebar-width: 272px;
  --navbar-height: 54px;

  --font-display: 'Outfit', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --mono: 'JetBrains Mono', monospace;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 24px rgba(212,168,83,0.1);

  --glass-bg: rgba(12,12,15,0.75);
  --glass-border: rgba(255,255,255,0.06);
  --glass-blur: blur(16px);

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.12s ease;
  --transition:      0.2s var(--ease-out-expo);
  --transition-slow:  0.4s var(--ease-out-expo);
}

/* ---------- reset ---------- */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-hover); }
p { color: var(--text-secondary); }
::selection { background: var(--accent); color: var(--text-inverse); }

/* ---------- typography ---------- */
h1 { font-family: var(--font-display); font-size: 1.85rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; }
h2 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; }

/* ---------- navbar ---------- */
.navbar {
  height: var(--navbar-height);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
}

.navbar .logo {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.04em;
  display: flex;
  align-items: center;
  gap: 9px;
}

.navbar .logo svg { width: 22px; height: 22px; }
.navbar .logo:hover { color: var(--text-primary); }
.nav-center { flex: 1; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.nav-right .nav-link {
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav-right .nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-right .nav-link.active { background: var(--accent-dim); color: var(--accent); }

/* ---------- user menu ---------- */
.user-menu { position: relative; margin-left: 10px; }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), #b8860b);
  color: var(--text-inverse);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 0.76rem; font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color var(--transition-fast), box-shadow var(--transition);
}

.user-avatar:hover { border-color: var(--accent); box-shadow: var(--shadow-glow); }

.user-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 224px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none; z-index: 200;
}

.user-dropdown.open { display: block; animation: fadeDown 0.2s var(--ease-out-expo); }

.user-dropdown .dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.user-dropdown .dropdown-header .name { font-family: var(--font-display); font-size: 0.9rem; font-weight: 600; }
.user-dropdown .dropdown-header .email { font-size: 0.74rem; color: var(--text-tertiary); margin-top: 2px; }

.user-dropdown a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  color: var(--text-secondary);
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.user-dropdown a:hover { background: var(--bg-hover); color: var(--text-primary); }
.user-dropdown a.danger { color: var(--danger); }
.user-dropdown a.danger:hover { background: var(--danger-bg); }
.user-dropdown a svg { width: 15px; height: 15px; opacity: 0.5; }

/* ---------- hamburger ---------- */
.hamburger {
  display: none; width: 36px; height: 36px;
  align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-secondary); cursor: pointer;
  border-radius: var(--radius-sm); margin-right: 8px;
}
.hamburger:hover { background: var(--bg-elevated); color: var(--text-primary); }
.hamburger svg { width: 20px; height: 20px; }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed; left: 0; top: var(--navbar-height); bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; z-index: 50;
  transition: transform var(--transition-slow);
}

.sidebar-header { padding: 14px 14px 10px; flex-shrink: 0; }

.new-chat-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px 16px;
  background: var(--accent); color: var(--text-inverse);
  border: none; border-radius: var(--radius-md);
  font-family: var(--font-display); font-size: 0.86rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}

.new-chat-btn:hover { background: var(--accent-hover); color: var(--text-inverse); transform: translateY(-1px); box-shadow: var(--shadow-glow); }

.sidebar-search { padding: 0 14px 12px; flex-shrink: 0; }

.sidebar-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 10px 8px 34px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 0.82rem;
  outline: none;
  transition: border-color var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%235c5750' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cline x1='9.5' y1='9.5' x2='13' y2='13'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
}

.sidebar-search input::placeholder { color: var(--text-tertiary); }
.sidebar-search input:focus { border-color: var(--accent); }

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

.convo-section-label {
  padding: 10px 18px 5px;
  font-family: var(--font-display);
  font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.convo-item { position: relative; }

.convo-item a {
  display: block; padding: 9px 36px 9px 18px;
  color: var(--text-secondary); font-size: 0.84rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-radius: var(--radius-sm); margin: 1px 8px;
  transition: all var(--transition-fast);
}

.convo-item a:hover { background: var(--bg-elevated); color: var(--text-primary); }
.convo-item.active a { background: var(--accent-dim); color: var(--accent); font-weight: 500; }

.convo-item .convo-delete {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px;
  display: none; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-tertiary); cursor: pointer;
  border-radius: var(--radius-xs);
}

.convo-item:hover .convo-delete { display: flex; }
.convo-item .convo-delete:hover { color: var(--danger); background: var(--danger-bg); }

/* ---------- layout ---------- */
.layout-with-sidebar {
  display: flex; height: 100vh;
  padding-top: var(--navbar-height);
  overflow: hidden;
}

.layout-with-sidebar .main-area {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  display: flex; flex-direction: column;
  overflow: hidden; flex: 1; min-height: 0;
}

/* ---------- welcome screen ---------- */
.welcome-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 40px 20px 100px; text-align: center;
  animation: fadeIn 0.5s var(--ease-out-expo);
}

.welcome-screen .messages-container, .welcome-screen .chat-input-bar { text-align: left; }

.welcome-logo {
  width: 60px; height: 60px;
  background: linear-gradient(145deg, var(--accent), #b8860b, #8b6914);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-glow), 0 8px 32px rgba(212,168,83,0.12);
}

.welcome-logo svg { width: 28px; height: 28px; color: var(--text-inverse); }

.welcome-screen h1 {
  font-family: var(--font-display); font-size: 2.2rem; font-weight: 800;
  letter-spacing: -0.04em; margin-bottom: 8px;
}

.welcome-screen p { font-size: 0.95rem; max-width: 440px; line-height: 1.6; }

.welcome-suggestions {
  display: flex; flex-wrap: wrap; gap: 8px;
  max-width: 540px; justify-content: center; margin-top: 28px;
}

.welcome-suggestion {
  padding: 9px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.82rem; cursor: pointer;
  transition: all var(--transition);
}

.welcome-suggestion:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* ---------- chat input ---------- */
.welcome-input-container { max-width: 680px; width: 100%; margin-top: 36px; }

.chat-input-bar {
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  padding: 14px 24px 22px;
  z-index: 30; text-align: left; flex-shrink: 0;
}

.chat-input-bar .chat-input-container { max-width: 720px; margin: 0 auto; }

.chat-input-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  transition: all var(--transition);
  display: flex; flex-direction: column;
}

.chat-input-box:focus-within {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-sm);
}

.chat-input-box textarea {
  width: 100%; background: transparent; border: none;
  color: var(--text-primary); padding: 14px 18px 6px;
  font-family: var(--font-body); font-size: 0.94rem;
  line-height: 1.55; resize: none; outline: none;
  display: block; max-height: 200px;
}

.chat-input-box textarea::placeholder { color: var(--text-tertiary); }

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

.chat-input-left { display: flex; align-items: center; gap: 4px; }

.model-selector select {
  appearance: none;
  background: var(--bg-surface); border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-body); font-size: 0.76rem; font-weight: 500;
  padding: 5px 26px 5px 10px;
  border-radius: var(--radius-full); cursor: pointer;
  transition: all var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239a9590' fill='none' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}

.model-selector select:hover { border-color: var(--border-strong); color: var(--text-primary); }
.model-selector select:focus { outline: none; border-color: var(--accent); }
.model-selector select option { background: var(--bg-elevated); color: var(--text-primary); }

.send-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-full); border: none;
  background: var(--accent); color: var(--text-inverse);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); flex-shrink: 0;
}

.send-btn:hover { background: var(--accent-hover); transform: scale(1.06); box-shadow: var(--shadow-glow); }
.send-btn:disabled { opacity: 0.25; cursor: not-allowed; transform: none; box-shadow: none; }
.send-btn svg { width: 16px; height: 16px; }

/* ---------- messages ---------- */
.chat-scroll { flex: 1; overflow-y: auto; padding: 0; min-height: 0; text-align: left; }

.messages-container {
  max-width: 720px; margin: 0 auto;
  padding: 28px 24px 20px; text-align: left;
}

.message {
  padding: 22px 0; display: flex; gap: 14px;
  animation: msgFadeIn 0.3s var(--ease-out-expo); text-align: left;
}

.message + .message { border-top: 1px solid var(--border); }

.message-avatar {
  width: 30px; height: 30px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 0.72rem; font-weight: 700;
  flex-shrink: 0; margin-top: 2px;
}

.message.user .message-avatar {
  background: var(--bg-surface); color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--accent), #b8860b);
  color: var(--text-inverse);
}

.message-body { flex: 1; min-width: 0; }
.message-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

.message-role {
  font-family: var(--font-display); font-size: 0.82rem; font-weight: 600;
}

.message-content {
  font-size: 0.94rem; line-height: 1.75;
  word-wrap: break-word; overflow-wrap: break-word; text-align: left;
}

/* markdown */
.message-content p { color: var(--text-primary); margin-bottom: 12px; text-align: left; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 10px 0; padding-left: 24px; color: var(--text-primary); }
.message-content li { margin-bottom: 5px; }
.message-content strong { font-weight: 600; }
.message-content blockquote {
  border-left: 3px solid var(--accent); padding: 6px 16px; margin: 12px 0;
  color: var(--text-secondary); background: var(--accent-glow);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.message-content h1, .message-content h2, .message-content h3 { font-family: var(--font-display); margin: 18px 0 8px; }
.message-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(212,168,83,0.3); }

/* inline code */
.message-content code:not(pre code) {
  font-family: var(--mono); background: var(--bg-surface);
  padding: 2px 7px; border-radius: var(--radius-xs);
  font-size: 0.86em; color: var(--accent); border: 1px solid var(--border);
}

/* code blocks */
.message-content pre {
  background: var(--bg-void); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); margin: 14px 0; overflow: hidden; text-align: left;
}

.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem; color: var(--text-tertiary);
  font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.04em;
}

.copy-btn {
  padding: 3px 10px; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text-tertiary);
  font-size: 0.68rem; font-family: var(--font-body); cursor: pointer;
  transition: all var(--transition-fast); text-transform: uppercase; letter-spacing: 0.03em;
}

.copy-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.copy-btn.copied { color: var(--success); border-color: var(--success); }

.message-content pre code {
  display: block; padding: 16px 18px;
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.65;
  overflow-x: auto; color: var(--text-primary);
  background: transparent; border: none; text-align: left; white-space: pre;
}

/* tables */
.message-content table { border-collapse: collapse; margin: 14px 0; width: 100%; font-size: 0.88rem; }
.message-content th, .message-content td { padding: 9px 14px; text-align: left; border: 1px solid var(--border-strong); }
.message-content th { background: var(--bg-surface); font-family: var(--font-display); font-weight: 600; }

/* streaming */
.streaming-cursor::after {
  content: ''; display: inline-block; width: 2px; height: 1.1em;
  background: var(--accent); margin-left: 2px; vertical-align: text-bottom;
  animation: cursorBlink 0.9s step-end infinite;
}

.typing-indicator { display: flex; gap: 5px; padding: 6px 0; }

.typing-indicator span {
  width: 6px; height: 6px; background: var(--accent);
  border-radius: 50%; opacity: 0.4;
  animation: typingBounce 1.3s ease-in-out infinite;
}

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

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-body); font-size: 0.84rem; font-weight: 500;
  cursor: pointer; background: var(--bg-elevated);
  transition: all var(--transition); text-decoration: none;
}

.btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--text-inverse); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--text-inverse); box-shadow: var(--shadow-glow); }
.btn-sm { padding: 5px 13px; font-size: 0.78rem; }
.btn-xs { padding: 3px 9px; font-size: 0.72rem; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: var(--danger-bg); border-color: rgba(248,113,113,0.15); color: var(--danger); }
.btn-danger:hover { background: rgba(248,113,113,0.14); }

/* ---------- cards ---------- */
.card {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px;
  transition: border-color var(--transition-fast);
}
.card:hover { border-color: var(--border-strong); }
.card + .card { margin-top: 14px; }
.card-title { font-family: var(--font-display); font-size: 0.95rem; font-weight: 600; margin-bottom: 14px; }

/* ---------- forms ---------- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 7px; color: var(--text-secondary); font-size: 0.82rem; font-weight: 500; }

.form-input {
  width: 100%; background: var(--bg-deep); border: 1px solid var(--border-strong);
  color: var(--text-primary); padding: 10px 14px;
  border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 0.9rem;
  transition: all var(--transition);
}

.form-input::placeholder { color: var(--text-tertiary); }
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
select.form-input { cursor: pointer; }
.form-hint { font-size: 0.76rem; color: var(--text-tertiary); margin-top: 5px; }

/* ---------- tables ---------- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 11px 14px; text-align: left; font-size: 0.86rem; }
.data-table th {
  color: var(--text-tertiary); font-family: var(--font-display); font-weight: 600;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-strong); padding-bottom: 9px;
}
.data-table td { border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--bg-elevated); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--radius-full);
  font-family: var(--font-display); font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}

.badge-healthy, .badge-success { background: var(--success-bg); color: var(--success); }
.badge-degraded, .badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-down, .badge-error { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-free { background: var(--success-bg); color: var(--success); }
.badge-pro { background: var(--accent-dim); color: var(--accent); }
.badge-max { background: var(--info-bg); color: var(--info); }
.badge-ultra { background: rgba(168,85,247,0.1); color: #a855f7; }
.badge-unlimited { background: rgba(236,72,153,0.1); color: #ec4899; }

/* ---------- stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }

.stat-card {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px;
  transition: all var(--transition);
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.stat-icon {
  width: 38px; height: 38px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.stat-icon.purple { background: var(--accent-dim); color: var(--accent); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon svg { width: 18px; height: 18px; }

.stat-value {
  font-family: var(--font-display); font-size: 1.7rem; font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.1;
}
.stat-label { font-size: 0.78rem; color: var(--text-secondary); margin-top: 5px; }

/* ---------- toggle ---------- */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; }
.toggle-switch input { display: none; }
.toggle-track { position: absolute; inset: 0; background: var(--bg-active); border-radius: 11px; transition: background var(--transition); }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: var(--text-primary); border-radius: 50%; transition: transform var(--transition); box-shadow: var(--shadow-sm); }
.toggle-switch input:checked ~ .toggle-track { background: var(--accent); }
.toggle-switch input:checked ~ .toggle-thumb { transform: translateX(18px); }

/* ---------- admin ---------- */
.admin-layout { display: flex; padding-top: var(--navbar-height); min-height: 100vh; }

.admin-sidebar {
  position: sticky; top: var(--navbar-height); align-self: flex-start;
  width: 210px; min-height: calc(100vh - var(--navbar-height));
  background: var(--bg-primary); border-right: 1px solid var(--border);
  padding: 18px 0; flex-shrink: 0;
}

.admin-sidebar .sidebar-label {
  padding: 8px 22px 8px;
  font-family: var(--font-display); font-size: 0.64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-tertiary);
}

.admin-sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 22px; color: var(--text-secondary); font-size: 0.86rem;
  transition: all var(--transition-fast);
}
.admin-sidebar a svg { width: 16px; height: 16px; opacity: 0.45; }
.admin-sidebar a:hover { background: var(--bg-elevated); color: var(--text-primary); }
.admin-sidebar a:hover svg { opacity: 0.7; }
.admin-sidebar a.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.admin-sidebar a.active svg { opacity: 1; color: var(--accent); }

.admin-content { flex: 1; padding: 32px 36px 52px; min-width: 0; max-width: 1100px; }
.admin-header { margin-bottom: 28px; }
.admin-header h2 { margin-bottom: 5px; }
.admin-header p { font-size: 0.88rem; }
.admin-header-actions { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }

/* ---------- auth ---------- */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-void); padding: var(--navbar-height) 20px 20px;
  position: relative;
}

.auth-page::after {
  content: ''; position: absolute; top: 30%; left: 50%;
  transform: translate(-50%, -50%); width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(212,168,83,0.04) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg-primary); border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl); padding: 40px 36px 32px;
  box-shadow: var(--shadow-lg); position: relative; z-index: 1;
}

.auth-logo {
  width: 50px; height: 50px;
  background: linear-gradient(145deg, var(--accent), #b8860b);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 22px; box-shadow: var(--shadow-glow);
}
.auth-logo svg { width: 24px; height: 24px; color: var(--text-inverse); }

.auth-title {
  text-align: center; font-family: var(--font-display);
  font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.03em;
}
.auth-subtitle { text-align: center; color: var(--text-secondary); font-size: 0.88rem; margin-bottom: 30px; }
.auth-divider { text-align: center; margin: 20px 0 0; color: var(--text-tertiary); font-size: 0.82rem; cursor: pointer; transition: color var(--transition-fast); padding: 8px 0; }
.auth-divider:hover { color: var(--accent); }
.auth-error { background: var(--danger-bg); border: 1px solid rgba(248,113,113,0.15); color: var(--danger); padding: 11px 16px; border-radius: var(--radius-sm); font-size: 0.84rem; margin-bottom: 18px; display: none; }

/* ---------- settings ---------- */
.settings-layout { max-width: 720px; margin: 0 auto; padding: calc(var(--navbar-height) + 32px) 24px 52px; }
.settings-section { margin-bottom: 36px; }
.settings-section h3 { margin-bottom: 4px; }
.settings-section p { font-size: 0.84rem; margin-bottom: 18px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; top: calc(var(--navbar-height) + 16px); right: 20px;
  padding: 13px 20px; background: var(--bg-elevated);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  font-size: 0.86rem; z-index: 300; box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s var(--ease-out-expo); max-width: 380px;
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-info { border-left: 3px solid var(--accent); }
.toast.toast-out { animation: toastOut 0.2s ease-in forwards; }

/* ---------- misc ---------- */
.empty-state { text-align: center; padding: 52px 20px; color: var(--text-tertiary); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.2; }
.empty-state p { font-size: 0.9rem; margin-bottom: 16px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }

/* ---------- animations ---------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes msgFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes cursorBlink { 50% { opacity: 0; } }
@keyframes typingBounce { 0%, 80%, 100% { transform: scale(0.5); opacity: 0.3; } 40% { transform: scale(1); opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

/* ---------- responsive ---------- */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar { transform: translateX(-100%); z-index: 90; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay { position: fixed; inset: 0; top: var(--navbar-height); background: rgba(0,0,0,0.6); z-index: 80; display: none; }
  .sidebar-overlay.open { display: block; }
  .layout-with-sidebar .main-area { margin-left: 0; width: 100%; }
  .admin-sidebar { display: none; }
  .admin-content { padding: 20px 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chat-input-bar { padding: 12px 14px 16px; }
  .messages-container { padding: 18px 14px 14px; }
  .welcome-screen h1 { font-size: 1.6rem; }
  .auth-card { padding: 32px 24px 28px; }
}

@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; } }

.hljs { background: transparent !important; padding: 0 !important; }
