/* ==========================================================================
   Deep Research Agent — Modern UI/UX Design System
   ========================================================================== */

:root,
[data-theme="dark"] {
  --bg: #090d16;
  --bg-subtle: #0d131f;
  --panel: #111827;
  --panel-2: #182234;
  --panel-hover: #1e293b;
  --border: #243044;
  --border-subtle: #1c2638;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #8492a6;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --accent-2: #818cf8;
  --accent-glow: rgba(56, 189, 248, 0.16);
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.12);
  --red: #f43f5e;
  --red-bg: rgba(244, 63, 94, 0.12);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245, 158, 11, 0.12);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --topbar-h: 62px;
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-subtle: #eef2f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --panel-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-subtle: #edf2f7;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --accent-2: #6366f1;
  --accent-glow: rgba(2, 132, 199, 0.12);
  --green: #059669;
  --green-bg: rgba(5, 150, 105, 0.1);
  --red: #e11d48;
  --red-bg: rgba(225, 29, 72, 0.08);
  --yellow: #d97706;
  --yellow-bg: rgba(217, 119, 6, 0.1);
  --shadow-sm: 0 1px 4px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.14);
}

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

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ==========================================================================
   TOP NAVIGATION BAR
   ========================================================================== */
.topbar {
  height: var(--topbar-h);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(129, 140, 248, 0.18));
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

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

.topbar h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-pill {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.subtitle {
  color: var(--muted);
  font-size: 11.5px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  font-family: "JetBrains Mono", monospace;
}

.metric-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

/* API Key Dropdown Popover */
.api-dropdown-wrap {
  position: relative;
}

.api-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.api-status-btn:hover {
  border-color: var(--accent);
  background: var(--panel-hover);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.status-dot.warn {
  background: var(--yellow);
}
.status-dot.err {
  background: var(--red);
}

.api-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: fadeSlideDown 0.15s ease-out;
}

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.popover-header strong {
  font-size: 13.5px;
}

.key-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-label input,
.field-label select {
  width: 100%;
  margin-top: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-label input:focus,
.field-label select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.api-feedback {
  font-size: 11.5px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.api-feedback.ok { color: var(--green); border-color: rgba(16, 185, 129, 0.35); background: var(--green-bg); }
.api-feedback.err { color: var(--red); border-color: rgba(244, 63, 94, 0.35); background: var(--red-bg); }

/* ==========================================================================
   APP SHELL & COLLAPSIBLE TABBED SIDEBAR
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
  transition: grid-template-columns 0.22s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h));
  position: sticky;
  top: var(--topbar-h);
  overflow: hidden;
  transition: opacity 0.18s ease, transform 0.22s ease;
}

.app-shell.sidebar-collapsed .sidebar {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-16px);
  border-right: none;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-tab:hover {
  color: var(--text);
  background: var(--panel-hover);
}

.sidebar-tab.active {
  background: var(--panel);
  color: var(--accent);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.sidebar-pane {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.sidebar-pane.active {
  display: flex;
}

.sidebar-section {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
}

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

.section-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.role {
  display: block;
  font-weight: 400;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 8px;
}

/* Sliders in Config */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}

.slider-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
}

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

.slider-val {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 700;
  font-size: 11.5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-family: "JetBrains Mono", monospace;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.model-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.model-grid .role {
  margin-bottom: 2px;
}

/* Badges & Buttons */
.badge {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.badge.accent {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--panel-hover);
}

.btn.sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn.xs {
  padding: 4px 9px;
  font-size: 11.5px;
}

.btn.full-w {
  width: 100%;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-2));
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn.danger {
  background: var(--red-bg);
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--red);
}

.btn.danger:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.2);
}

.btn.ghost {
  background: transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-secondary);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s;
}

.icon-btn.sm {
  width: 26px;
  height: 26px;
  font-size: 12px;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--panel-hover);
}

.link-btn {
  background: none;
  border: none;
  font-size: 11.5px;
  cursor: pointer;
  color: var(--muted);
}
.link-btn.danger-text:hover {
  color: var(--red);
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* Sidebar Lists: Checkpoints, History, Docs, Memory */
.checkpoint-list,
.doc-list,
.memory-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 240px;
  overflow-y: auto;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkpoint-item,
.doc-item,
.memory-item,
.history-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 12px;
  transition: border-color 0.15s, transform 0.12s;
}

.checkpoint-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.cp-topic,
.doc-name,
.h-topic {
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
  line-height: 1.35;
}

.cp-meta,
.doc-kind {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.history-search {
  width: 100%;
  margin-bottom: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.history-search:focus {
  outline: none;
  border-color: var(--accent);
}

.history-stats {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 7px 10px;
  margin-bottom: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", monospace;
}

.history-item {
  cursor: pointer;
  position: relative;
}

.history-item:hover {
  border-color: var(--accent);
  background: var(--panel-hover);
}

.history-item .h-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 10.5px;
  margin-top: 4px;
}

.history-item .h-score-good { color: var(--green); font-weight: 600; }
.history-item .h-score-bad { color: var(--yellow); font-weight: 600; }
.history-item .h-error { color: var(--red); font-weight: 600; }

.history-item .h-del {
  float: right;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 3px;
  border-radius: 4px;
}
.history-item .h-del:hover {
  color: var(--red);
  background: var(--red-bg);
}

/* File Dropzone */
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  transition: all 0.15s;
  margin-bottom: 10px;
}

.file-drop:hover,
.file-drop.drag {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text);
}

.file-drop-icon {
  font-size: 22px;
}

.file-drop-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.file-drop-hint {
  font-size: 11px;
  color: var(--muted);
}

.memory-actions {
  display: flex;
  gap: 6px;
}

.memory-item .meta {
  color: var(--muted);
  font-size: 10.5px;
  margin-bottom: 4px;
}
.memory-item .score-good { color: var(--green); font-weight: 600; }
.memory-item .score-bad { color: var(--red); font-weight: 600; }

.blacklist-item {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 11.5px;
  background: var(--red-bg);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--text-secondary);
}
.blacklist-item .bl-model {
  color: var(--red);
  font-weight: 600;
}

/* ==========================================================================
   MAIN WORKSPACE
   ========================================================================== */
.workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 28px 40px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

/* Command Composer Card */
.query-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.query-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-md);
}

.query-input-wrap textarea {
  width: 100%;
  resize: vertical;
  min-height: 62px;
  max-height: 220px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15.5px;
  font-family: inherit;
  line-height: 1.5;
}

.query-input-wrap textarea:focus {
  outline: none;
}

.query-input-wrap textarea::placeholder {
  color: var(--muted);
}

/* Starter Prompt Chips */
.starter-prompts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.starter-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.starter-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.starter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* Composer Footer */
.query-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.query-meta-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.meta-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.query-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kbd-hint {
  font-size: 10.5px;
  font-family: "JetBrains Mono", monospace;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  color: rgba(255, 255, 255, 0.85);
}

/* ==========================================================================
   PIPELINE STEPPER BAR
   ========================================================================== */
.pipeline-bar {
  padding: 12px 18px;
}

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

.pipeline-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.status-pulse.running {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
  animation: pulseRing 1.5s infinite;
}

.status-pulse.done {
  background: var(--green);
}

.status-pulse.error {
  background: var(--red);
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.status-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.timer-badge {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 2px 9px;
  border-radius: 999px;
}

.phases {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.phase {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border-subtle);
  opacity: 0.45;
  transition: all 0.2s ease;
}

.phase-node {
  font-size: 15px;
}

.phase span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.phase.active {
  opacity: 1;
  background: var(--accent-glow);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.phase.active span {
  color: var(--accent);
}

.phase.completed {
  opacity: 0.92;
  border-color: rgba(16, 185, 129, 0.35);
  background: var(--green-bg);
}

.phase.completed span {
  color: var(--green);
}

/* ==========================================================================
   WORKSPACE TABS & CONTENT PANES
   ========================================================================== */
.workspace-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.workspace-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ws-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.ws-tab:hover {
  color: var(--text);
  background: var(--panel);
}

.ws-tab.active {
  background: var(--panel);
  color: var(--accent);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.workspace-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ws-pane {
  display: none;
}

.ws-pane.active {
  display: block;
  animation: fadeIn 0.16s ease-out;
}

/* Split View Mode: Shows Report on left, Activity + Sources on right */
.workspace-content.split-view {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 16px;
  align-items: start;
}

.workspace-content.split-view .ws-pane {
  display: block !important;
}

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

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-head h2 {
  font-size: 15px;
  font-weight: 700;
}

.inline-filter {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  width: 200px;
}

/* Live Log Terminal */
.log {
  max-height: 460px;
  min-height: 220px;
  overflow-y: auto;
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.log .line {
  padding: 4px 0;
  border-bottom: 1px dashed var(--border-subtle);
  white-space: pre-wrap;
  word-break: break-word;
}

.log .line:last-child {
  border-bottom: none;
}

.log .warn { color: var(--yellow); }
.log .err { color: var(--red); font-weight: 500; }
.log .time {
  color: var(--muted);
  margin-right: 8px;
  font-size: 11px;
  user-select: none;
}

/* Sources Grid */
.sources {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
}

.source-item {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  transition: border-color 0.15s, transform 0.15s;
}

.source-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.source-item .title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}

.source-item a {
  color: var(--accent);
  font-size: 11.5px;
  word-break: break-all;
  text-decoration: none;
}

.source-item a:hover {
  text-decoration: underline;
}

.source-item .role {
  margin-bottom: 0;
  display: inline-block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* Quality Audit / Judge Card */
.judge-body {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.score-ring {
  min-width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 800;
  border: 5px solid var(--green);
  color: var(--green);
  background: var(--green-bg);
  flex-shrink: 0;
}

.score-ring.bad {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-bg);
}

.score-ring.mid {
  border-color: var(--yellow);
  color: var(--yellow);
  background: var(--yellow-bg);
}

.judge-details {
  flex: 1;
  min-width: 240px;
}

.judge-verdict {
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 12px;
}

.judge-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.judge-meta-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
}

.meta-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ==========================================================================
   FINAL REPORT & MARKDOWN TYPOGRAPHY
   ========================================================================== */
.answer-panel {
  padding: 24px 28px;
}

.answer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.answer-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.answer-title-group h2 {
  font-size: 16px;
  font-weight: 700;
}

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

.empty-state {
  text-align: center;
  padding: 48px 20px;
  max-width: 520px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
}

.empty {
  color: var(--muted);
  font-size: 12.5px;
  padding: 12px 0;
}

/* Rich Report Markdown */
.markdown {
  line-height: 1.75;
  font-size: 15px;
  color: var(--text);
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  margin: 24px 0 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.markdown h1 {
  font-size: 22px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.markdown h2 {
  font-size: 18.5px;
  color: var(--accent);
}

.markdown h3 {
  font-size: 16px;
}

.markdown p {
  margin: 10px 0;
  color: var(--text-secondary);
}

.markdown strong {
  color: var(--text);
  font-weight: 600;
}

.markdown ul,
.markdown ol {
  margin: 10px 0 12px 24px;
  color: var(--text-secondary);
}

.markdown li {
  margin: 6px 0;
}

.markdown a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-word;
}

.markdown a:hover {
  text-decoration: underline;
}

.markdown code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: "JetBrains Mono", monospace;
}

.markdown pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  margin: 12px 0;
}

.markdown pre code {
  border: none;
  background: none;
  padding: 0;
}

.markdown blockquote {
  border-left: 3px solid var(--accent-2);
  background: var(--panel-2);
  padding: 10px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  margin: 14px 0;
}

.markdown table {
  border-collapse: collapse;
  margin: 16px 0;
  width: 100%;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.markdown th,
.markdown td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
}

.markdown th {
  background: var(--panel-2);
  font-weight: 600;
  color: var(--text);
}

/* Interactive Citation Pill Markers [1] */
.citation-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0px 6px;
  margin: 0 2px;
  border-radius: 6px;
  background: var(--accent-glow);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--accent) !important;
  font-size: 11.5px;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
  cursor: pointer;
  text-decoration: none !important;
  transition: all 0.15s;
}

.citation-ref:hover {
  background: var(--accent);
  color: #ffffff !important;
  transform: translateY(-1px);
}

/* ==========================================================================
   SLIDE-OVER CITATION INSPECTOR DRAWER
   ========================================================================== */
.citation-drawer {
  position: fixed;
  top: calc(var(--topbar-h) + 16px);
  right: 20px;
  width: 400px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-2);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideInRight 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

.citation-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.citation-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14.5px;
}

.citation-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.citation-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.citation-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.citation-link:hover {
  text-decoration: underline;
}

.citation-quote {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 13.5px;
  line-height: 1.7;
  overflow-y: auto;
  max-height: 360px;
}

.citation-quote .ctx {
  color: var(--muted);
}

.citation-quote mark {
  background: rgba(129, 140, 248, 0.25);
  color: var(--text);
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 600;
}

/* ==========================================================================
   HISTORICAL RUN BANNER
   ========================================================================== */
.history-banner {
  margin-bottom: 16px;
  border-left: 4px solid var(--accent);
  background: var(--panel-2);
}

.history-banner-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.history-banner-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}

.history-banner-actions {
  display: flex;
  gap: 8px;
}

.history-panel-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   ERROR BOX
   ========================================================================== */
.error-box {
  border: 1px solid var(--red);
  background: var(--red-bg);
  border-radius: var(--radius);
  padding: 18px;
  margin: 8px 0;
}

.error-title {
  color: var(--red);
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 8px;
}

.error-fix {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 10px;
}

.error-hint {
  color: var(--muted);
  font-size: 12px;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 1080px) {
  .workspace-content.split-view {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    width: 320px;
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .app-shell.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }
  .workspace {
    padding: 16px;
  }
  .phases {
    grid-template-columns: repeat(4, 1fr);
  }
  .judge-meta-grid {
    grid-template-columns: 1fr;
  }
  .subtitle {
    display: none;
  }
}
