:root {
  --bg: #f4f4f4;
  --panel: #fff;
  --ink: #161616;
  --muted: #525252;
  --line: #dedede;
  --blue: #0f62fe;
  --green: #198038;
  --amber: #f1c21b;
  --red: #da1e28;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #e8e8e8 0, var(--bg) 35rem);
  font-family: var(--sans);
}

.top {
  display: flex;
  align-items: center;
  min-height: 3rem;
  padding: 0 1.4rem;
  color: #fff;
  background: #161616;
}

.brand {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.pill {
  margin-left: auto;
  padding: .25rem .6rem;
  border: 1px solid #525252;
  color: #c6c6c6;
  font: .72rem var(--mono);
}

.pill.ok {
  border-color: var(--green);
  color: #a7f0ba;
  background: #071d0e;
}

.pill.warn {
  border-color: var(--red);
  color: #ffd7d9;
  background: #2d0709;
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(92rem, calc(100% - 2rem));
  margin: 1rem auto 2rem;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem 1.6rem;
  background: #161616;
  color: #f4f4f4;
}

.hero .sub { max-width: 52rem; color: #c6c6c6; }
.hero h1 { max-width: 42rem; margin: .2rem 0 .5rem; font-size: clamp(1.6rem, 3vw, 2.5rem); line-height: 1.1; }

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.hero .eyebrow { color: #a8a8a8; }
.sub { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }

.problem-note {
  display: flex;
  align-items: center;
  align-self: flex-end;
  gap: .45rem;
  min-width: 14rem;
  color: #c6c6c6;
  font-size: .75rem;
}

.dot, .source-status {
  display: inline-block;
  flex: 0 0 auto;
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--green);
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem 1.3rem;
}

h2 { margin: .2rem 0 .35rem; font-size: 1.15rem; }
.controls-actions { display: flex; align-items: end; gap: .75rem; min-width: min(34rem, 50%); }
.field { display: flex; flex: 1; flex-direction: column; gap: .3rem; }
.field-label { color: var(--muted); font-size: .72rem; }
select, input { height: 2.55rem; padding: 0 .7rem; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; }
select:focus, input:focus { outline: 2px solid var(--blue); outline-offset: -2px; }
button { border: 0; font: inherit; cursor: pointer; }
.primary { padding: .7rem 1rem; color: #fff; background: var(--blue); font-weight: 600; white-space: nowrap; }
.primary:hover { background: #0353e9; }
.primary:disabled { cursor: wait; opacity: .55; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(20rem, .75fr); gap: 1rem; align-items: start; }
.main-column, .side-column { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.panel-h { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.mono { color: var(--muted); font: .7rem var(--mono); }
.empty { margin: 0; color: var(--muted); font-size: .85rem; }
.trace { display: flex; flex-direction: column; padding: 1rem 1.25rem; gap: .7rem; }
.trace-step { display: flex; gap: .8rem; padding: .85rem; border: 1px solid var(--line); border-left: 3px solid var(--green); background: #fafafa; }
.trace-index { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; color: #fff; background: var(--green); font: .7rem var(--mono); }
.trace-content { flex: 1; min-width: 0; }
.trace-heading { display: flex; justify-content: space-between; gap: .5rem; }
.trace-heading h3 { margin: 0; font-size: .9rem; }
.trace-system { color: var(--muted); font-size: .75rem; }
.trace-step p { margin: .3rem 0; font-size: .85rem; line-height: 1.4; }
.trace-meta { display: flex; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .7rem; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; padding: 1rem 1.25rem .5rem; }
.metric { padding: .7rem; border-left: 3px solid #8d8d8d; background: #f4f4f4; }
.metric span, .metric small { display: block; color: var(--muted); font-size: .7rem; }
.metric strong { display: block; margin: .2rem 0; font: 1.45rem var(--mono); }
.metric.critical { border-color: var(--red); background: #fff1f1; }
.metric.warning { border-color: var(--amber); background: #fcf4d6; }
.metric.positive { border-color: var(--green); background: #defbe6; }
.disclaimer { margin: .5rem 1.25rem 1rem; padding: .65rem .8rem; color: var(--muted); background: #f4f4f4; font-size: .75rem; }
.findings { display: flex; flex-direction: column; gap: .6rem; padding: 0 1.25rem 1.25rem; }
.finding { border: 1px solid var(--line); border-left: 3px solid var(--amber); background: #fff; }
.finding.high { border-left-color: var(--red); }
.finding summary { display: flex; align-items: center; gap: .65rem; padding: .8rem; cursor: pointer; list-style: none; }
.finding summary::-webkit-details-marker { display: none; }
.severity { padding: .2rem .4rem; color: #8a1a1a; background: #fff1f1; font: .65rem var(--mono); text-transform: uppercase; }
.finding:not(.high) .severity { color: #735c00; background: #fcf4d6; }
.finding-title { flex: 1; font-weight: 600; font-size: .85rem; }
.confidence { color: var(--muted); font-size: .7rem; white-space: nowrap; }
.finding-body { padding: 0 .8rem .85rem 4.4rem; }
.finding-body p { margin: 0 0 .7rem; font-size: .82rem; line-height: 1.5; }
.finding-foot { display: flex; flex-direction: column; gap: .3rem; color: var(--muted); font-size: .72rem; line-height: 1.4; }

.sources { padding: .75rem 1.25rem 1rem; }
.source { display: flex; align-items: center; gap: .6rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.source:last-child { border-bottom: 0; }
.source div { display: flex; flex: 1; flex-direction: column; gap: .15rem; min-width: 0; }
.source strong { font-size: .85rem; }
.source span:not(.source-status):not(.source-label) { color: var(--muted); font-size: .7rem; }
.source-label { color: var(--green); font: .65rem var(--mono); text-transform: uppercase; }

.suggestions { display: flex; flex-wrap: wrap; gap: .4rem; padding: .9rem 1.25rem 0; }
.suggestion { padding: .45rem .55rem; border: 1px solid var(--line); color: var(--muted); background: #fff; font-size: .72rem; text-align: left; }
.suggestion:hover { border-color: var(--blue); color: var(--blue); }
.suggestion:disabled { cursor: wait; opacity: .55; }
.chat-form { display: flex; gap: .5rem; padding: .9rem 1.25rem 1.25rem; }
.chat-form input { flex: 1; min-width: 0; }
.chat-form .primary { padding: .55rem .8rem; }
.chat-panel { overflow: hidden; }
.chat-header { background: #fff; }
.chat-thread { display: flex; flex-direction: column; gap: .9rem; min-height: 12rem; max-height: 27rem; overflow-y: auto; padding: 1rem 1.25rem; background: #f4f4f4; }
.chat-empty { display: flex; align-items: center; justify-content: center; flex: 1; flex-direction: column; gap: .35rem; min-height: 10rem; color: var(--muted); text-align: center; }
.chat-empty strong { color: var(--ink); font-size: .85rem; }
.chat-empty span { font-size: .75rem; }
.chat-message { display: flex; flex-direction: column; gap: .3rem; width: min(80%, 46rem); }
.chat-message.user { align-self: flex-end; align-items: flex-end; }
.chat-message.assistant { align-self: flex-start; align-items: flex-start; }
.chat-role { color: var(--muted); font: .65rem var(--mono); }
.chat-bubble { padding: .75rem .9rem; border: 1px solid var(--line); background: #fff; font-size: .82rem; line-height: 1.5; }
.chat-message.user .chat-bubble { border-color: #0f62fe; color: #fff; background: #0f62fe; }
.chat-message.assistant .chat-bubble { border-left: 3px solid var(--green); }
.chat-bubble p { margin: 0 0 .6rem; }
.chat-bubble p:last-of-type { margin-bottom: .7rem; }
.chat-bubble small { display: block; color: var(--muted); font-size: .68rem; }
.chat-message.user .chat-bubble small { color: #d0e2ff; }
.chat-message.error .chat-bubble { border-left-color: var(--red); color: var(--red); }
.chat-bubble.loading { color: var(--muted); font-style: italic; }
.suggestions-label { padding: .75rem 1.25rem 0; color: var(--muted); font: .65rem var(--mono); text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 800px) {
  .hero, .controls { flex-direction: column; }
  .problem-note { align-self: start; }
  .controls-actions { min-width: 0; }
  .workspace { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .layout { width: calc(100% - 1rem); }
  .top { padding: 0 .8rem; }
  .brand { font-size: .85rem; }
  .trace-heading, .trace-meta, .finding summary { align-items: flex-start; flex-direction: column; }
  .finding-body { padding-left: .8rem; }
}

/* Guided-demo layer: keep the data available, but make the story primary. */
.hero {
  min-height: 15rem;
  align-items: stretch;
  padding: 2rem;
  background: radial-gradient(circle at 85% 15%, #2d4f86 0, #161616 38%);
}

.hero-copy { display: flex; flex-direction: column; justify-content: center; }
.hero h1 { max-width: 38rem; margin: .4rem 0 .8rem; font-size: clamp(2rem, 4vw, 3.35rem); letter-spacing: -.03em; }
.hero .sub { max-width: 36rem; font-size: 1rem; line-height: 1.55; }
.story { align-self: center; width: min(19rem, 100%); padding: 1rem; border: 1px solid #393939; background: rgba(0, 0, 0, .22); }
.story-title { margin: 0 0 .75rem; color: #a8a8a8; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; }
.story-step { display: flex; align-items: center; gap: .65rem; padding: .55rem 0; color: #f4f4f4; font-size: .82rem; }
.story-step + .story-step { border-top: 1px solid #393939; }
.story-step b { display: grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; color: #161616; background: #78a9ff; font-size: .72rem; }

.orientation { display: flex; align-items: center; justify-content: space-between; gap: 2rem; padding: 1.15rem 1.4rem; }
.orientation h2 { margin-top: .3rem; }
.orientation-note { display: flex; align-items: center; gap: .5rem; min-width: 16rem; color: var(--muted); font-size: .75rem; }
.step-label { margin: 0; color: var(--blue); font: .7rem var(--mono); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.panel-help { margin: .25rem 0 0; color: var(--muted); font-size: .78rem; }
.controls { padding: 1.2rem 1.4rem; border-left: 4px solid var(--blue); }
.controls h2 { margin-top: .3rem; }
.controls-actions { min-width: min(38rem, 55%); }
.field-label { font-size: .75rem; }
.primary { border-radius: 2px; box-shadow: 0 2px 4px rgba(15, 98, 254, .2); }

.trace-step { border-left-width: 4px; }
.trace-step.complete { background: #f7fbf8; }
.trace-step.active { border-left-color: var(--blue); background: #edf5ff; }
.trace-index { background: var(--blue); }
.trace-step.complete .trace-index { background: var(--green); }
.trace-heading h3 { font-size: .95rem; }
.trace-explainer { margin-top: .2rem; color: var(--ink); font-size: .78rem; font-weight: 500; }
.trace-meta { margin-top: .45rem; }

.section-title { margin: .7rem 1.25rem .7rem; font-size: .95rem; }
.tag.ok { padding: .25rem .45rem; border: 1px solid var(--green); color: var(--green); background: #defbe6; font: .65rem var(--mono); text-transform: uppercase; }
.source-guide { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; padding: 1rem 1.25rem .4rem; }
.source-guide div { padding: .65rem; border: 1px solid var(--line); background: #fafafa; }
.source-guide strong, .source-guide span { display: block; }
.source-guide strong { margin-bottom: .2rem; font-size: .76rem; }
.source-guide span { color: var(--muted); font-size: .68rem; line-height: 1.35; }
.sources { padding-top: .35rem; }
.footer-note { margin: 0 .25rem; color: var(--muted); font-size: .72rem; text-align: center; }

@media (max-width: 800px) {
  .orientation { align-items: flex-start; flex-direction: column; gap: .7rem; }
  .orientation-note { min-width: 0; }
  .controls-actions { width: 100%; min-width: 0; }
}

@media (max-width: 600px) {
  .hero { padding: 1.4rem; }
  .story { align-self: stretch; width: auto; }
  .controls-actions { align-items: stretch; flex-direction: column; }
  .source-guide { grid-template-columns: 1fr; }
}

/* One-page-at-a-time presentation mode. */
.wizard-nav { display: flex; align-items: center; justify-content: center; gap: .65rem; padding: .25rem 0; }
.wizard-step { display: flex; align-items: center; gap: .45rem; padding: .35rem .45rem; color: var(--muted); background: transparent; font-size: .75rem; cursor: default; }
.wizard-step b { display: grid; place-items: center; width: 1.55rem; height: 1.55rem; border: 1px solid #a8a8a8; border-radius: 50%; font: .7rem var(--mono); }
.wizard-step.active { color: var(--blue); font-weight: 600; }
.wizard-step.active b { border-color: var(--blue); color: #fff; background: var(--blue); }
.wizard-step.done { color: var(--green); }
.wizard-step.done b { border-color: var(--green); color: #fff; background: var(--green); }
.wizard-step:disabled { cursor: not-allowed; opacity: .55; }
.wizard-step.active:disabled { cursor: default; opacity: 1; }
.wizard-line { width: min(5rem, 8vw); height: 1px; background: var(--line); }
.page { display: flex; flex-direction: column; gap: 1rem; min-height: 31rem; }
.page[hidden] { display: none; }
.page-heading { padding: .75rem .2rem 0; }
.page-heading h1 { margin: .35rem 0 .45rem; font-size: clamp(1.65rem, 3vw, 2.5rem); letter-spacing: -.02em; }
.page-heading .sub { max-width: 48rem; font-size: .95rem; }
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .2rem 0; }
.page-actions > div { display: flex; gap: .5rem; }
.page-actions .ghost { padding: .7rem 1rem; }

@media (max-width: 600px) {
  .wizard-nav { justify-content: space-between; gap: .1rem; }
  .wizard-step { padding: .25rem .1rem; }
  .wizard-step span { display: none; }
  .wizard-line { width: 100%; }
  .page { min-height: 0; }
}
