:root {
  --bg: #0f1115;
  --panel: #171a21;
  --ink: #e6e8eb;
  --muted: #9aa3af;
  --accent: #d9603b;
  --line: #262b35;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
header, main, footer { max-width: 820px; margin: 0 auto; padding: 1.5rem; }
header h1 { margin: 0 0 .25rem; letter-spacing: -.02em; }
.tagline { color: var(--muted); margin: 0; }
label { display: block; margin-bottom: .5rem; color: var(--muted); }
textarea {
  width: 100%;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .75rem;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}
.actions { display: flex; align-items: center; gap: 1rem; margin-top: .75rem; }
button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: .6rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
.htmx-indicator { color: var(--muted); opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator,
.htmx-indicator.htmx-request { opacity: 1; }
.error {
  margin-top: 1.5rem;
  background: #2a1414;
  border: 1px solid #5c2626;
  color: #f3b9b9;
  padding: 1rem 1.25rem;
  border-radius: 10px;
}

/* ── Report ── */
#report { margin-top: 1.5rem; }

.rpt-header {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  padding: 1.25rem 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.rpt-title { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.rpt-verdict {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .2rem .6rem;
  border-radius: 4px;
  width: fit-content;
}
.verdict-critical { background: #5c1a1a; color: #ff8080; border: 1px solid #8b2020; }
.verdict-high     { background: #4a2d0a; color: #ffaa55; border: 1px solid #7a4a10; }
.verdict-medium   { background: #3a3a0a; color: #e0d050; border: 1px solid #606010; }
.verdict-low      { background: #0a3a1a; color: #55cc88; border: 1px solid #105530; }
.verdict-inconclusive { background: #1e222b; color: var(--muted); border: 1px solid var(--line); }

.rpt-primary { margin: 0; font-size: 1.05rem; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.rpt-fmcode  { font-family: ui-monospace, monospace; font-size: .8rem; background: #11141a; padding: .15rem .4rem; border-radius: 4px; color: var(--accent); }
.rpt-cat     { font-size: .78rem; color: var(--muted); }

.rpt-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: none;
  padding: 1rem 1.5rem;
}
.rpt-section:last-child { border-radius: 0 0 10px 10px; }
.rpt-section-title { margin: 0 0 .75rem; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.rpt-chain { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.rpt-chain-step {
  font-family: ui-monospace, monospace;
  font-size: .82rem;
  background: #11141a;
  padding: .25rem .6rem;
  border-radius: 4px;
  color: var(--ink);
}
.rpt-chain-arrow { color: var(--muted); font-size: .9rem; }

.rpt-finding {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .9rem 1rem;
  margin-bottom: .75rem;
  background: #11141a;
}
.rpt-finding:last-child { margin-bottom: 0; }
.rpt-finding-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.rpt-fname { font-weight: 600; }
.rpt-sev {
  font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: .15rem .45rem; border-radius: 4px;
}
.sev-critical { background: #5c1a1a; color: #ff8080; }
.sev-high     { background: #4a2d0a; color: #ffaa55; }
.sev-medium   { background: #3a3a0a; color: #e0d050; }
.sev-low      { background: #0a3a1a; color: #55cc88; }
.rpt-conf { font-size: .78rem; color: var(--muted); margin-left: auto; }

.rpt-quote {
  border-left: 2px solid var(--accent);
  margin: .5rem 0;
  padding: .3rem .75rem;
  font-style: italic;
  color: #c0c8d4;
  background: #0d1017;
  border-radius: 0 4px 4px 0;
}
.rpt-meta { font-size: .78rem; color: var(--muted); margin: .35rem 0; display: flex; gap: 1rem; flex-wrap: wrap; }
.rpt-rem { margin: .5rem 0 0; font-size: .85rem; color: var(--ink); }
.rpt-fm00 { color: var(--muted); font-style: italic; }

.rpt-spec-section .rpt-spec {
  white-space: pre-wrap;
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.6;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .75rem 1rem;
  background: #0d1017;
}
.rpt-escalation { background: #1a1208; border-color: #4a3a10; }
.rpt-esc-summary { margin: 0 0 .5rem; font-weight: 500; }
.rpt-esc-meta { display: flex; gap: 1.5rem; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
footer { color: var(--muted); font-size: .85rem; }

/* ── Pipeline timeline ── */
.timeline {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.tl-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .55rem 0;
  position: relative;
}
.tl-row:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 28px;
  bottom: -6px;
  width: 2px;
  background: var(--line);
}
.tl-parallel {
  padding-left: 1.5rem;
}
.tl-parallel::after { left: calc(9px + 1.5rem) !important; }
.tl-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
  margin-top: 2px;
  transition: border-color .2s, background .2s;
}
.tl-running {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1s infinite;
}
.tl-done {
  border-color: #3a7d44;
  background: #3a7d44;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 6px var(--accent); }
  50%       { box-shadow: 0 0 14px var(--accent); }
}
.tl-body {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .9rem;
  flex: 1;
  min-width: 0;
}
.tl-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem .6rem;
}
.tl-name  { font-weight: 600; }
.tl-desc  { color: var(--muted); }
.tl-model { color: #6b8cba; font-size: .78rem; font-family: ui-monospace, monospace; }
.tl-ms    { color: var(--muted); font-size: .78rem; margin-left: auto; }

.tl-stream {
  margin: .25rem 0 0;
  padding: .5rem .7rem;
  background: #0a0d12;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .72rem;
  line-height: 1.6;
  color: #7a9bbf;
  font-family: ui-monospace, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tl-think {
  grid-column: 1 / -1;
  margin: .3rem 0 0 2rem;
  width: 100%;
}
.tl-think summary {
  font-size: .72rem;
  color: #6b8cba;
  cursor: pointer;
  letter-spacing: .04em;
  text-transform: uppercase;
  user-select: none;
}
.tl-think summary:hover { color: var(--ink); }
.tl-think-text {
  margin: .4rem 0 0;
  padding: .6rem .8rem;
  background: #0d1017;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .75rem;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}
.tl-think-reasoning { color: #6b5fa0; border-color: #2a1f4a; background: #0a0812; }
.tl-think-label { font-size: .65rem; color: #6b5fa0; letter-spacing: .06em; text-transform: uppercase; margin-top: .5rem; }
