/* Deep Research — design tokens: "Lab" (near-black + violet accent) */
:root {
  --bg: #0a0a0c;
  --bg-elevated: #12121a;
  --surface: #16161f;
  --surface-hover: #1c1c28;
  --border: rgba(139, 92, 246, 0.18);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --accent: #8b5cf6;
  --accent-bright: #a78bfa;
  --accent-dim: rgba(139, 92, 246, 0.12);
  --accent-fg: #0c0a12;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --font-ui: "Instrument Sans", system-ui, sans-serif;
  --font-report: "Source Serif 4", Georgia, serif;
}

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

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-bright);
}

/* Hero gradient (subtle) */
.hero-gradient {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, transparent 45%, rgba(34, 211, 238, 0.05) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

/* Sticky top bar */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

/* Layout: two column */
.layout-grid {
  display: grid;
  gap: 1.5rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

@media (min-width: 1024px) {
  .layout-grid {
    grid-template-columns: 1fr 18rem;
    align-items: start;
  }
}

/* Pipeline stepper */
.stepper {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.step {
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem 0;
  position: relative;
  border-left: 2px solid var(--border-subtle);
  padding-left: 1rem;
  margin-left: 0.5rem;
  transition: border-color 0.2s, color 0.2s;
}

.step:last-child {
  border-left-color: transparent;
}

.step .step-dot {
  position: absolute;
  left: -0.4rem;
  top: 0.7rem;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 9999px;
  background: var(--bg-elevated);
  border: 2px solid var(--text-faint);
}

.step.step--complete .step-dot {
  background: var(--success);
  border-color: var(--success);
}

.step.step--active .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.step-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.step--active .step-label,
.step--complete .step-label {
  color: var(--text-muted);
}

.step-title {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.step--active .step-title {
  color: var(--text);
  font-weight: 500;
}

/* Job card */
.job-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 9999px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.job-pill--pending {
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}

.job-pill--running {
  color: var(--accent-bright);
  border-color: var(--border);
  background: var(--accent-dim);
}

.job-pill--done {
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}

.job-pill--failed {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.08);
}

/* Toolbar */
.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border);
}

.btn-ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  font-size: 0.7rem;
  border-radius: 9999px;
  background: var(--accent-dim);
  color: var(--accent-bright);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.chip:hover {
  background: rgba(139, 92, 246, 0.22);
  transform: translateY(-1px);
}

/* Collapsible */
details.log-details > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: 0.5rem 0;
}

details.log-details > summary::-webkit-details-marker {
  display: none;
}

details.log-details .chev {
  transition: transform 0.2s;
  font-size: 0.6rem;
}

details.log-details[open] .chev {
  transform: rotate(90deg);
}

#log {
  max-height: 10rem;
  overflow-y: auto;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--text-faint);
}

#log p {
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.4rem 0;
  margin: 0;
}

#log p:last-child {
  border-bottom: none;
}

.log-icon {
  display: inline;
  color: var(--accent-bright);
  margin-right: 0.35rem;
}

/* Report body — scoped typography */
#out {
  font-family: var(--font-report);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text);
  max-width: 65ch;
}

#out h1,
#out h2,
#out h3 {
  font-family: var(--font-ui);
  line-height: 1.3;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

#out h1 {
  font-size: 1.5rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

#out h2 {
  font-size: 1.2rem;
  color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.35rem;
  margin-top: 2rem;
}

#out h3 {
  font-size: 1.05rem;
  color: var(--text-muted);
}

#out p {
  margin: 0.75rem 0;
}

#out a {
  color: var(--accent-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
}

#out a:hover {
  color: #c4b5fd;
}

#out ul,
#out ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

#out li {
  margin: 0.25rem 0;
}

#out code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.88em;
  background: var(--bg-elevated);
  padding: 0.12em 0.35em;
  border-radius: 0.3rem;
  border: 1px solid var(--border-subtle);
}

#out pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.88em;
}

#out pre code {
  background: none;
  border: none;
  padding: 0;
}

#out blockquote {
  border-left: 3px solid var(--accent);
  margin: 1rem 0;
  padding-left: 1rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Skeleton */
.skeleton {
  min-height: 4rem;
  background: linear-gradient(90deg, var(--surface) 25%, var(--bg-elevated) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: sk 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

/* Print */
@media print {
  .app-header,
  .no-print,
  .btn-ghost,
  .stepper,
  .hero-gradient,
  details {
    display: none !important;
  }

  body {
    background: white;
    color: #111;
  }

  #out {
    max-width: none;
    color: #111;
  }

  #out a {
    color: #1a0dab;
  }

  .report-panel {
    border: none;
    box-shadow: none;
  }
}

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

/* Footer */
.app-footer {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}
