:root {
  color-scheme: light;
  --white: #ffffff;
  --canvas: #f7f9fc;
  --ink: #11151d;
  --muted: #626a78;
  --faint: #8c94a2;
  --line: #d9dee7;
  --line-strong: #c4cad5;
  --blue: #075ee6;
  --blue-dark: #0349b8;
  --blue-soft: #edf4ff;
  --risk: #c5161d;
  --risk-soft: #fff1f1;
  --success: #118346;
  --heading: "Aptos Narrow", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--white); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--white);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
}

button, input { font: 600 0.94rem/1 var(--body); }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid rgba(7, 94, 230, 0.28);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 34px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--heading);
  font-size: 1.55rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 29px;
  height: 35px;
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar > p { margin: 0; color: var(--muted); font-size: 0.96rem; }
.topbar-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 31%) 1fr;
  min-height: calc(100vh - 128px);
}

.change-panel {
  padding: clamp(42px, 5vw, 76px) clamp(30px, 4vw, 62px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--heading); }
h1 {
  max-width: 480px;
  margin-bottom: 16px;
  font-size: clamp(2.1rem, 3.2vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}
.lede { max-width: 430px; color: var(--muted); font-size: 1.14rem; line-height: 1.55; }

.change-facts { margin: clamp(42px, 7vh, 72px) 0; border-top: 1px solid var(--line); }
.change-facts div {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  min-height: 88px;
  border-bottom: 1px solid var(--line);
}
.change-facts dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.change-facts dd { margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.change-facts dd span::before { content: "·"; margin-right: 9px; color: var(--faint); }
.change-facts code { font-family: var(--mono); font-size: 0.9rem; }

.run-region { margin-top: auto; }
.primary-button {
  width: 100%;
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--white);
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 4px;
  transition: background 160ms ease, transform 160ms ease;
}
.primary-button:hover { background: var(--blue-dark); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: wait; background: #7d9fd2; border-color: #7d9fd2; }
.primary-button svg { width: 18px; fill: currentColor; }
.run-region p { margin: 14px 0 0; text-align: center; color: var(--muted); font-size: 0.84rem; }

.decision-panel { padding: 30px clamp(30px, 4.2vw, 70px) 34px; overflow: hidden; }
.decision-heading-row, .section-heading-row { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
.decision-heading-row { min-height: 46px; }
.decision-heading-row h2 { margin: 0; font-size: 1.45rem; }
.decision-heading-row span, .section-heading-row span { color: var(--muted); font-size: 0.8rem; }

.empty-state, .loading-state, .error-state {
  min-height: 430px;
  display: grid;
  place-content: center;
  grid-template-columns: 5px minmax(240px, 520px);
  gap: 28px;
}
.empty-rail, .error-rule { display: block; width: 5px; min-height: 118px; background: var(--blue); }
.empty-state h3, .error-state h3 { margin-bottom: 12px; font-size: 1.8rem; letter-spacing: -0.02em; }
.empty-state p, .error-state p { margin: 0; color: var(--muted); }

.loading-state { display: flex; flex-direction: column; align-items: flex-start; max-width: 620px; margin: auto; }
.progress-line { width: 100%; height: 4px; background: var(--blue-soft); overflow: hidden; position: relative; }
.progress-line::after { content: ""; position: absolute; inset: 0; width: 38%; background: var(--blue); animation: trace 1.2s ease-in-out infinite; }
.loading-state p { margin: 20px 0 12px; font-weight: 700; }
.loading-state ol { margin: 0; padding-left: 20px; color: var(--muted); }

.error-state { background: var(--risk-soft); padding: 38px; min-height: 360px; align-content: center; }
.error-rule { background: var(--risk); }
.access-key-row { display: flex; margin-top: 10px; }
#access-key-form { margin-top: 24px; }
#access-key-form label { display: block; font-size: 0.8rem; font-weight: 750; }
#access-key-form input { min-width: 0; flex: 1; border: 1px solid var(--line-strong); border-radius: 3px 0 0 3px; padding: 12px; background: var(--white); }
#access-key-form button, .text-button { border: 0; color: var(--white); background: var(--ink); padding: 12px 18px; }
.text-button { margin-top: 22px; background: transparent; color: var(--blue); padding: 0; }

.verdict-rule { height: 7px; margin: 11px 0 26px; background: var(--risk); }
.verdict-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.75fr 0.95fr 1.05fr;
  border-bottom: 1px solid var(--line);
  padding-bottom: 23px;
}
.verdict-grid > div { min-height: 68px; display: flex; flex-direction: column; justify-content: center; padding: 0 26px; border-right: 1px solid var(--line); }
.verdict-grid > div:first-child { padding-left: 0; }
.verdict-grid > div:last-child { border-right: 0; padding-right: 0; }
.metric-label { color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.verdict-block strong { color: var(--risk); font: 750 clamp(2.6rem, 4.3vw, 4.2rem)/1 var(--heading); letter-spacing: -0.03em; }
.metric strong { font: 720 1.95rem/1.1 var(--heading); }
.metric span:last-child { color: var(--muted); font-size: 0.84rem; }
.metric #severity { color: var(--risk); font-size: 1.35rem; }
.completeness { flex-direction: row !important; align-items: center; gap: 10px; }
.completeness svg, .validation-row svg { width: 26px; flex: 0 0 auto; fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.decision-summary { margin: 0; padding: 20px 22px; border-left: 5px solid var(--risk); border-bottom: 1px solid var(--line); font-weight: 560; }
.lineage-section { padding: 20px 0 22px; border-bottom: 1px solid var(--line); }
.lineage-section h3, .actions-section h3 { margin: 0; font-size: 1.05rem; }
.lineage-flow { display: grid; grid-template-columns: minmax(170px, 1fr) 80px minmax(230px, 1.3fr) auto; align-items: center; margin-top: 16px; }
.source-node, .lineage-assets li { border: 1px solid var(--line-strong); border-radius: 4px; padding: 11px 14px; background: var(--white); }
.source-node { border-color: var(--blue); }
.source-node code, .lineage-assets strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 650 0.83rem/1.35 var(--mono); }
.source-node span, .lineage-assets span { color: var(--muted); font-size: 0.72rem; }
.lineage-rail { height: 130px; position: relative; }
.lineage-rail::before { content: ""; position: absolute; left: 0; top: 50%; width: 50%; border-top: 2px solid var(--blue); }
.lineage-rail::after { content: ""; position: absolute; left: 50%; top: 16px; bottom: 16px; border-left: 2px solid var(--blue); }
.lineage-rail i { position: absolute; left: 50%; right: 0; border-top: 2px solid var(--blue); }
.lineage-rail i:nth-child(1) { top: 16px; }
.lineage-rail i:nth-child(2) { top: 50%; }
.lineage-rail i:nth-child(3) { bottom: 16px; }
.lineage-assets { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.lineage-assets li { min-width: 0; padding: 7px 11px; }
.more-assets { margin-left: 14px; color: var(--blue); font: 650 0.78rem var(--mono); white-space: nowrap; }

.actions-section { padding: 18px 0 0; }
.action-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.action-list li { display: grid; grid-template-columns: 28px 1fr; gap: 2px 10px; align-content: center; min-height: 72px; padding: 9px 17px; border-right: 1px solid var(--line); }
.action-list li:first-child { padding-left: 0; }
.action-list li:last-child { border-right: 0; }
.action-index { grid-row: span 2; color: var(--blue); font: 650 0.75rem var(--mono); }
.action-list strong { font-size: 0.84rem; }
.action-list li > span:last-child { color: var(--muted); font-size: 0.7rem; line-height: 1.35; }
.validation-row { min-height: 54px; display: flex; align-items: center; gap: 10px; color: var(--success); font-size: 0.82rem; }
.validation-row svg { width: 23px; stroke: var(--success); }
#latency { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 0.72rem; }

footer { min-height: 52px; display: flex; align-items: center; gap: 9px; padding: 0 34px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; }
footer svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }

@keyframes trace { from { transform: translateX(-110%); } to { transform: translateX(280%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .change-panel { border-right: 0; border-bottom: 1px solid var(--line); min-height: auto; }
  .change-facts { margin: 34px 0; }
  .run-region { margin-top: 0; }
  .decision-panel { padding-top: 26px; }
}

@media (max-width: 700px) {
  .topbar { min-height: 66px; padding: 0 20px; }
  .topbar > p { display: none; }
  .topbar-status { font-size: 0; }
  .topbar-status::after { content: "Read-only"; font-size: 0.78rem; }
  .brand { font-size: 1.25rem; }
  .brand-mark { width: 24px; height: 30px; }
  .change-panel, .decision-panel { padding: 34px 20px; }
  h1 { font-size: 2.35rem; }
  .change-facts div { grid-template-columns: 70px 1fr; min-height: 72px; }
  .decision-heading-row { margin-bottom: 8px; }
  .verdict-grid { grid-template-columns: 1fr 1fr; }
  .verdict-grid > div { padding: 14px 12px; border-bottom: 1px solid var(--line); }
  .verdict-grid > div:nth-child(2) { border-right: 0; }
  .verdict-grid > div:nth-child(3), .verdict-grid > div:nth-child(4) { border-bottom: 0; }
  .verdict-block strong { font-size: 3rem; }
  .lineage-flow { grid-template-columns: 1fr; gap: 12px; }
  .lineage-rail { width: 2px; height: 28px; margin-left: 22px; background: var(--blue); }
  .lineage-rail::before, .lineage-rail::after, .lineage-rail i { display: none; }
  .more-assets { margin-left: 0; }
  .action-list { grid-template-columns: 1fr; }
  .action-list li, .action-list li:first-child { padding: 14px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .action-list li:last-child { border-bottom: 0; }
  .validation-row { align-items: flex-start; flex-wrap: wrap; padding-top: 14px; }
  #latency { width: 100%; margin-left: 33px; }
  footer { padding: 0 20px; }
  .error-state { padding: 24px 18px; grid-template-columns: 4px 1fr; gap: 17px; }
  .access-key-row { flex-direction: column; gap: 8px; }
  #access-key-form input, #access-key-form button { width: 100%; border-radius: 3px; }
}
