:root {
  --bg: #f7f7f2;
  --surface: #ffffff;
  --surface-2: #eeeee7;
  --text: #1d211f;
  --muted: #646a66;
  --line: #d8dbd2;
  --accent: #146b5f;
  --accent-2: #9d3f2f;
  --score-good: #167047;
  --score-mid: #9a6500;
  --score-bad: #b42318;
  --shadow: 0 18px 50px rgba(32, 38, 34, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 100;
  transform: translateY(-140%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 14px;
  color: var(--accent);
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 230px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  font-weight: 900;
}

.brand small,
.eyebrow,
.muted,
.result-meta,
.footer,
.section-head p,
.catalog-card p {
  color: var(--muted);
}

.brand small {
  display: block;
  font-size: 12px;
}

.topnav {
  display: flex;
  flex: 1;
  justify-content: flex-end;
  gap: 4px;
  overflow-x: auto;
}

.topnav a,
.button,
.chip {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.topnav a:hover,
.topnav a.active,
.button:hover {
  border-color: var(--line);
  background: var(--surface);
}

.topnav a.active {
  color: var(--accent);
  font-weight: 800;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(280px, 0.8fr);
  align-items: center;
  min-height: calc(100svh - 72px);
  padding: clamp(44px, 7vw, 104px) clamp(18px, 6vw, 86px);
  overflow: hidden;
}

.home-hero {
  border-bottom: 1px solid var(--line);
}

.page-hero {
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--surface-2) 72%, transparent), transparent),
    repeating-linear-gradient(90deg, transparent 0 54px, color-mix(in srgb, var(--line) 42%, transparent) 55px 56px);
}

.code-hero .lead {
  max-width: 980px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--bg) 94%, transparent), color-mix(in srgb, var(--bg) 45%, transparent)),
    repeating-linear-gradient(90deg, transparent 0 48px, color-mix(in srgb, var(--line) 50%, transparent) 49px 50px);
}

.hero-copy,
.hero-visual {
  position: relative;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  max-width: 100%;
  font-size: clamp(26px, 3.2vw, 38px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero h1 {
  max-width: 14ch;
  font-size: clamp(34px, 4.8vw, 54px);
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 20px;
}

.lead {
  max-width: 740px;
  color: var(--muted);
  font-size: clamp(16px, 1.5vw, 19px);
}

.hero-actions,
.search-row,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.ghost {
  border-color: var(--line);
}

.hero-visual {
  min-height: 500px;
}

.ledger-sheet {
  position: absolute;
  right: 5%;
  width: min(450px, 70vw);
  height: 330px;
  border: 1px solid color-mix(in srgb, var(--line), transparent 10%);
  border-radius: 8px;
  background:
    linear-gradient(var(--surface), var(--surface)),
    repeating-linear-gradient(0deg, transparent 0 31px, var(--line) 32px 33px),
    repeating-linear-gradient(90deg, transparent 0 74px, var(--line) 75px 76px);
  box-shadow: var(--shadow);
}

.sheet-a {
  top: 28px;
  transform: rotate(-7deg);
}

.sheet-b {
  top: 100px;
  right: 20%;
  transform: rotate(5deg);
}

.sheet-c {
  top: 176px;
  right: 0;
  transform: rotate(-2deg);
}

.code-stack {
  position: absolute;
  right: 12%;
  top: 235px;
  display: grid;
  gap: 10px;
  width: min(330px, 76vw);
}

.code-stack span {
  padding: 13px 16px;
  border-left: 4px solid var(--accent-2);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 18px;
}

.status-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
  background: var(--surface);
}

.status-band div {
  padding: 24px clamp(18px, 5vw, 56px);
  border-right: 1px solid var(--line);
}

.status-band strong {
  display: block;
  font-size: 34px;
}

.section {
  padding: clamp(52px, 8vw, 96px) clamp(18px, 5vw, 72px);
}

.section-head {
  max-width: 840px;
  margin-bottom: 34px;
}

.catalog-grid,
.etl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.catalog-card,
.result-item,
.etl-item,
.timeline-item,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.catalog-card {
  min-height: 240px;
  padding: 22px;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.catalog-card strong {
  display: block;
  color: var(--accent);
  font-size: 34px;
}

.catalog-card:hover,
.relation-card:hover,
.mini-link:hover,
.linked-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  box-shadow: 0 16px 44px rgba(32, 38, 34, 0.1);
}

.card-stat {
  display: inline-flex;
  margin-top: 12px;
  color: var(--text);
  font-weight: 900;
}

.path,
.code {
  color: var(--accent);
  font-family: Consolas, "Liberation Mono", monospace;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumbs [itemprop="itemListElement"] {
  display: inline-flex;
  align-items: center;
}

.breadcrumbs [itemprop="itemListElement"]::after {
  content: "›";
  margin: 0 10px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.breadcrumbs [itemprop="itemListElement"]:last-child::after {
  content: "";
  margin: 0;
}

.breadcrumbs a {
  color: var(--accent);
  text-decoration: none;
}

.structure-list {
  display: grid;
  gap: 8px;
  padding-left: 22px;
}

.structure-list a,
.result-item h3 a,
.row-link {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
}

.flow-section {
  border-bottom: 1px solid var(--line);
}

.flow-map {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}

.flow-map span {
  min-height: 76px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  color: var(--accent);
  font-weight: 900;
  text-align: center;
}

.flow-map span:last-child {
  border-right: 0;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.relation-strip,
.relation-grid,
.mini-link-grid {
  display: grid;
  gap: 12px;
}

.relation-strip {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.relation-strip a,
.relation-card,
.mini-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
}

.relation-strip a {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 18px;
}

.relation-strip span,
.relation-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.relation-strip strong,
.relation-card strong {
  color: var(--accent);
  font-size: 18px;
}

.relation-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.relation-card {
  display: grid;
  gap: 8px;
  min-height: 148px;
  padding: 18px;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.relation-card p {
  margin: 0;
  color: var(--muted);
}

.mini-link-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.mini-link {
  display: grid;
  gap: 6px;
  padding: 14px;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.mini-link span:last-child {
  color: var(--muted);
}

.risk-score {
  margin-top: 34px;
  padding: 22px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--score-mid);
  border-radius: 8px;
  background: var(--surface);
}

.risk-score-good {
  border-left-color: var(--score-good);
}

.risk-score-mid {
  border-left-color: var(--score-mid);
}

.risk-score-bad {
  border-left-color: var(--score-bad);
}

.risk-score-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.risk-score-value {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 116px;
  justify-content: flex-end;
  color: var(--score-mid);
  font-family: Consolas, "Liberation Mono", monospace;
}

.risk-score-good .risk-score-value {
  color: var(--score-good);
}

.risk-score-bad .risk-score-value {
  color: var(--score-bad);
}

.risk-score-value strong {
  font-size: 54px;
  line-height: 0.9;
}

.risk-score-note {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--score-mid) 35%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--score-mid) 8%, var(--surface));
  color: var(--text);
}

.risk-factor-list {
  display: grid;
  gap: 10px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.risk-factor {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--text);
}

.risk-factor-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 900;
  line-height: 1;
}

.risk-factor-pass .risk-factor-icon {
  background: color-mix(in srgb, var(--score-good) 12%, var(--surface));
  color: var(--score-good);
}

.risk-factor-fail .risk-factor-icon {
  background: color-mix(in srgb, var(--score-bad) 12%, var(--surface));
  color: var(--score-bad);
}

.risk-factor a,
.risk-method-link {
  color: var(--accent);
  font-weight: 800;
  text-underline-offset: 3px;
}

.risk-factor-evidence {
  color: var(--muted);
}

.risk-method-link {
  display: inline-flex;
  margin-top: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  border-block: 1px solid var(--line);
  background: var(--surface-2);
}

.workspace-sidebar,
.workspace-main {
  padding: clamp(24px, 5vw, 56px);
}

.workspace-sidebar {
  border-right: 1px solid var(--line);
}

.search-row {
  position: sticky;
  top: 88px;
  z-index: 3;
  padding-bottom: 14px;
  background: var(--surface-2);
}

input[type="search"] {
  flex: 1 1 320px;
  min-height: 52px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 16px;
  font: inherit;
}

.tool-workspace {
  border-top: 1px solid var(--line);
}

.tool-stats {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.tool-stats div {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.tool-stats strong {
  display: block;
  color: var(--accent);
  font-size: 28px;
}

.tool-stats span {
  color: var(--muted);
}

.tool-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

.tool-filter {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tool-filter.active,
.tool-filter:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--accent);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.tool-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.compact-results {
  gap: 8px;
}

.compact-results .result-item {
  padding: 14px;
}

.compact-results .result-item p {
  display: none;
}

.results {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.result-item,
.etl-item,
.timeline-item,
.side-panel {
  padding: 18px;
}

.content-block {
  display: grid;
  gap: 14px;
  margin-bottom: 22px;
}

.content-grid,
.faq-list {
  display: grid;
  gap: 12px;
}

.content-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 22px;
}

.content-card,
.faq-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.linked-card {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.faq-source {
  color: var(--accent);
  font-weight: 800;
  text-underline-offset: 3px;
}

.result-head,
.code-layout {
  display: grid;
  gap: 18px;
}

.result-head {
  grid-template-columns: 1fr auto;
}

.code-layout {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  align-items: start;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

td a,
.link-list a {
  color: var(--accent);
  font-weight: 700;
}

.link-list {
  display: grid;
  gap: 10px;
  padding-left: 18px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-color: var(--line);
  background: var(--surface);
}

.muted-chip {
  color: var(--muted);
}

.rail-sticky {
  position: sticky;
  top: 96px;
}

.side-divider {
  height: 1px;
  margin: 18px 0;
  background: var(--line);
}

.timeline {
  display: grid;
  gap: 12px;
  counter-reset: phase;
}

.timeline-item {
  display: grid;
  grid-template-columns: 56px 1fr 120px;
  gap: 18px;
  align-items: start;
}

.timeline-item::before {
  counter-increment: phase;
  content: counter(phase, decimal-leading-zero);
  color: var(--accent);
  font-size: 24px;
  font-weight: 900;
}

.api-section {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) 1.2fr;
  gap: 24px;
  align-items: start;
  background: var(--text);
  color: var(--bg);
}

pre {
  margin: 0;
  overflow-x: auto;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 22px;
  color: #fff;
  font-family: Consolas, "Liberation Mono", monospace;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 28px clamp(18px, 5vw, 72px);
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
  }

  .topnav {
    order: 3;
    justify-content: flex-start;
    width: 100%;
  }

  .hero,
  .workspace,
  .api-section,
  .code-layout,
  .flow-map {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .hero-visual {
    min-height: 360px;
  }

  .status-band {
    grid-template-columns: 1fr;
  }

  .status-band div,
  .workspace-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .timeline-item {
    grid-template-columns: 44px 1fr;
  }

  .flow-map span {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .flow-map span:last-child {
    border-bottom: 0;
  }

  .rail-sticky {
    position: static;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .hero-copy {
    animation: rise 520ms ease both;
  }

  .ledger-sheet {
    animation: drift 5s ease-in-out infinite alternate;
  }

  .sheet-b {
    animation-delay: 300ms;
  }

  .sheet-c {
    animation-delay: 600ms;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  from {
    translate: 0 -4px;
  }
  to {
    translate: 0 8px;
  }
}
