:root {
  color-scheme: light;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --line: #e2e8f0;
  --line-focus: #94a3b8;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;

  --badge-uchile-bg: #eff6ff;
  --badge-uchile-text: #1d4ed8;
  --badge-uls-bg: #ecfdf5;
  --badge-uls-text: #047857;

  --user-bubble-bg: #2563eb;
  --user-bubble-text: #ffffff;
  --bot-bubble-bg: #ffffff;
  --bot-bubble-text: #0f172a;

  --card-why-bg: #eff6ff;
  --card-why-text: #1e3a8a;
  --card-why-border: var(--primary);

  --btn-malla-bg: #fef2f2;
  --btn-malla-text: #b91c1c;
  --btn-malla-border: #fecaca;
  --btn-malla-hover-bg: #fee2e2;

  --btn-malla-disabled-bg: #f1f5f9;
  --btn-malla-disabled-text: #64748b;
  --btn-malla-disabled-border: #e2e8f0;

  --match-pill-bg: #ecfdf5;
  --match-pill-text: #047857;
  --match-pill-border: #a7f3d0;

  --trend-up-bg: #ecfdf5;
  --trend-up-text: #047857;
  --trend-up-border: #a7f3d0;

  --trend-down-bg: #fef2f2;
  --trend-down-text: #b91c1c;
  --trend-down-border: #fecaca;

  --input-focus-ring: rgba(37, 99, 235, 0.15);
  --footer-gradient-start: rgba(248, 250, 252, 0);
  --footer-gradient-end: #f8fafc;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Automatic Dark Mode for users already in dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg-main: #0b0f17;
    --bg-card: #151d2c;
    --bg-sidebar: #0f1624;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    --line: #1e293b;
    --line-focus: #334155;

    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: rgba(59, 130, 246, 0.15);
    --primary-border: rgba(59, 130, 246, 0.35);

    --badge-uchile-bg: rgba(59, 130, 246, 0.18);
    --badge-uchile-text: #93c5fd;
    --badge-uls-bg: rgba(16, 185, 129, 0.18);
    --badge-uls-text: #6ee7b7;

    --user-bubble-bg: #2563eb;
    --user-bubble-text: #ffffff;
    --bot-bubble-bg: #151d2c;
    --bot-bubble-text: #f8fafc;

    --card-why-bg: rgba(59, 130, 246, 0.12);
    --card-why-text: #93c5fd;
    --card-why-border: var(--primary);

    --btn-malla-bg: rgba(239, 68, 68, 0.15);
    --btn-malla-text: #fca5a5;
    --btn-malla-border: rgba(239, 68, 68, 0.3);
    --btn-malla-hover-bg: rgba(239, 68, 68, 0.25);

    --btn-malla-disabled-bg: #1e293b;
    --btn-malla-disabled-text: #64748b;
    --btn-malla-disabled-border: #334155;

    --match-pill-bg: rgba(16, 185, 129, 0.15);
    --match-pill-text: #6ee7b7;
    --match-pill-border: rgba(16, 185, 129, 0.3);

    --trend-up-bg: rgba(16, 185, 129, 0.15);
    --trend-up-text: #6ee7b7;
    --trend-up-border: rgba(16, 185, 129, 0.3);

    --trend-down-bg: rgba(239, 68, 68, 0.15);
    --trend-down-text: #fca5a5;
    --trend-down-border: rgba(239, 68, 68, 0.3);

    --input-focus-ring: rgba(59, 130, 246, 0.25);
    --footer-gradient-start: rgba(11, 15, 23, 0);
    --footer-gradient-end: #0b0f17;

    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.6);
  }
}

/* Explicit Dark Theme via data-theme="dark" */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-main: #0b0f17;
  --bg-card: #151d2c;
  --bg-sidebar: #0f1624;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --line: #1e293b;
  --line-focus: #334155;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: rgba(59, 130, 246, 0.15);
  --primary-border: rgba(59, 130, 246, 0.35);

  --badge-uchile-bg: rgba(59, 130, 246, 0.18);
  --badge-uchile-text: #93c5fd;
  --badge-uls-bg: rgba(16, 185, 129, 0.18);
  --badge-uls-text: #6ee7b7;

  --user-bubble-bg: #2563eb;
  --user-bubble-text: #ffffff;
  --bot-bubble-bg: #151d2c;
  --bot-bubble-text: #f8fafc;

  --card-why-bg: rgba(59, 130, 246, 0.12);
  --card-why-text: #93c5fd;
  --card-why-border: var(--primary);

  --btn-malla-bg: rgba(239, 68, 68, 0.15);
  --btn-malla-text: #fca5a5;
  --btn-malla-border: rgba(239, 68, 68, 0.3);
  --btn-malla-hover-bg: rgba(239, 68, 68, 0.25);

  --btn-malla-disabled-bg: #1e293b;
  --btn-malla-disabled-text: #64748b;
  --btn-malla-disabled-border: #334155;

  --match-pill-bg: rgba(16, 185, 129, 0.15);
  --match-pill-text: #6ee7b7;
  --match-pill-border: rgba(16, 185, 129, 0.3);

  --trend-up-bg: rgba(16, 185, 129, 0.15);
  --trend-up-text: #6ee7b7;
  --trend-up-border: rgba(16, 185, 129, 0.3);

  --trend-down-bg: rgba(239, 68, 68, 0.15);
  --trend-down-text: #fca5a5;
  --trend-down-border: rgba(239, 68, 68, 0.3);

  --input-focus-ring: rgba(59, 130, 246, 0.25);
  --footer-gradient-start: rgba(11, 15, 23, 0);
  --footer-gradient-end: #0b0f17;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.6);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* Main Layout */
.chat-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* Header */
.chat-header {
  height: 68px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 10;
  flex-shrink: 0;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 28px;
  line-height: 1;
  background: var(--primary-light);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--primary-border);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-indicator {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-main);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  background: var(--bg-main);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 6px;
  gap: 4px;
}

.lang-btn {
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.lang-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.lang-divider {
  color: var(--text-light);
  font-size: 12px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  border: 1px solid var(--line);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s ease;
  user-select: none;
}

.theme-toggle-btn:hover {
  background: var(--bg-card);
  border-color: var(--line-focus);
}

.btn-catalog {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-catalog:hover {
  background-color: var(--bg-main);
  border-color: var(--line-focus);
}

/* Chat Viewport */
.chat-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 68px);
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
}

/* Astro sits next to the input, so the messages keep the full height. */
.composer { display: flex; align-items: flex-end; gap: 6px; }
.composer .chat-input-form { flex: 1; min-width: 0; }
.mascot-slot { flex: 0 0 auto; width: 132px; margin: -36px 0 -8px -12px; }
.mascot-fallback { min-height: 64px; display: grid; place-items: center; color: #a78bfa; font-size: 2rem; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 16px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Message Styles */
.message {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 820px;
}

.message-bot {
  align-self: flex-start;
}

.message-user {
  align-self: flex-end;
  justify-content: flex-end;
}

.msg-avatar {
  font-size: 20px;
  width: 38px;
  height: 38px;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msg-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 760px;
}

.msg-bubble {
  background: var(--bot-bubble-bg);
  border: 1px solid var(--line);
  padding: 16px 18px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  font-size: 14.5px;
  color: var(--bot-bubble-text);
  line-height: 1.6;
}

.user-bubble {
  background: var(--user-bubble-bg);
  color: var(--user-bubble-text);
  border-radius: 16px;
  border: none;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.msg-citations {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
}

.citations-title {
  color: var(--text-muted);
  font-weight: 600;
}

.cite-pill {
  background: var(--bg-main);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  font-family: monospace;
}

/* Quick Chips */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chip-btn {
  background: var(--bg-card);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.chip-btn:hover {
  background: var(--primary);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Short follow-up suggestions (after a few turns) -- same row layout as the
   opening chips, but visually lighter/smaller so they read as an optional
   nudge, not another set of big starter choices. */
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip-btn-suggestion {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
}

/* Welcome / quick-start onboarding modal (name, age, city, student status --
   collected once, before the chat starts, with no LLM turn spent on it) */
.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.welcome-card {
  background: var(--bg-card);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 28px 26px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  font-family: var(--font-sans);
}

.welcome-emoji {
  font-size: 34px;
  margin-bottom: 6px;
}

.welcome-card h2 {
  margin: 0 0 6px;
  color: var(--text-main);
  font-size: 20px;
}

.welcome-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 18px;
}

.welcome-field {
  display: block;
  text-align: left;
  margin-bottom: 14px;
}

.welcome-field span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.welcome-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-main);
  color: var(--text-main);
  font-size: 14px;
  font-family: var(--font-sans);
}

.welcome-field input:focus {
  outline: none;
  border-color: var(--primary);
}

.welcome-row {
  display: flex;
  gap: 10px;
}

.welcome-row .welcome-field {
  flex: 1;
}

.status-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-btn {
  background: var(--bg-main);
  border: 1px solid var(--line);
  color: var(--text-main);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.status-btn:hover {
  border-color: var(--primary-border);
}

.status-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.welcome-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  gap: 10px;
}

.welcome-skip {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

.welcome-submit {
  flex: 1;
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.welcome-submit:hover {
  background: var(--primary-hover);
}

/* Cards Stream in Bot Message */
.cards-stream {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.chat-career-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.chat-career-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.inst-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inst-uchile {
  background: var(--badge-uchile-bg);
  color: var(--badge-uchile-text);
  border: 1px solid var(--primary-border);
}

.inst-uls {
  background: var(--badge-uls-bg);
  color: var(--badge-uls-text);
  border: 1px solid var(--match-pill-border);
}

.match-pill {
  font-size: 12px;
  color: var(--match-pill-text);
  background: var(--match-pill-bg);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid var(--match-pill-border);
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.card-faculty {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.card-why {
  font-size: 12.5px;
  color: var(--card-why-text);
  background: var(--card-why-bg);
  border-left: 3px solid var(--card-why-border);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 14px;
  line-height: 1.45;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-action {
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-malla {
  background: var(--btn-malla-bg);
  color: var(--btn-malla-text);
  border: 1px solid var(--btn-malla-border);
}

.btn-malla:hover {
  background: var(--btn-malla-hover-bg);
  border-color: var(--btn-malla-border);
}

.btn-malla-disabled {
  background: var(--btn-malla-disabled-bg);
  color: var(--btn-malla-disabled-text);
  border: 1px solid var(--btn-malla-disabled-border);
  cursor: default;
}

.btn-profile {
  background: var(--bg-main);
  color: var(--text-main);
  border: 1px solid var(--line);
}

.btn-profile:hover {
  background: var(--bg-card);
  border-color: var(--line-focus);
}

.btn-ask {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.btn-ask:hover {
  background: var(--primary);
  color: #ffffff;
}

/* Typing Indicator */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  background: var(--primary);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Footer / Chat Input Form */
.chat-footer {
  padding: 12px 0 20px 0;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--footer-gradient-start) 0%, var(--footer-gradient-end) 25%);
}

.chat-input-form {
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 8px 6px 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.chat-input-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--input-focus-ring);
}

.chat-input-form input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14.5px;
  color: var(--text-main);
  background: transparent;
}

.send-btn {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.send-btn:hover {
  background: var(--primary-hover);
}

.footer-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 4px;
  font-size: 11px;
  color: var(--text-light);
}

.storage-notice {
  margin: 8px 4px 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

/* Side Drawer (All 112 Careers) */
.career-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.career-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.drawer-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.drawer-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.drawer-close:hover {
  background: var(--bg-main);
}

.drawer-controls {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-controls select,
.drawer-controls input {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: var(--bg-main);
  color: var(--text-main);
}

.drawer-controls select:focus,
.drawer-controls input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
}

.drawer-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.15s ease;
}

.drawer-item:hover {
  border-color: var(--primary-border);
  background: var(--primary-light);
}

.drawer-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.malla-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--btn-malla-text);
  background: var(--btn-malla-bg);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--btn-malla-border);
}

.drawer-item h4 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
}

.drawer-item-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* History Drawer Items */
.history-item {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all 0.15s ease;
}

.history-item:hover {
  background: var(--bg-surface-hover, var(--bg-card));
  border-color: var(--primary, #3b82f6);
}

.history-item.active {
  border-color: var(--primary, #3b82f6);
  background: var(--primary-light, rgba(59, 130, 246, 0.1));
}

.history-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .chat-header {
    padding: 0 12px;
  }
  .brand-subtitle,
  .footer-meta {
    display: none;
  }
  .career-drawer {
    width: 100%;
  }
}

/* Job-market trend badge ("+3.2%" stock-ticker style) */
.trend-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.trend-up {
  background: var(--trend-up-bg);
  color: var(--trend-up-text);
  border: 1px solid var(--trend-up-border);
}

.trend-down {
  background: var(--trend-down-bg);
  color: var(--trend-down-text);
  border: 1px solid var(--trend-down-border);
}

/* Developer tools: debug toggle + backend select (M2/M3) */
.dev-tools {
  position: relative;
}

.dev-tools[hidden] {
  display: none;
}

.admin-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: #b42318;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.btn-dev {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-dev:hover {
  border-color: var(--primary-border);
}

.dev-tools-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 180px;
  font-size: 12.5px;
  color: var(--text-main);
}

/* Author `display: flex` above otherwise beats the UA [hidden] rule at
   equal specificity (author origin always wins ties) — this keeps the
   toggle actually hiding the panel. */
.dev-tools-panel[hidden] {
  display: none;
}

.dev-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-dev-action {
  border: 1px solid var(--line);
  background: var(--bg-main);
  color: var(--text-main);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-dev-action:hover {
  border-color: var(--primary-border);
}

/* Labor-market evidence block (get_labor_market results) */
.labor-market-block {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-main);
  border: 1px solid var(--line);
  font-size: 12.5px;
}

.lm-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}

.lm-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  border-top: 1px dashed var(--line);
}

.lm-row:first-of-type {
  border-top: none;
}

.lm-label {
  color: var(--text-muted);
}

.lm-value {
  color: var(--text-main);
  font-weight: 600;
  text-align: right;
}

.lm-warnings {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  color: var(--btn-malla-text);
  font-size: 11.5px;
}

/* Debug panel (M2) — collapsible, developer-only */
.debug-panel {
  margin-top: 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.debug-panel > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-main);
}

.debug-section {
  margin-top: 8px;
}

.debug-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.debug-tool {
  margin: 6px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}

.debug-tool > summary {
  cursor: pointer;
  font-family: monospace;
}

.debug-block pre,
.debug-section pre {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  overflow-x: auto;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
}

.debug-empty {
  font-style: italic;
}

.interactive-controls { width: 100%; min-width: 0; padding: 12px; }
.interactive-card { margin: 12px 0; padding: 16px; border: 1px solid #8b9baf; border-radius: 12px; overflow-wrap: anywhere; }
.interactive-card h3, .interactive-card h4 { margin: 0 0 8px; }
.interactive-card p { margin: 8px 0; }
.interactive-controls button { min-height: 44px; margin: 4px; padding: 8px 12px; border: 1px solid #8b9baf; border-radius: 8px; background: var(--bg-card, #f1f5f9); color: var(--text-primary, #172033); cursor: pointer; }
.interactive-card input:not([type="checkbox"]) { width: 100%; min-width: 0; min-height: 44px; padding: 8px; box-sizing: border-box; }
.interactive-card summary { cursor: pointer; padding: 12px 0; }
.interactive-controls :focus-visible { outline: 3px solid #3575ad; outline-offset: 3px; }
.signal-row { padding: 12px 0; border-bottom: 1px solid #8b9baf; }
.compare-options { max-height: 240px; overflow-y: auto; }
.compare-options label { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.compare-options label[hidden] { display: none; }
.compare-options input { width: 22px; height: 22px; flex-shrink: 0; }
.demo-banner { padding: 12px; background: #e3edf6; color: #172033; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
.chat-viewport, .chat-messages { min-height: 0; min-width: 0; }
.demo-banner { flex-shrink: 0; margin-top: 8px; }
.history-item { width: 100%; text-align: left; color: var(--text-main); font: inherit; }
.interactive-controls button { color: var(--text-main); }
@media (max-width: 640px) {
  .chat-header { height: auto; min-height: 112px; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .header-actions { width: 100%; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
  .header-actions .status-indicator { display: none; }
  .header-actions button { min-height: 44px; }
  .brand-badge { white-space: nowrap; }
  .chat-viewport { height: auto; }
  .mascot-slot { width: 76px; margin: -20px 0 -6px -8px; }
}
@media (max-width: 640px) {
  .header-actions .btn-catalog { width: 44px; padding: 8px; justify-content: center; }
  .header-actions .btn-catalog span:last-child { display: none; }
  .header-actions { flex-wrap: nowrap; }
}
.interactive-controls button.interactive-primary { background: var(--primary); color: white; border-color: var(--primary); }
.interactive-controls button:disabled { opacity: .6; cursor: wait; }

/* The admin header holds more controls: let them wrap instead of leaving the screen. */
.header-actions:has(#adminBadge) {
  flex-wrap: wrap;
  justify-content: flex-end;
  row-gap: 4px;
}
