:root {
  color-scheme: light;
  --bg: #f6f3ef;
  --surface: #fffdfa;
  --surface-strong: #ffffff;
  --ink: #17201b;
  --muted: #5f6d66;
  --line: #dad3ca;
  --line-strong: #c7bdb0;
  --blue: #256f9b;
  --blue-soft: #e6f3f8;
  --green: #3f7d58;
  --green-soft: #e7f2ea;
  --orange: #bd6b2a;
  --orange-soft: #faece0;
  --purple: #725ca8;
  --purple-soft: #eee9f7;
  --gold: #9d7a23;
  --gold-soft: #f7efd9;
  --shadow: 0 18px 50px rgba(54, 43, 28, 0.12);
  --radius: 8px;
  --max: 1180px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111715;
  --surface: #18211e;
  --surface-strong: #202b27;
  --ink: #eef3ef;
  --muted: #a9b5ad;
  --line: #33413b;
  --line-strong: #48574f;
  --blue: #73b6dc;
  --blue-soft: #163040;
  --green: #88c99e;
  --green-soft: #193626;
  --orange: #e5a16a;
  --orange-soft: #3e2719;
  --purple: #b7a4ee;
  --purple-soft: #2b2540;
  --gold: #e2c46b;
  --gold-soft: #3b3119;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 340px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

code {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-strong) 84%, var(--blue-soft));
  color: var(--ink);
  padding: 0.05rem 0.32rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 3px;
  background: transparent;
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--orange));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px max(20px, calc((100vw - var(--max)) / 2));
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 190px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 800;
  font-size: 0.86rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  line-height: 1.05;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 74%, transparent);
}

.topnav a {
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.theme-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  cursor: pointer;
}

.toggle-icon {
  width: 17px;
  height: 17px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: inset -5px -3px 0 color-mix(in srgb, var(--surface) 90%, var(--ink));
}

.band {
  width: min(var(--max), calc(100vw - 40px));
  margin: 0 auto;
  padding: 70px 0;
}

.band.compact {
  padding-top: 36px;
  padding-bottom: 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.14fr) minmax(320px, 0.86fr);
  gap: 28px;
  align-items: stretch;
  min-height: min(760px, calc(100vh - 72px));
  padding-top: 58px;
  padding-bottom: 44px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: min(480px, calc(100vh - 220px));
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--orange);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 18px;
  font-size: clamp(3rem, 7.2vw, 5.9rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.12rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.lede {
  max-width: 710px;
  color: var(--muted);
  font-size: 1.16rem;
}

.hero-actions,
.filter-group,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.button,
.filter,
.segment {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.button {
  padding: 0 17px;
}

.button.primary,
.filter.active,
.segment.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}

.button:hover,
.filter:hover,
.segment:hover {
  transform: translateY(-1px);
}

.system-snapshot {
  align-self: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.snapshot-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--green-soft) 66%, var(--surface));
  font-weight: 800;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 18%, transparent);
}

.system-snapshot dl {
  margin: 0;
}

.system-snapshot div:not(.snapshot-header) {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.system-snapshot div:last-child {
  border-bottom: 0;
}

.system-snapshot dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.system-snapshot dd {
  margin: 0;
}

.section-heading {
  max-width: 830px;
  margin-bottom: 24px;
}

.section-heading p:not(.eyebrow) {
  color: var(--muted);
}

.section-heading.split {
  display: flex;
  max-width: none;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.quick-card,
.decision,
.role-card,
.concept,
.timeline article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(54, 43, 28, 0.06);
}

.quick-card {
  display: flex;
  min-height: 174px;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
}

.quick-card:hover,
.concept:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.card-kicker {
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 900;
}

.quick-card span:last-child {
  color: var(--muted);
  font-size: 0.92rem;
}

.segmented {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
}

.segment {
  min-width: 102px;
  min-height: 38px;
  padding: 0 16px;
  border-color: transparent;
}

.map-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.map-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
}

.map-panel[hidden] {
  display: none;
}

.layer-label {
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.node-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.node-row.two {
  grid-template-columns: 0.82fr 1.18fr;
}

.node-row.data {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.node {
  min-height: 116px;
  border: 1px solid var(--line);
  border-top-width: 4px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  cursor: pointer;
  padding: 16px;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.node span,
.node small {
  display: block;
}

.node span {
  overflow-wrap: anywhere;
  font-weight: 850;
  line-height: 1.2;
}

.node small {
  margin-top: 8px;
  color: var(--muted);
}

.node:hover,
.node.active {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(54, 43, 28, 0.1);
}

.node.active {
  outline: 2px solid color-mix(in srgb, var(--ink) 38%, transparent);
  outline-offset: 2px;
}

.node.app {
  border-top-color: var(--blue);
}

.node.staff {
  border-top-color: var(--orange);
}

.node.respondent,
.node.data-node {
  border-top-color: var(--green);
}

.node.worker {
  border-top-color: var(--purple);
}

.node.edge {
  border-top-color: var(--gold);
}

.node.ai,
.node.context {
  border-top-color: var(--purple);
}

.connector-line {
  height: 32px;
  margin: 5px 0;
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) center / 1px 100% no-repeat,
    linear-gradient(90deg, transparent 10%, var(--line) 10% 90%, transparent 90%) center / 100% 1px no-repeat;
}

.connector-line.fan {
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) center / 1px 100% no-repeat,
    linear-gradient(90deg, var(--line) 0%, var(--line) 100%) center / 84% 1px no-repeat;
}

.detail-card {
  position: sticky;
  top: 92px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.detail-kind {
  margin-bottom: 8px;
  color: var(--orange);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.detail-card p:not(.detail-kind) {
  color: var(--muted);
}

.detail-files {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 20px;
}

.detail-files span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 80%, var(--blue-soft));
  padding: 5px 9px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
}

.split-content {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 42px;
  align-items: start;
}

.sticky-title {
  position: sticky;
  top: 92px;
}

.decision-list {
  display: grid;
  gap: 14px;
}

.decision {
  position: relative;
  padding: 22px 24px 22px 74px;
}

.decision-number {
  position: absolute;
  top: 22px;
  left: 22px;
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.78rem;
  font-weight: 900;
}

.decision p {
  margin-bottom: 0;
  color: var(--muted);
}

.flow {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.flow-step {
  display: grid;
  width: 100%;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 18px;
  text-align: left;
  cursor: pointer;
}

.flow-step.open {
  background: color-mix(in srgb, var(--blue-soft) 48%, var(--surface));
}

.step-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 900;
}

.step-title {
  min-width: 0;
  font-weight: 850;
}

.step-meta {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  white-space: nowrap;
}

.flow-panel {
  border-bottom: 1px solid var(--line);
  padding: 0 18px 18px 78px;
  color: var(--muted);
}

.flow-panel[hidden] {
  display: none;
}

.role-grid,
.concept-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.filter {
  min-height: 38px;
  padding: 0 14px;
}

.role-card,
.concept {
  padding: 21px;
}

.role-card[hidden],
.concept[hidden] {
  display: none;
}

.role-code {
  display: inline-flex;
  margin-bottom: 14px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  padding: 4px 9px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.role-card[data-role="staff"] .role-code {
  background: var(--orange-soft);
  color: var(--orange);
}

.role-card[data-role="respondent"] .role-code {
  background: var(--purple-soft);
  color: var(--purple);
}

.role-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.role-card li + li {
  margin-top: 8px;
}

.search-box {
  display: grid;
  gap: 6px;
  min-width: min(420px, 100%);
}

.search-box span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 12px 16px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 16%, transparent);
}

.concept {
  display: flex;
  min-height: 192px;
  flex-direction: column;
}

.concept p {
  color: var(--muted);
}

.concept a {
  margin-top: auto;
  color: var(--blue);
  font-weight: 850;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--muted);
}

.timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.timeline article {
  position: relative;
  min-height: 250px;
  padding: 24px 20px;
  overflow: hidden;
}

.timeline article::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--orange));
}

.timeline span {
  display: block;
  margin-bottom: 18px;
  color: var(--orange);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.timeline p {
  color: var(--muted);
}

.footer {
  display: flex;
  width: min(var(--max), calc(100vw - 40px));
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto;
  padding: 36px 0 52px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.footer strong {
  color: var(--ink);
}

.footer p {
  margin: 4px 0 0;
}

.footer a {
  color: var(--blue);
  font-weight: 850;
  white-space: nowrap;
}

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

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

  .hero,
  .map-shell,
  .split-content {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 0;
  }

  .hero-copy {
    min-height: auto;
  }

  .system-snapshot,
  .detail-card,
  .sticky-title {
    position: static;
  }

  .quick-grid,
  .timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .node-row,
  .node-row.two,
  .node-row.data,
  .role-grid,
  .concept-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .band {
    width: min(100% - 28px, var(--max));
    padding: 48px 0;
  }

  .topbar {
    padding-inline: 14px;
  }

  .brand {
    min-width: 0;
  }

  .section-heading.split {
    align-items: start;
    flex-direction: column;
  }

  h1 {
    font-size: clamp(2.45rem, 14vw, 4.4rem);
  }

  h2 {
    font-size: clamp(1.9rem, 9vw, 3rem);
  }

  .system-snapshot div:not(.snapshot-header) {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .quick-grid,
  .node-row,
  .node-row.two,
  .node-row.data,
  .role-grid,
  .concept-grid,
  .timeline {
    grid-template-columns: 1fr;
  }

  .node {
    min-height: 96px;
  }

  .flow-step {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .step-meta {
    grid-column: 2;
    justify-self: start;
    white-space: normal;
  }

  .flow-panel {
    padding-left: 70px;
  }

  .decision {
    padding: 70px 18px 20px;
  }

  .decision-number {
    top: 20px;
    left: 18px;
  }

  .footer {
    align-items: start;
    flex-direction: column;
  }
}
