/* ── SDI Intelligence Dashboard — Cyberpunk Design System ─────────────────── */

:root {
  --bg-base:       #0a0a0f;
  --bg-surface:    rgba(8, 18, 28, 0.82);
  --bg-surface-2:  rgba(0, 245, 255, 0.04);
  --bg-hover:      rgba(0, 245, 255, 0.07);

  --accent-cyan:   #00f5ff;
  --accent-green:  #00ff88;
  --danger-red:    #ff3366;
  --warning-amber: #ffaa00;
  --muted:         #3a4a5a;

  --text-primary:   #dde8f0;
  --text-secondary: #5a7080;

  --border:        rgba(0, 245, 255, 0.12);
  --border-bright: rgba(0, 245, 255, 0.38);

  --glow-cyan:  0 0 8px rgba(0,245,255,0.45), 0 0 24px rgba(0,245,255,0.15);
  --glow-green: 0 0 8px rgba(0,255,136,0.45), 0 0 24px rgba(0,255,136,0.12);
  --glow-red:   0 0 8px rgba(255,51,102,0.55);

  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --panel-radius: 8px;
  --left-pane-width: 270px;
  --right-pane-width: 390px;
  --topbar-h: 50px;
  --t: 0.18s ease;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Hex grid background */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='104'%3E%3Cpath d='M30 68L2 52V20L30 4l28 16v32L30 68zm0-4l24-14V22L30 8 6 22v28l24 14z' fill='none' stroke='%2300f5ff' stroke-opacity='0.045'/%3E%3C/svg%3E");
  background-size: 60px 104px;
  pointer-events: none;
  z-index: 0;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,0,0,0.028) 2px, rgba(0,0,0,0.028) 4px
  );
  pointer-events: none;
  z-index: 1;
  animation: scanlines 12s linear infinite;
}

@keyframes scanlines {
  from { background-position: 0 0; }
  to   { background-position: 0 200px; }
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-cyan); }

/* ── Panel ───────────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-surface);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--panel-radius);
  position: relative;
  z-index: 2;
  transition: border-color var(--t);
}
.panel:hover { border-color: rgba(0,245,255,0.22); }

.panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.panel-header::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
  animation: pulse-dot 2.4s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.3; transform: scale(0.7); }
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(6, 8, 14, 0.94);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 14px;
  z-index: 100;
}

.topbar-logo {
  width: 30px; height: 30px;
  border-radius: 5px;
  object-fit: cover;
  filter: drop-shadow(0 0 5px var(--accent-cyan));
  flex-shrink: 0;
}

.topbar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: var(--glow-cyan);
}

.topbar-sep {
  font-size: 10px;
  color: var(--muted);
}

/* Data stream bar */
.data-stream {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%, var(--accent-cyan) 40%, var(--accent-green) 60%, transparent 100%);
  background-size: 300% 100%;
  animation: data-flow 2.5s linear infinite;
  opacity: 0.6;
}

@keyframes data-flow {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Stats cluster */
.stats-cluster {
  display: flex;
  gap: 18px;
  align-items: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.stat-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-green);
  line-height: 1;
  text-shadow: var(--glow-green);
}

.stat-label {
  font-size: 8.5px;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 1px;
}

/* Icon button */
.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  width: 30px; height: 30px;
  border-radius: 5px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--t), border-color var(--t), box-shadow var(--t);
  flex-shrink: 0;
}
.icon-btn:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
}

/* ── Main layout ─────────────────────────────────────────────────────────── */
#main {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  display: flex;
  z-index: 2;
  overflow: hidden;
}

/* ── Left pane ───────────────────────────────────────────────────────────── */
#left-pane {
  width: var(--left-pane-width);
  min-width: var(--left-pane-width);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.28s cubic-bezier(0.4,0,0.2,1),
              min-width 0.28s cubic-bezier(0.4,0,0.2,1),
              opacity 0.2s ease;
  background: rgba(4, 8, 14, 0.6);
  flex-shrink: 0;
  backdrop-filter: blur(14px);
}

#left-pane.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  overflow: hidden;
}

#source-list {
  overflow-y: auto;
  flex: 1;
  padding: 6px 0 12px;
}

/* Source card */
.source-card {
  padding: 10px 12px;
  margin: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t), background var(--t);
  user-select: none;
  position: relative;
}

.source-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(0,245,255,0.05) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--t);
}

.source-card:hover {
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
  transform: translateX(3px);
  background: rgba(0,245,255,0.06);
}

.source-card:hover::after { opacity: 1; }
.source-card:active, .source-card.dragging { opacity: 0.45; cursor: grabbing; }

.source-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  color: var(--bg-base);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.avatar-yt   { background: linear-gradient(135deg, #00f5ff, #00b4d8); }
.avatar-rss  { background: linear-gradient(135deg, #ffaa00, #ff6b35); }

.source-info { flex: 1; min-width: 0; position: relative; z-index: 1; }

.source-name {
  font-size: 11.5px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.platform-badge {
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  margin-top: 3px;
  display: inline-block;
  font-weight: 700;
}

.badge-youtube { background: rgba(255,0,0,0.15); color: #ff5555; border: 1px solid rgba(255,0,0,0.2); }
.badge-rss     { background: rgba(255,170,0,0.15); color: var(--warning-amber); border: 1px solid rgba(255,170,0,0.2); }

.drag-handle {
  color: var(--muted);
  font-size: 14px;
  cursor: grab;
  position: relative; z-index: 1;
  flex-shrink: 0;
}

/* ── Center ──────────────────────────────────────────────────────────────── */
#center {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Drop zone — compact, top of center */
/* Confirm bar */
#confirm-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  background: color-mix(in srgb, var(--danger-red) 10%, var(--bg-surface));
  border-bottom: 1px solid color-mix(in srgb, var(--danger-red) 40%, transparent);
  font-size: 11px;
  color: var(--text-primary);
  flex-shrink: 0;
  z-index: 10;
}
#confirm-bar.show { display: flex; }
#confirm-msg { flex: 1; }
.confirm-actions { display: flex; gap: 8px; flex-shrink: 0; }
.confirm-btn {
  padding: 4px 14px;
  border-radius: 4px;
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: all var(--t);
}
.confirm-btn-ok {
  background: var(--danger-red);
  color: #fff;
  border-color: var(--danger-red);
}
.confirm-btn-ok:hover { opacity: 0.85; }
.confirm-btn-no {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.confirm-btn-no:hover { border-color: var(--text-secondary); color: var(--text-primary); }

#drop-zone {
  height: 130px;
  flex-shrink: 0;
  margin: 10px 12px 0;
  border: 2px dashed rgba(0,245,255,0.2);
  border-radius: 10px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
  transition: border-color var(--t), background var(--t), box-shadow var(--t);
  position: relative;
  overflow: hidden;
  cursor: default;
}

/* Radial glow center */
#drop-zone::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 50%,
    rgba(0,245,255,0.035) 0%, transparent 65%);
  animation: zone-breathe 5s ease-in-out infinite;
  pointer-events: none;
}

/* Corner accents */
#drop-zone::after {
  content: '';
  position: absolute;
  top: 12px; left: 12px;
  right: 12px; bottom: 12px;
  border: 1px solid rgba(0,245,255,0.06);
  border-radius: 6px;
  pointer-events: none;
}

@keyframes zone-breathe {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1.0; }
}

#drop-zone.drag-over {
  border-color: var(--accent-cyan);
  background: rgba(0,245,255,0.04);
  box-shadow: inset 0 0 40px rgba(0,245,255,0.06), var(--glow-cyan);
}

.drop-logo {
  width: 52px; height: 52px;
  border-radius: 10px;
  object-fit: cover;
  opacity: 0.22;
  filter: drop-shadow(0 0 10px var(--accent-cyan));
  transition: opacity var(--t);
  flex-shrink: 0;
}

#drop-zone.drag-over .drop-logo { opacity: 0.5; }

.drop-text { display: flex; flex-direction: column; gap: 4px; }

.drop-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  transition: color var(--t);
}

.drop-sub {
  font-size: 10px;
  color: var(--muted);
}

/* ── Pipeline Monitor — main content area ───────────────────────────────── */
#pipeline-section {
  background: rgba(4, 8, 14, 0.7);
  border-top: 1px solid var(--border);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-top: 10px;
}

.pipeline-section-header {
  padding: 8px 14px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Pipeline status pills row */
#pipeline-rings {
  display: flex;
  gap: 8px;
  padding: 8px 14px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--pill-color) 35%, transparent);
  background: color-mix(in srgb, var(--pill-color) 8%, transparent);
  transition: border-color var(--t);
}

.status-pill-count {
  font-size: 17px;
  font-weight: 700;
  color: var(--pill-color);
  line-height: 1;
}

.status-pill-label {
  font-size: 9.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Episode list — primary content, fills available space */
#episode-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 12px;
}

.ep-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: 1px solid rgba(0,245,255,0.06);
  transition: background var(--t), border-color var(--t);
  margin-bottom: 2px;
}

.ep-row:hover    { background: var(--bg-hover); border-color: rgba(0,245,255,0.1); }
.ep-row.selected { background: rgba(0,245,255,0.07); border-color: rgba(0,245,255,0.22); }

.ep-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ep-title {
  flex: 1;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  font-weight: 500;
}

.ep-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 9.5px;
  color: var(--text-secondary);
}

.ep-cost {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.ep-source-link {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-secondary);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--t), color var(--t);
}
.ep-row:hover .ep-source-link { opacity: 1; color: var(--accent-cyan); }

.ep-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  opacity: 0;
  padding: 0 2px;
  transition: opacity var(--t), color var(--t);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.ep-row:hover .ep-delete-btn { opacity: 1; }
.ep-delete-btn:hover { color: var(--danger-red); }

#console-source-link {
  margin-left: auto;
  font-size: 9px;
  color: var(--accent-cyan);
  text-decoration: none;
  letter-spacing: 0.08em;
  opacity: 0.7;
  transition: opacity var(--t);
}
#console-source-link:hover { opacity: 1; }

/* Episode summary one-liner + hover tooltip */
.ep-summary-wrap {
  position: relative;
}

.ep-summary {
  display: block;
  font-size: 10.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
  padding: 1px 0;
  cursor: default;
}

.ep-row:hover .ep-summary { color: rgba(0,245,255,0.6); }

/* Full-text tooltip — appears above the row on hover */
.ep-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: rgba(6, 14, 22, 0.97);
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.65;
  font-style: normal;
  z-index: 50;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), var(--glow-cyan);
  white-space: normal;
  pointer-events: none;
}

.ep-summary-wrap:hover .ep-tooltip { display: block; }

/* ── Pipeline Progress Bar ──────────────────────────────────────────────── */
.ep-progress-track {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.ep-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
  position: relative;
}

/* Shimmer animation for active/in-progress states */
.ep-progress-fill.active::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 40px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  animation: shimmer 1.6s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { transform: translateX(-40px); }
  100% { transform: translateX(40px); }
}

/* State-specific progress colors */
.ep-progress-fill.state-discovered  { width: 5%;   background: #4a5568; }
.ep-progress-fill.state-downloaded  { width: 25%;  background: linear-gradient(90deg, #4a5568, #ffaa00); }
.ep-progress-fill.state-transcribed { width: 50%;  background: linear-gradient(90deg, #ffaa00, #00f5ff); }
.ep-progress-fill.state-processed   { width: 80%;  background: linear-gradient(90deg, #00f5ff, #00ff88); }
.ep-progress-fill.state-exported    { width: 100%; background: linear-gradient(90deg, #00f5ff, #00ff88); box-shadow: 0 0 6px rgba(0,255,136,0.4); }
.ep-progress-fill.state-failed      { width: 100%; background: #ff3366; }

/* Stage dots strip */
.ep-stages {
  display: flex;
  gap: 4px;
  align-items: center;
}

.stage-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  transition: background var(--t), box-shadow var(--t);
}

.stage-dot.done     { background: var(--accent-green); }
.stage-dot.active   { background: var(--accent-cyan); box-shadow: 0 0 6px var(--accent-cyan); animation: pulse-dot 1.5s infinite; }
.stage-dot.failed   { background: var(--danger-red); }

/* Active ingest indicator */
.ep-dripping {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  color: var(--accent-cyan);
  animation: text-pulse 2s ease-in-out infinite;
}

.drip-dot {
  display: flex; gap: 2px;
}

.drip-dot span {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: drip-bounce 1.2s ease-in-out infinite;
}

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

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

@keyframes text-pulse {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 1; }
}

/* ── Active Ingestion Panel ─────────────────────────────────────────────── */
.ingest-panel {
  margin: 0 12px 10px;
  border: 1px solid rgba(0,245,255,0.35);
  border-radius: 8px;
  background: rgba(0, 20, 30, 0.9);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0,245,255,0.1), inset 0 0 30px rgba(0,245,255,0.03);
  animation: panel-appear 0.3s ease;
}

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

.ingest-panel-header {
  padding: 10px 14px 8px;
  border-bottom: 1px solid rgba(0,245,255,0.15);
}

.ingest-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ingest-view-logs-btn {
  flex: 0 0 auto;
  padding: 5px 9px;
  font-size: 9px;
}

#ingest-source-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 0.06em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ingest-elapsed {
  font-size: 10px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ingest-current-msg {
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-left: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 4-step stage track */
.ingest-stage-track {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 2px 0 4px;
}

.ingest-stage-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ingest-stage-step span {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: color var(--t);
}

.ingest-step-meta {
  font-size: 8px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}

.ingest-step-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: transparent;
  transition: all 0.3s ease;
  position: relative;
}

/* stage line connector */
.ingest-stage-line {
  flex: 1;
  height: 2px;
  background: var(--muted);
  margin-bottom: 14px;
  transition: background 0.4s ease;
}

/* Step states */
.ingest-stage-step.done .ingest-step-dot {
  border-color: var(--accent-green);
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(0,255,136,0.6);
}
.ingest-stage-step.done span { color: var(--accent-green); }
.ingest-stage-step.done .ingest-step-meta { color: var(--accent-green); }
.ingest-stage-step.done + .ingest-stage-line {
  background: var(--accent-green);
}

.ingest-stage-step.active .ingest-step-dot {
  border-color: var(--accent-cyan);
  background: rgba(0,245,255,0.2);
  box-shadow: 0 0 8px rgba(0,245,255,0.7);
  animation: step-pulse 1.2s ease-in-out infinite;
}
.ingest-stage-step.active span { color: var(--accent-cyan); }
.ingest-stage-step.active .ingest-step-meta { color: var(--accent-cyan); }

.ingest-stage-step.failed .ingest-step-dot {
  border-color: var(--danger-red);
  background: rgba(255,51,102,0.2);
  box-shadow: 0 0 8px rgba(255,51,102,0.5);
}
.ingest-stage-step.failed span,
.ingest-stage-step.failed .ingest-step-meta {
  color: var(--danger-red);
}

@keyframes step-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(0,245,255,0.6); }
  50%       { box-shadow: 0 0 14px rgba(0,245,255,0.9), 0 0 24px rgba(0,245,255,0.3); }
}

/* Scrolling log feed */
.ingest-log {
  height: 110px;
  overflow-y: auto;
  padding: 6px 12px 8px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  line-height: 1.55;
  color: var(--text-secondary);
}

.ingest-log-line {
  white-space: pre-wrap;
  word-break: break-all;
  padding: 1px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.ingest-log-line.line-success { color: var(--accent-green); }
.ingest-log-line.line-stage   { color: var(--accent-cyan); font-weight: 700; }
.ingest-log-line.line-error   { color: var(--danger-red); }
.ingest-log-line.line-done    { color: var(--accent-green); font-weight: 700; }
.ingest-log-line.line-info    { color: var(--warning-amber); }

/* ── Right panel ─────────────────────────────────────────────────────────── */
#right-panel {
  width: var(--right-pane-width);
  min-width: 260px;
  max-width: 780px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(4, 8, 14, 0.65);
  backdrop-filter: blur(14px);
  position: relative;
}

/* Drag handle — sits on the left edge of the right panel */
#right-resize-handle {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 10;
  transition: background var(--t);
}

#right-resize-handle:hover,
#right-resize-handle.dragging {
  background: rgba(0, 245, 255, 0.25);
  box-shadow: inset -1px 0 0 var(--accent-cyan), 1px 0 8px rgba(0,245,255,0.3);
}

/* Tabs */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
  gap: 2px;
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
  overflow-x: auto;
}

.tab-btn {
  padding: 8px 11px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t), border-color var(--t);
}

.tab-btn:hover  { color: var(--text-primary); }
.tab-btn.active { color: var(--accent-cyan); border-bottom-color: var(--accent-cyan); }

.tab-panel { display: none; flex: 1; overflow-y: auto; padding: 10px; flex-direction: column; gap: 7px; }
.tab-panel.active { display: flex; }

/* Intelligence cards */
.intel-card {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  transition: border-color var(--t), box-shadow var(--t);
  flex-shrink: 0;
}

.intel-card:hover {
  border-color: rgba(0,245,255,0.25);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.card-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 5px;
  line-height: 1.35;
}

.card-derived-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-green);
  margin-bottom: 5px;
}

.card-body {
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.65;
  margin-bottom: 5px;
}

.card-meta {
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.card-quote {
  border-left: 2px solid var(--accent-cyan);
  padding-left: 8px;
  font-size: 10px;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 6px;
  line-height: 1.6;
}

.research-pointer {
  font-size: 10px;
  color: var(--warning-amber);
  margin-top: 5px;
}

.tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

/* Severity badges */
.badge {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid transparent;
}

.badge-critical { background: rgba(255,51,102,0.18); color: var(--danger-red);    border-color: rgba(255,51,102,0.35); box-shadow: var(--glow-red); }
.badge-high     { background: rgba(255,170,0,0.15);  color: var(--warning-amber); border-color: rgba(255,170,0,0.3); }
.badge-medium   { background: rgba(0,245,255,0.1);   color: var(--accent-cyan);   border-color: rgba(0,245,255,0.25); }
.badge-low      { background: rgba(0,255,136,0.1);   color: var(--accent-green);  border-color: rgba(0,255,136,0.25); }

/* Confidence as badge */
.conf-high   { background: rgba(0,255,136,0.1);   color: var(--accent-green);  border: 1px solid rgba(0,255,136,0.3); }
.conf-medium { background: rgba(255,170,0,0.12);  color: var(--warning-amber); border: 1px solid rgba(255,170,0,0.3); }
.conf-low    { background: rgba(255,51,102,0.1);  color: var(--danger-red);    border: 1px solid rgba(255,51,102,0.3); }

/* Tag chips */
.chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10.5px;
  background: rgba(0,245,255,0.08);
  border: 1px solid rgba(0,245,255,0.2);
  color: var(--accent-cyan);
}

.chip-cve {
  background: rgba(255,51,102,0.1);
  border-color: rgba(255,51,102,0.25);
  color: var(--danger-red);
}

/* Empty state */
.empty-state {
  color: var(--text-secondary);
  font-size: 11px;
  padding: 20px;
  text-align: center;
  letter-spacing: 0.05em;
}


/* Schedule modal */
#schedule-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

#schedule-modal.open { display: flex; }

.modal-box {
  background: rgba(8,16,26,0.97);
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  padding: 24px;
  min-width: 300px;
  box-shadow: var(--glow-cyan), 0 20px 60px rgba(0,0,0,0.8);
}

.modal-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.modal-input {
  width: 100%;
  background: rgba(0,245,255,0.05);
  border: 1px solid var(--border-bright);
  border-radius: 5px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--t);
}

.modal-input:focus { border-color: var(--accent-cyan); box-shadow: var(--glow-cyan); }

.modal-actions { display: flex; gap: 8px; margin-top: 14px; }

.modal-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.modal-field label { font-size: 9px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.1em; }

.modal-btn {
  flex: 1;
  padding: 7px 12px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t);
  border: 1px solid var(--border);
}
.modal-btn-primary {
  background: rgba(0,245,255,0.12);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}
.modal-btn-primary:hover { background: rgba(0,245,255,0.2); }
.modal-btn-cancel {
  background: transparent;
  color: var(--text-secondary);
}
.modal-btn-cancel:hover { border-color: var(--text-secondary); color: var(--text-primary); }

#btn-add-source {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent-cyan);
  font-size: 14px;
  line-height: 1;
  width: 20px; height: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--t), background var(--t);
  flex-shrink: 0;
}
#btn-add-source:hover { border-color: var(--accent-cyan); background: rgba(0,245,255,0.08); }

.btn {
  flex: 1;
  padding: 7px 12px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t);
}

.btn-primary {
  background: rgba(0,245,255,0.12);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-primary:hover { background: rgba(0,245,255,0.22); box-shadow: var(--glow-cyan); }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover { border-color: var(--text-secondary); color: var(--text-primary); }

/* Quote card */
.quote-card {
  border-left: 2px solid var(--accent-cyan);
  padding: 8px 12px;
  background: var(--bg-surface-2);
  border-radius: 0 5px 5px 0;
  font-size: 11.5px;
  font-style: italic;
  line-height: 1.7;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* Mindset card accent */
.mindset-principle {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

.mindset-application {
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.65;
}

/* ── Modal overlay (shared) ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

/* Form rows inside modals */
.form-row {
  margin-bottom: 12px;
}
.form-label {
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

/* select element styling */
select.modal-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2300f5ff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
select.modal-input option {
  background: #0a0e18;
  color: var(--text-primary);
}

/* Source gear icon on card */
.source-gear {
  width: 20px; height: 20px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--t), border-color var(--t);
  flex-shrink: 0;
  position: relative; z-index: 1;
}
.source-gear:hover { color: var(--accent-cyan); border-color: var(--accent-cyan); }

.source-delete {
  width: 20px; height: 20px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--t), border-color var(--t);
  flex-shrink: 0;
  position: relative; z-index: 1;
  opacity: 0;
}
.source-card:hover .source-delete { opacity: 1; }
.source-delete:hover { color: var(--danger-red); border-color: var(--danger-red); }

/* Episode count badge on source card */
.source-ep-count {
  font-size: 8.5px;
  color: var(--accent-green);
  white-space: nowrap;
  flex-shrink: 0;
  position: relative; z-index: 1;
}

/* ── Chat FAB (floating action button) ───────────────────────────────────── */
#chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(0,20,30,0.95);
  border: 2px solid var(--accent-cyan);
  box-shadow: var(--glow-cyan), 0 4px 20px rgba(0,0,0,0.5);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 250;
  transition: transform var(--t), box-shadow var(--t);
  animation: fab-pulse 3s ease-in-out infinite;
}
#chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 0 16px rgba(0,245,255,0.7), 0 0 40px rgba(0,245,255,0.25);
}
@keyframes fab-pulse {
  0%, 100% { box-shadow: var(--glow-cyan), 0 4px 20px rgba(0,0,0,0.5); }
  50%       { box-shadow: 0 0 16px rgba(0,245,255,0.5), 0 0 30px rgba(0,245,255,0.2), 0 4px 20px rgba(0,0,0,0.5); }
}

/* ── Chat Panel ──────────────────────────────────────────────────────────── */
.chat-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 420px;
  max-height: 580px;
  display: flex;
  flex-direction: column;
  background: rgba(5, 12, 22, 0.97);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  box-shadow: var(--glow-cyan), 0 20px 60px rgba(0,0,0,0.8);
  z-index: 240;
  overflow: hidden;
  animation: panel-appear 0.25s ease;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,245,255,0.04);
  flex-shrink: 0;
}

.chat-panel-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: var(--glow-cyan);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
}

.chat-msg.user { align-items: flex-end; }
.chat-msg.assistant { align-items: flex-start; }

.chat-bubble {
  max-width: 90%;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 11.5px;
  line-height: 1.65;
  font-style: normal;
}

.chat-msg.user .chat-bubble {
  background: rgba(0,245,255,0.12);
  border: 1px solid rgba(0,245,255,0.25);
  color: var(--text-primary);
  border-radius: 10px 10px 2px 10px;
}

.chat-msg.assistant .chat-bubble {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 10px 10px 10px 2px;
}

.chat-msg.assistant .chat-bubble em {
  color: var(--accent-cyan);
  font-style: normal;
}

.chat-action-result {
  font-size: 10px;
  color: var(--accent-green);
  padding: 4px 8px;
  background: rgba(0,255,136,0.08);
  border: 1px solid rgba(0,255,136,0.2);
  border-radius: 4px;
  margin-top: 4px;
  align-self: flex-start;
}

.chat-thinking {
  display: flex; gap: 4px; align-items: center;
  padding: 9px 13px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: fit-content;
}
.chat-thinking span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: drip-bounce 1.2s infinite;
}
.chat-thinking span:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking span:nth-child(3) { animation-delay: 0.4s; }

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: rgba(0,245,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 8px 10px;
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color var(--t);
}
.chat-input:focus { border-color: var(--accent-cyan); }
.chat-input::placeholder { color: var(--muted); }

/* ── Ingest status toast */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(8,18,28,0.95);
  border: 1px solid var(--accent-cyan);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 11px;
  color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
  z-index: 300;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ── Detailed logs modal ─────────────────────────────────────────────────── */
.logs-modal-box {
  width: min(1100px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.logs-meta {
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.logs-content {
  flex: 1;
  min-height: 320px;
  max-height: 62vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Read-only snapshot pill ─────────────────────────────────────────────── */
.readonly-pill {
  margin-left: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background: rgba(0, 245, 255, 0.06);
  white-space: nowrap;
  cursor: help;
}
