:root {
  /* Brand & Accents */
  --navy: #0f172a;
  --navy-dark: #070b14;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --accent: #f59e0b;
  --accent-soft: #fffbeb;
  --crimson: #e11d48;
  
  /* Routing Card */
  --route-bg: #f8fafd;
  --route-border: #e2e8f0;
  --route-accent: #2563eb;
  
  /* Canvas & Neutrals */
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-subtle: #f1f5f9;
  
  /* System States */
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  
  /* Radius & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.03);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Prompt", "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.68;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, textarea {
  font-family: inherit;
}
button { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.full { width: 100%; }
[hidden] { display: none !important; }

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* ==================== Sidebar ==================== */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #090e1a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 14px 16px;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 4px;
}
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.brand-meta {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-weight: 700;
  color: #ffffff;
  font-size: 15.5px;
  line-height: 1.25;
}
.brand-sub {
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 1px;
}

.btn {
  border: 0;
  border-radius: 11px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.btn-primary:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
}

.side-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.side-section.grow {
  flex: 1;
  min-height: 160px;
  overflow: hidden;
}
.side-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  padding: 4px 6px 2px;
}
.count {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 10.5px;
  font-weight: 500;
}

.bot-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 2px;
}
.side-empty {
  font-size: 12.5px;
  color: #64748b;
  padding: 12px 8px;
  text-align: center;
}

.bot-row {
  display: flex;
  align-items: stretch;
  gap: 3px;
}
.bot-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: #cbd5e1;
  padding: 8px 10px;
  border-radius: 10px;
  display: flex;
  gap: 9px;
  align-items: center;
  transition: all 0.14s ease;
}
.bot-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}
.bot-btn.manager-btn {
  background: rgba(37, 99, 235, 0.1);
  border-color: rgba(37, 99, 235, 0.25);
  color: #93c5fd;
}
.bot-btn.manager-btn:hover {
  background: rgba(37, 99, 235, 0.18);
  color: #ffffff;
}
.bot-btn.active {
  background: #2563eb !important;
  color: #ffffff !important;
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.35);
}

.bot-emoji {
  font-size: 17px;
  line-height: 1;
  flex-shrink: 0;
}
.bot-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.bot-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 5px;
}
.bot-btn.active .bot-title {
  font-weight: 600;
}
.bot-folder {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.bot-btn.active .bot-folder {
  color: rgba(255, 255, 255, 0.8);
}

.pill-auto {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
}

.bot-files-btn {
  border: 0;
  border-radius: 9px;
  width: 30px;
  flex-shrink: 0;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  display: grid;
  place-items: center;
  transition: all 0.14s ease;
}
.bot-files-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.side-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11.5px;
}
.user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #cbd5e1;
}
.logout-link {
  color: #93c5fd;
  text-decoration: none;
  font-weight: 500;
  flex-shrink: 0;
}
.logout-link:hover { text-decoration: underline; }

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: #64748b;
  padding: 0 4px;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  flex-shrink: 0;
}
.dot.ok { background: var(--ok); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.dot.err { background: var(--err); }

/* ==================== Main & Topbar ==================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.menu-btn { display: none; }
.icon-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--navy);
  font-size: 14px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}
.icon-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.topbar-title {
  flex: 1;
  min-width: 0;
}
.topbar h1 {
  font-size: 15.5px;
  font-weight: 600;
  margin: 0;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.topbar p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ghost-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--navy);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}
.ghost-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.switch input { display: none; }
.track {
  width: 32px;
  height: 18px;
  background: #cbd5e1;
  border-radius: 99px;
  position: relative;
  transition: background 0.2s ease;
}
.track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(14px); }

/* ==================== Chat Canvas ==================== */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.chat > * {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

/* ==================== Welcome / Hero Screen ==================== */
.welcome {
  text-align: center;
  padding: 20px 0 36px;
}
.welcome-hero {
  margin-bottom: 24px;
}
.hero-badge {
  display: inline-block;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 99px;
  padding: 3px 12px;
  margin-bottom: 12px;
  letter-spacing: 0.2px;
}
.welcome h2 {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.welcome-hero p {
  max-width: 600px;
  margin: 0 auto;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.flow-pills {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 6px 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.flow-pill {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.flow-pill.highlight {
  color: #2563eb;
  font-weight: 600;
}
.flow-arrow {
  color: #94a3b8;
  font-size: 12px;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 16px;
}
.section-divider {
  flex: 1;
  height: 1px;
  background: var(--line);
}
.section-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.bot-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  text-align: left;
}
.bot-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}
.bot-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.bot-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.bot-card-emoji {
  font-size: 22px;
  line-height: 1.1;
}
.bot-card-title {
  font-weight: 600;
  color: #0f172a;
  font-size: 13.5px;
  line-height: 1.35;
}
.bot-card-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}
.bot-card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ex-btn {
  text-align: left;
  border: 1px solid #f1f5f9;
  background: #f8fafc;
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.4;
  transition: all 0.15s ease;
  margin-top: auto;
}
.ex-btn:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

/* ==================== Messages ==================== */
.msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.msg.user {
  flex-direction: row-reverse;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  background: #0f172a;
  color: #ffffff;
}
.msg.user .avatar {
  background: #e2e8f0;
  color: #0f172a;
  font-size: 12px;
}
.msg.agent .avatar {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  font-size: 16px;
}

.bubble {
  max-width: min(100%, 760px);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.msg.user .bubble {
  background: #0f172a;
  color: #f8fafc;
  border-color: #0f172a;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
}
.msg.agent .bubble {
  border-radius: 16px 16px 16px 4px;
}

.user-target {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 99px;
  padding: 1px 8px;
  margin-bottom: 5px;
  width: fit-content;
}

/* AI Manager Routing Card */
.route-card {
  background: #f0f7ff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 12px;
  font-size: 12.5px;
  line-height: 1.5;
}
.route-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: #1e40af;
  font-weight: 600;
}
.route-target {
  background: #ffffff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 1px 8px;
  font-weight: 600;
  color: #1d4ed8;
}
.route-helper {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
}
.route-reason {
  color: #475569;
  font-size: 12px;
  margin-top: 3px;
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
}
.dots {
  display: inline-flex;
  gap: 3px;
}
.dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #2563eb;
  animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

/* Markdown Typography */
.md { word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0.6em 0; line-height: 1.7; }
.md ul, .md ol { margin: 0.5em 0; padding-left: 1.4em; }
.md li { margin: 0.25em 0; line-height: 1.65; }
.md h1, .md h2, .md h3, .md h4 {
  color: #0f172a;
  margin: 0.9em 0 0.35em;
  font-weight: 600;
  line-height: 1.35;
}
.md h1, .md h2 { font-size: 16px; }
.md h3, .md h4 { font-size: 14.5px; }

.md code {
  background: #f1f5f9;
  color: #0f172a;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.md pre {
  background: #090e1a;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
}
.md pre code { background: transparent; padding: 0; color: inherit; }
.md blockquote {
  margin: 0.6em 0;
  padding: 8px 14px;
  border-left: 3px solid #2563eb;
  background: #f8fafd;
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
}
.md table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8em 0;
  font-size: 13.5px;
}
.md th, .md td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
}
.md th {
  background: #f8fafc;
  color: #0f172a;
  font-weight: 600;
}
.md tr:nth-child(even) td { background: #fafcff; }

/* Citations [1] */
.cite {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 5px;
  padding: 0 5px;
  margin: 0 2px;
  text-decoration: none;
  line-height: 1.4;
  vertical-align: baseline;
  transition: all 0.14s ease;
}
.cite:hover {
  background: #1d4ed8;
  color: #ffffff;
  border-color: #1d4ed8;
  transform: translateY(-1px);
}

/* Sources */
.sources {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line-subtle);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sources-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.link-btn {
  border: 0;
  background: transparent;
  color: #2563eb;
  font-size: 11.5px;
  padding: 0;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

.source {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12.5px;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.12s ease;
}
.source:hover { background: #f1f5f9; }
.source.flash { background: #fffbeb; }
.source-n {
  font-weight: 700;
  color: #2563eb;
  min-width: 22px;
  flex-shrink: 0;
  font-size: 12px;
}
.source-tag {
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 4px;
  background: #f1f5f9;
  color: var(--muted);
}
.source-tag.skill { background: #ecfdf5; color: #059669; }
.source-tag.helper { background: #fffbeb; color: #b45309; }
.source-loc { color: var(--muted); }

.msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.mini-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 6px;
  font-size: 11.5px;
  padding: 3px 8px;
  color: var(--muted);
  transition: all 0.12s ease;
}
.mini-btn:hover {
  color: #0f172a;
  border-color: #cbd5e1;
}
.badge {
  font-size: 11px;
  border-radius: 6px;
  padding: 2px 7px;
  font-weight: 500;
  background: #f1f5f9;
  color: var(--text-secondary);
}
.badge.model {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #dbeafe;
}

/* ==================== Composer (Input Island) ==================== */
.composer {
  padding: 10px 24px 18px;
  background: transparent;
}
.composer > * {
  max-width: 820px;
  margin: 0 auto;
}
.composer-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-bottom: 6px;
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  border-radius: 99px;
  padding: 2px 10px 2px 12px;
  font-size: 12px;
  font-weight: 500;
}
.chip-reset {
  border: 0;
  background: rgba(30, 64, 175, 0.1);
  color: #1e40af;
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.chip-reset:hover { background: rgba(30, 64, 175, 0.2); }

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #ffffff;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 8px 10px 8px 16px;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}
.composer-box:focus-within {
  border-color: #2563eb;
  box-shadow: 0 8px 24px -2px rgba(37, 99, 235, 0.12), 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.composer-box textarea {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  font-size: 14.5px;
  line-height: 1.5;
  max-height: 180px;
  padding: 6px 0;
  background: transparent;
  color: var(--text);
}
.composer-box textarea::placeholder {
  color: #94a3b8;
}

.send-btn, .stop-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 0;
  color: #ffffff;
  font-size: 15px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}
.send-btn {
  background: #0f172a;
}
.send-btn:hover:not(:disabled) {
  background: #2563eb;
  transform: translateY(-1px);
}
.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.stop-btn {
  background: var(--crimson);
  font-size: 12px;
}
.composer-hint {
  text-align: center;
  margin-top: 6px;
  color: #94a3b8;
  font-size: 11.5px;
}

/* ==================== Knowledge Modal ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal {
  background: #ffffff;
  border-radius: 18px;
  width: min(840px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--line);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  margin: 0;
  color: #0f172a;
  font-size: 16px;
  font-weight: 600;
}
.modal-head p { margin: 2px 0 0; }
.modal-toolbar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.doc-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
  outline: 0;
  background: #ffffff;
}
.doc-search:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.folder-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.folder-head {
  background: #f8fafc;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.folder-head-title {
  font-weight: 600;
  color: #0f172a;
  font-size: 13.5px;
}
.folder-head-sub {
  font-size: 11.5px;
  color: var(--muted);
}
.ask-bot-btn {
  border: 1px solid #bfdbfe;
  background: #ffffff;
  color: #1d4ed8;
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  transition: all 0.14s ease;
}
.ask-bot-btn:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}
.file-rows { display: flex; flex-direction: column; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  font-size: 12.5px;
  transition: background 0.12s ease;
}
.file-row:hover { background: #f8fafc; }
.ext-badge {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 4px;
  background: #475569;
  color: #ffffff;
  flex-shrink: 0;
}
.ext-badge.pdf { background: #dc2626; }
.ext-badge.xlsx { background: #059669; }
.ext-badge.gdoc { background: #2563eb; }
.ext-badge.md { background: #0d9488; }
.file-name {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.file-meta {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}
.file-warn {
  font-size: 11px;
  color: #d97706;
  display: block;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #0f172a;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 80;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 35;
}

/* ==================== Responsive ==================== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.3);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: grid; }
  .topbar { padding: 10px 14px; }
  .topbar p, .switch-label, .hide-sm { display: none; }
  .chat { padding: 14px 12px 10px; }
  .composer { padding: 6px 12px 12px; }
  .flow-pills { padding: 6px 10px; gap: 4px; }
}
