:root {
  --ink: #102a43;
  --ink-soft: #334e68;
  --muted: #627d98;
  --line: #d9e2ec;
  --surface: #f5f8fa;
  --paper: #ffffff;
  --teal: #147d8b;
  --teal-dark: #0b3c49;
  --teal-pale: #d9f3f4;
  --gold: #c78a19;
  --green: #2f855a;
  --header-height: 68px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input, a { font: inherit; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  transform: translateY(-160%);
  color: var(--paper);
  background: var(--ink);
}
.skip-link:focus { transform: none; }

.brandbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brandbar img { width: 54px; height: 52px; object-fit: contain; }
.brand-lockup { min-width: 190px; }
.brand-name { margin: 0; font-size: 17px; font-weight: 820; line-height: 1.1; }
.brand-sub { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.release {
  padding: 5px 7px;
  color: var(--teal-dark);
  background: var(--teal-pale);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
}
.view-links { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.view-links a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}
.view-links a:hover { color: var(--teal); }
.icon-controls { display: flex; gap: 6px; padding-left: 8px; border-left: 1px solid var(--line); }
.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.icon-button:hover, .icon-button[aria-pressed="true"] { color: var(--teal); border-color: var(--teal); background: var(--teal-pale); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  padding: 28px clamp(20px, 4vw, 58px) 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 11px; font-weight: 850; text-transform: uppercase; }
h1 { max-width: 850px; margin: 0; font-size: clamp(34px, 4vw, 56px); line-height: 1.02; letter-spacing: 0; }
.intro-copy { max-width: 820px; margin: 10px 0 0; color: var(--ink-soft); font-size: 15px; line-height: 1.55; }
.status-line { margin: 0 0 3px; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }

.mobile-phase-selector { display: none; }
.app-grid {
  display: grid;
  grid-template-columns: 74px minmax(500px, .95fr) minmax(500px, 1.05fr);
  align-items: start;
}
.phase-rail {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--ink);
}
.phase-rail a {
  min-height: 74px;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 8px 4px;
  color: #bcccdc;
  border-bottom: 1px solid rgba(255,255,255,.11);
  text-decoration: none;
  text-align: center;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.25;
}
.phase-rail strong { display: block; color: #829ab1; font-size: 10px; }
.phase-rail a:hover, .phase-rail a.active { color: var(--paper); background: var(--teal-dark); box-shadow: inset 4px 0 0 var(--gold); }
.phase-rail a.active strong { color: #fff4d6; }

.deep-dives { min-width: 0; background: var(--paper); border-right: 1px solid var(--line); }
.phase-section {
  min-height: 720px;
  padding: 44px clamp(28px, 3vw, 48px) 54px;
  scroll-margin-top: var(--header-height);
  border-bottom: 1px solid var(--line);
}
.phase-section:focus { outline: none; }
.phase-section.is-active { box-shadow: inset 4px 0 0 var(--teal); }
.phase-heading { display: grid; grid-template-columns: 58px 1fr; gap: 15px; align-items: start; }
.phase-number {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 850;
}
.phase-section.is-active .phase-number { background: var(--teal); }
.phase-kicker { margin: 0 0 4px; color: var(--teal); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.phase-heading h2 { margin: 0; font-size: clamp(27px, 2.8vw, 40px); line-height: 1; }
.core-question { max-width: 610px; margin: 9px 0 0; color: var(--ink-soft); font-size: 17px; line-height: 1.35; font-weight: 680; }
.outcome-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 18px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.outcome-row span { color: var(--muted); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.outcome-row strong { color: var(--teal-dark); font-size: 13px; text-align: right; }
.operation-band { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.operation-cell { min-width: 0; padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.operation-cell:nth-child(2n) { border-right: 0; }
.operation-cell:nth-last-child(-n+2) { border-bottom: 0; }
.operation-cell.gate { background: var(--surface); }
.operation-cell.output { background: var(--teal-pale); }
.operation-cell h3 { margin: 0 0 7px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.operation-cell ul { margin: 0; padding-left: 16px; color: var(--ink-soft); font-size: 11px; line-height: 1.55; }
.operation-cell p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.45; }
.modules-title { margin: 24px 0 7px; font-size: 12px; text-transform: uppercase; }
.module-entry {
  display: grid;
  grid-template-columns: minmax(150px, .8fr) minmax(0, 1.35fr) auto;
  gap: 15px;
  align-items: start;
  padding: 15px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.module-entry:hover, .module-entry.is-selected { background: linear-gradient(to right, rgba(217,243,244,.58), transparent 70%); }
.module-entry h4 { margin: 0 0 5px; font-size: 13px; }
.weight { display: inline-flex; min-height: 22px; align-items: center; padding: 0 6px; color: var(--teal-dark); background: var(--teal-pale); border-radius: 3px; font-size: 9px; font-weight: 850; }
.module-role { margin: 0 0 7px; color: var(--ink-soft); font-size: 11px; line-height: 1.4; }
.module-meta { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.48; }
.module-meta strong { color: var(--ink-soft); }
.open-module {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  color: var(--teal-dark);
  border: 1px solid var(--teal);
  border-radius: 5px;
  text-decoration: none;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.open-module:hover { color: var(--paper); background: var(--teal-dark); }

.graph-shell {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  min-height: 620px;
  scroll-margin-top: var(--header-height);
  display: grid;
  grid-template-rows: minmax(310px, 58%) minmax(270px, 42%);
  color: var(--paper);
  background: #071d2b;
  overflow: hidden;
}
.graph-stage { position: relative; min-height: 0; overflow: hidden; background: #071d2b; }
#graph { position: absolute; inset: 0; touch-action: none; }
#graph canvas { display: block; }
.graph-label {
  position: absolute;
  top: 18px;
  left: 20px;
  z-index: 4;
  pointer-events: none;
}
.graph-label p { margin: 0 0 3px; color: #9fb3c8; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.graph-label h2 { margin: 0; font-size: 17px; }
.graph-mode {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 6;
  display: inline-flex;
  padding: 3px;
  background: rgba(7,29,43,.92);
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 4px;
}
.graph-mode button { min-height: 44px; padding: 0 10px; color: #bcccdc; background: transparent; border: 0; border-radius: 3px; cursor: pointer; font: inherit; font-size: 9px; font-weight: 850; }
.graph-mode button[aria-pressed="true"] { color: var(--ink); background: #8ee5e8; }
.graph-mode button:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
.graph-legend {
  position: absolute;
  right: 16px;
  bottom: 13px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 10px;
  max-width: 320px;
  color: #bcccdc;
  font-size: 9px;
  pointer-events: none;
}
.graph-legend span { display: inline-flex; align-items: center; gap: 5px; }
.graph-legend i { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--teal); }
.graph-legend .module i { background: #66d9df; }
.graph-legend .artifact i { background: var(--gold); }
.graph-legend .support i { background: #9fb3c8; }
.graph-tooltip { color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 11px; }
.graph-fallback {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  place-content: center;
  padding: 28px;
  color: var(--paper);
  background: #071d2b;
  text-align: center;
}
.graph-fallback.visible { display: grid; }
.graph-fallback h3 { margin: 0 0 9px; }
.graph-fallback p { max-width: 450px; margin: 0 auto 15px; color: #bcccdc; line-height: 1.5; }
.graph-fallback a { color: #8ee5e8; }

.inspector {
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 22px;
  background: var(--ink);
  border-top: 1px solid rgba(255,255,255,.12);
}
.inspector-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.entity-type { margin: 0 0 4px; color: #8ee5e8; font-size: 9px; font-weight: 850; text-transform: uppercase; }
.inspector h3 { margin: 0; font-size: 19px; }
.entity-status { color: #bcccdc; font-size: 10px; white-space: nowrap; }
.entity-role { margin: 10px 0 12px; color: #d9e2ec; font-size: 11px; line-height: 1.5; }
.property-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.property-table th, .property-table td { padding: 7px 0; border-top: 1px solid rgba(255,255,255,.11); vertical-align: top; text-align: left; }
.property-table th { width: 34%; color: #9fb3c8; font-weight: 650; }
.property-table td { color: #f0f4f8; }
.relationship-list { margin: 10px 0 0; padding: 0; list-style: none; }
.relationship-list button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 0;
  color: #d9e2ec;
  background: transparent;
  border: 0;
  border-top: 1px solid rgba(255,255,255,.1);
  cursor: pointer;
  text-align: left;
  font-size: 9px;
}
.relationship-list b { color: #8ee5e8; }
.transferred-artifact { display: block; margin-left: auto; color: #9fb3c8; font-size: 8px; text-align: right; }
.inspector-command {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  padding: 0 12px;
  color: var(--ink);
  background: #8ee5e8;
  border-radius: 4px;
  text-decoration: none;
  font-size: 10px;
  font-weight: 850;
}
.semantic-explorer { margin-top: 12px; border-top: 1px solid rgba(255,255,255,.12); }
.semantic-explorer summary { min-height: 44px; display: flex; align-items: center; color: #d9e2ec; cursor: pointer; font-size: 10px; font-weight: 750; }
.entity-search { width: 100%; min-height: 44px; padding: 0 10px; color: var(--ink); border: 1px solid transparent; border-radius: 4px; }
.entity-results { max-height: 130px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 7px; overflow: auto; }
.entity-results button { min-height: 44px; padding: 5px 7px; color: #d9e2ec; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 3px; cursor: pointer; text-align: left; font-size: 9px; }
.entity-results button:hover { background: rgba(142,229,232,.14); }
.semantic-map { display: none; }
.semantic-map.visible { display: block; padding: 20px; color: var(--ink); background: var(--surface); }
.semantic-map h2 { margin-top: 0; }
.semantic-map ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-left: 20px; }
.semantic-map a { color: var(--teal-dark); }
.noscript-fallback {
  padding: 26px clamp(20px, 4vw, 58px);
  color: var(--paper);
  background: var(--ink);
  border-top: 1px solid rgba(255,255,255,.12);
}
.noscript-fallback h2 { margin: 0 0 8px; font-size: 20px; }
.noscript-fallback p { margin: 0 0 10px; color: #d9e2ec; line-height: 1.5; }
.noscript-fallback a { color: #8ee5e8; }

@media (max-width: 1180px) {
  .brand-sub { display: none; }
  .app-grid { grid-template-columns: 58px minmax(430px, .9fr) minmax(480px, 1.1fr); }
  .phase-rail a { font-size: 8px; }
  .phase-section { padding-left: 26px; padding-right: 26px; }
  .module-entry { grid-template-columns: minmax(130px, .75fr) minmax(0, 1.25fr); }
  .open-module { grid-column: 1 / -1; width: max-content; }
}

@media (max-width: 800px) {
  :root { --header-height: 62px; }
  .brandbar { min-height: var(--header-height); padding: 5px 10px; gap: 8px; }
  .brandbar img { width: 45px; height: 44px; }
  .brand-lockup { min-width: 0; }
  .brand-name { font-size: 14px; }
  .release, .view-links { display: none; }
  .icon-controls { margin-left: auto; padding-left: 0; border-left: 0; gap: 4px; }
  .icon-button { width: 44px; height: 44px; }
  .intro { grid-template-columns: 1fr; gap: 12px; padding: 24px 18px 20px; }
  h1 { font-size: 34px; }
  .intro-copy { font-size: 13px; }
  .status-line { white-space: normal; font-size: 10px; }
  .mobile-phase-selector {
    position: sticky;
    top: var(--header-height);
    z-index: 40;
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    overflow-x: auto;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }
  .mobile-phase-selector a { min-width: 74px; min-height: 44px; display: grid; place-items: center; padding: 4px 8px; color: var(--ink-soft); border-radius: 4px; text-decoration: none; font-size: 9px; font-weight: 800; }
  .mobile-phase-selector a.active { color: var(--paper); background: var(--teal-dark); }
  html[data-graph-mode="navigation"] .mobile-phase-selector { display: none; }
  html[data-graph-mode="navigation"] .graph-label { top: 50px; }
  html[data-graph-mode="navigation"] .graph-mode { top: 88px; }
  .app-grid { display: flex; flex-direction: column; }
  .phase-rail { display: none; }
  .graph-shell { position: relative; top: auto; order: 0; width: 100%; height: auto; min-height: 0; grid-template-rows: 44vh auto; }
  .graph-stage { min-height: 330px; }
  .inspector { height: 330px; padding: 16px 18px 20px; }
  .deep-dives { order: 1; width: 100%; border-right: 0; }
  .phase-section { min-height: 0; padding: 34px 18px 44px; scroll-margin-top: 108px; }
  .phase-heading { grid-template-columns: 48px 1fr; gap: 12px; }
  .phase-number { width: 44px; height: 44px; }
  .phase-heading h2 { font-size: 30px; }
  .core-question { font-size: 15px; }
  .operation-band { grid-template-columns: 1fr; }
  .operation-cell { border-right: 0; }
  .operation-cell:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
  .operation-cell:last-child { border-bottom: 0; }
  .module-entry { grid-template-columns: 1fr; gap: 8px; }
  .open-module { grid-column: auto; }
  .graph-legend { max-width: 220px; }
  .semantic-map ol { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .brand-name { max-width: 92px; }
  .graph-stage { min-height: 320px; }
  .graph-label { left: 14px; top: 14px; }
  .graph-label h2 { font-size: 15px; }
  .graph-mode { top: 58px; left: 14px; right: auto; }
  .graph-legend { left: 14px; right: auto; justify-content: flex-start; }
}

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

@media print {
  .brandbar { position: static; }
  .icon-controls, .mobile-phase-selector, .phase-rail, .graph-shell { display: none !important; }
  .intro { padding: 16px 0; }
  .app-grid { display: block; }
  .deep-dives { border: 0; }
  .phase-section { min-height: 0; padding: 20px 0; break-inside: avoid; box-shadow: none !important; }
  .module-entry { break-inside: avoid; }
  .open-module { border-color: var(--line); }
}
