/* ══════════════════════════════════════════════════════════════
   Starwood AI — Dashboard Styles
   Brand: Starwood Capital Group · #016bab
   ══════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Background layers */
  --bg-0:   #030c18;
  --bg-1:   #061525;
  --bg-2:   #091e34;
  --bg-3:   #0d2641;
  --bg-4:   #112f50;
  --bg-5:   #163860;

  /* Starwood Blue palette — official brand: #016bab */
  --sw:       #016bab;
  --sw-light: #0589d7;
  --sw-pale:  #4ab0e8;
  --sw-dim:   rgba(1, 107, 171, 0.22);
  --sw-glow:  rgba(1, 107, 171, 0.09);
  --sw-line:  rgba(1, 107, 171, 0.28);

  /* Alias for legacy references */
  --gold:       var(--sw);
  --gold-light: var(--sw-light);
  --gold-pale:  var(--sw-pale);
  --gold-dim:   var(--sw-dim);
  --gold-glow:  var(--sw-glow);
  --gold-line:  var(--sw-line);

  /* Text */
  --text-0: #f2f7fc;
  --text-1: #c4d9ed;
  --text-2: #8cb4cf;
  --text-3: #7aadc8;

  /* Semantic */
  --green:  #4ade80;
  --red:    #f87171;
  --blue:   #60a5fa;
  --amber:  #fbbf24;

  /* Borders */
  --border-0: rgba(255, 255, 255, 0.04);
  --border-1: rgba(255, 255, 255, 0.07);
  --border-2: rgba(255, 255, 255, 0.11);

  /* Layout */
  --sidebar-w:       268px;
  --news-w:          308px;
  --topbar-h:        44px;
  --handle-w:        10px;
  /* Horizontal panel splits */
  --sidebar-docs-h:  240px;   /* sidebar docs+datasets section height */
  --sources-h:       180px;   /* news-panel sources section height */
  --panel-dir-h:     140px;   /* tools/skills directory section height */
  --tools-footer-h:  120px;   /* Tools & Skills Used footer height */

  /* Typography */
  --font-serif:  'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-body:   'DM Sans', -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;

  /* Motion */
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:   cubic-bezier(0.4, 0, 1, 1);
  --ease-io:   cubic-bezier(0.4, 0, 0.2, 1);
  --duration:  220ms;
}

/* ── Light Mode ────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-0:   #f5f7fa;
  --bg-1:   #edf0f5;
  --bg-2:   #e4e8ef;
  --bg-3:   #dce1ea;
  --bg-4:   #d3d9e4;
  --bg-5:   #c8d0de;

  --sw:       #016bab;
  --sw-light: #0478bc;
  --sw-pale:  #1a8dd4;
  --sw-dim:   rgba(1, 107, 171, 0.12);
  --sw-glow:  rgba(1, 107, 171, 0.06);
  --sw-line:  rgba(1, 107, 171, 0.2);

  --text-0: #1a2233;
  --text-1: #3d4f66;
  --text-2: #617a94;
  --text-3: #7a92aa;

  --green:  #16a34a;
  --red:    #dc2626;
  --blue:   #2563eb;
  --amber:  #d97706;

  --border-0: rgba(0, 0, 0, 0.06);
  --border-1: rgba(0, 0, 0, 0.1);
  --border-2: rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .bg-grid {
  background-image:
    linear-gradient(rgba(1,107,171,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(1,107,171,0.04) 1px, transparent 1px);
}
[data-theme="light"] mark.search-hl { background: rgba(255,190,0,0.4); }
[data-theme="light"] mark.search-hl.current { background: rgba(255,140,0,0.55); }
[data-theme="light"] .analysis-search { background: var(--bg-2); border-color: var(--border-1); }
[data-theme="light"] .analysis-search-input { background: #fff; border-color: var(--border-1); color: var(--text-0); }
[data-theme="light"] .analysis-search-nav:hover:not(:disabled),
[data-theme="light"] .analysis-search-close:hover { background: rgba(0,0,0,0.06); }
[data-theme="light"] .toast { background: #fff; border-color: var(--border-1); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
[data-theme="light"] .sw-chart-wrap { background: var(--bg-1); }

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; -webkit-font-smoothing: antialiased; }
button:focus-visible, [role="button"]:focus-visible, a:focus-visible {
  outline: 2px solid var(--sw-light);
  outline-offset: 1px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-0);
  color: var(--text-0);
  font-size: 13.5px;
  line-height: 1.55;
}

/* ── Background Grid ────────────────────────────────────────── */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(1,107,171,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(1,107,171,0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  z-index: 0;
}

/* ── App Shell ──────────────────────────────────────────────── */
.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  /* sidebar | handle | main | handle | news */
  grid-template-columns: var(--sidebar-w) var(--handle-w) 1fr var(--handle-w) var(--news-w);
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
}

/* ── Resize Handles ─────────────────────────────────────────── */
.resize-handle {
  position: relative;
  z-index: 20;
  cursor: col-resize;
  background: transparent;          /* body invisible — visual via ::before */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  /* Full column width is the hit area. Visual stripe drawn by ::before. */
}

/* Visual divider stripe — 2px centered within the column */
.resize-handle::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--border-1);
  transition: background 140ms, box-shadow 140ms;
  pointer-events: none;
}

/* Grip dot column — shows on hover / drag */
.resize-handle::after {
  content: '';
  position: relative;
  z-index: 2;
  pointer-events: none;
  width: 3px;
  height: 36px;
  border-radius: 3px;
  background-image:
    radial-gradient(circle at center, rgba(255,255,255,0.28) 1.2px, transparent 1.2px);
  background-size: 3px 7px;
  opacity: 0;
  transition: opacity 140ms;
}

.resize-handle:hover::before {
  background: var(--sw-dim);
  box-shadow: 0 0 12px rgba(1,107,171,0.18);
}
.resize-handle:hover::after { opacity: 1; }

.resize-handle.is-dragging::before {
  background: var(--sw-line);
  box-shadow: 0 0 18px rgba(1,107,171,0.30);
  transition: none;
}
.resize-handle.is-dragging::after { opacity: 1; }

/* When the adjacent panel is fully collapsed: show an expand caret */
.resize-handle.will-expand {
  cursor: pointer;
}
.resize-handle.will-expand::before {
  background: rgba(1,107,171,0.20);
}
.resize-handle.will-expand::after {
  /* Draw a small ▶ or ◀ arrow to signal "click to expand" */
  width: 0; height: 0;
  background: none;
  border: none;
  opacity: 1;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
#resizeLeft.will-expand::after {
  border-left: none;
  border-right: 6px solid var(--sw-pale);
  margin-left: 1px;
}
#resizeRight.will-expand::after {
  border-right: none;
  border-left: 6px solid var(--sw-pale);
  margin-right: 1px;
}
.resize-handle.will-expand:hover::before {
  background: var(--sw-dim);
}

/* ── Horizontal resize handles (row-resize) ────────────────── */
/*
 * The hit area is the full element height (20px). The visual stripe
 * is drawn by ::before (3px centered line). This avoids the old
 * ::before hit-area-expansion approach, which was clipped by the
 * overflow:hidden on every parent flex container, leaving only the
 * 6px element body clickable — far too small to grab reliably.
 */
.resize-handle-h {
  position: relative;
  z-index: 20;
  cursor: row-resize;
  background: transparent;          /* body is invisible — visual via ::before */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 100%;
  height: 20px;                     /* large hit area — was 6px, clipping made it unusable */
}

/* Visual divider stripe — 3px centered within the 20px hit zone */
.resize-handle-h::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: var(--border-1);
  transition: background 140ms, box-shadow 140ms;
  pointer-events: none;
}

/* Horizontal grip dots — 3px tall × 36px wide */
.resize-handle-h::after {
  content: '';
  position: relative;
  z-index: 2;
  pointer-events: none;
  width: 36px;
  height: 3px;
  border-radius: 3px;
  background-image:
    radial-gradient(circle at center, rgba(255,255,255,0.28) 1.2px, transparent 1.2px);
  background-size: 7px 3px;
  opacity: 0;
  transition: opacity 140ms;
}

.resize-handle-h:hover::before {
  background: var(--sw-dim);
  box-shadow: 0 0 12px rgba(1,107,171,0.18);
}
.resize-handle-h:hover::after { opacity: 1; }

.resize-handle-h.is-dragging::before {
  background: var(--sw-line);
  box-shadow: 0 0 18px rgba(1,107,171,0.30);
  transition: none;
}
.resize-handle-h.is-dragging::after { opacity: 1; }

/* Collapsed state: show a ▼ expand caret */
.resize-handle-h.will-expand {
  cursor: pointer;
}
.resize-handle-h.will-expand::before {
  background: rgba(1,107,171,0.20);
}
.resize-handle-h.will-expand::after {
  width: 0; height: 0;
  background: none;
  border: none;
  opacity: 1;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--sw-pale);
  margin-bottom: 1px;
}
.resize-handle-h.will-expand:hover::before { background: var(--sw-dim); }

/* ══════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════ */
.sidebar {
  background: var(--bg-2);
  /* border-right removed — resize handle is now the visual divider */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, var(--sw-line) 30%, var(--sw-line) 70%, transparent);
}

/* ── Brand / Logo ───────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  padding: 0;
  flex-shrink: 0;
}

.brand-logo-wrap {
  background: var(--bg-2);
  padding: 16px 20px 10px;
  display: block;
  overflow: hidden;
  line-height: 0;
  border-bottom: 1px solid var(--border-1);
}

.brand-logo-img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 1px 8px rgba(1,107,171,0.3));
}

.brand-fallback {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-fallback-text {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sw);
  line-height: 1.3;
}

.brand-product-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 7px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border-0);
}

.model-info-toggle {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 2px 5px;
  transition: color var(--duration), border-color var(--duration);
}
.model-info-toggle:hover {
  color: var(--text-1);
  border-color: var(--sw-line);
}
.model-info-toggle.is-open {
  color: var(--sw-light);
  border-color: var(--sw-line);
  background: var(--sw-dim);
}

.brand-product-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

body.query-entry-view #btnNew {
  display: none !important;
}

/* ── Model selector ─────────────────────────────────────────── */
.model-select {
  font-family: var(--font-mono);
  font-size: 9px;
  background: var(--sw-dim);
  color: var(--sw-light);
  border: 1px solid var(--sw-line);
  padding: 3px 24px 3px 8px;
  border-radius: 3px;
  letter-spacing: 0.05em;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%230589d7' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  transition: border-color 0.15s, background-color 0.15s;
}

.model-select:hover {
  border-color: rgba(1,107,171,0.55);
  background-color: rgba(1,107,171,0.18);
}

.model-select:focus {
  border-color: var(--sw);
  box-shadow: 0 0 0 2px var(--sw-glow);
}

.model-select option {
  background: var(--bg-3);
  color: var(--text-0);
}

/* ── Model info panel ───────────────────────────────────────── */
.model-info {
  padding: 9px 14px 10px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-0);
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--text-2);
  flex-shrink: 0;
}

.model-info-name {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sw-light);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-info-tag {
  font-family: var(--font-mono);
  font-size: 7.5px;
  padding: 1px 5px;
  border-radius: 2px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.model-info-tag.recommended {
  background: rgba(74,222,128,0.1);
  color: var(--green);
  border: 1px solid rgba(74,222,128,0.2);
}

.model-info-tag.fast {
  background: rgba(251,191,36,0.1);
  color: var(--amber);
  border: 1px solid rgba(251,191,36,0.2);
}

.model-info-row {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  font-size: 10px;
  color: var(--text-2);
}

.model-info-row-label {
  color: var(--text-3);
  font-size: 9.5px;
  flex-shrink: 0;
  width: 56px;
}

.model-info-use {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-0);
  font-size: 10px;
  color: var(--text-2);
  font-style: italic;
}

/* ── New button ─────────────────────────────────────────────── */
.btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 28px);
  margin: 10px 14px 12px;
  padding: 9px 13px;
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.018));
  border: 1px solid var(--border-1);
  border-radius: 8px;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration) var(--ease-out), border-color var(--duration) var(--ease-out), color var(--duration) var(--ease-out), box-shadow var(--duration) var(--ease-out), transform var(--duration) var(--ease-out);
  letter-spacing: 0.015em;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.035) inset;
  text-transform: none;
}

.btn-new:hover {
  background: rgba(1, 107, 171, 0.12);
  border-color: var(--sw-line);
  color: var(--text-0);
  transform: translateY(-0.5px);
  box-shadow: 0 0 0 1px rgba(1,107,171,0.08), 0 8px 18px rgba(0,0,0,0.12);
}

.btn-new:active {
  transform: translateY(0);
  background: rgba(1, 107, 171, 0.16);
  box-shadow: 0 1px 0 rgba(255,255,255,0.025) inset;
}

.btn-new svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--sw-light);
  opacity: 0.86;
}

.btn-new:focus-visible {
  outline: 1px solid var(--sw-line);
  outline-offset: 2px;
}

/* ── Sidebar tabs ───────────────────────────────────────────── */
.sidebar-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-tabs {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-1);
  padding: 0 4px;
}

.sidebar-tab {
  flex: 1;
  padding: 8px 4px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  transition: color var(--duration), border-color var(--duration);
  position: relative;
}

.sidebar-tab.active {
  color: var(--sw-light);
  border-bottom-color: var(--sw);
}

.sidebar-tab:hover:not(.active) { color: var(--text-1); }

.tab-error-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
  position: absolute;
  top: 7px;
  right: 8px;
}

.tab-panel {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}

/* ── History list ───────────────────────────────────────────── */
.section-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  padding: 12px 18px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-search-wrap {
  padding: 6px 8px 4px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-0);
}
.history-search {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-0);
  border-radius: 5px;
  color: var(--text-0);
  outline: none;
  box-sizing: border-box;
}
.history-search:focus { border-color: var(--sw-accent); }
.history-search::placeholder { color: var(--text-3); }

.history-type-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.history-filter-chip {
  appearance: none;
  border: 1px solid var(--border-0);
  background: var(--bg-2);
  color: var(--text-2);
  border-radius: 999px;
  padding: 3px 7px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
}

.history-filter-chip:hover {
  border-color: var(--border-1);
  color: var(--text-1);
}

.history-filter-chip.is-active {
  border-color: var(--sw-line);
  background: var(--sw-glow);
  color: var(--sw);
}

.history-list { padding: 4px 8px; }

.history-empty {
  padding: 16px 10px;
  color: var(--text-3);
  font-size: 12px;
  font-style: italic;
  text-align: center;
}

.history-sentinel,
.team-sentinel {
  padding: 8px 0 4px;
}

.history-load-more-btn {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--border-1);
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.history-load-more-btn:hover {
  background: var(--bg-4);
  color: var(--text-0);
}

.history-item {
  padding: 9px 10px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--duration) var(--ease-out);
  margin-bottom: 2px;
}

.history-item:hover {
  background: var(--bg-4);
  border-color: var(--border-1);
}

.history-item-query {
  font-size: 11.5px;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.history-item-date {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-3);
  margin-top: 2px;
}

.history-item-meta {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.history-meta-tag {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--sw);
  background: var(--sw-glow);
  border: 1px solid var(--sw-line);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
}

.history-meta-skills {
  color: #4ab0e8;
  background: rgba(74, 176, 232, 0.08);
  border-color: rgba(74, 176, 232, 0.2);
}

.history-meta-followups {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.10);
  border-color: rgba(15, 118, 110, 0.24);
}

.history-followups {
  margin-top: 7px;
  padding: 6px 0 0 8px;
  border-top: 1px solid var(--border-1);
}

.history-followup-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  column-gap: 4px;
  row-gap: 1px;
  padding: 3px 0;
  color: var(--text-2);
}

.history-followup-arrow {
  grid-row: 1 / span 2;
  color: #0f766e;
  font-size: 10px;
  line-height: 1.2;
  padding-top: 1px;
}

.history-followup-query {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  line-height: 1.25;
}

.history-followup-meta,
.history-followup-more {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-3);
}

.history-followup-more {
  padding: 3px 0 1px 16px;
  font-style: italic;
}

/* ── Log Entries ────────────────────────────────────────────── */
.logs-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 5px 10px 2px;
  flex-shrink: 0;
}

.btn-copy-logs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  transition: color var(--duration), border-color var(--duration), background var(--duration);
}
.btn-copy-logs:hover {
  color: var(--text-1);
  border-color: var(--sw-line);
  background: var(--sw-glow);
}
.btn-copy-logs.copied {
  color: var(--green);
  border-color: rgba(74,222,128,0.3);
}

.logs-list { padding: 4px 0; }

.log-entry {
  padding: 7px 14px;
  border-bottom: 1px solid var(--border-0);
  cursor: pointer;
  transition: background var(--duration);
  user-select: none;
}

.log-entry:hover { background: var(--bg-3); }

.log-entry-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.log-type {
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.log-type.error  { background: rgba(248,113,113,0.12); color: var(--red);  border: 1px solid rgba(248,113,113,0.2); }
.log-type.tool   { background: var(--sw-glow); color: var(--sw-light); border: 1px solid var(--sw-line); }
.log-type.done   { background: rgba(74,222,128,0.08); color: var(--green); border: 1px solid rgba(74,222,128,0.15); }
.log-type.info   { background: rgba(96,165,250,0.08); color: var(--blue);  border: 1px solid rgba(96,165,250,0.15); }

.log-time {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  margin-left: auto;
  flex-shrink: 0;
}

.log-chevron {
  flex-shrink: 0;
  color: var(--text-3);
  transition: transform var(--duration), color var(--duration);
  margin-left: 2px;
}
.log-entry:hover .log-chevron { color: var(--text-2); }
.log-entry.expanded .log-chevron { transform: rotate(180deg); color: var(--text-2); }

.log-msg {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Expanded body — hidden by default, revealed on expand */
.log-entry-body {
  display: none;
  margin-top: 7px;
}
.log-entry.expanded .log-entry-body { display: block; }
.log-entry.expanded .log-msg { white-space: normal; overflow: visible; text-overflow: clip; }

.log-detail {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  background: var(--bg-0);
  border: 1px solid var(--border-1);
  border-radius: 4px;
  padding: 7px 9px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 7px;
}

/* Per-entry copy button (shown inside expanded body) */
.btn-log-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  transition: color var(--duration), border-color var(--duration), background var(--duration);
}
.btn-log-copy:hover {
  color: var(--text-1);
  border-color: var(--sw-line);
  background: var(--sw-glow);
}
.btn-log-copy.copied {
  color: var(--green);
  border-color: rgba(74,222,128,0.3);
}

/* ── Docs section ───────────────────────────────────────────── */
.sidebar-docs {
  flex: none;
  /* border-top removed — resize-handle-h acts as visual divider */
  padding: 0 0 8px;
  height: var(--sidebar-docs-h);
  overflow: hidden;
}

.drop-zone {
  margin: 4px 12px 8px;
  padding: 12px 10px;
  border: 1px dashed rgba(1,107,171,0.28);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-2);
  transition: all var(--duration) var(--ease-out);
  background: var(--bg-1);
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: rgba(1,107,171,0.55);
  background: var(--sw-glow);
  color: var(--sw-light);
}

.drop-zone svg { opacity: 0.6; }
.drop-zone-text { font-size: 11.5px; font-weight: 500; }
.drop-zone-sub  { font-size: 10.5px; color: var(--text-3); }

.doc-list {
  overflow-y: auto;
  max-height: 110px;
  padding: 0 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  margin-bottom: 4px;
}

.doc-item.uploading { opacity: 0.6; }

.doc-icon {
  width: 24px;
  height: 28px;
  border-radius: 3px;
  background: var(--bg-5);
  border: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 7px;
  color: var(--sw-light);
  letter-spacing: 0.05em;
  font-weight: 500;
}

.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 11px; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-size { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-3); }

.doc-badge {
  background: var(--sw-dim);
  color: var(--sw-light);
  border-radius: 10px;
  padding: 0 6px;
  font-size: 9px;
}

.doc-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 2px;
  border-radius: 3px;
  display: flex;
  transition: color var(--duration);
  flex-shrink: 0;
}
.doc-remove:hover { color: var(--red); }

/* ── Datasets section (Proprietary Data Vault) ───────────────── */
.sidebar-datasets {
  flex: none;
  border-top: 1px solid var(--border-0);
  padding: 0 0 8px;
  max-height: 240px;
}

.drop-zone--dataset {
  border-color: rgba(16, 185, 129, 0.25);
}
.drop-zone--dataset:hover, .drop-zone--dataset.drag-over {
  border-color: rgba(16, 185, 129, 0.55);
  background: rgba(16, 185, 129, 0.06);
  color: #10b981;
}

.dataset-list {
  overflow-y: auto;
  max-height: 110px;
  padding: 0 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}

.dataset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 4px;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  margin-bottom: 4px;
}
.dataset-item.uploading { opacity: 0.6; }

.dataset-item-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.dataset-schema-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.dataset-name {
  font-size: 11px;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.dataset-meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-3);
  flex-shrink: 0;
}

.dataset-badge {
  background: rgba(16, 185, 129, 0.18);
  color: #10b981;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 9px;
}

.dataset-active-indicator {
  font-size: 11px;
  margin-left: 2px;
}

/* ── Sidebar footer ─────────────────────────────────────────── */
.sidebar-footer { padding: 8px 16px 12px; }

/* ── Panel collapse state ───────────────────────────────────── */
.sidebar.is-collapsed,
.news-panel.is-collapsed {
  /* Content is hidden by the 0-width grid column;
     overflow:hidden prevents any bleed-through */
  overflow: hidden;
  pointer-events: none; /* don't intercept clicks when hidden */
}
/* Panel fade when close to collapse during drag */
.sidebar,
.news-panel {
  transition: opacity 80ms;
}

/* ══════════════════════════════════════════════════════════════
   MAIN PANEL
   ══════════════════════════════════════════════════════════════ */
.main-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-1);
  position: relative;
}

/* Topbar */
.main-topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-0);
  background: var(--bg-2);
  min-width: 0;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 9px 2px 8px;
  border-radius: 20px;
  transition: background 0.3s, border-color 0.3s;
  border: 1px solid transparent;
}
.topbar-status[data-state="idle"] {
  background: rgba(74,222,128,0.08);
  border-color: rgba(74,222,128,0.25);
}
.topbar-status[data-state="running"] {
  background: rgba(1,107,171,0.10);
  border-color: rgba(1,107,171,0.30);
}
.topbar-status[data-state="done"] {
  background: rgba(74,222,128,0.08);
  border-color: rgba(74,222,128,0.25);
}
.topbar-status[data-state="error"] {
  background: rgba(248,113,113,0.08);
  border-color: rgba(248,113,113,0.25);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s;
}

.status-dot[data-state="idle"] {
  background: var(--green);
  box-shadow: 0 0 6px rgba(74,222,128,0.5);
}
.status-dot[data-state="running"] {
  background: var(--sw);
  box-shadow: 0 0 0 0 rgba(1,107,171,0.7);
  animation: pulse-dot 1.5s ease-out infinite;
}
.status-dot[data-state="done"] {
  background: var(--green);
  box-shadow: 0 0 6px rgba(74,222,128,0.5);
}
.status-dot[data-state="error"] {
  background: var(--red);
  box-shadow: 0 0 6px rgba(248,113,113,0.5);
}

@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(1,107,171,0.7); }
  70%  { box-shadow: 0 0 0 6px rgba(1,107,171,0); }
  100% { box-shadow: 0 0 0 0 rgba(1,107,171,0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

.status-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  transition: color 0.3s;
  white-space: nowrap;
}
.topbar-status[data-state="idle"]    .status-label { color: var(--green); }
.topbar-status[data-state="running"] .status-label { color: var(--sw-line); }
.topbar-status[data-state="done"]    .status-label { color: var(--green); }
.topbar-status[data-state="error"]   .status-label { color: var(--red); }

.topbar-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-meta,
.topbar-status {
  flex-shrink: 0;
}

.topbar-primary-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-end;
  overflow: hidden;
}

.topbar-utility-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-primary-nav svg,
.topbar-utility-actions svg {
  width: 12px;
  height: 12px;
}

.expert-mode-toggle {
  height: 22px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 6px;
  border: 1px solid var(--border-1);
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.expert-mode-toggle:hover {
  color: var(--text-1);
  border-color: var(--border-2);
  background: var(--bg-4);
}

.expert-mode-toggle-track {
  width: 20px;
  height: 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-1);
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

.expert-mode-toggle-knob {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  position: absolute;
  left: 2px;
  top: 1px;
  transition: transform 0.15s var(--ease-out), background 0.15s;
}

.expert-mode-toggle.is-active {
  color: var(--text-0);
  border-color: var(--sw-line);
  background: rgba(1, 107, 171, 0.16);
}

.expert-mode-toggle.is-active .expert-mode-toggle-track {
  background: rgba(1, 107, 171, 0.28);
  border-color: var(--sw-line);
}

.expert-mode-toggle.is-active .expert-mode-toggle-knob {
  background: var(--sw-pale);
  transform: translateX(9px);
}

body.simple-mode .topbar-primary-nav .registry-link:not(#analystLink),
body.simple-mode .sidebar-tab[data-tab="logs"],
body.simple-mode #tabLogs,
body.simple-mode #resizeRight,
body.simple-mode #mobilePanelToggle,
body.simple-mode .news-panel,
body.simple-mode #resizeDirH,
body.simple-mode #panelDirWrap,
body.simple-mode #resizeToolsH,
body.simple-mode #rmsForum,
body.simple-mode .news-panel-footer,
body.simple-mode .btn-view-logs,
body.simple-mode #btnCopy,
body.simple-mode #btnExportCSV,
body.simple-mode #btnPrint,
body.simple-mode #btnDataPackage,
body.simple-mode #btnICDeck {
  display: none !important;
}

body.simple-mode .app-shell,
body.expert-mode.right-panel-empty .app-shell {
  grid-template-columns: var(--sidebar-w) var(--handle-w) minmax(0, 1fr) 0 0;
}

body.expert-mode.right-panel-empty #resizeRight,
body.expert-mode.right-panel-empty #mobilePanelToggle,
body.expert-mode.right-panel-empty .news-panel {
  display: none !important;
}

.topbar-date {
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: var(--text-3);
  white-space: nowrap;
}

.topbar-date-day {
  font-size: 9.5px;
}

.topbar-date-time {
  font-size: 8px;
  color: var(--text-3);
  opacity: 0.72;
}

.topbar-divider {
  width: 1px;
  height: 12px;
  background: var(--border-1);
}

.topbar-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sw-light);
  background: var(--sw-glow);
  border: 1px solid var(--sw-line);
  padding: 2px 7px;
  border-radius: 3px;
}

/* ── Query Section ──────────────────────────────────────────── */
.query-section {
  flex: 1;
  overflow-y: auto;
  padding: 36px 36px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}

.query-hero { margin-bottom: 28px; }

.query-headline {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 500;
  color: var(--text-0);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.query-subline {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
  font-weight: 300;
}

/* Asset chips */
.asset-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.asset-bar-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  flex-shrink: 0;
}

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  padding: 5px 13px;
  border-radius: 20px;
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 400;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  letter-spacing: 0.01em;
}

.chip:hover { border-color: var(--sw-line); color: var(--text-1); background: var(--sw-glow); }
.chip.active { border-color: var(--sw); color: var(--sw-pale); background: var(--sw-glow); }

/* Input */
.input-wrapper {
  border: 1px solid var(--border-2);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2);
  transition: border-color var(--duration) var(--ease-out), box-shadow var(--duration) var(--ease-out);
}

.input-wrapper:focus-within {
  border-color: rgba(1,107,171,0.5);
  box-shadow: 0 0 0 3px var(--sw-glow);
}

.query-textarea {
  width: 100%;
  min-height: 110px;
  padding: 18px 20px 10px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.65;
  resize: vertical;
  letter-spacing: 0.01em;
}

.query-textarea::placeholder { color: var(--text-3); }

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border-0);
  flex-wrap: wrap;
  row-gap: 4px;
}

.char-counter {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}

.btn-run {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  background: linear-gradient(135deg, var(--sw) 0%, #014f80 100%);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
}

.btn-run::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: translateX(-100%);
  transition: transform 600ms var(--ease-out);
}
.btn-run:hover::before { transform: translateX(100%); }

.btn-run:hover {
  background: linear-gradient(135deg, var(--sw-light) 0%, #0162a0 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(1,107,171,0.4);
}

/* ── btn-run icon visibility (default: show arrow) ── */
.btn-run-spinner,
.btn-run-check,
.btn-run-stop { display: none; }

/* idle — no input yet */
.btn-run[data-state="idle"] {
  background: var(--bg-5);
  color: var(--text-3);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-run[data-state="idle"]::before { display: none; }
.btn-run[data-state="idle"]:hover   { background: var(--bg-5); transform: none; box-shadow: none; }

/* ready — has input, not running */
.btn-run[data-state="ready"] {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}
.btn-run[data-state="ready"]:hover {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
}

/* running — clickable stop button */
.btn-run[data-state="running"] {
  background: linear-gradient(135deg, var(--sw) 0%, #014f80 100%);
  cursor: pointer;
  animation: btn-run-pulse 2s ease-in-out infinite;
}
.btn-run[data-state="running"]::before { display: none; }
.btn-run[data-state="running"]:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  animation: none;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.35);
}
.btn-run[data-state="running"] .btn-run-spinner { display: block; animation: btn-run-spin 0.9s linear infinite; }
.btn-run[data-state="running"] .btn-run-stop    { display: none; }
.btn-run[data-state="running"] .btn-run-arrow   { display: none; }
.btn-run[data-state="running"]:hover .btn-run-spinner { display: none; }
.btn-run[data-state="running"]:hover .btn-run-stop    { display: block; }

/* stop-confirm — red pulsing to signal "click again" */
.btn-run[data-state="stop-confirm"] {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  cursor: pointer;
  animation: btn-run-pulse 0.6s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
}
.btn-run[data-state="stop-confirm"]::before { display: none; }
.btn-run[data-state="stop-confirm"] .btn-run-spinner { display: none; }
.btn-run[data-state="stop-confirm"] .btn-run-stop    { display: block; }
.btn-run[data-state="stop-confirm"] .btn-run-arrow   { display: none; }

/* done — green with check */
.btn-run[data-state="done"] {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}
.btn-run[data-state="done"]:hover {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
}
.btn-run[data-state="done"] .btn-run-check { display: block; }
.btn-run[data-state="done"] .btn-run-arrow { display: none; }

/* error — red */
.btn-run[data-state="error"] {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}
.btn-run[data-state="error"]:hover {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.35);
}

@keyframes btn-run-spin  { from { transform: rotate(0deg); }   to { transform: rotate(360deg); } }
@keyframes btn-run-pulse { 0%, 100% { opacity: 1; }  50% { opacity: 0.65; } }

/* ── Report Mode Segmented Control ───────────────────────────── */
.report-mode-seg {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--border-1);
  border-radius: 20px;
  background: var(--bg-2);
  padding: 2px;
  gap: 1px;
  flex-shrink: 0;
}
.rms-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 16px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--font-ui);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.rms-btn:hover {
  color: var(--text-1);
  background: var(--bg-4);
}
.rms-btn.active {
  /* Subtle dark-on-dark highlight — avoids the too-bright white fallback */
  background: rgba(255,255,255,0.10);
  color: var(--text-0, #f0f2f5);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
/* Quick active: blue accent */
#rmsQuick.active {
  background: var(--sw);
  color: #fff;
  box-shadow: 0 1px 4px rgba(1,107,171,0.35);
}
#rmsQuick.active:hover {
  background: var(--sw-light, #0178c2);
}

/* ── Targeted Research Mode: button + badge ─────────────────────────────── */
#rmsTargeted.active {
  background: linear-gradient(135deg, #064e3b 0%, #0f766e 100%);
  border: 1px solid rgba(45, 212, 191, 0.35);
  color: #ccfbf1;
  box-shadow: 0 1px 4px rgba(15, 118, 110, 0.32);
}
#rmsTargeted.active:hover {
  background: linear-gradient(135deg, #065f46 0%, #0d9488 100%);
}
.run-mode-badge.mode-targeted-research {
  background: rgba(15, 118, 110, 0.14);
  color: #5eead4;
  border-color: rgba(45, 212, 191, 0.35);
}

/* ── Deep Research: Mode button ─────────────────────────────── */
#rmsDeep.active {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #c4b5fd;
  box-shadow: 0 1px 4px rgba(139, 92, 246, 0.3);
}
#rmsDeep.active:hover {
  background: linear-gradient(135deg, #1e1e35 0%, #1a2545 100%);
}
.run-mode-badge.mode-deep {
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.3);
}

/* ── Forum Mode: button + badge ────────────────────────────── */
#rmsForum.active {
  background: linear-gradient(135deg, #1a2e1a 0%, #163e2e 100%);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
  box-shadow: 0 1px 4px rgba(34, 197, 94, 0.3);
}
#rmsForum.active:hover {
  background: linear-gradient(135deg, #1e351e 0%, #1a4535 100%);
}
.run-mode-badge.mode-forum {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.3);
}

/* Forum philosophy picker */
.forum-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  width: 100%;
  order: 10;
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.03);
  margin-top: 6px;
  animation: forumFadeIn 0.2s ease-out;
}
@keyframes forumFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.forum-picker-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #86efac;
}
.forum-picker-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #86efac;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.forum-picker-count {
  font-size: 10px;
  color: var(--text-3);
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}
.forum-picker-toggle {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-1);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font-ui);
  transition: all 0.15s;
}
.forum-picker-toggle:hover {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.4);
}
.forum-picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.forum-picker-hint {
  font-size: 10px;
  color: var(--text-4);
  line-height: 1.3;
}
.forum-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border-1);
  background: var(--bg-2);
  color: var(--text-3);
  font-size: 11.5px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  user-select: none;
}
.forum-chip:hover {
  color: var(--text-1);
  border-color: var(--text-3);
  background: var(--bg-3);
}
.forum-chip.selected {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.12);
  font-weight: 500;
}
.forum-chip.selected:hover {
  background: rgba(34, 197, 94, 0.22);
  border-color: rgba(34, 197, 94, 0.6);
}

/* Forum agent panels (tabbed view in analysis card) */
.forum-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border-1);
  overflow-x: auto;
  flex-shrink: 0;
  /* Sticky: stays visible at top of scroll area */
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-1);
  /* Fade hint for scrollable overflow */
  mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}
/* Remove fade mask when scrolled to the end or not overflowing */
.forum-tabs:not(:hover) {
  scrollbar-width: none;
}
.forum-tab {
  padding: 7px 16px;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-3);
  font-size: 11.5px;
  font-family: var(--font-ui);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.forum-tab:hover {
  color: var(--text-1);
  background: var(--bg-3);
}
.forum-tab.active {
  background: rgba(34, 197, 94, 0.06);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.2);
  border-bottom-color: rgba(34, 197, 94, 0.5);
}
.forum-tab.forum-tab--meta {
  font-weight: 600;
}
.forum-tab.forum-tab--meta.active {
  color: #86efac;
  background: rgba(34, 197, 94, 0.1);
  border-bottom-color: #22c55e;
}
.forum-tab.forum-tab--done::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #22c55e;
  margin-left: 5px;
  vertical-align: middle;
}
.forum-panel {
  display: none;
  padding: 20px 16px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-0);
}
.forum-panel.active {
  display: block;
}
/* Forum panels inherit analysis-body typography */
.forum-panel h1, .forum-panel h2 { font-family: var(--font-serif); font-weight: 500; color: var(--text-0); line-height: 1.25; }
.forum-panel h1 { font-size: 22px; border-bottom: 1px solid var(--sw-line); padding-bottom: 10px; margin: 0 0 20px; }
.forum-panel h2 { font-size: 17px; margin: 32px 0 14px; }
.forum-panel h3 { font-size: 14px; font-weight: 600; color: var(--sw-pale); text-transform: uppercase; letter-spacing: 0.08em; margin: 24px 0 10px; }
.forum-panel h4 { font-size: 13.5px; font-weight: 600; color: var(--text-0); margin: 20px 0 8px; }
.forum-panel p { margin-bottom: 14px; }
.forum-panel ul, .forum-panel ol { padding-left: 20px; margin-bottom: 14px; }
.forum-panel li { margin-bottom: 5px; }
.forum-panel hr { border: none; border-top: 1px solid var(--border-1); margin: 24px 0; }
.forum-panel table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 12.5px; display: block; overflow-x: auto; }
.forum-panel th { background: var(--bg-3); border: 1px solid var(--border-1); padding: 7px 12px; text-align: left; font-size: 10px; color: var(--sw-light); }
.forum-panel td { border: 1px solid var(--border-0); padding: 7px 12px; color: var(--text-1); }

/* ── Deep Research: Agent groups in side panel ──────────────── */
.agent-group {
  margin: 0 0 8px 0;
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(139, 92, 246, 0.04);
  flex-shrink: 0;  /* prevent shrinking so parent feed scrolls */
}
.agent-group-header {
  padding: 8px 10px;
  background: rgba(139, 92, 246, 0.08);
  border-bottom: 1px solid rgba(139, 92, 246, 0.15);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  cursor: default;
}
.agent-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.agent-group-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8b5cf6;
  animation: agentPulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes agentPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}
.agent-group-name {
  font-size: 10px;
  font-weight: 600;
  color: #c4b5fd;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.agent-group-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}
.agent-group-domain {
  font-size: 9px;
  color: var(--text-3);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  max-width: 160px;
  text-align: right;
}
.agent-group-status {
  font-size: 9px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}
.agent-group-status.running {
  background: rgba(139, 92, 246, 0.2);
  color: #a78bfa;
}
.agent-group-status.done {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}
.agent-group-count {
  font-size: 9px;
  color: var(--text-3);
}
.agent-group-cards {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.agent-group-cards:empty {
  display: none;
}
/* Cards inside agent groups get a subtle indent */
.agent-group-cards .research-card,
.agent-group-cards .skill-card {
  margin: 0;
}

/* Tooltip data holder — hidden; JS reads its innerHTML and creates a fixed-position overlay */
.rms-tooltip { display: none; }

/* JS-driven fixed tooltip — appended to <body> to escape overflow:hidden containers */
.rms-floating-tooltip {
  position: fixed;
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #1a1d23;
  color: #e8eaed;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  font-family: var(--font-ui);
  line-height: 1.55;
  pointer-events: auto;
  z-index: 9999;
  white-space: normal;
  overflow-wrap: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.28) transparent;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: rms-tip-in 0.12s ease both;
}
@keyframes rms-tip-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Arrow pointing toward the control after JS clamps the tooltip to the viewport. */
.rms-floating-tooltip::after {
  content: '';
  position: absolute;
  left: var(--rms-tooltip-arrow-left, 50%);
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
}
.rms-floating-tooltip.arrow-down::after {
  top: 100%;
  border-top: 6px solid #1a1d23;
}
.rms-floating-tooltip.arrow-up::after {
  bottom: 100%;
  border-bottom: 6px solid #1a1d23;
}
.rms-tooltip-row { padding: 2px 0; }
.rms-tooltip-divider { margin-top: 6px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.1); }
.rms-tooltip-key {
  font-weight: 600;
  color: #7ec8f5;
}

/* Example prompts */
.example-prompts {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.example-label { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }

.example-btn {
  padding: 4px 11px;
  border: 1px solid var(--border-1);
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
}

.example-btn:hover { border-color: var(--border-2); color: var(--text-1); background: var(--bg-3); }

/* ══════════════════════════════════════════════════════════════
   OUTPUT SECTION
   ══════════════════════════════════════════════════════════════ */
.output-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  position: relative;
}

.output-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 28px 12px;
  border-bottom: 1px solid var(--border-0);
  flex-shrink: 0;
}

.output-header-left {
  flex: 1;
  min-width: 0;
}

.output-query-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sw-light);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Run-mode badge: appears next to "Analysis Query" label */
.run-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 8.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  font-weight: 600;
  text-transform: uppercase;
  border: 1px solid currentColor;
  line-height: 1.6;
}
.run-mode-badge.mode-full {
  color: var(--text-3);
  border-color: var(--border-1);
  background: var(--bg-3);
}
.run-mode-badge.mode-targeted {
  color: var(--sw-light);
  border-color: rgba(1,107,171,0.4);
  background: rgba(1,107,171,0.08);
}

.output-query-shell {
  max-width: min(760px, 100%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.output-query-text {
  font-size: 13px;
  color: var(--text-1);
  font-weight: 300;
  line-height: 1.5;
  width: 100%;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-0);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  transition: background var(--duration), border-color var(--duration), box-shadow var(--duration), max-height var(--duration);
}

.output-query-text.is-collapsed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  max-height: calc(1.5em * 2 + 2px);
}

.output-query-text.is-collapsed:hover {
  background: rgba(255,255,255,0.035);
  border-color: var(--border-1);
}

.output-query-shell.is-expanded .output-query-text {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  max-height: min(34vh, 260px);
  min-height: 84px;
  overflow: auto;
  resize: vertical;
  background: rgba(255,255,255,0.035);
  border-color: var(--sw-line);
  box-shadow: inset 0 0 0 1px rgba(1,107,171,0.08);
}

.output-query-toggle {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-1);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
}

.output-query-toggle:hover {
  color: var(--text-0);
  border-color: var(--sw-line);
  background: rgba(1,107,171,0.08);
}

.output-query-toggle:focus-visible {
  outline: 2px solid var(--sw-light);
  outline-offset: 2px;
}

.btn-icon-sm {
  width: 28px; height: 28px;
  border-radius: 5px;
  border: 1px solid var(--border-1);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration);
}
.btn-icon-sm:hover { background: var(--bg-4); color: var(--text-1); }

/* ── Pipeline ───────────────────────────────────────────────── */
.pipeline {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-0);
  background: var(--bg-2);
}

.pipeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px;
}

.pipeline-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-1);
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

.pipeline-cost {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-2);
  background: var(--bg-1);
  border: 1px solid var(--border-0);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
  margin-left: auto;
  margin-right: 8px;
  flex-shrink: 0;
}
.pipeline-cost.is-final {
  color: var(--green, #2ecc40);
  border-color: var(--green, #2ecc40);
}

/* Account usage section */
.acct-usage-content { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }
.acct-usage-loading { font-style: italic; opacity: 0.5; }
.acct-usage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-top: 8px;
}
.acct-usage-stat { display: flex; flex-direction: column; gap: 2px; }
.acct-usage-stat-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.acct-usage-stat-value { font-size: 16px; font-weight: 600; color: var(--text-1); }

#pipelineProgressText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-0);
}

.pulse-ring {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--sw);
  display: inline-block;
  position: relative;
  animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(1,107,171,0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(1,107,171,0); }
  100% { box-shadow: 0 0 0 0 rgba(1,107,171,0); }
}

.pipeline-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); padding: 4px; display: flex;
  border-radius: 3px; transition: all var(--duration);
}
.pipeline-toggle:hover { color: var(--text-1); background: var(--border-0); }
.pipeline-toggle.collapsed svg { transform: rotate(-90deg); }
.pipeline-toggle svg { transition: transform var(--duration) var(--ease-out); }

.pipeline-steps {
  padding: 0 28px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 50vh;
  transition: max-height 0.4s var(--ease-out);
}

.pipeline-steps.collapsed { max-height: 0 !important; padding-bottom: 0; overflow: hidden; }

/* ── Research Plan Panel ────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════
   WORK PLAN TAB
   ══════════════════════════════════════════════════════════════ */
.workplan-feed {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  scrollbar-width: thin;
}
.workplan-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-3);
  text-align: center;
  font-size: 12px;
}
.workplan-placeholder svg { margin-bottom: 8px; color: var(--text-3); }
.workplan-placeholder p { margin: 0; line-height: 1.5; }

/* Planning-in-progress state (before plan arrives) */
.workplan-planning {
  align-items: flex-start;
  padding: 16px 12px;
  gap: 0;
}
.workplan-planning-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-0);
  margin: 10px 0 8px;
}
.workplan-planning-log {
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.workplan-planning-line {
  font-size: 11px;
  color: var(--text-2);
  padding: 3px 0;
  border-bottom: 1px solid var(--border-0);
  animation: wpLineIn 0.15s ease-out;
}
.workplan-planning-line:last-child {
  color: var(--text-0);
  border-bottom: none;
}
@keyframes wpLineIn {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

.workplan-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--sw);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 8px;
  letter-spacing: 0;
}

/* ── Progress bar ── */
.wp-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0 2px;
}
.wp-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border-1, rgba(255,255,255,0.08));
  border-radius: 2px;
  overflow: hidden;
}
.wp-progress-fill {
  height: 100%;
  background: var(--sw, #2563eb);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.wp-progress-text {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}

/* ── Phase sections ── */
.wp-phase {
  margin-bottom: 10px;
}
.wp-phase-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.12);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-1);
}
.wp-phase-icon { font-size: 12px; }
.wp-phase-label { flex: 1; }
.wp-phase-count {
  font-weight: 400;
  font-size: 10px;
  color: var(--text-2);
}

/* ── Steps ── */
.wp-steps {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 4px;
}
.wp-step {
  position: relative;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  transition: opacity 0.3s ease, background 0.2s ease;
  cursor: default;
}
.wp-step-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.wp-step-expandable .wp-step-main {
  cursor: pointer;
}
.wp-step-expandable .wp-step-main:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: 3px;
  border-radius: 5px;
}
.wp-step:hover {
  background: rgba(255,255,255,0.04);
}
.wp-step-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.wp-step-label {
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wp-step-purpose {
  font-size: 10.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wp-step-caret {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1;
  margin-top: 1px;
  transition: color 0.15s ease, transform 0.18s ease;
}
.wp-step-expandable:hover .wp-step-caret,
.wp-step-expandable.is-expanded .wp-step-caret {
  color: var(--text-1);
}
.wp-step-expandable.is-expanded .wp-step-caret {
  transform: translateY(1px);
}
.wp-step-detail-panel {
  margin: 7px 0 2px 24px;
  padding: 9px 10px;
  border-left: 2px solid rgba(37, 99, 235, 0.35);
  background: rgba(255,255,255,0.035);
  border-radius: 0 6px 6px 0;
}
.wp-step-detail-panel[hidden] {
  display: none;
}
.wp-detail-section + .wp-detail-section,
.wp-detail-grid + .wp-detail-section {
  margin-top: 9px;
}
.wp-detail-label {
  margin-bottom: 4px;
  color: var(--text-3);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.wp-detail-text {
  color: var(--text-1);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.wp-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.wp-detail-stat {
  min-width: 0;
  padding: 6px 7px;
  background: rgba(0,0,0,0.14);
  border: 1px solid rgba(255,255,255,0.055);
  border-radius: 5px;
}
.wp-detail-stat span {
  display: block;
  color: var(--text-3);
  font-size: 9.5px;
  margin-bottom: 2px;
}
.wp-detail-stat strong {
  display: block;
  color: var(--text-1);
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wp-tool-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.wp-tool-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 6px;
  align-items: center;
  padding: 6px 7px;
  background: rgba(0,0,0,0.14);
  border: 1px solid rgba(255,255,255,0.055);
  border-radius: 5px;
}
.wp-tool-icon {
  grid-row: span 2;
  color: var(--text-2);
  font-size: 12px;
}
.wp-tool-label {
  min-width: 0;
  color: var(--text-1);
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wp-tool-chip code {
  min-width: 0;
  color: var(--text-3);
  font-family: var(--font-mono, 'SF Mono', monospace);
  font-size: 9.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wp-detail-notes {
  margin: 0;
  padding-left: 16px;
  color: var(--text-2);
  font-size: 10.5px;
  line-height: 1.45;
}
.wp-detail-notes li + li {
  margin-top: 3px;
}
@media (max-width: 520px) {
  .wp-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Status indicators */
.wp-step-status {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  margin-top: 2px;
  transition: all 0.3s ease;
}
.wp-status-pending {
  color: var(--text-3);
  border: 1.5px solid var(--border-1, rgba(255,255,255,0.12));
  font-size: 6px;
}
.wp-status-done {
  color: #fff;
  background: var(--color-success, #16a34a);
  border: none;
}
.wp-status-error {
  color: #fff;
  background: var(--color-error, #e53e3e);
  border: none;
}

/* Done / error / skipped step styling */
.wp-step-done .wp-step-main { opacity: 0.55; }
.wp-step-done .wp-step-label { text-decoration: line-through; text-decoration-color: var(--text-3); }
.wp-step-error .wp-step-main { opacity: 0.5; }
.wp-step-error .wp-step-label { color: var(--color-error, #e53e3e); text-decoration: line-through; }
.wp-step-skipped .wp-step-main { opacity: 0.4; }
.wp-step-skipped .wp-step-label { text-decoration: line-through; text-decoration-color: var(--text-3); }
.wp-step-skipped .wp-step-purpose::after { content: ' (replaced by forum)'; font-style: italic; color: var(--text-3); }
.wp-status-skipped {
  color: var(--text-2);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 10px;
}

/* ── Hover tooltip (portal — fixed position, not clipped by scroll container) ── */
.wp-step-tooltip { display: none; }   /* hidden inline; portal clone is shown */
#wp-tooltip-portal {
  position: fixed;
  z-index: 9999;
  max-width: 340px;
  min-width: 180px;
  padding: 10px 14px;
  background: var(--bg-2, #232323);
  border: 1px solid var(--border-1, rgba(255,255,255,0.15));
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-1);
  line-height: 1.55;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  pointer-events: none;
  white-space: normal;
  word-break: break-word;
  opacity: 0;
  transition: opacity 0.12s ease;
}
#wp-tooltip-portal.is-visible { opacity: 1; }
#wp-tooltip-portal .wp-tt-label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-0, #fff);
  margin-bottom: 4px;
}
#wp-tooltip-portal .wp-tt-detail {
  color: var(--text-2, #b0b0b0);
  font-size: 11.5px;
  line-height: 1.5;
}
#wp-tooltip-portal .wp-tt-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
#wp-tooltip-portal .wp-tt-tool {
  font-family: var(--font-mono, 'SF Mono', monospace);
  font-size: 10px;
  color: var(--text-3, #888);
  background: rgba(255,255,255,0.05);
  padding: 1px 5px;
  border-radius: 3px;
}
#wp-tooltip-portal .wp-tt-priority {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
}
#wp-tooltip-portal .wp-tt-priority--high   { color: #f87171; background: rgba(248,113,113,0.12); }
#wp-tooltip-portal .wp-tt-priority--medium { color: #fbbf24; background: rgba(251,191,36,0.12); }
#wp-tooltip-portal .wp-tt-priority--low    { color: #60a5fa; background: rgba(96,165,250,0.12); }

/* ── New step slide-in animation ── */
@keyframes wp-step-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wp-step-new {
  animation: wp-step-slide-in 0.35s ease forwards;
}

/* Legacy aliases — keep old classes working if any references remain */
.research-plan-panel { display: none; }

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  animation: step-in 0.25s var(--ease-out) both;
}

@keyframes step-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.step-icon { width: 16px; height: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }

.step-spinner {
  width: 12px; height: 12px;
  border: 1.5px solid var(--border-2);
  border-top-color: var(--sw);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.step-check { color: var(--green); font-size: 12px; line-height: 1; }

.step-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-2);
  letter-spacing: 0.01em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step.done .step-label { color: var(--text-1); }
.step.error .step-label { color: var(--red); }

.step-tool {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--sw-light);
  background: var(--sw-glow);
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

/* ── Reasoning Panel ────────────────────────────────────────── */
.reasoning-panel {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-0);
  background: linear-gradient(to bottom, rgba(1,107,171,0.04), transparent);
}

.reasoning-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 28px;
  cursor: pointer;
  list-style: none;
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 500;
  user-select: none;
}

.reasoning-summary::-webkit-details-marker { display: none; }
.reasoning-summary:hover { color: var(--text-1); }

.reasoning-summary svg:first-child { color: var(--sw-light); flex-shrink: 0; }

.reasoning-count {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--sw);
  background: var(--sw-glow);
  border: 1px solid var(--sw-line);
  padding: 1px 6px;
  border-radius: 3px;
}

.reasoning-chevron {
  margin-left: auto;
  color: var(--text-3);
  transition: transform var(--duration) var(--ease-out);
}
.reasoning-panel[open] .reasoning-chevron { transform: rotate(180deg); }

.reasoning-body {
  max-height: 500px;
  overflow-y: auto;
  padding: 0 28px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}

.thinking-block {
  margin-bottom: 8px;
  padding: 10px 14px;
  background: var(--bg-0);
  border: 1px solid rgba(1,107,171,0.12);
  border-left: 3px solid var(--sw-line);
  border-radius: 0 5px 5px 0;
  animation: step-in 0.3s var(--ease-out) both;
}

.thinking-block-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sw);
  margin-bottom: 5px;
}

.thinking-block-text {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-2);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Analysis Card ──────────────────────────────────────────── */
/* Scrollable wrapper: analysis + actions + chat all scroll together */
.output-scroll-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}

.analysis-card {
  padding: 28px 36px 24px;
  position: relative;
}

.fact-check-panel {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border-1);
  color: var(--text-2);
  font-size: 12px;
}
.fact-check-details {
  display: block;
}
.fact-check-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.fact-check-details > summary.fact-check-header {
  cursor: pointer;
  list-style: none;
  margin-bottom: 0;
}
.fact-check-details > summary.fact-check-header::-webkit-details-marker {
  display: none;
}
.fact-check-title-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.fact-check-toggle-icon {
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
  transition: transform 0.16s ease;
}
.fact-check-details[open] .fact-check-toggle-icon {
  transform: rotate(90deg);
}
.fact-check-title {
  color: var(--text-1);
  font-size: 13px;
  font-weight: 700;
}
.fact-check-status {
  border: 1px solid var(--border-1);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--text-3);
  font-size: 10px;
  text-transform: uppercase;
}
.fact-check-body {
  margin-top: 10px;
}
.fact-check-summary {
  margin-bottom: 10px;
  color: var(--text-2);
}
.fact-check-issue {
  display: grid;
  gap: 5px;
  padding: 10px 0;
  border-top: 1px solid var(--border-1);
}
.fact-check-issue:first-of-type {
  border-top: 0;
}
.fact-check-issue-title {
  color: var(--text-1);
  font-weight: 650;
}
.fact-check-issue-meta {
  color: var(--text-3);
}
.fact-check-empty {
  color: var(--text-3);
}

.analysis-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-family: var(--font-serif);
  font-size: 80px;
  font-weight: 600;
  color: rgba(1,107,171,0.03);
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: 0.1em;
  user-select: none;
}

.analysis-body { font-size: 14px; line-height: 1.8; color: var(--text-0); font-weight: 300; }

/* Sections added via "Add to Report" */
.report-addendum {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 2px dashed var(--sw-line);
  position: relative;
  animation: fadeIn 350ms var(--ease-out) both;
}
.report-addendum::before {
  content: 'Follow-up Addition';
  position: absolute;
  top: -9px;
  left: 0;
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sw-light);
  background: var(--bg-3);
  padding: 0 7px;
}

.analysis-body h1, .analysis-body h2 {
  font-family: var(--font-serif);
  font-weight: 500;
  color: var(--text-0);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.analysis-body h1 {
  font-size: 24px;
  border-bottom: 1px solid var(--sw-line);
  padding-bottom: 12px;
  margin-bottom: 24px;
}

.analysis-body h2 { font-size: 18px; margin: 36px 0 16px; }

.analysis-body h3 {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--sw-pale);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 28px 0 12px;
}

.analysis-body h4 {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
  margin: 24px 0 10px;
}

.analysis-body h5 {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 20px 0 8px;
}

.analysis-body p { margin-bottom: 16px; }
.analysis-body strong { color: var(--text-0); font-weight: 600; }
.analysis-body em { color: var(--text-1); }

.analysis-body ul, .analysis-body ol { padding-left: 20px; margin-bottom: 16px; }
.analysis-body li { margin-bottom: 6px; color: var(--text-0); }
.analysis-body li::marker { color: var(--sw-light); }

.analysis-body blockquote {
  border-left: 3px solid var(--sw-line);
  padding: 12px 20px;
  margin: 20px 0;
  background: var(--bg-2);
  border-radius: 0 5px 5px 0;
  color: var(--text-1);
}

.analysis-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-4);
  border: 1px solid var(--border-1);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--sw-pale);
}

.analysis-body pre {
  background: var(--bg-0);
  border: 1px solid var(--border-1);
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
  margin-bottom: 14px;
}

.analysis-body pre code { background: none; border: none; padding: 0; font-size: 12px; color: var(--text-1); }

.analysis-body hr { border: none; border-top: 1px solid var(--border-1); margin: 28px 0; }

.analysis-body table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 12.5px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.analysis-body th {
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  padding: 7px 12px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sw-light);
}
.analysis-body td { border: 1px solid var(--border-0); padding: 7px 12px; color: var(--text-1); }
.analysis-body tr:hover td { background: var(--bg-2); }

/* ── Hyperlinks in analysis ─────────────────────────────────── */
.analysis-body a {
  color: var(--sw-pale);
  text-decoration: underline;
  text-decoration-color: rgba(74,176,232,0.35);
  text-underline-offset: 2px;
  transition: color var(--duration), text-decoration-color var(--duration);
}

.analysis-body a:hover {
  color: #fff;
  text-decoration-color: var(--sw-light);
}

/* ── Error Banner ───────────────────────────────────────────── */
.error-banner {
  margin: 20px 28px 0;
  padding: 14px 18px;
  background: rgba(248,113,113,0.05);
  border: 1px solid rgba(248,113,113,0.18);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: step-in 0.25s var(--ease-out) both;
}

.error-banner-icon { color: var(--red); opacity: 0.7; flex-shrink: 0; }

.error-banner-text { flex: 1; font-size: 13px; color: var(--text-1); }
.error-banner-text small { display: block; font-size: 11px; color: var(--text-3); margin-top: 2px; }

.btn-view-logs {
  padding: 5px 12px;
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: 5px;
  background: transparent;
  color: var(--red);
  font-size: 11.5px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--duration);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-view-logs:hover { background: rgba(248,113,113,0.1); }

.error-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-error-retry {
  padding: 5px 12px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-size: 11.5px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: opacity var(--duration);
  white-space: nowrap;
}
.btn-error-retry:hover { opacity: 0.85; }
.btn-error-retry:disabled { opacity: 0.5; cursor: default; }

.btn-error-notify {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--duration);
  white-space: nowrap;
}
.btn-error-notify:hover { background: var(--surface-2); }
.btn-error-notify:disabled { opacity: 0.5; cursor: default; }

/* ── Cursor ─────────────────────────────────────────────────── */
.cursor-blink {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--sw);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.9s step-end infinite;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Output actions ─────────────────────────────────────────── */
.output-actions {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px 28px 16px;
  border-top: 1px solid var(--border-0);
}

.btn-action {
  padding: 7px 16px;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  background: transparent;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
}

.btn-action:hover { background: var(--bg-4); border-color: var(--sw-line); color: var(--sw-pale); }

.followup-jump-btn {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(260px, calc(100% - 48px));
  padding: 10px 13px 10px 11px;
  border: 1px solid rgba(139,92,246,.42);
  border-radius: 999px;
  background: var(--bg-1);
  color: var(--text-0);
  box-shadow: 0 12px 34px rgba(0,0,0,.32), 0 0 0 1px rgba(139,92,246,.08);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(.98);
  pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), border-color 140ms var(--ease-out), background 140ms var(--ease-out);
}
.followup-jump-btn[hidden] {
  display: none !important;
}
.followup-jump-btn.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.followup-jump-btn:hover {
  border-color: rgba(196,181,253,.8);
  background: var(--bg-2);
}
.followup-jump-btn:focus-visible {
  outline: 2px solid var(--sw-light);
  outline-offset: 3px;
}
.followup-jump-icon {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #e9d5ff;
  background: rgba(139,92,246,.22);
}
.followup-jump-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  line-height: 1.15;
}
.followup-jump-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--text-0);
}
.followup-jump-subtitle {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--text-2);
}

/* Action overflow menu (narrow screens) */
.action-overflow { position: relative; display: none; }
.btn-action--overflow-toggle {
  padding: 7px 12px;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  background: transparent;
  color: var(--text-1);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
}
.btn-action--overflow-toggle:hover { background: var(--bg-4); }
.action-overflow-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 4px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 4px;
  min-width: 160px;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.action-overflow.is-open .action-overflow-menu { display: block; }
.action-overflow-menu .btn-action {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
}
.action-overflow-menu .btn-action:hover { background: var(--bg-4); }

/* On narrow screens, hide secondary buttons and show overflow when actions remain */
@media (max-width: 900px) {
  .output-actions .btn-action--secondary { display: none; }
  .output-actions .action-overflow.has-actions { display: block; }
}
[data-theme="light"] .action-overflow-menu { background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.12); }

/* ══════════════════════════════════════════════════════════════
   NEWS / INTELLIGENCE PANEL
   ══════════════════════════════════════════════════════════════ */
.news-panel {
  background: var(--bg-2);
  /* border-left removed — resize handle is now the visual divider */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.news-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, var(--sw-line) 30%, var(--sw-line) 70%, transparent);
}

.news-header {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border-0);
  flex-shrink: 0;
}

.news-title {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-0);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(74,222,128,0.1);
  border: 1px solid rgba(74,222,128,0.2);
  border-radius: 20px;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  color: var(--green);
}

.live-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s ease-out infinite;
}

.news-sub { font-size: 11px; color: var(--text-3); }

.news-feed {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
  min-height: 0;
}

.news-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 20px;
  color: var(--text-3);
  text-align: center;
}

.news-placeholder-icon { opacity: 0.4; }
.news-placeholder p { font-size: 12px; line-height: 1.6; }

.news-card {
  padding: 10px;
  border: 1px solid var(--border-0);
  border-radius: 6px;
  background: var(--bg-3);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  opacity: 0;
  transform: translateX(12px);
}
.news-card.is-visible {
  animation: card-in 0.3s var(--ease-out) both;
}

@keyframes card-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }

.news-card:hover { border-color: var(--border-2); background: var(--bg-4); }

.news-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }

.news-source-badge {
  font-family: var(--font-mono);
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--sw-light);
  background: var(--sw-glow);
  border: 1px solid var(--sw-line);
}

.news-source-badge.web { color: var(--blue); background: rgba(96,165,250,0.08); border-color: rgba(96,165,250,0.2); }
.news-source-badge.sec { color: var(--amber); background: rgba(251,191,36,0.08); border-color: rgba(251,191,36,0.2); }
.news-source-badge.rss { color: var(--green); background: rgba(74,222,128,0.08); border-color: rgba(74,222,128,0.2); }

.news-date { font-family: var(--font-mono); font-size: 9px; color: var(--text-3); }

.news-card-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
  line-height: 1.4;
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-card-snippet {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Sources panel ──────────────────────────────────────────── */
.sources-panel {
  flex-shrink: 0;
  /* border-top removed — resize-handle-h acts as visual divider */
  height: var(--sources-h);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sources-panel-header {
  padding: 8px 14px 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-0);
}

.sources-count {
  background: var(--sw-dim);
  color: var(--sw-light);
  border-radius: 8px;
  padding: 0 5px;
  font-size: 8.5px;
}

.sources-list-urls {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}

.source-url-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 4px;
  border-radius: 4px;
  transition: background var(--duration);
}
.source-url-item:hover { background: var(--bg-3); }

.source-url-link {
  font-size: 10.5px;
  color: var(--sw-pale);
  text-decoration: none;
  word-break: break-all;
  line-height: 1.4;
  flex: 1;
}
.source-url-link:hover { color: #fff; text-decoration: underline; }

.source-url-domain {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-3);
  flex-shrink: 0;
  margin-top: 1px;
}

.source-url-tool-tag {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--sw-pale);
  background: rgba(1, 107, 171, 0.1);
  border: 1px solid rgba(1, 107, 171, 0.2);
  border-radius: 3px;
  padding: 1px 4px;
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  transition: background var(--duration), border-color var(--duration);
}
.source-url-tool-tag:hover {
  background: rgba(1, 107, 171, 0.22);
  border-color: rgba(1, 107, 171, 0.4);
}

/* ── News footer ────────────────────────────────────────────── */
.news-panel-footer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.run-cost-display {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-3);
  opacity: 0.7;
  white-space: nowrap;
  cursor: default;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(1, 107, 171, 0.08);
}

.news-panel-footer {
  /* border-top removed — resize-handle-h acts as visual divider */
  padding: 8px 12px;
  flex-shrink: 0;
  height: var(--tools-footer-h);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.news-panel-footer-label {
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

/* ── Run summary tags (replace static source tags) ─── */
.run-summary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 16px;
  align-items: flex-start;
  overflow-y: auto;
  flex: 1;
}

.run-summary-empty {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-3);
  opacity: 0.45;
  font-style: italic;
  line-height: 1.8;
}

.run-tag {
  font-family: var(--font-mono);
  font-size: 7.5px;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--duration), border-color var(--duration);
}

.run-tag:hover {
  filter: brightness(1.3);
}

.run-tag--tool {
  color: var(--sw-pale);
  background: rgba(1, 107, 171, 0.13);
  border: 1px solid rgba(1, 107, 171, 0.28);
}

.run-tag--skill {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.28);
}

.run-tag--sources {
  color: var(--text-2);
  background: var(--bg-2);
  border: 1px solid var(--border-1);
}

/* Highlight flash for navigated-to cards */
@keyframes card-highlight {
  0%   { box-shadow: 0 0 0 2px var(--sw-pale); }
  100% { box-shadow: 0 0 0 0px transparent; }
}
.card-highlight {
  animation: card-highlight 1.2s ease-out;
}

/* ── Scrollbars ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ── Chart wrappers (auto-generated from data tables) ──────── */
.sw-chart-wrap {
  margin: 12px 0 24px;
  padding: 16px 16px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  animation: step-in 0.4s var(--ease-out) both;
}
.sw-skill-chart-wrap {
  height: 340px;
  min-height: 280px;
  max-width: 100%;
}
.sw-skill-chart-wrap canvas.sw-chart {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ══════════════════════════════════════════════════════════════
   CHAT PANEL — follow-up Q&A grounded in the analysis
   ══════════════════════════════════════════════════════════════ */

.chat-panel {
  margin: 28px 28px 36px;
  border: 1px solid rgba(139,92,246,.35);
  border-top: 2px solid var(--sw);
  border-radius: 10px;
  background: var(--bg-1);
  overflow: hidden;
  animation: fadeIn 320ms var(--ease-out) both;
  box-shadow: 0 0 0 1px rgba(139,92,246,.08), 0 4px 20px rgba(0,0,0,.25);
}

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

/* ── Header ───────────────────────────────────────────────── */
.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 18px;
  border-bottom: 1px solid rgba(139,92,246,.18);
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(139,92,246,.08);
}

.chat-model-label {
  margin-left: auto;
  font-size: 10px;
  color: #a78bfa;
  font-family: var(--font-mono);
  background: rgba(139,92,246,.12);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(139,92,246,.25);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Hint chips ───────────────────────────────────────────── */
.chat-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(139,92,246,.12);
  background: var(--bg-1);
}

.chat-hint-btn {
  background: rgba(139,92,246,.08);
  border: 1px solid rgba(139,92,246,.25);
  border-radius: 20px;
  color: #c4b5fd;
  font-size: 11.5px;
  font-family: var(--font-body);
  padding: 5px 14px;
  cursor: pointer;
  transition: background 110ms, border-color 110ms, color 110ms;
  line-height: 1.4;
}
.chat-hint-btn:hover {
  background: rgba(139,92,246,.18);
  border-color: rgba(139,92,246,.5);
  color: #e9d5ff;
}
.chat-hint-btn:focus-visible {
  outline: 2px solid var(--sw-light);
  outline-offset: 1px;
}
.chat-hints-loading {
  color: var(--text-2);
  font-size: 11px;
  font-style: italic;
  padding: 2px 0;
  animation: pulse-hint 1.2s ease-in-out infinite;
}
@keyframes pulse-hint {
  0%, 100% { opacity: .5; }
  50%      { opacity: 1; }
}

/* ── Thread ───────────────────────────────────────────────── */
.chat-thread {
  /* No max-height — outer scroll area (.output-scroll-area) handles overflow */
  scroll-behavior: smooth;
}

/* ── Q&A pair — collapsible wrapper ───────────────────────── */
.chat-pair {
  border-bottom: 1px solid var(--border-0);
}
.chat-pair:last-child { border-bottom: none; }

.chat-pair-body {
  /* Visible by default */
}
.chat-pair.is-collapsed .chat-pair-body {
  display: none;
}

/* Chevron on user header */
.chat-pair-chevron {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--text-3);
  transform: rotate(90deg);   /* points down = expanded */
  transition: transform 0.2s ease, color 0.15s;
}
.chat-pair.is-collapsed .chat-pair-chevron {
  transform: rotate(0deg);    /* points right = collapsed */
}
.chat-message--user:hover .chat-pair-chevron {
  color: var(--text-1);
}

/* ── "Add to Report" button ───────────────────────────────── */
.chat-add-report-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 16px 12px;
  padding: 5px 12px;
  font-size: 11px;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--sw-pale);
  background: rgba(1, 107, 171, 0.08);
  border: 1px solid rgba(1, 107, 171, 0.25);
  border-radius: 5px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
  width: fit-content;
}
.chat-add-report-btn:hover {
  background: rgba(1, 107, 171, 0.16);
  border-color: var(--sw-line);
  color: #fff;
}
.chat-add-report-btn.is-added {
  color: var(--green);
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.25);
  cursor: default;
}

.chat-message {
  padding: 14px 16px;
  animation: step-in 0.28s var(--ease-out) both;
}

/* User bubble */
.chat-message--user {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--bg-2);
  cursor: pointer;
  user-select: none;
}

.chat-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 8px;
  color: var(--text-1);
  font-weight: 700;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
}

.chat-user-text {
  color: var(--text-0);
  font-size: 13px;
  line-height: 1.55;
  padding-top: 3px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* AI response */
.chat-message--ai {
  background: var(--bg-1);
}

.chat-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--sw-pale);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  opacity: 0.85;
}

.chat-ai-body {
  color: var(--text-0);
  font-size: 13px;
  line-height: 1.68;
}

/* Markdown inside AI responses */
.chat-ai-body h2,
.chat-ai-body h3 {
  font-family: var(--font-serif);
  font-size: 1em;
  font-weight: 500;
  color: var(--text-0);
  margin: 14px 0 6px;
}
.chat-ai-body p  { margin: 0 0 10px; }
.chat-ai-body ul,
.chat-ai-body ol { margin: 0 0 10px 20px; }
.chat-ai-body li { margin-bottom: 3px; }
.chat-ai-body strong { color: var(--sw-pale); font-weight: 600; }
.chat-ai-body a   { color: var(--sw-pale); }
.chat-ai-body code {
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
}
.chat-ai-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 10px 0;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-ai-body th {
  background: var(--bg-3);
  color: var(--sw-pale);
  border: 1px solid var(--border-1);
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
}
.chat-ai-body td {
  border: 1px solid var(--border-1);
  padding: 5px 10px;
  color: var(--text-0);
}
.chat-ai-body tr:nth-child(even) td { background: var(--bg-2); }

/* ── Chat progress panel (pipeline-style follow-up progress) ─ */
.chat-progress-panel {
  margin: 8px 0 4px;
  border: 1px solid var(--border-0);
  border-radius: 8px;
  background: var(--bg-1);
  overflow: hidden;
  animation: step-in 0.25s var(--ease-out) both;
}
.chat-progress-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-0);
}
.chat-progress-pulse {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--sw);
  display: inline-block;
  flex-shrink: 0;
  animation: pulse-ring 2s ease-out infinite;
}
.chat-progress-title {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-1);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Inline thinking blocks ─────────────────────────────── */
.chat-progress-thinking {
  padding: 8px 16px 4px;
  border-bottom: 1px solid var(--border-0);
}
.chat-thinking-block {
  padding: 4px 0;
  animation: step-in 0.2s var(--ease-out) both;
}
.chat-thinking-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sw);
  margin-right: 8px;
}
.chat-thinking-text {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.5;
  word-break: break-word;
}

/* ── Inline tool steps ──────────────────────────────────── */
.chat-progress-steps {
  padding: 6px 16px 8px;
}
.chat-tool-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 11px;
  color: var(--text-2);
  animation: step-in 0.25s var(--ease-out) both;
  transition: opacity 0.2s;
}
.chat-tool-step.is-done {
  opacity: 0.55;
}
.chat-tool-icon {
  width: 16px; height: 16px;
  font-size: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-tool-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.01em;
}
.chat-tool-spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--border-2);
  border-top-color: var(--sw);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.chat-tool-done {
  color: var(--green, #22c55e);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Compose area ─────────────────────────────────────────── */
.chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(139,92,246,.18);
  background: rgba(139,92,246,.05);
}

.chat-textarea {
  flex: 1;
  background: var(--bg-2);
  border: 1.5px solid rgba(139,92,246,.3);
  border-radius: 8px;
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.55;
  padding: 10px 14px;
  resize: none;
  min-height: 40px;
  max-height: 140px;
  overflow-y: auto;
  transition: border-color 150ms, box-shadow 150ms;
}
.chat-textarea:focus {
  outline: none;
  border-color: var(--sw);
  box-shadow: 0 0 0 3px rgba(139,92,246,.15);
}
.chat-textarea::placeholder { color: var(--text-3); font-size: 13px; }

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--sw);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 110ms, opacity 110ms, box-shadow 110ms;
}
.chat-send-btn:hover    { background: var(--sw-light); box-shadow: 0 2px 8px rgba(139,92,246,.4); }
.chat-send-btn:disabled { opacity: 0.35; cursor: default; }

/* ── Print ──────────────────────────────────────────────────── */
@media print {
  .sidebar, .resize-handle, .news-panel, .main-topbar, .output-header .btn-icon-sm,
  .pipeline, .reasoning-panel, .output-actions, .chat-panel, .followup-jump-btn,
  .sw-chart-wrap, .bg-grid, .analysis-watermark, .cursor-blink,
  .error-banner { display: none !important; }
  html, body { overflow: visible !important; height: auto !important; }
  .app-shell  { display: block; overflow: visible; }
  .main-panel { overflow: visible; height: auto; }
  .output-section { display: block !important; overflow: visible; height: auto; }
  .analysis-card  { overflow: visible; padding: 0; height: auto; box-shadow: none; }
  body { background: #fff; color: #000; }
  .analysis-body { color: #111; font-size: 11pt; }
  .analysis-body a { color: #016bab; }
  .analysis-body h1, .analysis-body h2 { color: #0a1929; }
  .analysis-body th { background: #016bab !important; color: #fff !important; }
}

/* ── Utility ────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.upload-spinner {
  width: 10px; height: 10px;
  border: 1.5px solid var(--border-2);
  border-top-color: var(--sw);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* ══════════════════════════════════════════════════════════════
   RIGHT PANEL TABS (Intelligence / Analysis)
   ══════════════════════════════════════════════════════════════ */

.news-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
}

.news-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--duration) var(--ease-out),
              border-color var(--duration) var(--ease-out),
              background var(--duration) var(--ease-out);
  white-space: nowrap;
}

.news-tab:hover {
  color: var(--text-1);
  background: var(--border-0);
}

.news-tab.active {
  color: var(--text-0);
  background: var(--bg-3);
  border-color: var(--border-1);
}

.analysis-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--sw);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 8px;
  letter-spacing: 0;
}

/* ══════════════════════════════════════════════════════════════
   ANALYSIS FEED (skill artifacts panel)
   ══════════════════════════════════════════════════════════════ */

.analysis-feed {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
  min-height: 0;
}

.analysis-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 11.5px;
  text-align: center;
  padding: 32px 16px;
}

.analysis-placeholder .news-placeholder-icon {
  opacity: 0.4;
}

/* ── Skill artifact card ─────────────────────────────────────── */

.skill-card {
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color var(--duration) var(--ease-out);
  opacity: 0;
  transform: translateX(12px);
  flex-shrink: 0;
}
.skill-card.is-visible {
  animation: card-in 0.3s var(--ease-out) both;
}

.skill-card:hover {
  border-color: var(--border-2);
}

.skill-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border-0);
  background: rgba(0,0,0,0.08);
  cursor: pointer;
  user-select: none;
}

.skill-card-icon {
  font-size: 15px;
  line-height: 1;
}

.skill-card-title {
  flex: 1;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-0);
  letter-spacing: 0.01em;
}

.skill-card-time {
  font-size: 10px;
  color: var(--text-3);
  font-family: var(--font-mono);
}

/* Chevron for expand/collapse */
.skill-card-chevron {
  width: 12px;
  height: 12px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.15s;
}
.skill-card.is-expanded .skill-card-chevron {
  transform: rotate(90deg);
  color: var(--sw-pale);
}
.skill-card-header:hover .skill-card-chevron {
  color: var(--text-1);
}

/* 10.7: Ask → button on skill card header */
.skill-ask-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.skill-card-header:hover .skill-ask-btn {
  opacity: 1;
}
.skill-ask-btn:hover {
  color: var(--sw-light);
  border-color: var(--sw-light);
}

.skill-card-summary {
  display: none;
  padding: 8px 14px;
  font-size: 11.5px;
  color: var(--text-1);
  line-height: 1.55;
  border-bottom: 1px solid var(--border-0);
}
.skill-card.is-expanded .skill-card-summary {
  display: block;
}

/* Collapsed by default — body hidden until expanded */
.skill-card-body {
  display: none;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}
.skill-card.is-expanded .skill-card-body {
  display: block;
}

/* Skill table */
.skill-table {
  width: 100%;
  min-width: 360px;
  border-collapse: collapse;
  font-size: 11.5px;
}

.skill-table th {
  background: var(--sw);
  color: #fff;
  padding: 7px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.skill-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-0);
  color: var(--text-1);
  vertical-align: top;
  line-height: 1.5;
}

.skill-table-link {
  color: var(--sw-pale);
  text-decoration: none;
  font-weight: 600;
}

.skill-table-link:hover {
  color: var(--text-0);
  text-decoration: underline;
}

.skill-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.skill-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.04);
}

.skill-table th.sort-asc::after,
.skill-table th.sort-desc::after {
  margin-left: 4px;
  font-size: 9px;
  opacity: 0.7;
}
.skill-table th.sort-asc::after  { content: '\25B2'; }
.skill-table th.sort-desc::after { content: '\25BC'; }

.skill-table tbody tr:last-child td {
  border-bottom: none;
}

/* Second table separator label */
.skill-table-sep {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 10px 14px 6px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* Skill chart */
.skill-chart-wrap {
  padding: 12px 14px 14px;
  position: relative;
}
.skill-chart-wrap:hover .chart-download-btn {
  opacity: 1;
}

.skill-chart {
  max-width: 100%;
}

/* ── Risk severity colors ─────────────────────────────────────── */

.severity-low {
  color: var(--green);
  font-weight: 600;
}

.severity-medium {
  color: #f5a623;
  font-weight: 600;
}

.severity-high {
  color: #e05c5c;
  font-weight: 600;
}

.severity-critical {
  color: #c0392b;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 9.5px;
  letter-spacing: 0.04em;
}

/* ── Output header doc list ──────────────────────────────────── */

.output-docs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.output-docs-label {
  width: 100%;
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 1px;
}

.output-doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-1);
  text-decoration: none;
}
a.output-doc-chip--link,
button.output-doc-chip--link {
  color: var(--sw-pale);
  border-color: var(--sw-line);
  background: var(--sw-glow);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  font-size: 11px;
}
a.output-doc-chip--link:hover,
button.output-doc-chip--link:hover {
  background: var(--sw-dim);
  border-color: var(--sw);
  text-decoration: none;
}

.output-doc-size {
  color: var(--text-3);
  font-size: 10px;
}

/* ══════════════════════════════════════════════════════════════
   RESEARCH CARDS (Research tab — replaces news cards)
   ══════════════════════════════════════════════════════════════ */

.research-card {
  border: 1px solid var(--border-1);
  background: var(--bg-3);
  border-radius: 6px;
  margin-bottom: 6px;
  opacity: 0;
  transform: translateX(12px);
  overflow: hidden;
}
.research-card.is-visible {
  animation: card-in 0.3s var(--ease-out) both;
}

.research-card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px 6px;
  cursor: pointer;
  user-select: none;
}

.research-card-icon {
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}

.research-card-label {
  flex: 1;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-0);
}

.research-card-time {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
}

.research-params {
  padding: 0 10px 6px;
  font-size: 11px;
  font-style: italic;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.research-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 7px;
  border-top: 1px solid var(--border-0);
  background: rgba(0,0,0,0.15);
  font-size: 10.5px;
}

.research-result--pending {
  color: var(--text-3);
}

.research-result--done {
  color: var(--text-2);
}

.research-result-text {
  font-family: var(--font-mono);
  font-size: 10px;
}

.research-check {
  color: var(--green);
  font-size: 11px;
  flex-shrink: 0;
}

.research-spinner {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--border-2);
  border-top-color: var(--sw-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

.research-url-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
  margin-top: 2px;
}

.research-url-chip {
  font-family: var(--font-mono);
  font-size: 9px;
  background: var(--sw-glow);
  border: 1px solid var(--sw-line);
  color: var(--sw-pale);
  padding: 2px 6px;
  border-radius: 3px;
  text-decoration: none;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  transition: background var(--duration), color var(--duration);
}

.research-url-chip:hover {
  background: var(--sw-dim);
  color: #fff;
}

/* Research card chevron + expandable detail */
.research-card-chevron {
  width: 12px;
  height: 12px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.15s;
}
.research-card.is-expanded .research-card-chevron {
  transform: rotate(90deg);
  color: var(--sw-pale);
}
.research-card-header:hover .research-card-chevron {
  color: var(--text-1);
}

.research-detail {
  display: none;
  border-top: 1px solid var(--border-1);
  background: rgba(0,0,0,0.18);
  padding: 10px 10px 10px;
}
.research-card.is-expanded .research-detail {
  display: block;
}

/* ── Panel Directory (available tools/skills listing) ──────────── */
.panel-directory-wrap {
  flex-shrink: 0;
  height: var(--panel-dir-h);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}
.panel-directory {
  padding: 12px 14px 16px;
}
.panel-directory-header {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.panel-directory-count {
  font-weight: 400;
  color: var(--text-4);
}
.panel-directory-search-wrap {
  margin-bottom: 7px;
}
.panel-directory-search {
  width: 100%;
  height: 28px;
  padding: 0 9px;
  color: var(--text-1);
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border-1);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 11px;
  outline: none;
}
.panel-directory-search:focus {
  border-color: var(--sw-line);
  box-shadow: 0 0 0 2px rgba(1,107,171,0.16);
}
.panel-directory-help {
  margin-bottom: 10px;
  color: var(--text-4);
  font-family: var(--font-body);
  font-size: 10px;
  line-height: 1.35;
}
.panel-directory-section + .panel-directory-section {
  margin-top: 11px;
}
.panel-directory-section-title {
  margin-bottom: 6px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel-directory-empty {
  padding: 10px 9px;
  color: var(--text-4);
  background: rgba(255,255,255,0.026);
  border: 1px dashed var(--border-1);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 11px;
  line-height: 1.4;
}
.panel-directory-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.dir-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  background: var(--bg-3);
  border: 1px solid var(--border-0);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
  appearance: none;
  text-align: left;
}
.dir-item:hover {
  border-color: var(--border-2);
  background: var(--bg-4);
  color: var(--text-1);
}
.dir-item:focus-visible {
  outline: 1px solid var(--sw-line);
  outline-offset: 2px;
}
.dir-item.forced {
  border-color: var(--accent);
  background: rgba(1,107,171,0.15);
  color: var(--text-0);
  box-shadow: 0 0 0 1px var(--accent);
}
.dir-item.forced::before {
  content: '\2713';
  font-size: 8px;
  margin-right: 2px;
  color: var(--accent);
}
.dir-item-icon {
  font-size: 11px;
  line-height: 1;
}
.dir-item-label {
  line-height: 1;
}

/* Hidden tooltip text (read by JS) */
.dir-item .dir-tooltip { display: none; }
/* Floating tooltip (appended to body, escapes overflow containers) */
.dir-floating-tooltip {
  position: fixed;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-1);
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 9999;
  white-space: normal;
  pointer-events: none;
}
.dir-floating-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
}
.dir-floating-tooltip.arrow-down::after {
  top: 100%;
  border-top-color: var(--border-2);
}
.dir-floating-tooltip.arrow-up::after {
  bottom: 100%;
  border-bottom-color: var(--border-2);
}

.rd-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rd-section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin-bottom: 5px;
}

.rd-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rd-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.rd-key {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--sw-pale);
  flex-shrink: 0;
  min-width: 70px;
}

.rd-val {
  font-size: 10.5px;
  color: var(--text-1);
  word-break: break-word;
  line-height: 1.4;
}

.rd-preview {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-2);
  background: var(--bg-2);
  border: 1px solid var(--border-0);
  border-radius: 4px;
  padding: 7px 9px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: 360px;
  line-height: 1.45;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}

.rd-urls {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rd-url-link {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-decoration: none;
  padding: 4px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-0);
  background: var(--bg-2);
  transition: background var(--duration), border-color var(--duration);
  overflow: hidden;
}
.rd-url-link:hover {
  background: var(--sw-glow);
  border-color: var(--sw-line);
}

.rd-url-domain {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--sw-pale);
}

.rd-url-full {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Research badge (on Research tab when Skills tab is active) */
.research-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--sw);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 8px;
  letter-spacing: 0;
}

/* ══════════════════════════════════════════════════════════════
   SKILL CARD INPUTS (input summary line above skill output)
   ══════════════════════════════════════════════════════════════ */

.skill-card-inputs {
  display: none;
  padding: 5px 14px 6px;
  font-size: 10.5px;
  font-style: italic;
  color: var(--text-2);
  border-bottom: 1px solid var(--border-0);
  background: rgba(0,0,0,0.10);
}
.skill-card.is-expanded .skill-card-inputs {
  display: block;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ══════════════════════════════════════════════════════════════ */

/* Tablet — collapse news panel */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: var(--sidebar-w) var(--handle-w) 1fr 0px 0px;
  }
  .news-panel,
  .news-panel + .resize-handle {
    display: none;
  }
}

/* Narrow laptop — shrink sidebar for more main panel space */
@media (max-width: 900px) and (min-width: 641px) {
  :root { --sidebar-w: 200px; }
}
@media (max-width: 768px) and (min-width: 641px) {
  :root { --sidebar-w: 180px; }
  .sidebar-brand { padding: 12px 10px; }
  .sidebar-brand-name { font-size: 14px; }
}

/* Mobile — single column, hide sidebar */
@media (max-width: 640px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .sidebar,
  .sidebar + .resize-handle,
  .news-panel,
  .news-panel + .resize-handle,
  .resize-handle {
    display: none;
  }
  .main-panel {
    min-width: 0;
  }
  .main-topbar {
    padding: 0 12px;
  }
  .output-header {
    flex-wrap: wrap;
    gap: 6px;
  }
  .chat-input-bar {
    padding: 8px;
  }
}

/* ══════════════════════════════════════════════════════════════
   Auth Overlay
   ══════════════════════════════════════════════════════════════ */

/* ── Page Loader ─────────────────────────────────────────────── */
#pageLoader {
  position: fixed;
  inset: 0;
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary, #0f0f0f);
  pointer-events: all;
}
.page-loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-2, #aaa);
}
.page-loader-ring {
  color: #016bab;
  animation: loaderSpin 0.9s linear infinite;
}
@keyframes loaderSpin {
  to { transform: rotate(360deg); }
}
.page-loader-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-3, #888);
}

/* History item loading pulse */
.history-item.is-loading {
  opacity: 0.55;
  pointer-events: none;
  position: relative;
}
.history-item.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.04) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: historyShimmer 1.2s ease-in-out infinite;
}
@keyframes historyShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 12, 24, 0.96);
  backdrop-filter: blur(8px);
}

.auth-card {
  width: 380px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  padding: 32px 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.auth-logo-img {
  height: 32px;
  width: auto;
}

.auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-1);
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 0 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.auth-tab:hover { color: var(--text-1); }
.auth-tab.active { color: var(--sw-light); border-bottom-color: var(--sw-light); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.auth-input {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  color: var(--text-0);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.auth-input:focus {
  border-color: var(--sw);
  box-shadow: 0 0 0 2px var(--sw-dim);
}

.auth-input::placeholder { color: var(--text-3); }

.auth-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 6px;
  color: var(--red);
  font-size: 12px;
  padding: 8px 12px;
}

.auth-submit {
  background: var(--sw);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s;
  margin-top: 4px;
}

.auth-submit:hover { background: var(--sw-light); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

.auth-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}

/* ══════════════════════════════════════════════════════════════
   User Footer
   ══════════════════════════════════════════════════════════════ */

.user-footer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  position: relative;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sw);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.user-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.user-menu-btn:hover { color: var(--text-1); background: var(--bg-4); }

.user-menu-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  right: 0;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 7px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
}

.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 14px;
  font-size: 12px;
  color: var(--text-1);
  cursor: pointer;
  transition: background 0.12s;
}

.user-menu-item:hover { background: var(--bg-4); }
.user-menu-item--danger { color: var(--red); }
.user-menu-item--danger:hover { background: rgba(248,113,113,0.08); }

/* ══════════════════════════════════════════════════════════════
   Admin Panel
   ══════════════════════════════════════════════════════════════ */

.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 12, 24, 0.9);
  backdrop-filter: blur(6px);
}

.admin-panel {
  width: min(620px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.admin-panel > .admin-panel-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
  flex-shrink: 0;
}

.admin-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
  letter-spacing: 0.02em;
}

.admin-close-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.admin-close-btn:hover { color: var(--text-1); }

.admin-tabs {
  display: flex;
  gap: 0;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border-1);
  flex-shrink: 0;
}

.admin-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 14px 10px;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.admin-tab:hover { color: var(--text-1); }
.admin-tab.active { color: var(--sw-light); border-bottom-color: var(--sw-light); }

.admin-tab-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.admin-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-1);
}

.admin-table td {
  padding: 8px 10px;
  color: var(--text-1);
  border-bottom: 1px solid var(--border-0);
  vertical-align: middle;
}

.admin-table tr:hover td { background: var(--bg-3); }

.admin-table-loading {
  text-align: center;
  color: var(--text-3);
  padding: 20px !important;
  font-size: 12px;
}

.admin-role-badge, .admin-status-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-role-badge--admin { background: rgba(1,107,171,0.2); color: var(--sw-pale); }
.admin-role-badge--user  { background: var(--bg-4); color: var(--text-3); }
.admin-status-badge--active { background: rgba(74,222,128,0.1); color: var(--green); }
.admin-status-badge--inactive { background: rgba(248,113,113,0.1); color: var(--red); }

.admin-btn-sm {
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s;
  margin-right: 4px;
}

.admin-btn-sm:hover { background: var(--bg-5); color: var(--text-0); }
.admin-btn-sm--danger { border-color: rgba(248,113,113,0.3); color: var(--red); }
.admin-btn-sm--danger:hover { background: rgba(248,113,113,0.08); }

.admin-whitelist-add {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}

.admin-wl-email { flex: 2; }
.admin-wl-hint  { flex: 1.2; }

.admin-btn-add {
  background: var(--sw);
  border: none;
  color: #fff;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.admin-btn-add:hover { background: var(--sw-light); }

.admin-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 6px;
  color: var(--red);
  font-size: 12px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

/* ══════════════════════════════════════════════════════════════
   Admin History Folders
   ══════════════════════════════════════════════════════════════ */

.admin-history-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.admin-hist-btn {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text-3);
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.12s;
}

.admin-hist-btn:hover { color: var(--text-1); background: var(--bg-4); }
.admin-hist-btn.active { background: var(--sw-dim); color: var(--sw-pale); border-color: var(--sw-line); }

.admin-hist-content { /* scrolls within the panel */ }

.admin-user-folder {
  border: 1px solid var(--border-1);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.admin-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--bg-3);
  transition: background 0.12s;
  user-select: none;
}

.admin-folder-header:hover { background: var(--bg-4); }

.admin-folder-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sw-dim);
  color: var(--sw-pale);
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.admin-folder-name {
  font-size: 12px;
  color: var(--text-1);
  flex: 1;
}

.admin-folder-email {
  font-size: 10px;
  color: var(--text-3);
}

.admin-folder-count {
  background: var(--sw-dim);
  color: var(--sw-pale);
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 3px;
}

.admin-folder-chevron {
  color: var(--text-3);
  transition: transform 0.2s;
}

.admin-user-folder.is-open .admin-folder-chevron {
  transform: rotate(180deg);
}

.admin-folder-items {
  display: none;
  background: var(--bg-2);
  border-top: 1px solid var(--border-1);
}

.admin-user-folder.is-open .admin-folder-items { display: block; }

.admin-folder-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 14px 8px 22px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border-0);
}

.admin-folder-item:last-child { border-bottom: none; }
.admin-folder-item:hover { background: var(--bg-3); }

.admin-folder-item-query {
  font-size: 12px;
  color: var(--text-1);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-folder-item-date {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Account settings ───────────────────────────────────────── */
.acct-panel {
  max-width: 620px;
}
.acct-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sw-pale);
  margin-bottom: 12px;
}
.acct-field { margin-bottom: 12px; }
.acct-label {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.acct-value {
  font-size: 13px;
  color: var(--text-1);
  padding: 6px 0;
}
.acct-input {
  width: 100%;
  font-size: 13px;
}
.acct-field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.acct-field-row .acct-input { flex: 1; }
.acct-toggle-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--text-1);
  font-size: 13px;
  line-height: 1.45;
}
.acct-toggle-row input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--sw);
}
.acct-toggle-row strong {
  display: block;
  font-size: 13px;
}
.acct-toggle-row em {
  display: block;
  margin-top: 2px;
  color: var(--text-3);
  font-size: 11px;
  font-style: normal;
}
.admin-btn-secondary {
  background: transparent;
  color: var(--text-1);
  border: 1px solid var(--border-1);
}
.admin-btn-secondary:hover {
  background: var(--bg-4);
  border-color: var(--sw-line);
}
.acct-success {
  font-size: 12px;
  color: var(--green, #22c55e);
  padding: 6px 0;
}
.acct-custom-panel {
  margin: 14px 0 16px;
  padding: 14px 14px 12px;
  border: 1px solid var(--border-0);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
}
.acct-custom-header {
  margin-bottom: 10px;
}
.acct-custom-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.acct-custom-subtitle {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
  line-height: 1.45;
}
.acct-textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.5;
}
.acct-custom-actions {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.acct-inline-note {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.45;
}
.philosophy-read-modal {
  max-width: 900px;
}
.philosophy-read-body {
  max-height: calc(86vh - 148px);
}
.philosophy-read-loading {
  font-size: 13px;
  color: var(--text-2);
}
.philosophy-read-content {
  color: var(--text-1);
  line-height: 1.7;
  font-size: 14px;
}
.philosophy-read-content h1,
.philosophy-read-content h2,
.philosophy-read-content h3 {
  color: var(--text-0);
  line-height: 1.3;
}
.philosophy-read-content h1 {
  font-size: 24px;
  margin: 0 0 14px;
}
.philosophy-read-content h2 {
  font-size: 18px;
  margin: 22px 0 10px;
}
.philosophy-read-content h3 {
  font-size: 15px;
  margin: 18px 0 8px;
}
.philosophy-read-content p,
.philosophy-read-content li,
.philosophy-read-content blockquote {
  color: var(--text-1);
}
.philosophy-read-content blockquote {
  border-left: 3px solid var(--sw-accent, #016bab);
  margin: 14px 0;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
}
.philosophy-read-content pre,
.philosophy-read-content code {
  white-space: pre-wrap;
  word-break: break-word;
}
.philosophy-read-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.acct-spend-row, .acct-spending .acct-spend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-0);
  color: var(--text-2);
}
.acct-spend-row:last-child { border-bottom: none; }
.acct-spend-row strong { color: var(--text-1); }
.acct-spending, .acct-usage-content {
  border: 1px solid var(--border-0);
  border-radius: 6px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.15);
  font-size: 12px;
  color: var(--text-3);
}

@media (max-width: 720px) {
  .acct-panel {
    max-width: min(94vw, 620px);
  }
  .acct-custom-actions {
    align-items: stretch;
  }
  .acct-custom-actions .admin-btn-add {
    width: 100%;
  }
}

/* ── Email verification sent state ─────────────────────────── */
.auth-email-sent {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 8px 4px;
  gap: 10px;
}

.auth-sent-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 2px;
}

.auth-sent-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #f0f0f0);
}

.auth-sent-body {
  font-size: 13px;
  color: var(--text-muted, #888);
  line-height: 1.55;
  max-width: 300px;
}

.auth-sent-body strong {
  color: var(--text-primary, #f0f0f0);
}

.auth-sent-resend {
  background: transparent;
  border: 1px solid var(--border, #333);
  color: var(--text-muted, #888);
  padding: 7px 18px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  margin-top: 4px;
  font-family: inherit;
}

.auth-sent-resend:hover:not(:disabled) {
  border-color: var(--accent, #016bab);
  color: var(--accent, #016bab);
}

.auth-sent-resend:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-sent-error {
  margin-top: 4px;
  font-size: 12px;
}

/* Dev-mode direct link box */
.auth-dev-link-box {
  width: 100%;
  background: rgba(1, 107, 171, 0.1);
  border: 1px solid rgba(1, 107, 171, 0.35);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 12px 0;
  text-align: left;
}

.auth-dev-link-label {
  font-size: 11px;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.auth-dev-link {
  font-size: 13px;
  color: var(--accent, #016bab);
  word-break: break-all;
  text-decoration: underline;
  cursor: pointer;
}

.auth-dev-link:hover { opacity: 0.8; }

/* Back link inside "sent" state panels */
.auth-sent-back {
  margin-top: 14px;
  font-size: 12px;
  padding: 0;
  cursor: pointer;
}

/* Inline resend button inside login error */
.auth-resend-inline {
  background: transparent;
  border: none;
  color: var(--accent, #016bab);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
  margin-left: 4px;
}

.auth-resend-inline:hover { opacity: 0.8; }
.auth-resend-inline:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forgot / Reset password UI ────────────────────────────── */
.auth-forgot-row {
  text-align: center;
  margin-top: 10px;
}

.auth-forgot-link {
  background: transparent;
  border: none;
  color: var(--text-muted, #888);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
  padding: 0;
  transition: color 0.15s;
}

.auth-forgot-link:hover { color: var(--accent, #016bab); }

.auth-back-row {
  margin-bottom: 12px;
}

.auth-back-link {
  background: transparent;
  border: none;
  color: var(--text-muted, #888);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: color 0.15s;
}

.auth-back-link:hover { color: var(--text-primary, #f0f0f0); }

.auth-form-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #f0f0f0);
  margin-bottom: 4px;
}

.auth-form-subtitle {
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-bottom: 16px;
  line-height: 1.4;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — iPad & iPhone (Touch Devices)
   All styles scoped to html.is-touch / .is-ipad / .is-iphone
   so desktop browsers are NEVER affected.
   ══════════════════════════════════════════════════════════════ */

/* ── Mobile toggle buttons — hidden on desktop ─────────────── */
.mobile-nav-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-btn:active {
  color: var(--text-0);
  background: var(--bg-4);
  border-color: var(--sw-line);
}

/* Activity dot on panel toggle button */
.mobile-panel-dot {
  display: none;
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sw-light);
  box-shadow: 0 0 5px rgba(1,107,171,0.5);
}

/* ── Backdrop overlay ──────────────────────────────────────── */
.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  -webkit-tap-highlight-color: transparent;
}

/* ══════════════════════════════════════════════════════════════
   Touch device core overrides
   ══════════════════════════════════════════════════════════════ */

html.is-touch .mobile-nav-btn {
  display: flex;
}

html.is-touch .mobile-backdrop {
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

html.is-touch .mobile-backdrop.is-visible {
  pointer-events: auto;
  opacity: 1;
}

html.is-touch .mobile-panel-dot.has-results {
  display: block;
}

/* Core grid → single-column (main panel fills viewport) */
html.is-touch .app-shell {
  grid-template-columns: 1fr !important;
  grid-template-rows: 100vh;
  /* Reset stacking context so fixed-position drawer panels and backdrop
     share the root stacking context — prevents z-index isolation that
     traps panels below the backdrop on iOS. */
  z-index: auto;
}

/* Hide vertical resize handles (not usable with touch) */
html.is-touch .resize-handle {
  display: none !important;
}

/* Prevent body scroll when a drawer is open */
html.is-touch body.drawer-open {
  overflow: hidden;
}

/* Override collapse state for drawers (don't let JS collapse hide them) */
html.is-touch .sidebar,
html.is-touch .news-panel {
  pointer-events: auto !important;
  opacity: 1 !important;
}

/* ── Sidebar → left drawer ─────────────────────────────────── */
html.is-touch .sidebar {
  position: fixed !important;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 85vw) !important;
  z-index: 1001;
  transform: translateX(-100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: none;
  display: flex !important;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

html.is-touch .sidebar::after {
  display: none;
}

html.is-touch .sidebar.is-drawer-open {
  transform: translateX(0);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
}

/* ── News panel → right drawer ─────────────────────────────── */
html.is-touch .news-panel {
  position: fixed !important;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 90vw) !important;
  z-index: 1001;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: none;
  display: flex !important;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

html.is-touch .news-panel::before {
  display: none;
}

html.is-touch .news-panel.is-drawer-open {
  transform: translateX(0);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
}


/* ── Topbar adjustments ────────────────────────────────────── */
html.is-touch .main-topbar {
  padding: 0 12px;
  gap: 8px;
}

/* ── Touch-friendly sizing (iOS HIG: 44px minimum targets) ── */

/* Chips */
html.is-touch .chip {
  padding: 8px 16px;
  font-size: 12.5px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

/* Buttons */
html.is-touch .btn-run {
  padding: 11px 22px;
  font-size: 13px;
  min-height: 42px;
}

html.is-touch .btn-action {
  padding: 10px 18px;
  font-size: 13px;
  min-height: 42px;
}

html.is-touch .example-btn {
  padding: 8px 14px;
  font-size: 12px;
  min-height: 36px;
}

html.is-touch .btn-new {
  padding: 12px 16px;
  font-size: 13px;
}

/* Chat */
html.is-touch .chat-hint-btn {
  padding: 8px 16px;
  font-size: 12px;
  min-height: 36px;
}

html.is-touch .chat-textarea {
  font-size: 16px; /* prevents iOS auto-zoom on focus */
  min-height: 44px;
}

html.is-touch .chat-send-btn {
  width: 44px;
  height: 44px;
}

html.is-touch .followup-jump-btn {
  right: 14px;
  bottom: 14px;
  padding: 9px 11px 9px 9px;
}

/* Query textarea: prevent iOS zoom */
html.is-touch .query-textarea {
  font-size: 16px;
}

/* Auth inputs: prevent iOS zoom */
html.is-touch .auth-input {
  font-size: 16px;
  padding: 12px 14px;
}

/* Table horizontal scroll on touch (chat tables handled in main section) */
html.is-touch .chat-ai-body table {
  -webkit-overflow-scrolling: touch;
}

html.is-touch .analysis-body pre {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

html.is-touch .chat-ai-body table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Skill card tables */
html.is-touch .skill-table-wrap,
html.is-touch .news-card {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Scrollable panel containers on touch ─────────────────── */
html.is-touch .tab-panel,
html.is-touch .news-feed,
html.is-touch .sidebar-section {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

/* ── Padding adjustments for touch ─────────────────────────── */
html.is-touch .query-section {
  padding: 24px 20px 20px;
}

html.is-touch .query-headline {
  font-size: 26px;
}

html.is-touch .pipeline-header {
  padding: 10px 16px;
}

html.is-touch .pipeline-steps {
  padding: 0 16px 10px;
  max-height: 35vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html.is-touch .output-header {
  padding: 14px 16px 10px;
}

html.is-touch .analysis-card {
  padding: 20px 16px;
}

html.is-touch .output-actions {
  padding: 12px 16px;
  flex-wrap: wrap;
}

html.is-touch .chat-panel {
  margin: 16px 16px 20px;
}

html.is-touch .reasoning-summary {
  padding: 9px 16px;
}

html.is-touch .reasoning-body {
  padding: 0 16px 12px;
  max-height: 30vh;
  -webkit-overflow-scrolling: touch;
}

html.is-touch .error-banner {
  margin: 16px 16px 0;
}

/* ── Auth / Admin responsive ───────────────────────────────── */
html.is-touch .auth-card {
  width: min(380px, calc(100vw - 32px));
}

html.is-touch .admin-panel {
  width: min(620px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
}

html.is-touch .admin-table {
  display: block;
  overflow-x: auto;
}

/* ══════════════════════════════════════════════════════════════
   iPad-specific
   ══════════════════════════════════════════════════════════════ */

html.is-ipad .sidebar {
  width: 300px !important;
}

html.is-ipad .news-panel {
  width: 340px !important;
}

/* iPad landscape: more generous spacing */
@media (orientation: landscape) and (min-width: 1024px) {
  html.is-ipad .query-section {
    padding: 28px 32px 24px;
  }
  html.is-ipad .query-headline {
    font-size: 30px;
  }
  html.is-ipad .analysis-card {
    padding: 24px 28px;
  }
  html.is-ipad .pipeline-header {
    padding: 10px 24px;
  }
  html.is-ipad .pipeline-steps {
    padding: 0 24px 10px;
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  html.is-ipad .output-header {
    padding: 16px 24px 12px;
  }
  html.is-ipad .output-actions {
    padding: 12px 24px;
  }
  html.is-ipad .reasoning-summary {
    padding: 9px 24px;
  }
  html.is-ipad .reasoning-body {
    padding: 0 24px 12px;
    max-height: 35vh;
    -webkit-overflow-scrolling: touch;
  }
  html.is-ipad .chat-panel {
    margin: 20px 24px 24px;
  }
}

/* ══════════════════════════════════════════════════════════════
   iPhone-specific
   ══════════════════════════════════════════════════════════════ */

html.is-iphone .sidebar {
  width: 85vw !important;
  max-width: 320px;
}

html.is-iphone .news-panel {
  width: 92vw !important;
  max-width: 380px;
}

/* Compact query hero */
html.is-iphone .query-headline {
  font-size: 22px;
}

html.is-iphone .query-subline {
  font-size: 12px;
}

html.is-iphone .query-section {
  padding: 16px 14px 16px;
}

/* Stack asset bar vertically */
html.is-iphone .asset-bar {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

/* Compact input footer */
html.is-iphone .input-footer {
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px 10px;
}

html.is-iphone .report-mode-seg {
  order: -1;
}

/* Analysis */
html.is-iphone .analysis-card {
  padding: 16px 12px;
}

html.is-iphone .analysis-body h1 {
  font-size: 20px;
}

html.is-iphone .analysis-body h2 {
  font-size: 16px;
}

html.is-iphone .analysis-body {
  font-size: 13px;
}

html.is-iphone .chat-panel {
  margin: 12px 10px 16px;
}

html.is-iphone .followup-jump-btn {
  left: 12px;
  right: 12px;
  bottom: 12px;
  max-width: none;
  justify-content: center;
}

/* Example prompts: stack vertically on small screens */
html.is-iphone .example-prompts {
  flex-direction: column;
  align-items: stretch;
}

html.is-iphone .example-label {
  display: none;
}

html.is-iphone .example-btn {
  text-align: left;
}

/* ── Safe area insets (iPhone notch / home indicator) ──────── */
@supports (padding-top: env(safe-area-inset-top)) {
  html.is-iphone .main-topbar {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }

  html.is-iphone .sidebar {
    padding-top: env(safe-area-inset-top);
  }

  html.is-iphone .news-panel {
    padding-top: env(safe-area-inset-top);
  }

  html.is-iphone .chat-compose {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  html.is-iphone .query-section {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  html.is-iphone .input-footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

/* ══════════════════════════════════════════════════════════════
   Override existing media queries for touch devices
   (Ensure drawer panels remain flex, not display:none)
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  html.is-touch .news-panel {
    display: flex !important;
  }
}

@media (max-width: 640px) {
  html.is-touch .sidebar {
    display: flex !important;
  }
  html.is-touch .news-panel {
    display: flex !important;
  }
  html.is-touch .main-panel {
    min-width: 0;
  }
}

html.is-touch body.simple-mode .news-panel,
html.is-touch body.simple-mode #resizeRight,
html.is-touch body.expert-mode.right-panel-empty .news-panel,
html.is-touch body.expert-mode.right-panel-empty #resizeRight {
  display: none !important;
}

/* ══════════════════════════════════════════════════════════════
   New UI feature styles (6.x, 10.x improvements)
   ══════════════════════════════════════════════════════════════ */

/* ── 10.7: Ask Claude button ────────────────────────────────── */
.ask-claude-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 9px;
  line-height: 1;
  margin-left: 6px;
  padding: 2px 5px;
  opacity: .5;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s, background 0.15s;
  vertical-align: middle;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: none;
}
.analysis-body h2:hover .ask-claude-btn,
.analysis-body h3:hover .ask-claude-btn {
  opacity: 1;
}
.ask-claude-btn:hover {
  color: var(--sw-light);
  background: rgba(1, 107, 171, 0.08);
  border-color: rgba(1, 107, 171, 0.22);
  opacity: 1;
}

/* ── 10.2: Chart download button ────────────────────────────── */
.chart-download-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(9, 30, 52, 0.8);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 3px 6px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  z-index: 2;
  white-space: nowrap;
}
.sw-chart-wrap:hover .chart-download-btn {
  opacity: 1;
}
.chart-download-btn:hover {
  color: var(--sw-light);
  border-color: var(--sw-light);
}

/* ── 10.3: Keyboard shortcuts modal ─────────────────────────── */
.kbd-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 12, 24, 0.75);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.kbd-modal {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 24px 28px;
  min-width: 320px;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.kbd-modal-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--text-0);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-1);
}
.kbd-modal table {
  width: 100%;
  border-collapse: collapse;
}
.kbd-modal td {
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-1);
  vertical-align: middle;
}
.kbd-modal td:first-child {
  font-family: var(--font-mono);
  font-size: 11px;
  padding-right: 16px;
  white-space: nowrap;
}
.kbd-key {
  display: inline-block;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-1);
}
.kbd-modal-close {
  margin-top: 16px;
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 12px;
  padding: 8px;
  transition: background 0.15s;
}
.kbd-modal-close:hover { background: var(--bg-4); color: var(--text-0); }
.kbd-help-btn {
  background: none;
  border: 1px solid var(--border-1);
  border-radius: 50%;
  color: var(--text-3);
  cursor: pointer;
  font-size: 10.5px;
  font-family: var(--font-mono);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.kbd-help-btn:hover { color: var(--text-1); border-color: var(--border-2); }

/* Product walkthrough */
.tour-help-btn {
  background: none;
  border: 1px solid var(--border-1);
  border-radius: 50%;
  color: var(--text-3);
  cursor: pointer;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.tour-help-btn:hover {
  color: var(--text-1);
  border-color: var(--border-2);
  background: var(--bg-3);
}
.product-tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 9200;
  pointer-events: none;
}
.product-tour-scrim {
  position: absolute;
  inset: 0;
  background: rgba(3, 12, 24, 0.58);
  backdrop-filter: blur(2px);
  pointer-events: auto;
}
.product-tour-highlight {
  position: absolute;
  border: 1px solid var(--sw-pale);
  border-radius: 8px;
  box-shadow:
    0 0 0 9999px rgba(3, 12, 24, 0.28),
    0 0 0 4px rgba(1, 107, 171, 0.16),
    0 12px 34px rgba(1, 107, 171, 0.2);
  transition: left 0.18s var(--ease-out), top 0.18s var(--ease-out), width 0.18s var(--ease-out), height 0.18s var(--ease-out);
  pointer-events: none;
}
.product-tour-card {
  position: absolute;
  width: min(360px, calc(100vw - 32px));
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.48);
  padding: 18px;
  pointer-events: auto;
  animation: productTourIn 0.18s var(--ease-out);
}
.product-tour-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0;
  color: var(--sw-pale);
  margin-bottom: 8px;
}
.product-tour-title {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 500;
  color: var(--text-0);
  margin-bottom: 8px;
}
.product-tour-body {
  color: var(--text-1);
  font-size: 12.5px;
  line-height: 1.55;
  margin-bottom: 16px;
}
.product-tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.product-tour-step-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.product-tour-btn {
  border: 1px solid var(--border-2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-body);
  line-height: 1;
  min-height: 32px;
  padding: 0 12px;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.product-tour-btn--ghost {
  background: var(--bg-3);
  color: var(--text-2);
}
.product-tour-btn--ghost:hover:not(:disabled) {
  background: var(--bg-4);
  color: var(--text-0);
}
.product-tour-btn--primary {
  background: var(--sw);
  border-color: var(--sw-light);
  color: white;
}
.product-tour-btn--primary:hover {
  background: var(--sw-light);
}
.product-tour-btn:disabled {
  opacity: 0.42;
  cursor: default;
}
@keyframes productTourIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 640px) {
  .product-tour-scrim {
    background: rgba(3, 12, 24, 0.66);
  }
  .product-tour-card {
    width: calc(100vw - 24px);
    padding: 16px;
  }
  .product-tour-actions {
    align-items: stretch;
  }
  .product-tour-step-actions {
    flex: 1;
    justify-content: flex-end;
  }
  .product-tour-btn {
    min-height: 36px;
  }
}

/* Theme toggle */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border-1);
  border-radius: 50%;
  color: var(--text-3);
  cursor: pointer;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.theme-toggle-btn:hover { color: var(--text-1); border-color: var(--border-2); }
/* Dark mode (default): show sun icon, hide moon */
.theme-icon-moon { display: none; }
.theme-icon-sun  { display: block; }
[data-theme="light"] .theme-icon-sun  { display: none; }
[data-theme="light"] .theme-icon-moon { display: block; }

.registry-link {
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: 5px;
  color: var(--text-2);
  cursor: pointer;
  height: 23px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.02em;
}
.registry-link:hover {
  color: var(--text-0);
  border-color: var(--sw-line);
  background: var(--bg-4);
  text-decoration: none;
}
.registry-link.is-active,
.registry-link[aria-current="page"] {
  color: var(--text-0);
  border-color: var(--sw-line);
  background: linear-gradient(180deg, rgba(1, 107, 171, 0.22) 0%, rgba(1, 107, 171, 0.12) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
.registry-link-label {
  white-space: nowrap;
}
@media (max-width: 900px) {
  .registry-link-label { display: none; }
  .main-topbar {
    gap: 6px;
    padding: 0 12px;
  }
  .topbar-primary-nav {
    gap: 4px;
  }
  .topbar-status {
    padding-inline: 7px;
  }
  .topbar-date-day {
    display: none;
  }
}

/* ── 10.4: Pipeline step expandable detail ──────────────────── */
.step-detail {
  background: var(--bg-1);
  border-top: 1px solid var(--border-1);
  border-radius: 0 0 4px 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  padding: 6px 10px;
  display: none;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-1) transparent;
}
.step.done { cursor: pointer; }
.step.done:hover .step-label { color: var(--text-0); }
.step.done .step-expand-hint {
  font-size: 9px; color: var(--text-4); margin-left: auto; padding-left: 6px;
  opacity: 0; transition: opacity 0.15s;
}
.step.done:hover .step-expand-hint { opacity: 1; }
.step.done.is-expanded .step-detail { display: block; }
.step.done.is-expanded .step-expand-hint::after { content: '▾'; }
.step.done:not(.is-expanded) .step-expand-hint::after { content: '▸'; }

/* ── 10.5: Annotation / Notes panel ────────────────────────── */
.annotation-panel {
  margin: 12px 0 0;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  overflow: hidden;
}
.annotation-panel-header {
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border-1);
  display: flex;
  align-items: center;
  gap: 6px;
}
.annotation-textarea {
  background: transparent;
  border: none;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.6;
  outline: none;
  padding: 10px 12px;
  resize: vertical;
  width: 100%;
  min-height: 72px;
  placeholder-color: var(--text-3);
}
.annotation-textarea::placeholder { color: var(--text-3); }

/* ── 10.8: Draft query restore banner ───────────────────────── */
.draft-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-3);
  border: 1px solid var(--sw-line);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-2);
}
.draft-banner-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draft-banner-restore {
  background: var(--sw-dim);
  border: 1px solid var(--sw-line);
  border-radius: 5px;
  color: var(--sw-pale);
  cursor: pointer;
  font-size: 11px;
  padding: 3px 9px;
  white-space: nowrap;
  transition: background 0.15s;
}
.draft-banner-restore:hover { background: var(--sw); color: #fff; }
.draft-banner-dismiss {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.draft-banner-dismiss:hover { color: var(--text-1); }

/* ── 10.9: Template buttons row ─────────────────────────────── */
.template-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.template-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  align-self: center;
  margin-right: 2px;
}
.template-btn {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 9px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.template-btn:hover {
  background: var(--sw-dim);
  border-color: var(--sw-line);
  color: var(--sw-pale);
}

.acct-overrides-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.acct-override-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border-1);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--bg-2);
}

.acct-override-main {
  min-width: 0;
}

.acct-override-vertical {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-1);
}

.acct-override-style {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-3);
}

.acct-override-remove {
  border: 0;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
}

.acct-override-remove:hover {
  color: var(--red);
}

/* ── 6.5: PDF generating overlay ────────────────────────────── */
.pdf-generating-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 12, 24, 0.7);
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.pdf-generating-box {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 24px 32px;
  text-align: center;
  font-size: 13px;
  color: var(--text-1);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.pdf-generating-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-2);
  border-top-color: var(--sw-light);
  border-radius: 50%;
  animation: pdf-spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes pdf-spin { to { transform: rotate(360deg); } }

/* ── Peer Review Modal ──────────────────────────────────────────── */
.review-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 12, 24, 0.82);
  z-index: 9100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.review-modal {
  background: var(--bg-2);
  border: 1px solid var(--sw-line);
  border-radius: 14px;
  width: 100%;
  max-width: 800px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: review-modal-in 0.22s ease;
}
@keyframes review-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.review-modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-2);
  background: var(--bg-3);
  flex-shrink: 0;
}
.review-modal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.review-modal-icon {
  font-size: 1.2rem;
  line-height: 1;
}
.review-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-0);
  flex: 1;
  letter-spacing: -.01em;
}
.review-grade-badge {
  font-size: 18px;
  font-weight: 800;
  padding: 3px 11px;
  border-radius: 7px;
  background: rgba(34,197,94,.15);
  color: #22c55e;
  border: 1px solid rgba(34,197,94,.3);
  letter-spacing: -.01em;
  line-height: 1.4;
}
.review-grade-badge.grade-a  { background: rgba(34,197,94,.15); color: #22c55e; border-color: rgba(34,197,94,.3); }
.review-grade-badge.grade-b  { background: rgba(251,191,36,.15); color: #f59e0b; border-color: rgba(251,191,36,.3); }
.review-grade-badge.grade-c  { background: rgba(249,115,22,.15); color: #f97316; border-color: rgba(249,115,22,.3); }
.review-grade-badge.grade-d  { background: rgba(239,68,68,.15); color: #ef4444; border-color: rgba(239,68,68,.3); }
.review-modal-close {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 5px;
  line-height: 1;
  transition: background .15s, color .15s;
  margin-left: 4px;
}
.review-modal-close:hover { background: var(--bg-4); color: var(--text-0); }
.review-verdict {
  font-size: 12.5px;
  color: var(--text-1);
  margin-top: 7px;
  font-style: italic;
  line-height: 1.5;
}
.review-modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(85vh - 120px);
  flex: 1;
}
/* Loading */
.review-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  gap: 14px;
  text-align: center;
}
.review-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-2);
  border-top-color: var(--sw-light);
  border-radius: 50%;
  animation: review-spin 0.9s linear infinite;
}
@keyframes review-spin { to { transform: rotate(360deg); } }
.review-loading-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
}
.review-loading-sub {
  font-size: 12px;
  color: var(--text-2);
}
/* Error */
.review-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--text-1);
  text-align: center;
}
.review-error-msg { font-size: 13px; color: #ef4444; }
/* Scorecard */
.review-scorecard {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 9px;
}
.review-scorecard-item {
  flex: 1;
  min-width: 100px;
  text-align: center;
}
.review-scorecard-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-0);
  line-height: 1.2;
}
.review-scorecard-value.strong { color: #22c55e; }
.review-scorecard-value.adequate { color: #f59e0b; }
.review-scorecard-value.weak { color: #ef4444; }
.review-scorecard-label {
  font-size: 10.5px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
}
/* Section label */
.review-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 18px 0 8px;
}
/* Critique text */
.review-critique-text {
  font-size: 13.5px;
  color: var(--text-1);
  line-height: 1.75;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 14px 16px;
}
.review-critique-text p { margin: 0 0 10px; }
.review-critique-text p:last-child { margin-bottom: 0; }
.review-critique-text strong { color: var(--text-0); }
/* Tables */
.review-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  margin-bottom: 2px;
}
.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.review-table th {
  background: var(--bg-3);
  color: var(--text-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
}
.review-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text-1);
  vertical-align: top;
  line-height: 1.5;
}
.review-table tbody tr:last-child td { border-bottom: none; }
.review-table tbody tr:hover td { background: var(--bg-3); }
/* Rating badges in tables */
.review-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.review-badge-strong    { background: rgba(34,197,94,.15);  color: #22c55e; border: 1px solid rgba(34,197,94,.25); }
.review-badge-adequate  { background: rgba(245,158,11,.15); color: #f59e0b; border: 1px solid rgba(245,158,11,.25); }
.review-badge-weak      { background: rgba(239,68,68,.15);  color: #ef4444; border: 1px solid rgba(239,68,68,.25); }
.review-badge-verified     { background: rgba(34,197,94,.15);  color: #22c55e; border: 1px solid rgba(34,197,94,.25); }
.review-badge-plausible    { background: rgba(99,179,237,.15); color: #63b3ed; border: 1px solid rgba(99,179,237,.25); }
.review-badge-questionable { background: rgba(245,158,11,.15); color: #f59e0b; border: 1px solid rgba(245,158,11,.25); }
.review-badge-unverified   { background: rgba(239,68,68,.15);  color: #ef4444; border: 1px solid rgba(239,68,68,.25); }
.review-badge-high   { background: rgba(239,68,68,.15);  color: #ef4444; border: 1px solid rgba(239,68,68,.25); }
.review-badge-medium { background: rgba(245,158,11,.15); color: #f59e0b; border: 1px solid rgba(245,158,11,.25); }
.review-badge-low    { background: rgba(34,197,94,.15);  color: #22c55e; border: 1px solid rgba(34,197,94,.25); }
/* Chart */
.review-chart-wrap {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 2px;
}
.review-chart-wrap canvas { max-height: 240px; }
/* Tools coverage */
.review-tools-coverage {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.review-tools-col {
  flex: 1;
  min-width: 180px;
}
.review-tools-col-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.review-tools-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.review-tools-tag {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  color: var(--text-1);
  background: var(--bg-3);
  border: 1px solid var(--border-2);
}
.review-tools-tag.missing {
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.2);
  color: #ef4444;
}
/* Footer */
.review-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 20px;
  border-top: 1px solid var(--border-2);
  background: var(--bg-3);
  flex-shrink: 0;
}
.review-footer-note {
  font-size: 11px;
  color: var(--text-2);
  font-style: italic;
}
/* Review action button highlight */
.btn-action--review {
  background: rgba(139,92,246,.12);
  border-color: rgba(139,92,246,.35);
  color: #a78bfa;
}
.btn-action--review:hover {
  background: rgba(139,92,246,.22);
  border-color: rgba(139,92,246,.55);
  color: #c4b5fd;
}
.btn-action--email {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-action--email svg { flex-shrink: 0; }

/* ── Review modal footer actions ────────────────────────────── */
.review-footer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn-action--update-review {
  background: rgba(16,185,129,.12);
  border-color: rgba(16,185,129,.35);
  color: #34d399;
  font-weight: 600;
}
.btn-action--update-review:hover {
  background: rgba(16,185,129,.22);
  border-color: rgba(16,185,129,.55);
  color: #6ee7b7;
}
/* Update running indicator in review modal */
.review-update-running {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #34d399;
}
.review-update-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(52,211,153,.3);
  border-top-color: #34d399;
  border-radius: 50%;
  animation: review-spin 0.9s linear infinite;
  flex-shrink: 0;
}

/* ── Review modal — live streaming panel ──────────────────────── */
.review-live {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.review-live-status {
  font-size: 12px;
  color: var(--text-3);
  font-style: italic;
  padding-left: 4px;
}
/* Thinking panel */
.review-thinking-panel {
  border: 1px solid var(--sw-line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(139,92,246,.05);
}
.review-thinking-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #a78bfa;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}
.review-thinking-toggle:hover { background: rgba(139,92,246,.08); }
.review-thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a78bfa;
  flex-shrink: 0;
  animation: review-thinking-pulse 1.4s ease-in-out infinite;
}
@keyframes review-thinking-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .45; transform: scale(.75); }
}
.review-thinking-label { flex: 1; }
.review-thinking-chevron { font-size: 10px; opacity: .7; }
.review-thinking-body {
  padding: 10px 14px 14px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-3);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
  border-top: 1px solid var(--sw-line);
}

/* ═══════════════════════════════════════════════════════════════
   DESIGN MODE
   ═══════════════════════════════════════════════════════════════ */

/* Design mode button accent */
#rmsDesign.active {
  background: linear-gradient(135deg, #1a1200 0%, #2a1e00 100%);
  border: 1px solid rgba(212,175,55,0.45);
  color: #d4af37;
  box-shadow: 0 1px 4px rgba(212,175,55,0.25);
}
#rmsDesign.active:hover {
  background: linear-gradient(135deg, #1e1500 0%, #2e2200 100%);
}

/* Hide standard query UI when in design mode */
body.design-mode .asset-bar,
body.design-mode .query-textarea,
body.design-mode .example-prompts,
body.design-mode #templateRow,
body.design-mode .char-counter {
  display: none !important;
}
body.design-mode #btnRun { display: none !important; }
body.design-mode #outputSection { display: none !important; }

/* ── Design read-only view (shared link or history restore) ── */
/* Hides input UI; #designResults (inside querySection) stays visible */
body.design-read-view .query-hero,
body.design-read-view .asset-bar,
body.design-read-view .draft-banner,
body.design-read-view .input-wrapper,
body.design-read-view #designPanel,
body.design-read-view #examplePrompts,
body.design-read-view #templateRow,
body.design-read-view .design-iteration-panel,
body.design-read-view .design-iteration-btns { display: none !important; }

/* Shared analysis read-only: hide interactive controls */
body.shared-read-view .chat-composer,
body.shared-read-view .chat-input-area,
body.shared-read-view .chat-add-to-report,
body.shared-read-view .chat-add-report-btn,
body.shared-read-view .followup-jump-btn,
body.shared-read-view #btnPeerReview,
body.shared-read-view #btnEmailSelf,
body.shared-read-view #btnDataPackage,
body.shared-read-view #btnListen,
body.shared-read-view #btnExportPDF { display: none !important; }

/* ── Design Panel ──────────────────────────────────────────── */
.design-panel {
  margin: 0 0 12px;
  animation: fadeInUp 0.2s ease;
}
.design-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Upload zone */
.design-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px dashed var(--border-1);
  border-radius: 10px;
  padding: 28px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text-3);
  background: var(--bg-1);
}
.design-upload-zone:hover,
.design-upload-zone.drag-over {
  border-color: #d4af37;
  background: rgba(212,175,55,0.05);
  color: var(--text-2);
}
.design-drop-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.design-drop-sub {
  font-size: 11px;
  color: var(--text-4);
}

/* Image preview strip */
.design-image-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.design-thumb-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-1);
  flex-shrink: 0;
}
.design-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.design-thumb-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
}
.design-thumb-wrap:hover .design-thumb-remove { opacity: 1; }

/* Selectors row */
.design-selectors {
  display: flex;
  gap: 10px;
}
.design-selector-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.design-selector-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.design-select {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: 6px;
  color: var(--text-1);
  font-size: 12px;
  padding: 6px 8px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: auto;
}
.design-select:focus {
  outline: none;
  border-color: #d4af37;
}

/* ── Design temperature control ── */
.design-temp-row {
  margin: 0 0 12px 0;
}
.design-temp-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.design-temp-hint {
  font-size: 9px;
  font-weight: 400;
  color: #bbb;
  text-transform: none;
  letter-spacing: 0;
}
.design-temp-track {
  display: flex;
  align-items: center;
  gap: 10px;
}
.design-temp-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, #016bab 0%, #016bab calc((var(--pct, 33.3)) * 1%), #e8e8e8 calc((var(--pct, 33.3)) * 1%), #e8e8e8 100%);
  outline: none;
  cursor: pointer;
}
.design-temp-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #016bab;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.design-temp-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #016bab;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.design-temp-value {
  font-size: 11px;
  font-weight: 700;
  color: #016bab;
  min-width: 24px;
  text-align: right;
}

/* Design brief textarea */
.design-brief-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
  resize: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.design-brief-input:focus {
  outline: none;
  border-color: #d4af37;
}
.design-brief-input::placeholder { color: var(--text-4); }

/* Generate button */
.btn-design-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #b8942a 0%, #d4af37 60%, #c9a82e 100%);
  color: #1a1200;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-ui);
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  align-self: flex-start;
}
.btn-design-generate:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}
.btn-design-generate:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn-design-generate.generating {
  opacity: 0.7;
  cursor: wait;
}
.btn-design-spinner {
  animation: spin 0.9s linear infinite;
}

/* ── Design Results ──────────────────────────────────────────── */
.design-results {
  margin-top: 4px;
  animation: fadeInUp 0.25s ease;
}
.design-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.design-results-title {
  font-size: 12px;
  font-weight: 600;
  color: #d4af37;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.design-results-clear {
  background: none;
  border: none;
  color: var(--text-4);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}
.design-results-clear:hover { color: var(--text-2); }

.design-gallery {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.design-result-img-wrap {
  position: relative;
  flex: 1;
  min-width: 280px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-1);
  background: var(--bg-1);
}
.design-result-img {
  width: 100%;
  height: auto;
  display: block;
}
.design-img-download {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-ui);
}
.design-result-img-wrap:hover .design-img-download { opacity: 1; }

.design-commentary {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-left: 3px solid #d4af37;
  border-radius: 0 8px 8px 0;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.design-commentary strong {
  color: var(--text-1);
  font-weight: 600;
}
.design-commentary h3, .design-commentary h4 {
  color: #d4af37;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 14px 0 6px;
}
.design-error {
  background: rgba(231,76,60,0.08);
  border: 1px solid rgba(231,76,60,0.2);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #e74c3c;
}

/* ── Design Context Header (loaded runs) ────────────────────── */
.design-context-header {
  margin-bottom: 18px;
  padding: 12px 16px;
  background: rgba(212,175,55,0.05);
  border: 1px solid rgba(212,175,55,0.18);
  border-radius: 10px;
}
.design-context-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}
.design-context-sep { color: var(--text-4); font-weight: 400; }
.design-context-space { color: var(--text-3); font-weight: 400; }
.design-context-brief {
  font-size: 11px;
  color: var(--text-3);
  font-style: italic;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ── Design Iteration Panel ──────────────────────────────────── */
.design-iteration-panel {
  margin-top: 14px;
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 10px;
  padding: 14px 16px;
  background: rgba(212,175,55,0.04);
}
.design-iteration-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #d4af37;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.design-iteration-count {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-4);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.design-iteration-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: 7px;
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  padding: 9px 11px;
  resize: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
  margin-bottom: 10px;
}
.design-iteration-input:focus {
  outline: none;
  border-color: #d4af37;
}
.design-iteration-input::placeholder { color: var(--text-4); }
.design-iteration-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.design-iteration-history-hint {
  font-size: 10.5px;
  color: var(--text-4);
  flex: 1;
}
.design-iteration-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-design-iterate {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 7px;
  border: 1px solid rgba(212,175,55,0.4);
  background: transparent;
  color: #d4af37;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-design-iterate:hover:not(:disabled) {
  background: rgba(212,175,55,0.1);
  border-color: rgba(212,175,55,0.7);
}
.btn-design-iterate:disabled {
  opacity: 0.45;
  cursor: wait;
}
.btn-design-email {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid var(--sw-line);
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-design-email:hover:not(:disabled) {
  background: var(--bg-3);
  border-color: var(--sw-line-2);
  color: var(--sw-light);
}
.btn-design-email:disabled { opacity: 0.45; cursor: wait; }

/* ── Design Timeline ─────────────────────────────────────────── */
.design-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.design-timeline-originals {
  margin-bottom: 4px;
}
.design-timeline-entry {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeInUp 0.2s ease;
}
.design-tl-label {
  font-size: 10px;
  font-weight: 700;
  color: #d4af37;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.design-tl-brief {
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg-2);
  border-left: 2px solid rgba(212,175,55,0.4);
  padding: 6px 10px;
  border-radius: 0 5px 5px 0;
  font-style: italic;
  margin-bottom: 6px;
}
.design-tl-images {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.design-tl-arrow {
  display: flex;
  justify-content: center;
  padding: 8px 0;
  color: rgba(212,175,55,0.5);
}

/* ── AI Review Pass ──────────────────────────────────────── */
.design-review-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 20px;
  width: fit-content;
}
.design-review-badge--pass {
  color: #3aaa6e;
  background: rgba(58,170,110,0.10);
  border: 1px solid rgba(58,170,110,0.25);
}
.design-review-badge--warn {
  color: #b97a1b;
  background: rgba(245,158,11,0.10);
  border: 1px solid rgba(245,158,11,0.25);
}

.design-review-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.design-review-section--initial {
  opacity: 0.65;
}
.design-review-section-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.design-review-section-label--final {
  color: #3aaa6e;
  margin-top: 2px;
}
.design-tl-images--muted img {
  max-height: 130px;
  opacity: 0.7;
}

.design-review-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(255, 190, 0, 0.05);
  border: 1px solid rgba(255, 190, 0, 0.22);
  border-radius: 8px;
}
.design-review-block-header {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: #c9960a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.design-review-issues {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.55;
  white-space: pre-line;
}
.design-review-revised-prompt {
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid rgba(255,190,0,0.15);
  padding-top: 8px;
  line-height: 1.5;
}
.design-review-revised-prompt strong {
  color: var(--text-2);
}

/* ── Toast notifications ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 420px;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-1, #e8e8e8);
  background: var(--surface-2, #1e1e24);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  animation: toastIn 0.25s ease-out;
  max-width: 100%;
  word-break: break-word;
}
.toast.toast-exit {
  animation: toastOut 0.2s ease-in forwards;
}
.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}
.toast-body {
  flex: 1;
  min-width: 0;
}
.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-3, #888);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
  margin-top: -1px;
}
.toast-close:hover {
  color: var(--text-1, #e8e8e8);
}
.toast--error   { border-color: rgba(255,80,80,0.35);  background: rgba(255,50,50,0.12); }
.toast--warning { border-color: rgba(255,190,0,0.35);  background: rgba(255,190,0,0.10); }
.toast--success { border-color: rgba(80,220,120,0.35); background: rgba(80,220,120,0.10); }
.toast--info    { border-color: rgba(80,160,255,0.35); background: rgba(80,160,255,0.10); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

/* ── Analysis search bar ──────────────────────────────────────── */
.analysis-search {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-2, #1e1e24);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}
.analysis-search-icon {
  flex-shrink: 0;
  color: var(--text-3, #888);
}
.analysis-search-input {
  flex: 1;
  background: var(--surface-1, #151518);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--text-1, #e8e8e8);
  outline: none;
  min-width: 0;
}
.analysis-search-input:focus {
  border-color: var(--sw, #0077b6);
}
.analysis-search-count {
  font-size: 11px;
  color: var(--text-3, #888);
  white-space: nowrap;
  min-width: 48px;
  text-align: center;
}
.analysis-search-nav,
.analysis-search-close {
  background: none;
  border: none;
  color: var(--text-3, #888);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 3px;
}
.analysis-search-nav:hover:not(:disabled),
.analysis-search-close:hover {
  color: var(--text-1, #e8e8e8);
  background: rgba(255,255,255,0.06);
}
.analysis-search-nav:disabled {
  opacity: 0.3;
  cursor: default;
}
mark.search-hl {
  background: rgba(255,210,0,0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
mark.search-hl.current {
  background: rgba(255,150,0,0.6);
}

/* ── Monitors UI ──────────────────────────────────────────────── */

.monitors-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 6px 8px 4px;
  flex-wrap: wrap;
}
.btn-new-monitor {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-new-monitor:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent);
}
.monitors-list {
  overflow-y: auto;
  padding: 0 8px 8px;
}

/* Monitor card in sidebar */
.monitor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.monitor-card:hover {
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.monitor-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.monitor-card-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.monitor-card-status {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-left: 8px;
}
.monitor-card-status--active   { background: #dcfce7; color: #166534; }
.monitor-card-status--paused   { background: #fef3c7; color: #92400e; }
.monitor-card-status--error    { background: #fecaca; color: #991b1b; }
.monitor-card-status--stopped  { background: #f1f5f9; color: #64748b; }
.monitor-card-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.monitor-card-briefing {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.monitor-card-run-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 4px 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(1,107,171,0.08);
  border: 1px solid rgba(1,107,171,0.2);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.monitor-card-run-btn:hover {
  background: rgba(1,107,171,0.18);
  border-color: var(--accent);
}
.monitor-card-run-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.monitor-change-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.monitor-change-bar-track {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.monitor-change-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.3s;
}
.monitor-change-bar-label {
  font-size: 9px;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 24px;
  text-align: right;
}

/* Monitor modal form fields */
.monitor-field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 12px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.monitor-field-label:first-child { margin-top: 0; }
.monitor-input,
.monitor-select,
.monitor-textarea {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text-primary);
  font-family: inherit;
  box-sizing: border-box;
}
.monitor-textarea { resize: vertical; }
.monitor-input:focus,
.monitor-select:focus,
.monitor-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.monitor-input-sm,
.monitor-select-sm {
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text-primary);
  font-family: inherit;
  width: 80px;
}
.monitor-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}
.monitor-radio-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.monitor-time-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-top: 4px;
}
.monitor-cost-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-top: 4px;
}

/* Monitor detail modal */
.monitor-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}
.monitor-detail-actions .btn-action {
  font-size: 11px;
  padding: 4px 10px;
}
.monitor-detail-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 0;
  border-bottom: 1px solid var(--border-light, var(--border));
}
.monitor-detail-info-row:last-child { border-bottom: none; }
.monitor-detail-label {
  color: var(--text-muted);
}
.monitor-detail-thesis {
  background: var(--bg-3, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.monitor-detail-thesis-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.monitor-detail-thesis-text {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
}
.monitor-forced-tool-tag {
  display: inline-block;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  background: rgba(1,107,171,0.12);
  border: 1px solid rgba(1,107,171,0.25);
  border-radius: 3px;
  color: var(--accent);
}
.monitor-tool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border-0);
  border-radius: 6px;
  background: var(--bg-secondary);
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-3, rgba(255,255,255,0.02));
}
.monitor-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-2);
  background: var(--bg-3);
  border: 1px solid var(--border-0);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
  user-select: none;
}
.monitor-tool-chip:hover {
  border-color: var(--border-2);
  background: var(--bg-4);
  color: var(--text-1);
}
.monitor-tool-chip.forced {
  border-color: var(--accent);
  background: rgba(1,107,171,0.15);
  color: var(--text-0);
  box-shadow: 0 0 0 1px var(--accent);
}
.monitor-tool-chip.forced::before {
  content: '\2713';
  font-size: 8px;
  margin-right: 1px;
}

/* ── Shared Monitor Page ─────────────────────────────────────── */
.shared-monitor-page {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-0, #0a1628);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  color: var(--text-1);
}
.shared-monitor-loading, .shared-monitor-error {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
  font-size: 14px;
}
.shared-monitor-error h2 { color: var(--text-0); margin-bottom: 8px; }
.shared-monitor-error p { color: var(--text-2); }
.shared-monitor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.shared-monitor-logo {
  height: 28px;
  opacity: 0.9;
}
.shared-monitor-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  background: rgba(1,107,171,0.15);
  border: 1px solid rgba(1,107,171,0.3);
  border-radius: 4px;
  color: var(--accent);
}
.shared-monitor-card {
  width: 100%;
  max-width: 640px;
  background: var(--bg-2, #0f1d2f);
  border: 1px solid var(--border-1, rgba(255,255,255,0.08));
  border-radius: 12px;
  padding: 28px 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.shared-monitor-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-0);
  margin: 0 0 6px;
}
.shared-monitor-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 16px;
}
.shared-monitor-thesis {
  background: var(--bg-3, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 16px;
}
.shared-monitor-metrics-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
}
.shared-monitor-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.shared-monitor-run {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg-3, rgba(255,255,255,0.02));
}
.shared-monitor-run-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.shared-monitor-footer {
  margin-top: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#monitorRunsList {
  margin-top: 12px;
  max-height: 400px;
  overflow-y: auto;
}
.monitor-run-card {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 12px;
  margin-bottom: 6px;
}
.monitor-run-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.monitor-run-status {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
}
.monitor-run-status--completed { background: #dcfce7; color: #166534; }
.monitor-run-status--completed_with_error { background: #fef3c7; color: #92400e; }
.monitor-run-status--failed    { background: #fecaca; color: #991b1b; }
.monitor-run-status--running   { background: #dbeafe; color: #1d4ed8; }
.monitor-run-briefing {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 4px;
}
.monitor-run-view-btn {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}
.monitor-run-view-btn:hover { text-decoration: underline; }
.monitor-timeline-list,
.monitor-comments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.monitor-timeline-item,
.monitor-comment-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--bg-3, rgba(255,255,255,0.02));
}
.monitor-timeline-item--comment {
  border-left: 3px solid var(--accent);
}
.monitor-timeline-item--run {
  padding: 0;
  overflow: hidden;
}
.monitor-timeline-item--run.is-expanded {
  border-color: var(--sw-line, var(--accent));
  background: rgba(255,255,255,0.035);
}
.monitor-timeline-run-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}
.monitor-timeline-run-toggle:hover {
  background: rgba(255,255,255,0.025);
}
.monitor-timeline-run-toggle:focus-visible {
  outline: 2px solid var(--sw-line, var(--accent));
  outline-offset: -2px;
}
.monitor-timeline-item-header,
.monitor-comment-item-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--text-3);
}
.monitor-timeline-item-title,
.monitor-comment-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
}
.monitor-timeline-item-copy,
.monitor-comment-body {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.55;
  white-space: pre-wrap;
}
.monitor-timeline-expand-label {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.monitor-timeline-detail {
  border-top: 1px solid var(--border);
  padding: 12px;
}
.monitor-timeline-detail-inner {
  display: grid;
  gap: 10px;
}
.monitor-timeline-detail-takeaway {
  padding: 9px 10px;
  border-radius: 6px;
  background: rgba(1, 107, 171, 0.08);
  color: var(--text-1);
  font-size: 12px;
  line-height: 1.55;
}
.monitor-timeline-detail-takeaway span {
  display: block;
  margin-bottom: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.monitor-timeline-detail-meta,
.monitor-timeline-detail-evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-3);
}
.monitor-comment-form {
  margin-top: 12px;
}
.monitor-comment-input {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  background: var(--bg-2, rgba(255,255,255,0.03));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-1);
  font: inherit;
}
.monitor-comment-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(1,107,171,0.22);
}
.monitor-comment-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.shared-monitor-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Metrics Over Time chart ──────────────────────────────── */
.monitor-metrics-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 16px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
#monitorMetricsCanvas {
  width: 100% !important;
  max-height: 200px;
  margin-bottom: 8px;
}
.monitor-metrics-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.monitor-metrics-header-row .monitor-metrics-header {
  margin: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.monitor-metrics-range-select {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}
.monitor-metric-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.monitor-metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all 0.15s;
  user-select: none;
}
.monitor-metric-pill:hover { border-color: var(--accent); }
.monitor-metric-pill--active {
  border-color: var(--pill-border, var(--accent));
  background: var(--pill-bg, rgba(1,107,171,0.12));
  color: var(--pill-color, var(--accent));
  font-weight: 500;
}
.monitor-metric-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.monitor-metric-pill-value {
  font-size: 9px;
  opacity: 0.7;
  margin-left: 2px;
}

/* ── Monitor comparison ──────────────────────────────────── */
.monitor-compare-selectors {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.monitor-compare-select {
  flex: 1;
  min-width: 140px;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
}
.btn-compare-monitors {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}
.btn-compare-monitors:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.compare-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
}
.compare-table th,
.compare-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.compare-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.compare-table td { color: var(--text-primary); }

/* ── Monitor templates ───────────────────────────────────── */
.hidden { display: none !important; }
.monitor-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.monitor-template-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.monitor-template-card:hover {
  border-color: var(--accent);
  background: rgba(1,107,171,0.06);
}
.monitor-template-card--selected {
  border-color: var(--accent);
  background: rgba(1,107,171,0.10);
}
.monitor-template-icon {
  font-size: 20px;
  margin-bottom: 4px;
}
.monitor-template-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.monitor-template-desc {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Enhanced briefing display ────────────────────────────── */
.monitor-briefing-headline {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.monitor-briefing-changes {
  margin: 6px 0;
}
.monitor-briefing-change {
  font-size: 11px;
  line-height: 1.5;
  margin-bottom: 2px;
}
.monitor-briefing-change--positive { color: #16a34a; }
.monitor-briefing-change--negative { color: #dc2626; }
.monitor-briefing-change--neutral  { color: var(--text-secondary); }
.monitor-briefing-sig {
  display: inline-block;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 2px;
  margin-left: 4px;
  vertical-align: middle;
}
.monitor-briefing-sig--high   { background: #fecaca; color: #991b1b; }
.monitor-briefing-sig--medium { background: #fef3c7; color: #92400e; }
.monitor-briefing-sig--low    { background: var(--bg-secondary); color: var(--text-muted); }
.monitor-briefing-thesis {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 6px 0;
  padding: 6px 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  border-left: 2px solid var(--accent);
}
.monitor-briefing-actions {
  margin: 6px 0 0;
}
.monitor-briefing-action {
  font-size: 11px;
  line-height: 1.5;
  margin-bottom: 2px;
  color: var(--text-secondary);
}
.monitor-briefing-urgency {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 2px;
  margin-right: 4px;
  text-transform: uppercase;
}
.monitor-briefing-urgency--immediate { background: #fecaca; color: #991b1b; }
.monitor-briefing-urgency--this_week { background: #fed7aa; color: #9a3412; }
.monitor-briefing-urgency--monitor   { background: var(--bg-secondary); color: var(--text-muted); }
.monitor-regime-banner {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #dc2626;
}
.monitor-change-level {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
}
.monitor-change-level--major    { background: #fecaca; color: #991b1b; }
.monitor-change-level--moderate { background: #fed7aa; color: #9a3412; }
.monitor-change-level--minor    { background: #e0f2fe; color: #0369a1; }
.monitor-change-level--none     { background: var(--bg-secondary); color: var(--text-muted); }

/* ── Phase 3: Delete button, empty state, budget bar ────────── */
.btn-action--danger {
  background: #dc2626 !important;
  color: #fff !important;
  border-color: #dc2626 !important;
}
.btn-action--danger:hover { background: #b91c1c !important; }
.btn-action--danger:disabled { opacity: 0.6; cursor: not-allowed; }

.monitor-empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-secondary);
}
.monitor-empty-state .btn-action {
  margin-top: 4px;
  font-size: 11px;
}

.monitor-budget-bar {
  margin-top: 4px;
}

/* ── Monitor Runs page ──────────────────────────────────── */
.btn-monitor-runs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}
.btn-monitor-runs:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.monitor-runs-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.monitor-runs-filter-select {
  flex: 1;
  max-width: 260px;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
}
.monitor-runs-count {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
}
.monitor-runs-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 8px 16px;
}
.monitor-runs-pagination {
  padding: 10px 16px;
  text-align: center;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.monitor-run-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.monitor-run-item:hover {
  border-color: var(--accent);
  background: rgba(1,107,171,0.04);
}
.monitor-run-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.monitor-run-item-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.monitor-run-item-meta {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.monitor-run-item-status {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.monitor-run-item-status--completed { background: #dcfce7; color: #166534; }
.monitor-run-item-status--completed_with_error { background: #fef3c7; color: #92400e; }
.monitor-run-item-status--running   { background: #dbeafe; color: #1e40af; }
.monitor-run-item-status--failed    { background: #fecaca; color: #991b1b; }
.monitor-run-item-briefing {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 4px;
}
.monitor-run-item--running {
  border-color: rgba(1,107,171,0.3);
  background: rgba(1,107,171,0.04);
  animation: monitor-run-pulse 2s ease-in-out infinite;
}
@keyframes monitor-run-pulse {
  0%, 100% { border-color: rgba(1,107,171,0.3); }
  50% { border-color: rgba(1,107,171,0.6); }
}
.monitor-run-view-btn--live {
  color: var(--accent) !important;
  font-weight: 600;
}
.monitor-run-item-vertical {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
