/* ── Variables ─────────────────────────────────────────────────────── */
:root {
  --bg:        #090910;
  --surface:   #111118;
  --surface2:  #0d0d1a;
  --border:    #1c1c2e;
  --border2:   #2a2a45;
  --blue:      #006EFF;
  --blue-dim:  rgba(0, 110, 255, 0.15);
  --green:     #00C07A;
  --amber:     #F59E0B;
  --red:       #F87171;
  --text:      #EEEEF5;
  --muted:     #7878A0;
  --muted2:    #4a4a6a;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Prose ─────────────────────────────────────────────────────────── */
.prose { color: var(--text); }
.prose h1 { font-size: 1.5rem; font-weight: 700; margin: 1.5rem 0 0.75rem; letter-spacing: -0.3px; }
.prose h2 { font-size: 1.2rem; font-weight: 700; margin: 1.5rem 0 0.5rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border2); }
.prose h3 { font-size: 1rem; font-weight: 600; margin: 1.1rem 0 0.375rem; color: var(--blue); }
.prose ul { list-style: none; padding-left: 1.25rem; margin: 0.5rem 0; }
.prose ul > li { position: relative; }
.prose ul > li::before {
  content: "–";
  position: absolute;
  left: -1.25rem;
  color: var(--blue);
  font-weight: 700;
}
.prose ol { list-style: decimal; padding-left: 1.5rem; margin: 0.5rem 0; }
.prose li { margin-bottom: 0.4rem; line-height: 1.65; }
.prose p  { margin-bottom: 0.8rem; line-height: 1.8; }
.prose strong { font-weight: 700; color: var(--text); }
.prose em { color: var(--muted); font-style: italic; }
.prose code {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 0.1em 0.45em;
  font-size: 0.82em;
  font-family: "SF Mono", Consolas, monospace;
  color: #A0A8FF;
}
.prose pre {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
}
.prose pre code { background: none; border: none; padding: 0; color: inherit; }
.prose a {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid rgba(0,110,255,0.35);
  transition: color 0.15s, border-color 0.15s;
}
.prose a:hover { color: #3395ff; border-bottom-color: rgba(0,110,255,0.75); }
.prose blockquote {
  border-left: 3px solid var(--blue);
  padding: 0.5rem 1rem;
  margin: 0.85rem 0;
  color: var(--muted);
  background: var(--blue-dim);
  border-radius: 0 6px 6px 0;
}
.prose hr { border: none; border-top: 1px solid var(--border2); margin: 1.5rem 0; }

.prose-report {
  max-width: 700px;
  margin: 0 auto;
}

/* ── Final report container ────────────────────────────────────────── */
.final-report-wrapper {
  margin: 12px 4px;
  border-radius: 12px;
  border: 1px solid var(--border2);
  background: var(--surface);
  overflow: hidden;
}
.final-report-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  background: linear-gradient(90deg, rgba(0,110,255,0.14) 0%, transparent 80%);
  border-bottom: 1px solid var(--border);
}
.final-report-label {
  font-size: 0.6rem;
  font-family: "SF Mono", Consolas, monospace;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue);
}
.final-report-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--green);
}
.final-report-body {
  padding: 24px 28px 28px;
}
.prose-report h1 {
  font-size: 1.75rem;
  letter-spacing: -0.5px;
  background: linear-gradient(100deg, var(--text) 60%, #8888cc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.prose-report h2 { font-size: 1.3rem; }
.prose-report h3 { font-size: 1.1rem; }
.prose-report p  { line-height: 1.85; }

.prose-sm { font-size: 0.8rem; }
.prose-lg { font-size: 0.92rem; }
.prose-block {
  margin: 10px 0;
  padding: 14px 16px;
  background: rgba(255,255,255,0.015);
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ── Tool result block ─────────────────────────────────────────────── */
.tool-result-block {
  margin: 8px 0;
  padding: 10px 14px;
  background: var(--surface2);
  border-left: 2px solid var(--amber);
  border-radius: 0 6px 6px 0;
}

.type-badge {
  font-size: 0.6rem;
  font-family: "SF Mono", Consolas, monospace;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.type-badge.type-result { color: var(--amber); }
.type-badge.type-text   { color: var(--muted2); }

/* ── Animations ────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0   rgba(0,110,255,0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(0,110,255,0); }
  100% { box-shadow: 0 0 0 0   rgba(0,110,255,0); }
}
@keyframes slide-left {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.spinner { animation: spin 0.75s linear infinite; }
.pulse-ring { animation: pulse-ring 1.4s ease-out infinite; }
.slide-left { animation: slide-left 0.25s ease-out; }
.fade-up    { animation: fade-up 0.3s ease-out; }
.fade-in    { animation: fade-in 0.25s ease-out; }

/* ── Stepper ───────────────────────────────────────────────────────── */
.stepper-step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 600;
  transition: background 0.4s, box-shadow 0.4s, color 0.4s;
  flex-shrink: 0;
}
.step-dot.pending  { background: var(--border); color: var(--muted); }
.step-dot.active   { background: var(--blue); color: #fff; }
.step-dot.active.pulse-ring { }
.step-dot.done     { background: var(--green); color: #fff; }

.step-label {
  font-size: 0.72rem; font-weight: 500;
  transition: color 0.3s, font-weight 0.3s;
}
.step-label.pending  { color: var(--muted2); }
.step-label.active   { color: var(--text); font-weight: 600; }
.step-label.done     { color: var(--muted); }

.step-line {
  flex: 1; height: 2px;
  margin: 0 8px;
  background: var(--border);
  transition: background 0.5s;
}
.step-line.done { background: var(--blue); }

/* ── Sidebar ───────────────────────────────────────────────────────── */
#file-sidebar {
  width: 0;
  opacity: 0;
  overflow: hidden;
  transition: width 0.35s cubic-bezier(0.4,0,0.2,1),
              opacity 0.35s ease;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
#file-sidebar.open {
  width: 230px;
  opacity: 1;
}
#file-sidebar .inner {
  width: 230px;
  padding: 14px 12px;
  overflow-y: auto;
  flex: 1;
}

.file-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  animation: slide-left 0.25s ease-out;
}
.file-icon { font-size: 0.9rem; flex-shrink: 0; margin-top: 1px; }
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.file-status {
  display: flex; align-items: center; gap: 4px;
  margin-top: 3px;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.pending  { background: var(--muted2); }
.status-dot.reading  { background: var(--blue); animation: pulse-ring 1.2s ease-out infinite; }
.status-dot.done     { background: var(--green); }
.status-label { font-size: 0.65rem; }
.status-label.pending { color: var(--muted2); }
.status-label.reading { color: var(--blue); }
.status-label.done    { color: var(--green); }

/* ── Phase tabs ────────────────────────────────────────────────────── */
.phase-tab {
  padding: 10px 16px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  background: none;
  border-top: none; border-left: none; border-right: none;
  white-space: nowrap;
}
.phase-tab:hover { color: var(--text); }
.phase-tab.active { color: var(--text); border-bottom-color: var(--blue); }

/* ── Phase panels ──────────────────────────────────────────────────── */
.phase-panel {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 20px;
}
.phase-panel.report {
  padding: 28px 36px;
}

/* ── Tool pills ────────────────────────────────────────────────────── */
.tool-pill {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  font-size: 0.7rem;
  font-family: "SF Mono", Consolas, monospace;
  margin: 4px 0;
  max-width: 100%;
  flex-wrap: wrap;
}
.tool-name { color: #A0A8FF; font-weight: 600; flex-shrink: 0; }
.tool-arg  { color: var(--muted); word-break: break-word; }

.result-pill {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface2);
  border-left: 2px solid var(--green);
  border-radius: 0 6px 6px 0;
  font-size: 0.68rem;
  font-family: "SF Mono", Consolas, monospace;
  color: var(--muted);
  margin: 4px 0 8px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 80px;
  overflow: hidden;
}

/* ── Delegation block ──────────────────────────────────────────────── */
.delegation-block {
  margin: 6px 0 10px;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  border-left: 2px solid var(--blue);
}
.delegation-header {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blue);
  margin-bottom: 6px;
}
.delegation-body {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.55;
  word-break: break-word;
}

/* ── Error block ───────────────────────────────────────────────────── */
.error-block {
  color: var(--red);
  font-size: 0.85rem;
  padding: 12px;
  background: rgba(248,113,113,0.08);
  border-radius: 8px;
  border: 1px solid rgba(248,113,113,0.2);
}

/* ── Input styling ─────────────────────────────────────────────────── */
#theme-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#theme-input::placeholder { color: var(--muted2); }
#theme-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,110,255,0.2);
}

#generate-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px 22px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
#generate-btn:hover:not(:disabled) {
  background: #0080ff;
  box-shadow: 0 4px 20px rgba(0,110,255,0.4);
}
#generate-btn:active:not(:disabled) { transform: scale(0.98); }
#generate-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a60; }

/* ── Deepset logo mark ─────────────────────────────────────────────── */
.ds-mark {
  width: 26px; height: 26px;
  background: var(--blue);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85rem; color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

/* ── Header ────────────────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  letter-spacing: -0.3px;
}
.brand-sep {
  color: var(--border2);
  font-size: 1.1rem;
  font-weight: 200;
  margin: 0 2px;
}
.brand-subtitle {
  color: var(--muted);
  font-size: 0.8rem;
}
.header-spinner {
  border-color: var(--border2);
  border-top-color: var(--blue);
}
.status-text {
  font-size: 0.75rem;
  color: var(--muted);
}
#new-report-btn {
  background: var(--border);
  color: var(--muted);
  border: 1px solid var(--border2);
}

/* ── Input section ─────────────────────────────────────────────────── */
#input-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  gap: 2.5rem;
  overflow: hidden;
}
.hero-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.hero-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.75rem;
  letter-spacing: -0.5px;
  max-width: 560px;
}
.hero-desc {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0;
  max-width: 480px;
}
.hero-powered {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.hero-model {
  font-size: 0.72rem;
  background: var(--border);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--text);
}
.input-row {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: flex-start;
}
.agent-graph {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1.25rem;
  gap: 0;
}
.ag-top { display: flex; justify-content: center; }
.ag-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.ag-vline {
  width: 1px;
  height: 12px;
  background: var(--border2);
}
.ag-hline {
  width: 72%;
  height: 1px;
  background: var(--border2);
}
.ag-bottom {
  display: flex;
  justify-content: center;
  gap: 20px;
  width: 100%;
}
.ag-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}
.ag-col::before {
  content: '';
  width: 1px;
  height: 12px;
  background: var(--border2);
}
.ag-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--surface);
  font-size: 0.72rem;
  white-space: nowrap;
}
.ag-orchestrator {
  border-color: var(--blue);
  background: var(--blue-dim);
}
.ag-planner  { border-color: var(--border2); color: var(--muted); }
.ag-researcher { border-color: var(--green); background: rgba(0,192,122,0.08); }
.ag-writer   { border-color: var(--amber); background: rgba(245,158,11,0.08); }
.ag-icon { font-size: 0.85rem; }
.ag-name { font-weight: 600; letter-spacing: 0.2px; }
.ag-tools {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.ag-tool {
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border2);
  color: var(--muted);
  background: var(--surface2);
  font-family: "SF Mono", Consolas, monospace;
}

/* ── Run section ───────────────────────────────────────────────────── */
#run-section {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
  overflow: hidden;
  min-height: 0;
}
#stepper {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  gap: 0;
}
#workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}
#workspace main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
#tab-bar {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 4px;
}
#panels-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* ── Sidebar header ────────────────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sidebar-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
#file-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--blue);
  font-family: monospace;
}
#file-stats {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.7;
}
#stat-found { color: var(--text); font-weight: 600; }
#stat-read  { color: var(--green); font-weight: 600; }
