/* ==============================================
   GRC Expert — Enterprise Cybersecurity Platform
   Design tokens and base styles
   ============================================== */

:root {
  /* Dark theme (default) */
  --bg: #060912;
  --bg-elev: #0B111E;
  --bg-surface: #0F1729;
  --bg-hover: #131C32;
  --border: rgba(99, 179, 237, 0.08);
  --border-strong: rgba(99, 179, 237, 0.18);
  --text: #E2E8F0;
  --text-bright: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --text-faint: #475569;
  --primary: #38BDF8;
  --primary-strong: #0EA5E9;
  --primary-glow: rgba(14, 165, 233, 0.35);
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --user-bubble-from: #0EA5E9;
  --user-bubble-to: #0284C7;
  --user-text: #F0F9FF;
  --code-bg: rgba(0, 0, 0, 0.3);
  --code-text: #7DD3FC;
  --table-header-bg: rgba(56, 189, 248, 0.08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --transition: 150ms ease;
}

[data-theme="light"] {
  --bg: #F8FAFC;
  --bg-elev: #FFFFFF;
  --bg-surface: #FFFFFF;
  --bg-hover: #F1F5F9;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.15);
  --text: #1E293B;
  --text-bright: #0F172A;
  --text-muted: #64748B;
  --text-dim: #94A3B8;
  --text-faint: #CBD5E1;
  --primary: #0284C7;
  --primary-strong: #0369A1;
  --primary-glow: rgba(2, 132, 199, 0.2);
  --user-bubble-from: #0EA5E9;
  --user-bubble-to: #0284C7;
  --user-text: #FFFFFF;
  --code-bg: #F1F5F9;
  --code-text: #0369A1;
  --table-header-bg: #F1F5F9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
}

::selection { background: var(--primary-glow); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -1000px 0; } 100% { background-position: 1000px 0; } }

/* ============ APP LAYOUT ============ */
.app { display: flex; height: 100vh; position: relative; overflow: hidden; }

.bg-decoration {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, rgba(56, 189, 248, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 40%);
}
[data-theme="light"] .bg-decoration { display: none; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: 264px; min-width: 264px;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 30;
}

.sb-header {
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #10B981);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #fff;
  font-family: 'JetBrains Mono', monospace;
  box-shadow: 0 4px 12px var(--primary-glow);
  letter-spacing: -0.5px;
}
.brand-meta { display: flex; flex-direction: column; gap: 2px; }
.brand-name { font-weight: 700; font-size: 14.5px; color: var(--text-bright); letter-spacing: -0.2px; }
.brand-tag {
  font-size: 9.5px; color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 1.5px; font-weight: 600; text-transform: uppercase;
}

.sb-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }

.nav-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 1.8px;
  color: var(--text-faint); margin: 12px 10px 6px;
  font-weight: 700; font-family: 'JetBrains Mono', monospace;
}
.nav-label:first-child { margin-top: 4px; }

.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px; border: none; cursor: pointer;
  font-size: 13px; font-family: inherit; text-align: left;
  color: var(--text-muted); background: transparent;
  margin-bottom: 1px; transition: var(--transition);
  font-weight: 500; position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-bright); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.12), rgba(56, 189, 248, 0.04));
  color: var(--primary); font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 2px;
  background: var(--primary); box-shadow: 0 0 8px var(--primary);
}
.nav-icon {
  width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85;
  stroke: currentColor; fill: none; stroke-width: 2;
}

.fw-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: transparent; border: none; cursor: pointer;
  color: var(--text-faint); font-size: 9px; text-transform: uppercase; letter-spacing: 1.8px;
  font-family: 'JetBrains Mono', monospace; font-weight: 700; margin-top: 6px;
}
.fw-toggle:hover { color: var(--text-muted); }
.fw-toggle-icon { transition: transform 150ms; }
.fw-toggle.open .fw-toggle-icon { transform: rotate(90deg); }

.fw-list { display: none; padding: 2px 0; }
.fw-list.open { display: block; animation: fadeIn 0.2s; }
.fw-group {
  padding: 6px 12px 3px; font-size: 8.5px; color: var(--text-faint);
  letter-spacing: 1.4px; font-family: 'JetBrains Mono', monospace; font-weight: 700;
}
.fw-item {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 22px; border-radius: 5px; border: none; cursor: pointer;
  font-size: 12px; font-family: inherit; text-align: left;
  color: var(--text-dim); background: transparent;
  margin-bottom: 1px; transition: var(--transition);
}
.fw-item:hover { background: var(--bg-hover); color: var(--text-muted); }
.fw-item.ac {
  color: var(--primary); background: rgba(56, 189, 248, 0.08);
  font-weight: 500;
}
.fw-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; opacity: 0.6; flex-shrink: 0;
}

.sb-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.btn-primary {
  width: 100%; padding: 9px; border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: rgba(56, 189, 248, 0.08); color: var(--primary);
  font-size: 12.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: var(--transition);
}
.btn-primary:hover { background: rgba(56, 189, 248, 0.15); border-color: var(--primary); }
.btn-primary svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.5; }

.theme-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10.5px; color: var(--text-dim); padding: 0 4px;
}
.theme-toggle {
  background: var(--bg-hover); border: 1px solid var(--border);
  color: var(--text-muted); padding: 4px 8px; border-radius: 5px;
  font-size: 11px; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 5px;
}
.theme-toggle:hover { background: var(--border-strong); color: var(--text-bright); }
.credit { font-size: 10px; color: var(--text-faint); text-align: center; line-height: 1.5; padding-top: 4px; }
.credit strong { color: var(--text-dim); font-weight: 600; }
.footer-disclaimer { color: var(--text-faint); }

/* ============ MAIN ============ */
.main { flex: 1; display: flex; flex-direction: column; z-index: 1; min-width: 0; position: relative; }

.topbar {
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-elev);
  z-index: 5;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.hamburger {
  background: none; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer; padding: 6px; border-radius: 6px;
  display: none; align-items: center; justify-content: center;
}
.hamburger:hover { background: var(--bg-hover); color: var(--text-bright); }
.hamburger svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

.page-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-title h1 {
  font-size: 15.5px; font-weight: 700; color: var(--text-bright);
  letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fw-pill {
  font-size: 10.5px; padding: 3px 10px; border-radius: 12px;
  background: rgba(56, 189, 248, 0.1); color: var(--primary);
  font-family: 'JetBrains Mono', monospace; font-weight: 600;
  border: 1px solid rgba(56, 189, 248, 0.2);
  white-space: nowrap;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }
.kb-status {
  display: flex; align-items: center; gap: 6px;
  background: rgba(16, 185, 129, 0.08); padding: 4px 10px; border-radius: 14px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.kb-status.loading { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.2); }
.kb-status.error { background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.2); }
.kb-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}
.kb-status.loading .kb-status-dot { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.kb-status.error .kb-status-dot { background: var(--danger); box-shadow: 0 0 6px var(--danger); animation: none; }
.kb-status-text {
  font-size: 10.5px; font-family: 'JetBrains Mono', monospace;
  font-weight: 600; color: var(--success);
}
.kb-status.loading .kb-status-text { color: var(--warning); }
.kb-status.error .kb-status-text { color: var(--danger); }

/* ============ CHAT AREA ============ */
.chat-area {
  flex: 1; overflow-y: auto; padding: 22px 22px 8px;
  scroll-behavior: smooth;
}

/* Welcome screen */
.welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100%; text-align: center;
  animation: fadeUp 0.4s ease;
  padding: 20px 0;
}
.welcome-icon {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.18), rgba(16, 185, 129, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.12);
}
.welcome h2 {
  font-size: 22px; font-weight: 700; color: var(--text-bright);
  margin-bottom: 6px; letter-spacing: -0.4px;
}
.welcome-sub {
  color: var(--text-muted); font-size: 13px;
  max-width: 540px; line-height: 1.6; margin-bottom: 28px;
}

.starters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px; width: 100%; max-width: 720px;
}
.starter {
  padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-muted);
  font-size: 13px; cursor: pointer; text-align: left;
  font-family: inherit; line-height: 1.5; transition: var(--transition);
  display: flex; align-items: flex-start; gap: 10px;
}
.starter:hover {
  border-color: var(--primary); background: rgba(56, 189, 248, 0.05);
  color: var(--text-bright); transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.08);
}
.starter-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* Messages */
.msg-row { display: flex; margin-bottom: 16px; animation: fadeUp 0.3s ease; }
.msg-row.user { justify-content: flex-end; }
.msg-row.bot { justify-content: flex-start; }

.bubble {
  max-width: 85%; padding: 13px 16px; font-size: 13.5px; line-height: 1.65;
  word-break: break-word;
}
.bubble.user {
  border-radius: 14px 14px 4px 14px;
  background: linear-gradient(135deg, var(--user-bubble-from), var(--user-bubble-to));
  color: var(--user-text);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.22);
}
.bubble.bot {
  border-radius: 14px 14px 14px 4px;
  background: var(--bg-surface); color: var(--text);
  border: 1px solid var(--border);
  max-width: 92%;
}

.msg-tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--primary); margin-bottom: 6px; font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.msg-model { font-size: 9px; color: var(--text-faint); font-weight: 500; letter-spacing: 0.5px; }
.msg-mode {
  font-size: 9px; color: var(--text-muted);
  background: var(--bg-hover); padding: 2px 6px; border-radius: 4px;
  letter-spacing: 0.3px; font-weight: 500;
}

.bot-content strong { color: var(--text-bright); font-weight: 700; }
.bot-content code {
  background: var(--code-bg); color: var(--code-text);
  padding: 2px 6px; border-radius: 4px; font-size: 12.5px;
  font-family: 'JetBrains Mono', monospace;
}
.bot-content pre {
  background: var(--code-bg); border: 1px solid var(--border);
  padding: 12px; border-radius: 8px; margin: 8px 0; overflow-x: auto;
  font-size: 12.5px; line-height: 1.5;
}
.bot-content pre code { background: transparent; padding: 0; color: var(--text); }
.bot-content .table-wrap { overflow-x: auto; margin: 10px 0; border-radius: 8px; }
.bot-content table {
  border-collapse: collapse; width: 100%; font-size: 12.5px;
  background: var(--bg-elev);
}
.bot-content th, .bot-content td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left;
}
.bot-content th { background: var(--table-header-bg); color: var(--primary); font-weight: 600; font-size: 12px; }
.bot-content ul, .bot-content ol { margin: 8px 0; padding-left: 24px; }
.bot-content li { margin: 4px 0; }
.bot-content h1, .bot-content h2, .bot-content h3, .bot-content h4 {
  color: var(--text-bright); font-weight: 700; margin: 14px 0 8px; letter-spacing: -0.2px;
}
.bot-content h1 { font-size: 17px; }
.bot-content h2 { font-size: 15.5px; }
.bot-content h3 { font-size: 14px; }
.bot-content h4 { font-size: 13px; }
.bot-content p { margin: 6px 0; }
.bot-content blockquote {
  border-left: 3px solid var(--primary);
  padding: 6px 12px; margin: 8px 0;
  background: rgba(56, 189, 248, 0.04);
  color: var(--text); font-style: italic;
}
.bot-content a { color: var(--primary); text-decoration: none; }
.bot-content a:hover { text-decoration: underline; }

/* Citations */
.citations {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
}
.citations-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-muted); margin-bottom: 6px; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
.citation-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  background: rgba(56, 189, 248, 0.08); color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.18);
  margin: 2px 4px 2px 0; font-weight: 500;
}
.citation-chip svg { width: 10px; height: 10px; }

/* Typing dots */
.dots { display: flex; gap: 5px; align-items: center; padding: 4px 0; }
.dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary); animation: pulse 1.4s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

.err-bar {
  text-align: center; padding: 12px 16px; color: var(--danger);
  font-size: 13px; background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25); border-radius: 10px;
  margin: 8px 0;
}

/* ============ FILE CHIPS ============ */
.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 11px; border-radius: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-size: 12px; color: #6EE7B7;
  margin: 2px 4px 2px 0; max-width: 100%;
}
.file-chip-name {
  font-weight: 500; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 200px;
}
.file-chip-size { color: var(--text-faint); font-size: 11px; }
.file-chip-x {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 0 0 0 4px; font-size: 14px; line-height: 1;
}
.file-chip-x:hover { color: var(--danger); }

/* ============ INPUT BAR ============ */
.input-bar {
  padding: 10px 22px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}

.input-wrapper {
  background: var(--bg-surface);
  border-radius: 14px; border: 1px solid var(--border-strong);
  padding: 8px 8px 8px 14px;
  transition: var(--transition);
}
.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.08);
}

.attached-files { padding-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.attached-files:empty { display: none; padding: 0; }

.input-row { display: flex; align-items: flex-end; gap: 6px; }
.input-row textarea {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-size: 13.5px; font-family: inherit; resize: none; line-height: 1.6;
  padding: 6px 0; max-height: 140px; overflow-y: auto; outline: none;
}
.input-row textarea::placeholder { color: var(--text-faint); }

.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: none;
  background: transparent; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: var(--transition); flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--primary); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; }

.send-btn {
  width: 36px; height: 36px; border-radius: 9px; border: none;
  background: var(--bg-hover); color: var(--text-faint);
  font-size: 16px; cursor: default; display: flex;
  align-items: center; justify-content: center; transition: var(--transition);
  flex-shrink: 0;
}
.send-btn.on {
  background: linear-gradient(135deg, var(--user-bubble-from), var(--user-bubble-to));
  color: #fff; cursor: pointer;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}
.send-btn.on:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(14, 165, 233, 0.4); }
.send-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.5; }

#fileInput { display: none; }

.input-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; font-size: 10.5px; color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
}
.input-meta-left { display: flex; gap: 12px; }

/* ============ FILE PROCESSING OVERLAY ============ */
.file-processing {
  position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev); border: 1px solid var(--primary);
  padding: 10px 18px; border-radius: 24px;
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--primary);
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.3s ease; z-index: 10;
}
.file-spin {
  width: 14px; height: 14px;
  border: 2px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}

/* ============ KNOWLEDGE BASE PAGE ============ */
.kb-page { padding: 22px 24px; overflow-y: auto; flex: 1; }
.kb-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.kb-stat {
  background: var(--bg-surface); border: 1px solid var(--border);
  padding: 16px; border-radius: 10px;
}
.kb-stat-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted); margin-bottom: 6px; font-family: 'JetBrains Mono', monospace; font-weight: 600;
}
.kb-stat-value { font-size: 22px; font-weight: 700; color: var(--text-bright); letter-spacing: -0.5px; }
.kb-stat-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.kb-section { margin-bottom: 24px; }
.kb-section h3 { font-size: 14px; font-weight: 700; color: var(--text-bright); margin-bottom: 12px; }

.fw-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.fw-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 8px; transition: var(--transition);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.fw-card:hover { border-color: var(--primary); }
.fw-card-info { min-width: 0; }
.fw-card-name { font-size: 13px; font-weight: 600; color: var(--text-bright); margin-bottom: 2px; }
.fw-card-count { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.fw-card-link {
  flex-shrink: 0; padding: 4px 8px; border-radius: 5px;
  background: rgba(56, 189, 248, 0.08); color: var(--primary);
  text-decoration: none; font-size: 11px; font-weight: 500;
  display: flex; align-items: center; gap: 4px;
}
.fw-card-link:hover { background: rgba(56, 189, 248, 0.15); }

.user-docs { margin-top: 8px; }
.doc-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 6px;
}
.doc-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(56, 189, 248, 0.1); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.doc-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.doc-info { flex: 1; min-width: 0; }
.doc-name {
  font-size: 13px; font-weight: 600; color: var(--text-bright);
  margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-meta { font-size: 11px; color: var(--text-dim); }
.doc-actions { display: flex; gap: 6px; }
.doc-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); padding: 5px 10px; border-radius: 6px;
  font-size: 11.5px; cursor: pointer; font-family: inherit;
}
.doc-btn:hover { border-color: var(--primary); color: var(--primary); }
.doc-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.empty {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted); font-size: 13px;
}

/* ============ MOBILE ============ */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  z-index: 25; display: none; backdrop-filter: blur(2px);
}
.overlay.open { display: block; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: -280px; top: 0; bottom: 0;
    transition: left 250ms ease; width: 280px;
  }
  .sidebar.open { left: 0; box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4); }
  .hamburger { display: flex; }
  .topbar { padding: 10px 16px; }
  .chat-area { padding: 14px; }
  .input-bar { padding: 8px 14px 12px; }
  .kb-page { padding: 14px; }
  .starters { grid-template-columns: 1fr; }
  .welcome h2 { font-size: 19px; }
  .welcome-sub { font-size: 12.5px; }
  .bubble { max-width: 95%; font-size: 13px; }
  .fw-pill { display: none; }
}

/* ============ TOAST ============ */
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-10px);
  padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 100; opacity: 0; transition: all 200ms;
  box-shadow: var(--shadow-lg); pointer-events: none;
  font-weight: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.4); color: #6EE7B7; }
.toast-error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.4); color: #FCA5A5; }
.toast-info { background: rgba(56, 189, 248, 0.15); border: 1px solid rgba(56, 189, 248, 0.4); color: #7DD3FC; }

[data-theme="light"] .toast-success { background: #D1FAE5; color: #047857; border-color: #6EE7B7; }
[data-theme="light"] .toast-error { background: #FEE2E2; color: #B91C1C; border-color: #FCA5A5; }
[data-theme="light"] .toast-info { background: #DBEAFE; color: #1E40AF; border-color: #93C5FD; }

/* ============ EXPORT BUTTONS ============ */
.export-bar {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
  display: flex; flex-wrap: wrap; gap: 6px;
}
.export-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 11px; border-radius: 7px;
  background: var(--bg-hover); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 11.5px; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: var(--transition);
}
.export-btn:hover {
  background: rgba(56, 189, 248, 0.1); border-color: var(--primary);
  color: var(--primary);
}
.export-btn:active { transform: translateY(1px); }
.export-btn svg { stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }
.export-btn[data-action="word"]:hover { color: #2563EB; border-color: #2563EB; background: rgba(37, 99, 235, 0.08); }
.export-btn[data-action="pdf"]:hover { color: #DC2626; border-color: #DC2626; background: rgba(220, 38, 38, 0.08); }
.export-btn[data-action="excel"]:hover { color: #059669; border-color: #059669; background: rgba(5, 150, 105, 0.08); }

.input-disclaimer { color: var(--text-faint); font-size: 11px; text-align: right; max-width: 420px; }
@media (max-width: 720px) { .input-disclaimer { display: none; } }
