/* ─── Google Fonts ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ═══════════════════════════════════════════════════════════════════
   THEME TOKENS
   All colours flow through these variables. To add a new theme,
   add a [data-theme="name"] block and override the tokens below.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Brand — unchanged across themes */
  --red-dot:   #ef4444;
  --accent:    #7c3aed;
  --accent-2:  #6d28d9;

  /* Dark theme (default) */
  --surface:        #0d0d14;
  --surface-2:      #12121c;
  --surface-3:      #0a0a12;
  --surface-4:      #0f0f1c;
  --surface-glass:  rgba(13,13,20,.80);
  --surface-card:   rgba(255,255,255,.03);
  --surface-input:  rgba(10,10,18,.5);
  --surface-input-focus: rgba(14,13,24,.8);
  --surface-modal:  rgba(19,18,30,.95);

  --border:         rgba(255,255,255,.06);
  --border-2:       rgba(255,255,255,.08);
  --border-3:       rgba(255,255,255,.10);
  --border-hover:   rgba(255,255,255,.25);

  --text:           #e8e8f0;
  --text-2:         #e2e8f0;
  --text-3:         #cbd5e1;
  --text-heading:   #ffffff;
  --muted:          #94a3b8;
  --muted-2:        #64748b;
  --muted-3:        #475569;
  --muted-4:        #334155;

  --accent-text:    #c4b5fd;
  --accent-text-2:  #a78bfa;

  /* Archetype colours — stable across themes */
  --arch-amber:   #c4b5fd;
  --arch-pink:    #f9a8d4;
  --arch-emerald: #6ee7b7;

  /* Scrollbar */
  --scroll-thumb: rgba(124,58,237,.25);

  /* Chat bubble tokens (overridden in light mode) */
  --bubble-user-bg:     rgba(96,165,250,.10);
  --bubble-user-border: rgba(96,165,250,.20);
  --bubble-user-text:   #bfdbfe;
  --bubble-ai-bg:       rgba(239,68,68,.06);
  --bubble-ai-border:   rgba(239,68,68,.12);
  --bubble-ai-text:     #e2e8f0;

  /* Invert icon for theme toggle */
  --theme-icon-filter: none;

  color-scheme: dark;
}

[data-theme="light"] {
  /* Muted blue-grey slate — calm, professional, easy on the eyes */
  --surface:        #e8eaed;
  --surface-2:      #f1f3f5;
  --surface-3:      #dde0e4;
  --surface-4:      #f6f7f9;
  --surface-glass:  rgba(232,234,237,.92);
  --surface-card:   rgba(0,0,0,.04);
  --surface-input:  rgba(255,255,255,.85);
  --surface-input-focus: #ffffff;
  --surface-modal:  rgba(241,243,245,.98);

  --border:         rgba(60,70,90,.12);
  --border-2:       rgba(60,70,90,.16);
  --border-3:       rgba(60,70,90,.20);
  --border-hover:   rgba(60,70,90,.35);

  --text:           #1e2330;
  --text-2:         #2a3040;
  --text-3:         #3a4258;
  --text-heading:   #0f1420;
  --muted:          #5a6478;
  --muted-2:        #6e7890;
  --muted-3:        #8892a8;
  --muted-4:        #a8b0c0;

  --accent-text:    #5b21b6;
  --accent-text-2:  #6d28d9;

  /* Chat bubble overrides for light mode */
  --bubble-user-bg:     rgba(99,102,241,.1);
  --bubble-user-border: rgba(99,102,241,.25);
  --bubble-user-text:   #2a2060;
  --bubble-ai-bg:       rgba(239,68,68,.06);
  --bubble-ai-border:   rgba(239,68,68,.14);
  --bubble-ai-text:     #2a3040;

  --scroll-thumb: rgba(124,58,237,.15);
  --theme-icon-filter: none;

  color-scheme: light;
}

/* ─── Base ─── */
html { scroll-behavior: smooth; }

body {
  background-color: var(--surface);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  overflow-x: hidden;
  transition: background-color .25s, color .25s;
}

/* ─── Nav ─── */
.nav-bg {
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
}
.border-white6 { border-color: var(--border); }
.nav-brand { text-decoration: none; }

/* Desktop links — hidden below 640 px */
.nav-links {
  display: none;
  align-items: center;
  gap: 1.5rem;
  font-size: .875rem;
  color: var(--muted);
}
@media (min-width: 640px) { .nav-links { display: flex; } }

.nav-link  { color: inherit; text-decoration: none; transition: color .2s; }
.nav-link:hover { color: var(--text-heading); }

.nav-cta {
  padding: .375rem 1rem;
  border-radius: 9999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  transition: background .2s;
}
.nav-cta:hover { background: var(--accent-2); }

/* Right-side cluster: theme toggle + hamburger */
.nav-right {
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── Hamburger button — visible below 640 px ── */
.nav-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2rem;
  height: 2rem;
  padding: .25rem;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: .375rem;
  transition: background .15s;
}
.nav-hamburger:hover { background: rgba(255,255,255,.07); }

@media (min-width: 640px) { .nav-hamburger { display: none; } }

.nav-hamburger-bar {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform .25s, opacity .2s;
  transform-origin: center;
}

/* Animate to ✕ when open */
.nav-hamburger-bar--open:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger-bar--open:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger-bar--open:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile drawer ── */
.nav-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}

.nav-drawer {
  position: fixed;
  top: 4rem;           /* below the sticky nav */
  left: 0; right: 0;
  z-index: 45;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-2);
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  animation: slideDown .2s ease;
}

@media (min-width: 640px) {
  .nav-drawer,
  .nav-drawer-overlay { display: none; }
}

@keyframes slideDown {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.nav-drawer-links {
  display: flex;
  flex-direction: column;
  padding: .75rem 1.25rem 1.25rem;
  gap: .125rem;
}

.nav-drawer-link {
  display: block;
  padding: .7rem .75rem;
  border-radius: .5rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-drawer-link:hover      { background: rgba(255,255,255,.05); color: var(--text); }
.nav-drawer-link--accent    { color: #c4b5fd; }
.nav-drawer-link--green     { color: #6ee7b7; }
.nav-drawer-link--blue      { color: #93c5fd; }

.nav-drawer-user {
  display: flex;
  flex-direction: column;
  gap: .125rem;
  padding: .7rem .75rem .35rem;
  border-top: 1px solid var(--border);
  margin-top: .375rem;
}

.nav-drawer-logout {
  width: 100%;
  margin-top: .25rem;
  text-align: left;
}

.nav-drawer-cta {
  display: block;
  margin: .5rem .75rem 0;
  text-align: center;
}

/* Theme toggle button */
.theme-toggle {
  display: none; /* temporarily hidden — theme switching WIP */
}
/* CSS-driven icon — no server round-trip needed, works instantly on every page */
.theme-icon-dark  { display: inline; }   /* ☀️ shown in dark mode → click to go light */
.theme-icon-light { display: none; }     /* 🌙 hidden in dark mode */
[data-theme="light"] .theme-icon-dark  { display: none; }
[data-theme="light"] .theme-icon-light { display: inline; }

/* ─── Section helpers ─── */
.section-pad  { padding: 6rem 0; }
.section-title {
  font-size: clamp(1.875rem, 4vw, 2.25rem);
  font-weight: 700;
  color: var(--text-heading);
  text-align: center;
  margin-bottom: 1rem;
}
.section-subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 3.5rem;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}
.features-bg { background: var(--surface-card); }

/* ─── Hero ─── */
.hero-section {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 1.5rem;
  text-align: center;
}
.hero-content { position: relative; z-index: 10; max-width: 48rem; margin: 0 auto; }
.hero-title {
  font-size: clamp(2.25rem, 6vw, 3.75rem);
  font-weight: 700;
  letter-spacing: -.025em;
  margin-bottom: 1rem;
  color: var(--text-heading);
}
.hero-subtitle {
  display: block;
  font-size: clamp(1.25rem, 3vw, 1.875rem);
  font-weight: 300;
  color: var(--accent-text);
  margin-top: .5rem;
}
.hero-desc {
  margin-top: 1rem;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-3);
  line-height: 1.7;
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}
.hero-cta {
  margin-top: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}
.btn-primary {
  padding: .75rem 1.5rem;
  border-radius: 9999px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  text-decoration: none;
  transition: background .2s;
  box-shadow: 0 10px 30px rgba(124,58,237,.4);
}
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary {
  padding: .75rem 1.5rem;
  border-radius: 9999px;
  border: 1px solid var(--accent);
  color: var(--accent-text);
  font-weight: 500;
  text-decoration: none;
  transition: background .2s;
}
.btn-secondary:hover { background: rgba(124,58,237,.15); }

/* Archetype floating badges */
.archetype-badge {
  position: absolute;
  display: none;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border-radius: 1rem;
  background: var(--surface-card);
  border: 1px solid var(--border-3);
  backdrop-filter: blur(8px);
  font-size: .875rem;
}
@media (min-width: 768px) { .archetype-badge { display: flex; } }
.badge-milo  { top: 18%; left: 8%;  color: var(--arch-amber); }
.badge-se    { top: 30%; right: 7%; color: var(--arch-pink); }
.badge-ha    { bottom: 28%; left: 6%; color: var(--arch-emerald); }

@keyframes badge-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.badge-bounce { animation: badge-bounce 3s ease-in-out infinite; }

.scroll-hint {
  position: absolute;
  bottom: 2rem; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column;
  align-items: center; gap: .25rem;
  color: var(--muted-2);
  animation: badge-bounce 2s ease-in-out infinite;
}

/* ─── Chaos orbs ─── */
@keyframes drift {
  0%   { transform: translate(0,0) rotate(0deg); }
  33%  { transform: translate(20px,-15px) rotate(120deg); }
  66%  { transform: translate(-15px,25px) rotate(240deg); }
  100% { transform: translate(0,0) rotate(360deg); }
}
.chaos-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: drift var(--dur, 18s) ease-in-out infinite;
}
.orb-violet  { width: 24rem; height: 24rem; background: #6d28d9; top: -80px; left: -120px;  opacity: .35; }
.orb-indigo  { width: 18rem; height: 18rem; background: #6366f1; bottom: -40px; right: -80px; opacity: .35; }
.orb-fuchsia { width: 14rem; height: 14rem; background: #c026d3; top: 40%; right: 10%; opacity: .35; }
.orb-sky     { width: 10rem; height: 10rem; background: #0ea5e9; bottom: 20%; left: 5%; opacity: .35; }

[data-theme="light"] .orb-violet  { opacity: .12; }
[data-theme="light"] .orb-indigo  { opacity: .10; }
[data-theme="light"] .orb-fuchsia { opacity: .10; }
[data-theme="light"] .orb-sky     { opacity: .10; }

/* ─── Red AI Dot ─── */
@keyframes pulse-dot {
  0%, 100% { transform: scale(1);   box-shadow: 0 0 0 0   rgba(239,68,68,.6); }
  50%       { transform: scale(1.2); box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}
.red-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--red-dot);
  animation: pulse-dot 2s ease-in-out infinite;
  cursor: pointer;
}
.red-dot-lg { width: 20px; height: 20px; }

.red-dot-container { position: relative; display: inline-block; z-index: 1; }
.red-dot-button {
  position: relative;
  width: 32px; height: 32px; padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(248,113,113,.65);
  background: radial-gradient(circle at 35% 35%, #f87171 0%, #ef4444 50%, #991b1b 100%);
  box-shadow: 0 0 24px rgba(239,68,68,.75);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
  isolation: isolate;
}
.red-dot-button::before {
  content: '';
  position: absolute; inset: -14px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(239,68,68,.58) 0%, rgba(239,68,68,0) 72%);
  filter: blur(9px); z-index: -1;
  animation: glow-breathe 2.4s ease-in-out infinite;
  pointer-events: none;
}
.red-dot-button::after {
  content: '';
  position: absolute; inset: -6px;
  border-radius: 999px;
  border: 1px solid rgba(248,113,113,.82);
  box-shadow: 0 0 30px rgba(239,68,68,.95);
  z-index: -1;
  animation: glow-ring 1.9s ease-in-out infinite;
  pointer-events: none;
}
.red-dot-button:hover { transform: scale(1.3); box-shadow: 0 0 30px rgba(239,68,68,.9); }
.red-dot-visual {
  display: block; width: 16px; height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fca5a5 0%, #ef4444 55%, #7f1d1d 100%);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes glow-breathe {
  0%, 100% { transform: scale(.9); opacity: .75; }
  50%       { transform: scale(1.2); opacity: 1; }
}
@keyframes glow-ring {
  0%, 100% { transform: scale(1); opacity: .8; }
  50%       { transform: scale(1.08); opacity: 1; }
}

/* ─── Reflection Modal ─── */
.reflection-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0);
  opacity: 0; pointer-events: none;
  transition: opacity .3s, backdrop-filter .3s;
  padding: 1rem;
}
.reflection-modal-open {
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  opacity: 1; pointer-events: auto;
}
[data-theme="light"] .reflection-modal-open { background: rgba(0,0,0,.25); }

.reflection-modal-content {
  width: 100%; max-width: 420px; max-height: 70vh;
  border-radius: 1rem;
  border: 1px solid rgba(239,68,68,.3);
  background: var(--surface-modal);
  box-shadow: 0 20px 60px rgba(0,0,0,.25), inset 0 1px 0 var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modal-slide-up .35s cubic-bezier(.34,1.56,.64,1);
  text-align: left;
}
.rmc-wide { max-width: 400px !important; max-height: 85vh !important; }

@keyframes modal-slide-up {
  from { transform: translateY(24px) scale(.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.reflection-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid rgba(239,68,68,.15);
  background: rgba(239,68,68,.05);
}
.close-btn {
  width: 28px; height: 28px; border-radius: .5rem;
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; transition: background .2s, color .2s;
}
.close-btn:hover { background: rgba(239,68,68,.2); color: #ef4444; }

.reflection-history {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: .75rem;
  scroll-behavior: smooth;
}
.reflection-history::-webkit-scrollbar { width: 4px; }
.reflection-history::-webkit-scrollbar-track { background: transparent; }
.reflection-history::-webkit-scrollbar-thumb { background: rgba(168,85,247,.3); border-radius: 2px; }

.reflection-bubble {
  border-radius: .75rem; padding: .75rem;
  font-size: .95rem; line-height: 1.4;
  animation: bubble-pop .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes bubble-pop {
  from { transform: scale(.85) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.reflection-bubble.ai-greeting {
  background: rgba(168,85,247,.08);
  border: 1px solid rgba(168,85,247,.2);
  color: var(--accent-text); font-size: .9rem; margin-bottom: .5rem;
}
.reflection-bubble.ai-message {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  color: var(--text); padding: .85rem;
}
.reflection-ai-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .8rem; opacity: .8;
}
.reflection-bubble.user-message {
  background: rgba(96,165,250,.1);
  border: 1px solid rgba(96,165,250,.2);
  color: var(--text-2);
  margin-left: auto; max-width: 85%;
  display: flex; flex-direction: column; gap: .3rem;
}
.thinking-dots { display: inline-block; animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .2; } }

.reflection-input-zone {
  padding: 1rem;
  border-top: 1px solid rgba(239,68,68,.1);
  background: rgba(239,68,68,.02);
}
.reflection-textarea {
  width: 100%; padding: .75rem;
  border-radius: .5rem;
  border: 1px solid rgba(239,68,68,.25);
  background: var(--surface-input);
  color: var(--text); font-family: inherit; font-size: .95rem; resize: none;
  transition: border-color .2s, background .2s;
  box-sizing: border-box;
}
.reflection-textarea:focus {
  outline: none; border-color: #ef4444;
  background: var(--surface-input-focus);
  box-shadow: 0 0 0 3px rgba(239,68,68,.1);
}
.reflection-textarea::placeholder { color: var(--muted-4); }
.reflection-footer {
  display: flex; align-items: center; justify-content: space-between; margin-top: .75rem;
}
.reflection-submit-btn {
  padding: .5rem 1rem; border-radius: .5rem; border: none;
  background: #ef4444; color: white; font-weight: 500; font-size: .85rem;
  cursor: pointer; transition: background .2s, transform .15s;
}
.reflection-submit-btn:hover:not(:disabled) { background: #dc2626; transform: translateY(-1px); }
.reflection-submit-btn:disabled { background: var(--muted-3); cursor: not-allowed; opacity: .5; }
.reflection-info {
  padding: .75rem 1rem;
  background: var(--surface-card);
  border-top: 1px solid var(--border);
}

/* ─── Hire me form ─── */
.hire-input {
  width: 100%; padding: .75rem 1rem;
  border-radius: .5rem;
  border: 1px solid var(--border-2);
  background: var(--surface-card);
  color: var(--text); font-family: inherit; font-size: .95rem;
  transition: border-color .2s;
  box-sizing: border-box;
}
.hire-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,.15); }
.hire-input::placeholder { color: var(--muted-2); }
.hire-submit-btn {
  display: inline-flex; align-items: center; gap: .75rem;
  padding: .875rem 2rem; border-radius: 9999px; border: none;
  background: var(--accent); color: white; font-weight: 600; font-size: 1.125rem;
  cursor: pointer; transition: background .2s, transform .2s, box-shadow .2s;
  box-shadow: 0 10px 40px rgba(124,58,237,.4);
  width: 100%; justify-content: center;
}
.hire-submit-btn:hover:not(:disabled) {
  background: var(--accent-2); transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(124,58,237,.5);
}

/* ─── Archetype card ─── */
.arch-card { transition: transform .25s, box-shadow .25s; }
.arch-card:hover { transform: translateY(-6px) scale(1.02); box-shadow: 0 12px 40px rgba(124,58,237,.25); }

/* ─── Feature card ─── */
.feat-card {
  background: var(--surface-card);
  transition: border-color .25s, transform .25s;
}
.feat-card:hover { border-color: var(--accent); transform: translateY(-4px); }

/* ─── Loop SVG animation ─── */
@keyframes trace {
  from { stroke-dashoffset: 800; }
  to   { stroke-dashoffset: 0; }
}
.loop-path {
  stroke-dasharray: 800; stroke-dashoffset: 800;
  animation: trace 4s ease-in-out infinite alternate;
}

/* ─── Lot 49 easter egg ─── */
.lot-49 { opacity: 0; transition: opacity 1s; color: var(--muted-3); }
.lot-49:hover { opacity: 1; }

.lot49-quote {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
  max-width: 22rem; padding: .85rem 1rem;
  border-radius: .75rem;
  border: 1px solid rgba(250,204,21,.4);
  background: var(--surface-modal);
  color: #f8e9a8;
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
  transform: translateY(10px); opacity: 0; pointer-events: none;
  transition: transform .35s, opacity .35s;
}
.lot49-quote strong { color: #facc15; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; }
.lot49-quote p  { margin-top: .35rem; font-size: .95rem; line-height: 1.4; }
.lot49-quote small { display: block; margin-top: .2rem; color: #d4c17a; font-size: .72rem; }
.lot49-awake .lot49-quote { transform: translateY(0); opacity: 1; }

.waste-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #facc15;
  box-shadow: 0 0 0 0 rgba(250,204,21,.5);
  animation: waste-pulse 2.2s ease-in-out infinite;
}
@keyframes waste-pulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(250,204,21,.45); }
  50%       { box-shadow: 0 0 0 6px rgba(250,204,21,0); }
}

/* ─── Tailwind utility shims ─── */
.text-red-500   { color: #ef4444; }
.text-red-400   { color: #f87171; }
.text-red-700   { color: #b91c1c; }
.text-violet-400 { color: #a78bfa; }
.text-violet-300 { color: #c4b5fd; }
.text-pink-400  { color: #f472b6; }
.text-pink-300  { color: #f9a8d4; }
.text-emerald-400 { color: #34d399; }
.text-emerald-300 { color: #6ee7b7; }
.text-amber-400 { color: #fbbf24; }
.text-yellow-400 { color: #facc15; }
.text-indigo-400 { color: #818cf8; }
.text-sky-300   { color: #7dd3fc; }
.text-slate-400 { color: #94a3b8; }
.text-slate-500 { color: #64748b; }
.text-slate-600 { color: #475569; }
.text-slate-300 { color: #cbd5e1; }
.text-white     { color: #ffffff; }
.bg-amber-900\/20   { background: rgba(120,53,15,.2); }
.bg-pink-900\/20    { background: rgba(131,24,67,.2); }
.bg-emerald-900\/20 { background: rgba(6,78,59,.2); }
.bg-red-900\/20     { background: rgba(127,29,29,.2); }
.border-white\/8    { border-color: rgba(255,255,255,.08); }
.border-amber-500\/40   { border-color: rgba(245,158,11,.4); }
.border-pink-500\/40    { border-color: rgba(236,72,153,.4); }
.border-emerald-500\/40 { border-color: rgba(16,185,129,.4); }
.border-red-500\/40     { border-color: rgba(239,68,68,.4); }
.hover\:border-amber-400:hover   { border-color: #fbbf24; }
.hover\:border-pink-400:hover    { border-color: #f472b6; }
.hover\:border-emerald-400:hover { border-color: #34d399; }
.hover\:border-red-400:hover     { border-color: #f87171; }
.hover\:border-violet-400:hover  { border-color: #a78bfa; }
.hover\:border-sky-400:hover     { border-color: #38bdf8; }
.border-violet-500\/40 { border-color: rgba(139,92,246,.4); }
.border-sky-500\/40    { border-color: rgba(14,165,233,.4); }
.bg-violet-900\/50 { background: rgba(76,29,149,.5); }
.bg-sky-900\/50    { background: rgba(12,74,110,.5); }
.bg-emerald-900\/50 { background: rgba(6,78,59,.5); }
.bg-violet-600 { background: #7c3aed; }
.hover\:bg-violet-500:hover { background: #8b5cf6; }
.bg-red-500 { background: #ef4444; }
.shadow-violet-900\/30 { box-shadow: 0 10px 15px rgba(76,29,149,.3); }
.tracking-widest { letter-spacing: .1em; }
.not-italic  { font-style: normal; }
.font-medium  { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold    { font-weight: 700; }
.rounded-full { border-radius: 9999px; }
.rounded-2xl  { border-radius: 1rem; }
.rounded-xl   { border-radius: .75rem; }
.antialiased  { -webkit-font-smoothing: antialiased; }
.select-none  { user-select: none; }
.cursor-default { cursor: default; }
.overflow-hidden { overflow: hidden; }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-10 { margin-bottom: 2.5rem; }
.mb-14 { margin-bottom: 3.5rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mt-auto { margin-top: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.px-3 { padding-left: .75rem; padding-right: .75rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-7 { padding-left: 1.75rem; padding-right: 1.75rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.py-1 { padding-top: .25rem; padding-bottom: .25rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-24 { padding-top: 6rem; padding-bottom: 6rem; }
.py-28 { padding-top: 7rem; padding-bottom: 7rem; }
.p-6  { padding: 1.5rem; }
.p-7  { padding: 1.75rem; }
.p-8  { padding: 2rem; }
.w-full { width: 100%; }
.w-2  { width: .5rem; }
.w-5  { width: 1.25rem; }
.w-8  { width: 2rem; }
.w-12 { width: 3rem; }
.h-2  { height: .5rem; }
.h-5  { height: 1.25rem; }
.h-8  { height: 2rem; }
.h-12 { height: 3rem; }
.max-w-3xl { max-width: 48rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-5xl { max-width: 64rem; }
.max-w-lg  { max-width: 32rem; }
.max-w-xl  { max-width: 36rem; }
.text-xs   { font-size: .75rem; }
.text-sm   { font-size: .875rem; }
.text-base { font-size: 1rem; }
.text-lg   { font-size: 1.125rem; }
.text-xl   { font-size: 1.25rem; }
.text-2xl  { font-size: 1.5rem; }
.text-3xl  { font-size: 1.875rem; }
.text-4xl  { font-size: 2.25rem; }
.text-center { text-align: center; }
.text-left   { text-align: left; }
.leading-relaxed { line-height: 1.625; }
.leading-tight   { line-height: 1.25; }
.uppercase  { text-transform: uppercase; }
.italic     { font-style: italic; }
.block      { display: block; }
.inline-block { display: inline-block; }
.inline-flex  { display: inline-flex; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.inset-0  { inset: 0; }
.inset-x-0 { left: 0; right: 0; }
.top-0  { top: 0; }
.top-16 { top: 4rem; }
.bottom-0 { bottom: 0; }
.z-50  { z-index: 50; }
.z-100 { z-index: 100; }
.hidden { display: none; }
.grid   { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
@media (min-width: 640px) {
  .sm\:text-4xl { font-size: 2.25rem; }
  .sm\:text-5xl { font-size: 3rem; }
  .sm\:text-6xl { font-size: 3.75rem; }
  .sm\:text-3xl { font-size: 1.875rem; }
  .sm\:text-xl  { font-size: 1.25rem; }
  .sm\:flex { display: flex; }
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
  .sm\:inline { display: inline; }
}
@media (min-width: 768px) {
  .md\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}
.pt-16 { padding-top: 4rem; }
.border-t { border-top: 1px solid; }
.border-b { border-bottom: 1px solid; }
.border   { border: 1px solid; }
.border-white\/6  { border-color: var(--border); }
.border-white\/10 { border-color: var(--border-3); }
.backdrop-blur-md { backdrop-filter: blur(12px); }
.transition-colors { transition: color .2s, background-color .2s; }
.tracking-\[0\.24em\] { letter-spacing: .24em; }
.text-\[10px\] { font-size: 10px; }
.shadow-lg { box-shadow: 0 10px 15px rgba(0,0,0,.2); }
.w-96 { width: 24rem; }
.h-96 { height: 24rem; }
.w-72 { height: 18rem; width: 18rem; }
.gap  { gap: .5rem; }

/* ─── Archetype picker ─── */
.arch-picker-section {
  padding: 1.25rem 1rem 1rem;
  display: flex; flex-direction: column; gap: .75rem;
  overflow-y: auto; text-align: left;
}
.arch-picker-label {
  font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted-3); text-align: center;
}
.arch-pill-grid {
  display: flex; flex-direction: column; gap: .4rem; width: 100%;
}
.arch-pill {
  display: flex !important; flex-direction: row !important;
  align-items: center !important;
  gap: .75rem; width: 100%; box-sizing: border-box;
  padding: .65rem 1rem;
  border-radius: 9999px;
  border: 1px solid var(--border-2);
  background: var(--surface-card);
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .15s;
  user-select: none; text-align: left;
}
.arch-pill:hover {
  background: rgba(255,255,255,.07);
  transform: translateX(3px);
}
[data-theme="light"] .arch-pill:hover { background: rgba(0,0,0,.04); }
.arch-pill--active { background: rgba(255,255,255,.06); }
[data-theme="light"] .arch-pill--active { background: rgba(124,58,237,.07); }
.arch-pill-emoji { font-size: 1.3rem; line-height: 1; flex-shrink: 0; width: 1.6rem; }
.arch-pill-name  { font-size: .875rem; font-weight: 600; flex: 1; min-width: 0; color: var(--text); }
.arch-pill-sub   { font-size: .7rem; color: var(--muted-2); flex-shrink: 0; }
.arch-pill-check { font-size: .75rem; font-weight: 700; flex-shrink: 0; width: 1rem; opacity: 0; transition: opacity .15s; }
.arch-pill--active .arch-pill-check { opacity: 1; }

.arch-pick-desc-box {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .5rem .75rem; border-radius: .5rem;
  border: 1px solid transparent;
  background: var(--surface-card);
  font-size: .72rem; color: var(--muted-2); line-height: 1.45;
}
.arch-start-btn {
  display: block; width: 100%; box-sizing: border-box;
  padding: .65rem 1rem; border-radius: 9999px; border: none;
  color: #fff; font-weight: 600; font-size: .875rem;
  text-align: center; cursor: pointer;
  transition: filter .2s, transform .15s;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.arch-start-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }

.arch-active-bar {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .875rem;
  border-bottom: 1px solid transparent;
}
.arch-active-icon { font-size: 1rem; flex-shrink: 0; }
.arch-active-name { font-weight: 600; font-size: .78rem; color: var(--text); }
.arch-active-mode { font-size: .62rem; color: var(--muted-3); text-transform: uppercase; letter-spacing: .08em; }
.arch-switch-btn {
  margin-left: auto;
  padding: .25rem .65rem; border-radius: 9999px;
  border: 1px solid var(--border-2);
  background: var(--surface-card);
  color: var(--muted); font-size: .72rem; font-family: inherit;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  flex-shrink: 0;
}
.arch-switch-btn:hover {
  color: var(--text-2);
  border-color: var(--border-hover);
  background: var(--surface-glass);
}

/* ─── AI bubbles ─── */
.rflx-ai-bubble { border: 1px solid transparent; padding: .85rem !important; }
.arch-icon { font-size: .9rem; line-height: 1; }
.thinking-bubble { opacity: .7; }
.thinking-dots {
  display: inline-block;
  font-size: 1.3rem; letter-spacing: .15em;
  color: var(--muted);
  animation: thinking-blink 1.2s steps(3,end) infinite;
}
@keyframes thinking-blink { 0%,100%{opacity:.15} 50%{opacity:1} }

/* ═══════════════════════════════════════════════════════════════════
   ASK PAGE  —  /ask
   ═══════════════════════════════════════════════════════════════════ */

.ask-page {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "banner  banner"
    "sidebar chat";
  min-height: calc(100vh - 4rem);
  background: var(--surface);
  color-scheme: inherit;
}
/* ── Mobile panel switcher tab bar (hidden on desktop) ── */
.ask-mobile-tabs {
  display: none;
}

@media (max-width: 639px) {
  /* Stack the grid — mobile tab bar controls which panel is visible */
  .ask-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "banner"
      "sidebar"
      "chat";
    min-height: calc(100vh - 4rem);
    overflow: visible;
  }

  /* Tab bar appears at top */
  .ask-mobile-tabs {
    display: flex;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-2);
    padding: .375rem .75rem;
    gap: .375rem;
    /* Spans both grid columns (only 1 on mobile) */
    grid-column: 1 / -1;
    position: sticky;
    top: 4rem;   /* below sticky nav */
    z-index: 30;
  }

  .ask-mobile-tab {
    flex: 1;
    padding: .5rem;
    border-radius: .5rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
  }
  .ask-mobile-tab:hover {
    background: rgba(255,255,255,.05);
    color: var(--text);
  }
  .ask-mobile-tab--active {
    background: rgba(99,102,241,.18);
    border-color: rgba(99,102,241,.4);
    color: var(--accent-text, #a5b4fc);
  }

  /* Hide the non-active panel — display:none so it doesn't take up space */
  .ask-panel--hidden-mobile {
    display: none !important;
  }

  /* Full-height panels on mobile */
  .ask-sidebar {
    min-height: 0;   /* let content dictate height on mobile */
  }
  .ask-chat-panel {
    min-height: calc(100dvh - 9rem);  /* chat needs full height for the message list */
  }
}

/* ── Sidebar ── */
.ask-sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 0;
  overflow-y: auto;
  padding: 1.25rem 1rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
  align-self: stretch;
}
.ask-sidebar::-webkit-scrollbar { width: 4px; }
.ask-sidebar::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 2px; }

.ask-sidebar-header {
  display: flex; align-items: center; gap: .75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.ask-sidebar-icon-wrap {
  width: 36px; height: 36px; border-radius: .6rem;
  background: rgba(124,58,237,.15);
  border: 1px solid rgba(139,92,246,.25);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ask-sidebar-title { font-size: .875rem; font-weight: 700; color: var(--text-heading); line-height: 1.2; }
.ask-sidebar-sub   { font-size: .7rem;  color: var(--muted-2); margin-top: .1rem; }

.ingest-tabs { display: flex; gap: .35rem; margin-bottom: 1rem; }
.ingest-tab {
  flex: 1; padding: .35rem .4rem; border-radius: .45rem;
  border: 1px solid var(--border-2);
  background: var(--surface-card);
  color: var(--muted-2); font-size: .75rem; font-family: inherit;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.ingest-tab:hover { background: var(--surface-glass); color: var(--text-2); }
.ingest-tab--active {
  background: rgba(124,58,237,.15);
  border-color: rgba(139,92,246,.35);
  color: var(--accent-text); font-weight: 600;
}

.ingest-form { display: flex; flex-direction: column; }
.ingest-field-label {
  font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted-3); margin-bottom: .45rem; display: block;
}
.ingest-textarea {
  width: 100%; padding: .7rem .75rem; border-radius: .5rem;
  border: 1px solid var(--border-2) !important;
  background: var(--surface-input) !important;
  color: var(--text) !important;
  font-family: inherit; font-size: .825rem; line-height: 1.5;
  resize: vertical; transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
}
.ingest-textarea:focus {
  outline: none;
  border-color: rgba(124,58,237,.5) !important;
  box-shadow: 0 0 0 3px rgba(124,58,237,.1) !important;
  background: var(--surface-input-focus) !important;
}
.ingest-textarea::placeholder { color: var(--muted-4); }

.ingest-url-input {
  width: 100%; padding: .65rem .75rem; border-radius: .5rem;
  border: 1px solid var(--border-2);
  background: var(--surface-input) !important;
  color: var(--text) !important;
  font-family: inherit; font-size: .825rem;
  transition: border-color .2s, box-shadow .2s; box-sizing: border-box;
}
.ingest-url-input:focus {
  outline: none;
  border-color: rgba(124,58,237,.5);
  box-shadow: 0 0 0 3px rgba(124,58,237,.1);
}
.ingest-url-input::placeholder { color: var(--muted-4); }
.ingest-hint { font-size: .7rem; color: var(--muted-3); margin-top: .4rem; line-height: 1.4; }

.ingest-meta-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: .5rem; gap: .5rem;
}
.ingest-char-count      { font-size: .72rem; color: var(--muted-3); }
.ingest-char-count--warn { color: #f59e0b; }

.ingest-submit-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem 1rem; border-radius: .5rem; border: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff; font-weight: 600; font-size: .78rem;
  cursor: pointer; transition: filter .2s, transform .15s; white-space: nowrap;
}
.ingest-submit-btn:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-1px); }
.ingest-submit-btn:disabled { filter: grayscale(.7) brightness(.6); cursor: not-allowed; transform: none; }

.ingest-clear-btn {
  padding: .35rem .7rem; border-radius: .4rem;
  border: 1px solid rgba(239,68,68,.25);
  background: rgba(239,68,68,.08); color: #f87171;
  font-size: .72rem; font-family: inherit; cursor: pointer;
  transition: background .15s;
}
.ingest-clear-btn:hover { background: rgba(239,68,68,.18); }

.btn-spinner {
  width: 10px; height: 10px;
  border: 1.5px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.file-drop-zone {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 1.75rem 1rem; border-radius: .75rem;
  border: 2px dashed rgba(124,58,237,.25);
  background: rgba(124,58,237,.03);
  cursor: pointer; transition: border-color .2s, background .2s;
  position: relative; text-align: center; min-height: 120px;
}
.file-drop-zone--over   { border-color: var(--accent); background: rgba(124,58,237,.12); }
.file-drop-zone--loaded { border-color: rgba(16,185,129,.4); border-style: solid; background: rgba(6,78,59,.12); }
.file-input-hidden { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.ingest-status {
  margin-top: .875rem; padding: .55rem .75rem; border-radius: .5rem;
  font-size: .78rem; font-weight: 500;
  display: flex; align-items: center; gap: .5rem;
  animation: bubble-pop .3s ease;
}
.ingest-status--ok  { background: rgba(16,185,129,.1);  border: 1px solid rgba(16,185,129,.28); color: #6ee7b7; }
.ingest-status--err { background: rgba(239,68,68,.1);   border: 1px solid rgba(239,68,68,.28);  color: #fca5a5; }

.ingest-log-section { margin-top: 1.5rem; flex: 1; display: flex; flex-direction: column; }

.ingest-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .625rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.ingest-log-header-left {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.ingest-log-view-all {
  font-size: .7rem;
  color: var(--accent-text-2);
  text-decoration: none;
  flex-shrink: 0;
}
.ingest-log-view-all:hover { text-decoration: underline; }

.ingest-log-label {
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .14em; color: var(--muted-3);
}
.ingest-log-badge {
  font-size: .65rem; font-weight: 700;
  padding: .1rem .45rem; border-radius: 9999px;
  background: rgba(124,58,237,.2); color: #a78bfa;
  border: 1px solid rgba(139,92,246,.25);
}
.ingest-log-empty  { font-size: .75rem; color: var(--muted-4); font-style: italic; }
.ingest-log-list   { display: flex; flex-direction: column; gap: .3rem; list-style: none; padding: 0; margin: 0; }
.ingest-log-item {
  display: flex; align-items: center; gap: .45rem;
  padding: .35rem .6rem; border-radius: .4rem;
  background: var(--surface-card);
  border: 1px solid var(--border);
  font-size: .73rem; animation: bubble-pop .3s ease;
}
.ingest-log-item--err { border-color: rgba(239,68,68,.18); }
.ingest-log-icon       { font-size: .85rem; flex-shrink: 0; }
.ingest-log-label-text { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ingest-log-time       { color: var(--muted-4); flex-shrink: 0; font-size: .68rem; }

/* ── Chat panel ── */
.ask-chat-panel {
  grid-area: chat;
  display: flex; flex-direction: column;
  background: var(--surface); min-height: 0;
}
.ask-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-card);
  flex-shrink: 0; gap: 1rem;
}
.ask-chat-header-left { display: flex; align-items: center; gap: .625rem; min-width: 0; }
.ask-live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #ef4444; flex-shrink: 0;
  animation: pulse-dot 2s ease-in-out infinite;
}
.ask-chat-header-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.ask-header-btn {
  padding: .3rem .75rem; border-radius: .4rem;
  border: 1px solid var(--border-2);
  background: var(--surface-card);
  color: var(--muted); font-size: .75rem; font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: background .15s, color .15s; white-space: nowrap;
}
.ask-header-btn:hover { background: var(--surface-glass); color: var(--text-2); }

.ask-history {
  flex: 1; overflow-y: auto;
  padding: 1.5rem 1.5rem 1rem;
  display: flex; flex-direction: column; gap: 1rem;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
  max-height: calc(100vh - 12rem);
}
.ask-history::-webkit-scrollbar { width: 4px; }
.ask-history::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 2px; }

.ask-empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 3rem 2rem; text-align: center; min-height: 300px;
}
.ask-empty-orb {
  width: 56px; height: 56px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f87171 0%, #ef4444 50%, #7f1d1d 100%);
  box-shadow: 0 0 40px rgba(239,68,68,.45);
  animation: pulse-dot 2.5s ease-in-out infinite; margin-bottom: 1.25rem;
}
.ask-empty-title { font-size: 1.125rem; font-weight: 700; color: var(--text-heading); margin-bottom: .5rem; }
.ask-empty-sub   { font-size: .875rem; color: var(--muted-2); line-height: 1.6; max-width: 26rem; }
.ask-suggestion-chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: 1.5rem; }
.ask-chip {
  padding: .4rem 1rem; border-radius: 9999px;
  border: 1px solid rgba(124,58,237,.28);
  background: rgba(124,58,237,.07);
  color: var(--accent-text-2); font-size: .78rem; font-family: inherit;
  cursor: pointer; transition: background .15s, border-color .15s, transform .12s;
}
.ask-chip:hover { background: rgba(124,58,237,.18); border-color: rgba(139,92,246,.5); transform: translateY(-1px); }

.ask-bubble-row {
  display: flex; align-items: flex-end; gap: .625rem;
  animation: bubble-pop .35s cubic-bezier(.34,1.56,.64,1);
}
.ask-bubble-row--user { flex-direction: row-reverse; }
.ask-bubble-row--ai   { flex-direction: row; }

.ask-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: .7rem; font-weight: 700;
}
.ask-avatar--user {
  background: rgba(96,165,250,.18);
  border: 1px solid rgba(96,165,250,.25);
  color: #93c5fd; font-size: .6rem;
}
.ask-avatar--ai {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.2);
  font-size: .85rem;
}

.ask-bubble {
  border-radius: .875rem; padding: .8rem .95rem;
  max-width: min(80%, 560px);
}
.ask-bubble--user {
  background: var(--bubble-user-bg);
  border: 1px solid var(--bubble-user-border);
  border-bottom-right-radius: .2rem;
}
.ask-bubble--ai {
  background: var(--bubble-ai-bg);
  border: 1px solid var(--bubble-ai-border);
  border-bottom-left-radius: .2rem;
  max-width: min(88%, 640px);
}
.ask-bubble--err     { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); }
.ask-bubble--thinking { opacity: .65; }

.ask-ai-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .45rem; gap: .5rem;
}
.ask-ai-label {
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em; color: #f87171;
}
.ask-bubble-text { font-size: .875rem; line-height: 1.65; color: var(--bubble-ai-text); }
.ask-bubble--user .ask-bubble-text { color: var(--bubble-user-text); }
.ask-bubble-time { font-size: .7rem; color: var(--muted-3); display: block; margin-top: .35rem; }
.ask-bubble--user .ask-bubble-time { text-align: right; }

.ask-input-zone {
  padding: .875rem 1.25rem 1rem;
  border-top: 1px solid var(--border);
  background: rgba(239,68,68,.015);
  flex-shrink: 0;
}
.ask-input-wrap { display: flex; align-items: flex-end; gap: .625rem; }
.ask-textarea {
  flex: 1; padding: .7rem .875rem; border-radius: .625rem;
  border: 1px solid rgba(239,68,68,.2) !important;
  background: var(--surface-input) !important;
  color: var(--text) !important;
  font-family: inherit; font-size: .9rem; line-height: 1.5;
  resize: none; transition: border-color .2s, box-shadow .2s; box-sizing: border-box;
}
.ask-textarea:focus {
  outline: none;
  border-color: rgba(239,68,68,.5) !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,.09) !important;
  background: var(--surface-input-focus) !important;
}
.ask-textarea::placeholder { color: var(--muted-4); }
.ask-send-btn {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: .625rem; border: none;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: filter .2s, transform .15s;
  box-shadow: 0 4px 16px rgba(239,68,68,.35);
}
.ask-send-btn:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-1px); }
.ask-send-btn:disabled { filter: grayscale(.7) brightness(.55); cursor: not-allowed; transform: none; box-shadow: none; }
.ask-input-hint {
  display: flex; justify-content: space-between;
  font-size: .7rem; color: var(--muted-4);
  margin-top: .4rem; padding: 0 .1rem;
}

/* ─── Ask page UA stylesheet overrides ─── */
.ask-page {
  color-scheme: inherit;
}
.ask-page textarea,
.ask-page input[type="url"],
.ask-page input[type="text"],
.ask-page input {
  -webkit-appearance: none; appearance: none;
}
.ask-page textarea:focus,
.ask-page input:focus { outline: none; }

/* Stacking context */
.ask-sidebar    { position: relative; }
.ask-chat-panel { position: relative; }

/* ═══════════════════════════════════════════════════════════════════
   KNOWLEDGE ENGINE PAGE  —  /knowledge
   ═══════════════════════════════════════════════════════════════════ */

.knowledge-page {
  min-height: calc(100vh - 4rem);
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.knowledge-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.knowledge-header-left { display: flex; align-items: center; gap: 1rem; }
.knowledge-header-icon { font-size: 2rem; line-height: 1; }
.knowledge-title {
  font-size: 1.25rem; font-weight: 700;
  color: var(--text-heading); margin: 0;
}
.knowledge-subtitle { font-size: .8rem; color: var(--muted-2); margin: .1rem 0 0; }
.knowledge-header-actions { display: flex; gap: .5rem; }
.knowledge-nav-btn {
  padding: .45rem 1rem; border-radius: .5rem;
  border: 1px solid var(--border-2);
  background: var(--surface-card); color: var(--muted);
  font-size: .8rem; text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s;
}
.knowledge-nav-btn--active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.knowledge-nav-btn:hover:not(.knowledge-nav-btn--active) {
  background: var(--surface-glass); color: var(--text);
}

/* ── Tab bar ── */
.knowledge-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0 2rem;
  flex-shrink: 0;
}
.knowledge-tab {
  padding: .75rem 1.25rem;
  border: none; border-bottom: 2px solid transparent;
  background: transparent; color: var(--muted);
  font-size: .875rem; font-family: inherit; cursor: pointer;
  transition: color .15s, border-color .15s;
  display: flex; align-items: center; gap: .4rem;
  margin-bottom: -1px;
}
.knowledge-tab:hover { color: var(--text); }
.knowledge-tab--active { color: var(--accent-text-2); border-bottom-color: var(--accent); }
.knowledge-tab-count {
  font-size: .7rem; font-weight: 700;
  padding: .1rem .4rem; border-radius: 9999px;
  background: var(--surface-card); color: var(--muted);
}
.knowledge-tab--active .knowledge-tab-count {
  background: rgba(124,58,237,.15); color: var(--accent-text-2);
}

/* ── Content area ── */
.knowledge-content {
  flex: 1; padding: 1.5rem 2rem; overflow-y: auto;
}
.knowledge-loading {
  display: flex; align-items: center; gap: .75rem;
  color: var(--muted); padding: 3rem; justify-content: center;
}
.knowledge-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.knowledge-filters {
  display: flex; gap: .5rem; margin-bottom: 1.25rem;
}
.knowledge-filter-select {
  padding: .45rem 2.25rem .45rem .875rem;
  border-radius: .5rem;
  border: 1px solid var(--border-2);
  background: var(--surface-2); color: var(--text);
  font-size: .8rem; font-weight: 500; font-family: inherit;
  cursor: pointer;
  /* Custom chevron — replaces the OS-default arrow */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e7890' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .625rem center;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.knowledge-filter-select:hover {
  border-color: rgba(139,92,246,.5);
  background-color: var(--surface-glass);
}
.knowledge-filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,.12);
}
.knowledge-filter-select option {
  background: var(--surface-2);
  color: var(--text);
}
.knowledge-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4rem 2rem; text-align: center; gap: .875rem;
}
.knowledge-empty-icon  { font-size: 3rem; line-height: 1; }
.knowledge-empty-title { font-size: 1.1rem; font-weight: 700; color: var(--text-heading); margin: 0; }
.knowledge-empty-sub   {
  font-size: .875rem; color: var(--muted-2);
  max-width: 30rem; margin: 0; line-height: 1.65;
}
.knowledge-link        { color: var(--accent-text-2); text-decoration: none; }
.knowledge-link:hover  { text-decoration: underline; }

/* ── Primary CTA button used in empty states across all pages ── */
.empty-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: .375rem;
  padding: .6rem 1.4rem;
  border-radius: 9999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: .875rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, transform .1s, opacity .15s;
  box-shadow: 0 4px 16px rgba(124,58,237,.3);
}
.empty-cta-btn:hover:not(:disabled)  { background: var(--accent-2); transform: translateY(-1px); }
.empty-cta-btn:active:not(:disabled) { transform: translateY(0); }
.empty-cta-btn:disabled { opacity: .6; cursor: not-allowed; }

.empty-cta-btn--secondary {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  box-shadow: none;
}
.empty-cta-btn--secondary:hover:not(:disabled) {
  background: var(--surface-3);
}

/* ── SOP grid ── */
.sop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.sop-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: 1rem 1.125rem;
  cursor: pointer;
  transition: border-color .2s, transform .15s, box-shadow .2s;
}
.sop-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124,58,237,.15);
}
.sop-card--approved { border-color: rgba(52,211,153,.3); }
.sop-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .625rem; }
.sop-card-meta   { display: flex; align-items: center; gap: .5rem; }
.sop-badge {
  font-size: .65rem; font-weight: 700;
  padding: .15rem .55rem; border-radius: 9999px;
  text-transform: uppercase; letter-spacing: .06em;
}
.sop-badge--candidate { background: rgba(251,191,36,.15); color: #fbbf24; }
.sop-badge--draft     { background: rgba(99,102,241,.15); color: #818cf8; }
.sop-badge--approved  { background: rgba(52,211,153,.15); color: #34d399; }
.sop-badge--archived  { background: var(--surface-card); color: var(--muted-3); }
.sop-badge--superseded { background: var(--surface-card); color: var(--muted-4); }
.sop-category { font-size: .7rem; color: var(--muted-3); }

.sop-confidence { display: flex; align-items: center; gap: .35rem; }
.sop-confidence-bar {
  width: 48px; height: 4px; border-radius: 2px;
  background: var(--surface-card); overflow: hidden;
}
.sop-confidence-fill { height: 100%; border-radius: 2px; transition: width .3s; }
.sop-confidence-label { font-size: .65rem; color: var(--muted-3); }

.sop-title { font-size: .95rem; font-weight: 600; color: var(--text-heading); margin: 0 0 .35rem; }
.sop-desc  { font-size: .78rem; color: var(--muted-2); line-height: 1.5; margin: 0 0 .625rem;
             display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sop-footer {
  display: flex; align-items: center; gap: .75rem;
  font-size: .7rem; color: var(--muted-3);
  border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .25rem;
}
.sop-steps  { flex: 1; }
.sop-version { font-weight: 600; }
.sop-date   { }

/* ── SOP Drawer ── */
.sop-drawer-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.4); backdrop-filter: blur(2px);
}
.sop-drawer {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 90;
  width: min(520px, 100vw);
  background: var(--surface-2);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,.25);
  animation: slide-in-right .25s ease;
}
@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.sop-drawer-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem 1.25rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-2);
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
}

.sop-drawer-titlebar-text {
  font-size: .875rem;
  font-weight: 700;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.sop-drawer-titlebar-close {
  flex-shrink: 0;
}

.sop-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: .5rem;
}
.sop-drawer-close {
  width: 28px; height: 28px; border-radius: .4rem;
  background: var(--surface-card); border: 1px solid var(--border-2);
  color: var(--muted); cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.sop-drawer-close:hover { background: var(--surface-glass); color: var(--text); }
.sop-action-btn {
  padding: .35rem .85rem; border-radius: .4rem; border: 1px solid;
  font-size: .78rem; font-family: inherit; cursor: pointer;
  transition: background .15s;
}
.sop-action-btn--approve {
  border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.08); color: #34d399;
}
.sop-action-btn--approve:hover { background: rgba(52,211,153,.18); }
.sop-action-btn--archive {
  border-color: var(--border-2); background: var(--surface-card); color: var(--muted);
}
.sop-action-btn--archive:hover { background: var(--surface-glass); color: var(--text); }

.sop-drawer-body { flex: 1; overflow-y: auto; padding: 1.25rem; }
.sop-drawer-title { font-size: 1.25rem; font-weight: 700; color: var(--text-heading); margin: 0 0 .5rem; }
.sop-drawer-desc  { font-size: .875rem; color: var(--muted-2); line-height: 1.6; margin: 0 0 .75rem; }
.sop-drawer-meta  {
  display: flex; align-items: center; gap: .5rem;
  font-size: .75rem; color: var(--muted-3); margin-bottom: .75rem;
}
.sop-drawer-tags  { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1.25rem; }

.sop-steps-list   { margin-top: 1rem; }
.sop-steps-heading { font-size: .8rem; font-weight: 700; text-transform: uppercase;
                     letter-spacing: .1em; color: var(--muted-3); margin: 0 0 .75rem; }
.sop-step {
  display: flex; gap: .875rem; margin-bottom: .875rem;
  padding-bottom: .875rem; border-bottom: 1px solid var(--border);
}
.sop-step:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.sop-step-number {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: rgba(124,58,237,.15); border: 1px solid rgba(139,92,246,.3);
  color: var(--accent-text-2); font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.sop-step-body    { flex: 1; min-width: 0; }
.sop-step-title   { font-size: .875rem; font-weight: 600; color: var(--text); margin-bottom: .25rem; }
.sop-step-desc    { font-size: .8rem; color: var(--muted-2); line-height: 1.5; margin: 0 0 .35rem; }
.sop-step-meta    { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }
.sop-step-meta-item { font-size: .72rem; color: var(--muted-3); }
.sop-step-warning { font-size: .75rem; color: #fbbf24; margin-top: .35rem; line-height: 1.4; }

/* ── Insights list ── */
.insights-list { display: flex; flex-direction: column; gap: .75rem; }
.insight-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: .75rem; padding: 1rem 1.125rem;
  border-left-width: 3px;
}
.insight-card--critical { border-left-color: #ef4444; }
.insight-card--high     { border-left-color: #f97316; }
.insight-card--medium   { border-left-color: #fbbf24; }
.insight-card--low      { border-left-color: #94a3b8; }
.insight-card--none     { border-left-color: var(--border); }
.insight-card-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.insight-type-badge {
  font-size: .65rem; font-weight: 700; padding: .15rem .55rem; border-radius: 9999px;
  background: rgba(124,58,237,.12); color: var(--accent-text-2);
  text-transform: uppercase; letter-spacing: .06em;
}
.insight-severity-badge {
  font-size: .65rem; font-weight: 700; padding: .15rem .55rem; border-radius: 9999px;
  text-transform: uppercase; letter-spacing: .06em;
}
.insight-severity--critical { background: rgba(239,68,68,.15); color: #f87171; }
.insight-severity--high     { background: rgba(249,115,22,.15); color: #fb923c; }
.insight-severity--medium   { background: rgba(251,191,36,.15); color: #fbbf24; }
.insight-severity--low      { background: var(--surface-card);  color: var(--muted-3); }
.insight-severity--none     { background: var(--surface-card);  color: var(--muted-4); }
.insight-domain { font-size: .7rem; color: var(--muted-3); }
.insight-title  { font-size: .95rem; font-weight: 600; color: var(--text-heading); margin: 0 0 .35rem; }
.insight-desc   { font-size: .8rem; color: var(--muted-2); line-height: 1.5; margin: 0 0 .5rem; }
.insight-recommendation { font-size: .78rem; color: var(--muted); line-height: 1.5; margin: 0 0 .5rem; }
.insight-rec-label { font-weight: 600; color: var(--muted-2); }
.insight-footer { display: flex; align-items: center; justify-content: space-between; margin-top: .5rem; }
.insight-confidence { font-size: .72rem; color: var(--muted-4); }
.insight-resolve-btn {
  padding: .3rem .75rem; border-radius: .4rem;
  border: 1px solid rgba(52,211,153,.3); background: rgba(52,211,153,.08); color: #34d399;
  font-size: .75rem; font-family: inherit; cursor: pointer;
  transition: background .15s;
}
.insight-resolve-btn:hover { background: rgba(52,211,153,.18); }

/* ── Memory list ── */
.memory-list { display: flex; flex-direction: column; gap: .5rem; }
.memory-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: .625rem; padding: .75rem 1rem;
}
.memory-card-header {
  display: flex; align-items: center; gap: .6rem; margin-bottom: .35rem; flex-wrap: wrap;
}
.memory-type-icon { font-size: 1rem; flex-shrink: 0; }
.memory-label { font-size: .825rem; font-weight: 600; color: var(--text); flex: 1; min-width: 0;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memory-status {
  font-size: .65rem; font-weight: 700; padding: .1rem .45rem; border-radius: 9999px;
  text-transform: uppercase; letter-spacing: .06em; flex-shrink: 0;
}
.memory-status--queued     { background: var(--surface-card); color: var(--muted-3); }
.memory-status--processing { background: rgba(251,191,36,.15); color: #fbbf24; }
.memory-status--enriched   { background: rgba(52,211,153,.15); color: #34d399; }
.memory-status--failed     { background: rgba(239,68,68,.15);  color: #f87171; }
.memory-date { font-size: .7rem; color: var(--muted-4); flex-shrink: 0; }
.memory-summary { font-size: .78rem; color: var(--muted-2); line-height: 1.5; margin: 0 0 .4rem; }
.memory-footer { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.memory-tag {
  font-size: .68rem; padding: .1rem .45rem; border-radius: 9999px;
  background: rgba(124,58,237,.1); color: var(--accent-text-2);
  border: 1px solid rgba(139,92,246,.2);
}
.memory-sop-badge {
  font-size: .68rem; padding: .1rem .45rem; border-radius: 9999px;
  background: rgba(251,191,36,.12); color: #fbbf24;
  border: 1px solid rgba(251,191,36,.25); font-weight: 600;
}

/* ── RAG SOP reference chips — shown below AI answers ── */
.ask-sop-refs {
  display: flex; flex-wrap: wrap; gap: .35rem;
  margin-top: .625rem;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}
.ask-sop-ref-chip {
  font-size: .7rem; font-weight: 500;
  padding: .2rem .6rem; border-radius: 9999px;
  background: rgba(124,58,237,.1);
  border: 1px solid rgba(139,92,246,.25);
  color: var(--accent-text-2);
  white-space: nowrap;
}

.ask-sop-backed-badge {
  font-size: .65rem; font-weight: 700;
  padding: .1rem .5rem; border-radius: 9999px;
  background: rgba(52,211,153,.12);
  border: 1px solid rgba(52,211,153,.25);
  color: #34d399;
  letter-spacing: .03em;
}

/* ── SOP edit mode ── */
.sop-action-btn--edit {
  border-color: rgba(124,58,237,.35); background: rgba(124,58,237,.08); color: var(--accent-text-2);
}
.sop-action-btn--edit:hover { background: rgba(124,58,237,.18); }

.sop-edit-section { margin-bottom: .875rem; }
.sop-edit-label {
  display: block; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted-3); margin-bottom: .3rem;
}
.sop-edit-input {
  width: 100%; padding: .45rem .7rem; border-radius: .45rem;
  border: 1px solid var(--border-2);
  background: var(--surface-input); color: var(--text);
  font-size: .875rem; font-family: inherit;
  box-sizing: border-box;
  transition: border-color .15s;
}
.sop-edit-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,.1);
}
.sop-edit-input--meta { font-size: .78rem; }
.sop-edit-textarea {
  width: 100%; padding: .45rem .7rem; border-radius: .45rem;
  border: 1px solid var(--border-2);
  background: var(--surface-input); color: var(--text);
  font-size: .875rem; font-family: inherit; resize: vertical;
  box-sizing: border-box;
  transition: border-color .15s;
}
.sop-edit-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,.1);
}

.sop-edit-steps-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .625rem;
}
.sop-edit-add-step {
  font-size: .75rem; font-weight: 600;
  padding: .3rem .7rem; border-radius: .4rem;
  border: 1px solid rgba(124,58,237,.35);
  background: rgba(124,58,237,.08); color: var(--accent-text-2);
  cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.sop-edit-add-step:hover { background: rgba(124,58,237,.18); }

.sop-edit-step {
  display: flex; gap: .75rem; align-items: flex-start;
  margin-bottom: .875rem; padding-bottom: .875rem;
  border-bottom: 1px solid var(--border);
}
.sop-edit-step:last-child { border-bottom: none; }
.sop-edit-step-fields { flex: 1; display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.sop-edit-step-meta-row { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.sop-edit-remove-step {
  flex-shrink: 0; width: 24px; height: 24px;
  border-radius: .35rem; border: 1px solid var(--border-2);
  background: var(--surface-card); color: var(--muted-3);
  cursor: pointer; font-size: .75rem; margin-top: .2rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.sop-edit-remove-step:hover { background: rgba(239,68,68,.12); color: #f87171; border-color: rgba(239,68,68,.3); }

/* ═══════════════════════════════════════════════════════════════════
   SEARCH PAGE  —  /search
   ═══════════════════════════════════════════════════════════════════ */

.search-page {
  min-height: calc(100vh - 4rem);
  background: var(--surface);
  display: flex; flex-direction: column;
}
.search-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2); flex-shrink: 0;
}
.search-header-left { display: flex; align-items: center; gap: 1rem; }

.search-input-area {
  padding: 1.5rem 2rem .75rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-input-wrap { display: flex; gap: .5rem; max-width: 680px; }
.search-input {
  flex: 1; padding: .6rem 1rem; border-radius: .5rem;
  border: 1px solid var(--border-2);
  background: var(--surface-input); color: var(--text);
  font-size: 1rem; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,.1);
}
.search-btn {
  padding: .6rem 1.5rem; border-radius: .5rem;
  border: none; background: var(--accent); color: #fff;
  font-size: .9rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: opacity .15s;
  display: flex; align-items: center; gap: .5rem;
}
.search-btn:hover:not(:disabled) { opacity: .88; }
.search-btn:disabled { opacity: .5; cursor: not-allowed; }
.search-result-count {
  margin-top: .5rem; font-size: .8rem; color: var(--muted-3);
}

.search-section { padding: 1.25rem 2rem 0; }
.search-section-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted-3); margin: 0 0 .875rem;
}

/* SOP results */
.search-sop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .625rem; margin-bottom: 1rem;
}
.search-sop-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: .625rem; padding: .75rem;
  text-decoration: none; display: block;
  transition: border-color .2s, transform .15s;
}
.search-sop-card:hover {
  border-color: var(--accent); transform: translateY(-1px);
}
.search-sop-card-header {
  display: flex; align-items: center; gap: .4rem; margin-bottom: .4rem; flex-wrap: wrap;
}
.search-sop-title { font-size: .875rem; font-weight: 600; color: var(--text-heading); }
.search-sop-meta  { font-size: .72rem; color: var(--muted-3); margin-top: .25rem; }

/* Chunk results */
.search-results-list { display: flex; flex-direction: column; gap: .625rem; margin-bottom: 1.5rem; }
.search-result-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: .625rem; padding: .875rem 1rem;
}
.search-result-header {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap;
}
.search-source-badge {
  font-size: .68rem; font-weight: 700; padding: .12rem .5rem; border-radius: 9999px;
  text-transform: uppercase; letter-spacing: .05em;
}
.search-source-badge--text    { background: rgba(99,102,241,.1); color: #818cf8; }
.search-source-badge--file    { background: rgba(52,211,153,.1); color: #34d399; }
.search-source-badge--url     { background: rgba(251,191,36,.1); color: #fbbf24; }
.search-source-badge--meeting { background: rgba(239,68,68,.1);  color: #f87171; }
.search-result-label  { font-size: .75rem; color: var(--muted-2); flex: 1; min-width: 0;
                        overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-score  { font-size: .72rem; color: var(--muted-4); flex-shrink: 0; }
.search-result-summary { font-size: .8rem; color: var(--muted-2); line-height: 1.5; margin: 0 0 .4rem; }
.search-result-content {
  font-size: .8rem; color: var(--text-2); line-height: 1.6; margin: 0 0 .4rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.search-result-tags { display: flex; flex-wrap: wrap; gap: .3rem; }

/* Suggestions */
.search-suggestions {
  padding: 2rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
}
.search-suggestions-label { font-size: .8rem; color: var(--muted-3); margin-right: .25rem; }

.search-result-content--expanded {
  display: block !important;
  -webkit-line-clamp: unset !important;
  overflow: visible !important;
}
.search-expand-btn {
  font-size: .72rem; color: var(--accent-text-2);
  background: none; border: none; cursor: pointer;
  padding: 0; font-family: inherit; flex-shrink: 0;
  white-space: nowrap;
}
.search-expand-btn:hover { text-decoration: underline; }

/* Highlighted SOP card — linked from Search page */
.sop-card--highlighted {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(124,58,237,.2), 0 8px 24px rgba(124,58,237,.15);
  animation: sop-highlight-pulse 2s ease-out forwards;
}
@keyframes sop-highlight-pulse {
  0%   { box-shadow: 0 0 0 6px rgba(124,58,237,.35), 0 8px 24px rgba(124,58,237,.2); }
  100% { box-shadow: 0 0 0 3px rgba(124,58,237,.15), 0 8px 24px rgba(124,58,237,.1); }
}

/* ═══════════════════════════════════════════════════════════════════
   AUTH PAGES  —  /login  /register
   ═══════════════════════════════════════════════════════════════════ */

.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  padding: 1rem;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-logo {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: 1.5rem;
}
.red-dot-icon { color: #ef4444; font-size: 1.25rem; line-height: 1; }
.auth-brand   { font-size: 1.25rem; font-weight: 700; color: var(--text-heading); }
.auth-title   { font-size: 1.5rem; font-weight: 700; color: var(--text-heading); margin: 0 0 .25rem; }
.auth-subtitle { font-size: .875rem; color: var(--muted-3); margin: 0 0 1.75rem; }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-field { display: flex; flex-direction: column; gap: .35rem; }
.auth-label {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted-3);
}
.auth-input {
  padding: .6rem .875rem; border-radius: .5rem;
  border: 1px solid var(--border-2);
  background: var(--surface-input); color: var(--text);
  font-size: .9375rem; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.auth-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}
.auth-hint       { font-size: .72rem; color: var(--muted-3); }
.auth-hint--warn { color: #f87171; }

.auth-btn {
  margin-top: .5rem; padding: .7rem;
  border-radius: .5rem; border: none;
  background: var(--accent); color: #fff;
  font-size: .9375rem; font-weight: 600; font-family: inherit;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: .5rem;
  transition: opacity .15s;
}
.auth-btn:hover:not(:disabled) { opacity: .88; }
.auth-btn:disabled { opacity: .5; cursor: not-allowed; }

.auth-error {
  padding: .625rem .875rem; border-radius: .5rem;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25);
  color: #f87171; font-size: .85rem; margin-bottom: .75rem;
}
.auth-switch { text-align: center; font-size: .85rem; color: var(--muted-3); margin: 1.25rem 0 0; }
.auth-link   { color: var(--accent-text-2); text-decoration: none; font-weight: 600; }
.auth-link:hover { text-decoration: underline; }

/* ── Nav user info ── */
.nav-user {
  display: flex; flex-direction: column; align-items: flex-end;
  margin-right: .25rem;
}
.nav-user-name   { font-size: .8rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.nav-user-tenant { font-size: .68rem; color: var(--muted-3); line-height: 1.2; }
.nav-logout {
  font-size: .78rem; font-weight: 600;
  padding: .3rem .75rem; border-radius: .4rem;
  border: 1px solid var(--border-2);
  background: transparent; color: var(--muted-3);
  cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s;
}
.nav-logout:hover { background: rgba(239,68,68,.1); color: #f87171; border-color: rgba(239,68,68,.3); }

/* ── URL mode toggle (Single page / Full site) ─────────────────────────── */
.url-mode-toggle {
  display: flex;
  gap: .375rem;
  margin-bottom: .875rem;
  background: var(--surface-2, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: .625rem;
  padding: .25rem;
}

.url-mode-btn {
  flex: 1;
  padding: .375rem .5rem;
  border: none;
  border-radius: .4rem;
  background: transparent;
  color: var(--muted-2, #94a3b8);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.url-mode-btn:hover {
  background: var(--surface-3, rgba(255,255,255,.07));
  color: var(--text, #e2e8f0);
}

.url-mode-btn--active {
  background: var(--accent, rgba(99,102,241,.25));
  color: var(--accent-text, #a5b4fc);
}

/* ── Crawl options panel ───────────────────────────────────────────────── */
.crawl-options {
  margin-top: .75rem;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: .625rem;
  padding: .625rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.crawl-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.crawl-option-label {
  font-size: .78rem;
  color: var(--muted-2, #94a3b8);
  flex: 1;
}

/* Stepper control */
.crawl-stepper {
  display: flex;
  align-items: center;
  gap: .375rem;
}

.crawl-step-btn {
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--border, rgba(255,255,255,.12));
  border-radius: .375rem;
  background: var(--surface-2, rgba(255,255,255,.05));
  color: var(--text, #e2e8f0);
  font-size: .9rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}

.crawl-step-btn:hover {
  background: var(--surface-3, rgba(255,255,255,.1));
}

.crawl-step-val {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-heading, #f1f5f9);
  min-width: 2.25rem;
  text-align: center;
}

.crawl-checkbox {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent-text, #a5b4fc);
  cursor: pointer;
}

/* ── Crawl progress bar ────────────────────────────────────────────────── */
.crawl-progress {
  margin-top: .625rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.crawl-progress-bar {
  width: 100%;
  height: .3rem;
  background: var(--surface-2, rgba(255,255,255,.06));
  border-radius: 99px;
  overflow: hidden;
}

.crawl-progress-fill {
  height: 100%;
  background: var(--accent-text, #a5b4fc);
  border-radius: 99px;
  transition: width .4s ease;
  min-width: 4px;
}

.crawl-progress-label {
  font-size: .75rem;
  color: var(--muted-2, #94a3b8);
}

/* ── Ingest log — live enrichment status ──────────────────────────────────── */
.ingest-log-item {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

.ingest-log-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}

.ingest-enrich-status {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  gap: .2rem;
}

.ingest-enrich-status--queued     { color: var(--muted-2, #94a3b8); }
.ingest-enrich-status--processing { color: #fbbf24; }
.ingest-enrich-status--enriched   { color: #34d399; }
.ingest-enrich-status--failed     { color: #f87171; }

.ingest-log-summary {
  font-size: .7rem;
  color: var(--muted-2, #94a3b8);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ingest-sop-pill {
  display: inline-block;
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 99px;
  background: rgba(99,102,241,.2);
  color: var(--accent-text, #a5b4fc);
  letter-spacing: .03em;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Knowledge Health Widget
   ═══════════════════════════════════════════════════════════════════════════ */

.health-widget {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.25rem;
  background: var(--surface-2, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: .875rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: .25rem;
}

/* ── Score dial ───────────────────────────────────────────────────────────── */
.health-score-block {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.health-dial {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  border: 3px solid var(--dial-color, rgba(255,255,255,.15));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: radial-gradient(circle, rgba(255,255,255,.03) 0%, transparent 80%);
}

.health-dial--excellent { --dial-color: #34d399; }
.health-dial--good      { --dial-color: #a3e635; }
.health-dial--fair      { --dial-color: #fbbf24; }
.health-dial--poor      { --dial-color: #fb923c; }
.health-dial--critical  { --dial-color: #f87171; }
.health-dial--none      { --dial-color: rgba(255,255,255,.15); }

.health-score-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--dial-color, var(--text-heading, #f1f5f9));
  line-height: 1;
}

.health-score-label {
  font-size: .65rem;
  color: var(--muted-2, #94a3b8);
  letter-spacing: .04em;
}

.health-grade-block {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.health-grade {
  font-size: 1.05rem;
  font-weight: 700;
}

.health-grade--excellent { color: #34d399; }
.health-grade--good      { color: #a3e635; }
.health-grade--fair      { color: #fbbf24; }
.health-grade--poor      { color: #fb923c; }
.health-grade--critical  { color: #f87171; }
.health-grade--none      { color: var(--muted-2, #94a3b8); }

.health-open-count {
  font-size: .78rem;
  color: var(--muted-2, #94a3b8);
}

/* ── Severity breakdown bars ─────────────────────────────────────────────── */
.health-breakdown {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.health-bar-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.health-bar-label {
  font-size: .72rem;
  color: var(--muted-2, #94a3b8);
  width: 4.5rem;
  flex-shrink: 0;
}

.health-bar-track {
  flex: 1;
  height: .3rem;
  background: rgba(255,255,255,.07);
  border-radius: 99px;
  overflow: hidden;
}

.health-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
  min-width: 2px;
}

.health-bar-fill--critical { background: #f87171; }
.health-bar-fill--high     { background: #fb923c; }
.health-bar-fill--medium   { background: #fbbf24; }
.health-bar-fill--low      { background: #34d399; }

.health-bar-count {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text, #e2e8f0);
  width: 1.5rem;
  text-align: right;
  flex-shrink: 0;
}

/* ── Type chips ──────────────────────────────────────────────────────────── */
.health-type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  align-self: center;
}

.health-type-chip {
  font-size: .7rem;
  padding: .2rem .55rem;
  border-radius: 99px;
  border: 1px solid var(--border, rgba(255,255,255,.1));
  color: var(--muted, #cbd5e1);
  background: var(--surface-3, rgba(255,255,255,.05));
}

.health-type-chip strong {
  color: var(--text-heading, #f1f5f9);
  margin-left: .2rem;
}

/* ── Run analysis button ─────────────────────────────────────────────────── */
.health-run-btn {
  align-self: center;
  margin-left: auto;
  padding: .5rem 1rem;
  border-radius: .5rem;
  border: 1px solid rgba(99,102,241,.35);
  background: rgba(99,102,241,.12);
  color: var(--accent-text, #a5b4fc);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .4rem;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.health-run-btn:hover:not(:disabled) {
  background: rgba(99,102,241,.22);
}

.health-run-btn--running,
.health-run-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* ── RAG source surface — Ask.razor chat bubbles ─────────────────────────── */
.ask-rag-badge {
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 99px;
  background: rgba(99,102,241,.2);
  color: #a5b4fc;
  letter-spacing: .03em;
}

.ask-sop-ref-chip--link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  cursor: pointer;
  transition: background .12s;
}

.ask-sop-ref-chip--link:hover {
  background: rgba(99,102,241,.18);
}

.ask-sop-status {
  font-size: .6rem;
  font-weight: 600;
  padding: .08rem .3rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.ask-sop-status--approved  { background: rgba(52,211,153,.15); color: #34d399; }
.ask-sop-status--draft     { background: rgba(251,191,36,.15);  color: #fbbf24; }
.ask-sop-status--candidate { background: rgba(148,163,184,.12); color: #94a3b8; }

/* ── Collapsible sources ─────────────────────────────────────────────────── */
.ask-sources-details {
  margin-top: .5rem;
}

.ask-sources-summary {
  font-size: .72rem;
  color: var(--muted-2, #94a3b8);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .3rem;
}

.ask-sources-summary::before { content: "▸"; font-size: .65rem; }
details[open] .ask-sources-summary::before { content: "▾"; }

.ask-sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .4rem;
}

.ask-source-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .68rem;
  padding: .15rem .45rem;
  border-radius: 99px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: var(--surface-2, rgba(255,255,255,.04));
  color: var(--muted, #cbd5e1);
}

.ask-source-score {
  color: var(--muted-2, #64748b);
  font-variant-numeric: tabular-nums;
}

/* ── SOP export buttons ──────────────────────────────────────────────────── */
.sop-action-btn--export {
  border-color: rgba(99,102,241,.3);
  background: rgba(99,102,241,.08);
  color: #a5b4fc;
}

.sop-action-btn--export:hover:not(:disabled) {
  background: rgba(99,102,241,.18);
}

.sop-action-btn--export:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── Search page — filter rows ───────────────────────────────────────────── */
.search-filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .5rem;
}

.search-filter-label {
  font-size: .75rem;
  color: var(--muted-3, #64748b);
  white-space: nowrap;
  min-width: 4rem;
}

/* Source type chip toggles */
.search-type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}

.search-type-chip {
  padding: .25rem .6rem;
  border-radius: 99px;
  border: 1px solid var(--border, rgba(255,255,255,.1));
  background: var(--surface-2, rgba(255,255,255,.04));
  color: var(--muted, #cbd5e1);
  font-size: .74rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  font-family: inherit;
}

.search-type-chip:hover {
  background: var(--surface-3, rgba(255,255,255,.08));
  color: var(--text, #e2e8f0);
}

.search-type-chip--active {
  background: rgba(99,102,241,.2);
  border-color: rgba(99,102,241,.5);
  color: var(--accent-text, #a5b4fc);
}

/* Date range inputs */
.search-date-input {
  padding: .3rem .5rem;
  border-radius: .4rem;
  border: 1px solid var(--border, rgba(255,255,255,.1));
  background: var(--surface-2, rgba(255,255,255,.04));
  color: var(--text, #e2e8f0);
  font-size: .75rem;
  font-family: inherit;
  color-scheme: dark;
}

.search-date-input:focus {
  outline: none;
  border-color: rgba(99,102,241,.5);
}


/* ── SOP drawer: action buttons scroll horizontally on narrow screens ── */
@media (max-width: 639px) {
  .sop-drawer {
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 1rem 1rem 0 0;
    max-height: 90dvh;
  }

  .sop-drawer-titlebar {
    border-radius: 1rem 1rem 0 0;
  }

  .sop-drawer-header {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-wrap: nowrap;
  }
  .sop-drawer-header::-webkit-scrollbar { display: none; }
}

/* ── Session log empty state ─────────────────────────────────────────────── */
.ingest-log-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  padding: 1.25rem .75rem;
  text-align: center;
}

.ingest-log-empty-icon {
  font-size: 1.5rem;
  opacity: .5;
}

.ingest-log-empty-text {
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted-2);
  margin: 0;
}

.ingest-log-empty-hint {
  font-size: .72rem;
  color: var(--muted-3);
  margin: 0;
}

/* ── Chat empty state: numbered steps ────────────────────────────────────── */
.ask-empty-steps {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin: .25rem 0;
  text-align: left;
  max-width: 22rem;
  width: 100%;
}

.ask-empty-step {
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.45;
}

.ask-empty-step-num {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: rgba(99,102,241,.2);
  color: var(--accent-text, #a5b4fc);
  font-size: .7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: .1rem;
}

.ask-empty-or {
  font-size: .72rem;
  color: var(--muted-3);
  margin: .25rem 0 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   ONBOARDING BANNER  (Step 7)
   ═══════════════════════════════════════════════════════════════════════════ */

.onboarding-banner {
  grid-area: banner;
  background: linear-gradient(135deg,
    rgba(124,58,237,.12) 0%,
    rgba(99,102,241,.08) 100%);
  border-bottom: 1px solid rgba(124,58,237,.2);
  padding: .75rem 1.5rem;
  animation: fadeIn .25s ease;
}

.onboarding-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .625rem;
}

.onboarding-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: .01em;
}

.onboarding-dismiss {
  width: 1.5rem; height: 1.5rem;
  border-radius: .375rem;
  border: none;
  background: rgba(255,255,255,.06);
  color: var(--muted-2);
  font-size: .75rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.onboarding-dismiss:hover { background: rgba(255,255,255,.12); color: var(--text); }

.onboarding-steps {
  display: flex;
  gap: .875rem;
  flex-wrap: wrap;
  max-width: 640px;   /* prevent stretching on wide screens */
}

.onboarding-step {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  flex: 1;
  min-width: 140px;
  opacity: 1;
  transition: opacity .2s;
}

.onboarding-step--done {
  opacity: .55;
}

.onboarding-step-check {
  flex-shrink: 0;
  width: 1.375rem; height: 1.375rem;
  border-radius: 50%;
  background: rgba(99,102,241,.2);
  border: 1.5px solid rgba(99,102,241,.4);
  color: var(--accent-text, #a5b4fc);
  font-size: .68rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, border-color .2s;
}

.onboarding-step--done .onboarding-step-check {
  background: rgba(52,211,153,.2);
  border-color: rgba(52,211,153,.5);
  color: #34d399;
}

.onboarding-step-body {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.onboarding-step-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text);
}

.onboarding-step-hint {
  font-size: .7rem;
  color: var(--muted-2);
}

.onboarding-link {
  color: var(--accent-text-2);
  text-decoration: none;
}
.onboarding-link:hover { text-decoration: underline; }

@media (max-width: 639px) {
  .onboarding-steps { gap: .5rem; }
  .onboarding-step  { min-width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SEARCH SCORE VISUALISATION  (Step 6)
   ═══════════════════════════════════════════════════════════════════════════ */

.search-score-pill {
  display: inline-flex;
  align-items: baseline;
  gap: .1rem;
  padding: .15rem .45rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -.01em;
}
.search-score-pill small { font-size: .6rem; font-weight: 500; opacity: .8; }

.search-score-pill--high   { background: rgba(52,211,153,.15);  color: #34d399; }
.search-score-pill--medium { background: rgba(251,191,36,.12);  color: #fbbf24; }
.search-score-pill--low    { background: rgba(148,163,184,.1);  color: #94a3b8; }

.search-score-bar {
  height: 2px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin: .25rem 0 .375rem;
}

.search-score-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
}
.search-score-bar-fill--high   { background: #34d399; }
.search-score-bar-fill--medium { background: #fbbf24; }
.search-score-bar-fill--low    { background: #64748b; }

/* ═══════════════════════════════════════════════════════════════════════════
   AL SOURCE PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.al-page {
    display: grid;
    grid-template-columns: 380px 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "sidebar chat";
    gap: 0;
    height: calc(100vh - 64px);
    overflow: hidden;
}

.al-page .ask-sidebar     { grid-area: sidebar; }
.al-page .ask-chat-panel  { grid-area: chat; }

@media (max-width: 900px) {
    .al-page {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        grid-template-areas: "sidebar" "chat";
        height: auto;
        overflow: visible;
    }
}

/* ── Filter row above input ─────────────────────────────────────────────── */

.al-filter-row {
    display: flex;
    gap: .5rem;
    padding: .5rem 1rem 0;
    flex-wrap: wrap;
}

.al-filter-select {
    font-size: .75rem;
    padding: .3rem .6rem;
    border-radius: .4rem;
    border: 1px solid var(--border-2);
    background: var(--surface-input);
    color: var(--text);
    cursor: pointer;
    flex: 1 1 120px;
    min-width: 0;
}

.al-filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

.al-filter-input {
    font-size: .75rem;
    padding: .3rem .6rem;
    border-radius: .4rem;
    border: 1px solid var(--border-2);
    background: var(--surface-input);
    color: var(--text);
    flex: 2 1 160px;
    min-width: 0;
}

.al-filter-input:focus {
    outline: none;
    border-color: var(--accent);
}

.al-filter-input::placeholder { color: var(--muted-4); }

/* ── Object context row ──────────────────────────────────────────────────── */

.al-context-row {
    padding: .35rem 1rem 0;
}

.al-context-input {
    width: 100%;
    font-size: .75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    padding: .35rem .6rem;
    border-radius: .4rem;
    border: 1px solid var(--border-2);
    background: var(--surface-input);
    color: var(--text-3);
    box-sizing: border-box;
}

.al-context-input:focus {
    outline: none;
    border-color: rgba(124,58,237,.45);
    background: var(--surface-input-focus);
}

.al-context-input::placeholder { color: var(--muted-4); }

/* ── Code block rendering ────────────────────────────────────────────────── */

.al-code-block {
    background: rgba(0,0,0,.35);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: .5rem;
    padding: .85rem 1rem;
    margin: .5rem 0;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8rem;
    line-height: 1.6;
    color: #c4b5fd;
    white-space: pre;
}

[data-theme="light"] .al-code-block {
    background: rgba(240,240,255,.7);
    border-color: rgba(100,100,180,.15);
    color: #4c1d95;
}

.al-code-block code {
    font-family: inherit;
    font-size: inherit;
    background: none;
    padding: 0;
}

/* ── Source attribution chips ────────────────────────────────────────────── */

.al-source-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    background: rgba(124,58,237,.08);
    border: 1px solid rgba(124,58,237,.2);
    border-radius: .35rem;
    padding: .2rem .5rem;
    font-size: .72rem;
    color: var(--muted);
    flex-wrap: wrap;
}

.al-source-type  { color: var(--accent-text-2); font-weight: 600; }
.al-source-name  { color: var(--text-3); }
.al-source-proc  { color: var(--muted-2); font-style: italic; }
.al-source-app   { color: var(--muted-3); font-size: .68rem; }

/* ── AL right-panel mode tabs + tool views ──────────────────────────────── */
.al-hidden { display: none !important; }

.al-mode-tabs {
    display: flex;
    gap: .35rem;
    padding: .5rem .9rem 0;
    border-bottom: 1px solid var(--border-1);
}
.al-mode-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted-2);
    font-size: .78rem;
    font-weight: 600;
    padding: .4rem .6rem;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.al-mode-tab:hover { color: var(--text-heading); }
.al-mode-tab--active {
    color: var(--accent-text);
    border-bottom-color: var(--accent-text);
}

.al-tool-panel {
    flex: 1;
    overflow-y: auto;
    padding: .9rem;
    display: flex;
    flex-direction: column;
}
.al-tool-form {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
}
.al-tool-results { margin-top: .9rem; }

.al-ref-toggle {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-top: .6rem;
    font-size: .75rem;
    color: var(--muted);
    cursor: pointer;
}
.al-ref-toggle input { accent-color: var(--accent-text); }

.al-impact-target { font-size: .85rem; color: var(--text-heading); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.al-impact-count  { font-size: .7rem; color: var(--muted-2); }
.al-impact-depth-label {
    font-size: .68rem;
    font-weight: 700;
    color: var(--muted-2);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: .55rem 0 .25rem;
}
.al-impact-narration {
    margin-top: .6rem;
    padding: .6rem .75rem;
    border-left: 3px solid var(--accent-text);
    background: var(--surface-2);
    border-radius: 6px;
}

.al-object-row {
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--border-1);
}
.al-object-row-top {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
    font-size: .78rem;
}
.al-object-actions { margin-left: auto; display: flex; gap: .25rem; }
.al-object-summary {
    font-size: .74rem;
    color: var(--muted);
    margin-top: .25rem;
    line-height: 1.4;
}

/* ── Copy button ─────────────────────────────────────────────────────────── */

.al-copy-btn {
    margin-left: auto;
    font-size: .7rem;
    padding: .15rem .45rem;
    border-radius: .3rem;
    border: 1px solid var(--border-2);
    background: var(--surface-card);
    color: var(--muted);
    cursor: pointer;
    transition: background .15s, color .15s;
}

.al-copy-btn:hover {
    background: rgba(124,58,237,.15);
    color: var(--accent-text);
    border-color: rgba(124,58,237,.3);
}

/* ── ZIP progress current file label ─────────────────────────────────────── */

.al-progress-current {
    color: var(--muted-3);
    font-size: .7rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
    display: inline-block;
    vertical-align: middle;
}

/* ── Optional label ───────────────────────────────────────────────────────── */

.al-optional {
    color: var(--muted-3);
    font-size: .7rem;
    font-weight: 400;
}
