:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fbfc;
  --ink: #101827;
  --muted: #5e6d7f;
  --line: #d8e0ea;
  --teal: #176f72;
  --blue: #245f9f;
  --gold: #a96f19;
  --red: #9a3f3f;
  --green: #2d7c52;
  --violet: #6750a4;
  --shadow: 0 14px 34px rgba(16, 24, 39, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(36, 95, 159, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 111, 114, 0.055) 1px, transparent 1px),
    radial-gradient(circle at 16% 12%, rgba(169, 111, 25, 0.16), transparent 280px),
    var(--bg);
  background-size: 28px 28px, 28px 28px, auto, auto;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(23, 111, 114, 0.42);
  outline-offset: 3px;
}

.console-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 56px;
}

.console-header,
.boundary,
.lineage-panel,
.facts-panel,
.role-panel,
.states-panel,
.side-index,
.source-cards article,
.module-wave,
.decision-gate,
.transfer-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.console-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 18px;
  align-items: end;
  padding: 24px;
  border-top: 5px solid var(--blue);
}

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

h1 {
  margin-top: 8px;
  max-width: 820px;
  font-size: 52px;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
  line-height: 1.16;
  letter-spacing: 0;
}

h3 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.lead {
  max-width: 760px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 17px;
}

.label {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-stack {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.status-stack div {
  min-height: 78px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.status-stack div:nth-child(2) {
  border-left-color: var(--gold);
}

.status-stack div:nth-child(3) {
  border-left-color: var(--red);
}

.status-stack span,
.fact-row span,
.fact-row em,
.role-row span,
.role-row em,
.timeline em,
.module-grid span,
.module-grid em,
.transfer-row em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.status-stack strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.boundary {
  margin-top: 12px;
  border-left: 5px solid var(--red);
  padding: 13px 15px;
}

.console-grid {
  display: grid;
  grid-template-columns: 132px minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: 12px;
  margin-top: 12px;
}

.side-index {
  position: sticky;
  top: 12px;
  grid-row: 1 / span 3;
  align-self: start;
  display: grid;
  gap: 6px;
  padding: 8px;
}

.side-index a {
  display: flex;
  min-height: 38px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: #25364b;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.side-index a:hover {
  background: #eef6f7;
}

.lineage-panel,
.facts-panel,
.states-panel,
.module-wave,
.decision-gate,
.transfer-panel {
  padding: 18px;
}

.section-head {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

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

.timeline li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.timeline li:nth-child(2) {
  border-left-color: var(--blue);
}

.timeline li:nth-child(3) {
  border-left-color: var(--gold);
}

.timeline li:nth-child(4) {
  border-left-color: var(--violet);
}

.timeline li:nth-child(5) {
  border-left-color: var(--green);
}

.timeline span {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--teal);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.timeline strong,
.timeline em {
  grid-column: 2;
}

.fact-table,
.transfer-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.fact-row,
.transfer-row {
  display: grid;
  grid-template-columns: 0.7fr minmax(0, 1fr) 0.75fr;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.fact-row:last-child,
.transfer-row:last-child {
  border-bottom: 0;
}

.fact-row.head,
.transfer-row.head {
  background: #eaf1f7;
  font-weight: 800;
}

.fact-row strong,
.transfer-row strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

#lifecycle,
.role-panel {
  grid-column: 2 / 4;
}

#lifecycle .fact-row {
  grid-template-columns: minmax(120px, 0.55fr) minmax(0, 1.45fr) minmax(0, 1.05fr);
  align-items: start;
}

#lifecycle .fact-row > * {
  min-width: 0;
}

#lifecycle .fact-row span,
#lifecycle .fact-row strong,
#lifecycle .fact-row em {
  overflow-wrap: anywhere;
}

.role-panel {
  display: grid;
  align-self: stretch;
  overflow: hidden;
}

#facts,
#visibility {
  grid-column: 2 / 4;
}

.role-row {
  display: grid;
  grid-template-columns: 0.58fr minmax(0, 1fr) 0.78fr;
  gap: 10px;
  align-items: center;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.role-row:last-child {
  border-bottom: 0;
}

.role-row:nth-child(1) {
  border-left: 5px solid var(--green);
}

.role-row:nth-child(2) {
  border-left: 5px solid var(--blue);
}

.role-row:nth-child(3) {
  border-left: 5px solid var(--gold);
}

.role-row:nth-child(4) {
  border-left: 5px solid var(--teal);
}

.role-row:nth-child(5) {
  border-left: 5px solid var(--violet);
}

.source-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.source-cards article {
  min-height: 170px;
  padding: 18px;
}

.source-cards h3 {
  margin-top: 8px;
}

.source-cards p:not(.label) {
  margin-top: 10px;
  color: var(--muted);
}

.states-panel,
.module-wave,
.decision-gate,
.transfer-panel {
  margin-top: 12px;
}

.state-grid,
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.state-grid article {
  min-height: 138px;
  border: 1px solid #e2bcbc;
  border-left: 5px solid var(--red);
  border-radius: 8px;
  padding: 12px;
  background: #fffafa;
}

.state-grid span {
  display: block;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.state-grid strong {
  display: block;
  margin-top: 7px;
}

.state-grid p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.module-grid div {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 4px 10px;
  min-height: 82px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.module-wave-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 0 14px;
  background: #fbfcfe;
  color: #25364b;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.module-wave-link:hover {
  background: #eef6f7;
}

.module-grid span {
  grid-row: 1 / span 2;
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #eaf1f7;
  color: var(--blue);
  font-weight: 800;
}

.module-grid strong {
  font-size: 14px;
}

.module-grid em {
  grid-column: 2;
}

.decision-gate {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(300px, 1.1fr);
  gap: 18px;
  border-top: 5px solid var(--green);
}

.flow-panel {
  border-top: 5px solid var(--blue);
}

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

.flow-grid article {
  display: grid;
  gap: 8px;
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfe;
}

.flow-grid span,
.flow-status-strip span {
  width: fit-content;
  border: 1px solid #c8d7e4;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef6f7;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.flow-grid strong {
  font-size: 18px;
  line-height: 1.25;
}

.flow-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.flow-status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.decision-gate ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.decision-gate li {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-soft);
}

.decision-gate li span {
  display: inline-flex;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--green);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.transfer-panel {
  border-top: 5px solid var(--gold);
}

@media (max-width: 1100px) {
  .console-header,
  .console-grid,
  .status-stack,
  .source-cards,
  .state-grid,
  .module-grid,
  .flow-grid,
  .decision-gate {
    grid-template-columns: 1fr;
  }

  .side-index {
    position: static;
    grid-row: auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #lifecycle,
  .role-panel,
  #facts,
  #visibility {
    grid-column: auto;
  }

  #lifecycle .fact-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  h1 {
    font-size: 40px;
  }
}

@media (max-width: 680px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .console-shell {
    width: 100%;
    max-width: 100%;
    padding: 12px 12px 56px;
    overflow-x: clip;
  }

  .console-header,
  .lineage-panel,
  .facts-panel,
    .states-panel,
    .module-wave,
    .flow-panel,
    .decision-gate,
    .transfer-panel {
    padding: 16px;
  }

  h1 {
    font-size: 34px;
  }

  h2 {
    font-size: 21px;
  }

  .console-header,
  .status-stack,
  .console-header > *,
  .status-stack > *,
  .boundary,
  .console-grid,
  .side-index,
  .lineage-panel,
  .facts-panel,
  .role-panel,
  .states-panel,
  .module-wave,
  .flow-panel,
  .decision-gate,
  .transfer-panel,
  .fact-table,
  .transfer-table,
  .state-grid,
  .module-grid,
  .flow-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .side-index a,
  .fact-row > *,
  .transfer-row > *,
  .role-row > *,
  .timeline > *,
  .module-grid > *,
  .flow-grid > *,
  .decision-gate > * {
    min-width: 0;
  }

  .console-header p,
  .boundary,
  .side-index a,
  .status-stack strong,
  .status-stack span,
  .timeline strong,
  .timeline em,
  .fact-row span,
  .fact-row strong,
  .fact-row em,
  .transfer-row span,
  .transfer-row strong,
  .transfer-row em,
  .role-row span,
  .role-row strong,
  .role-row em,
  .module-grid strong,
  .module-grid em,
  .flow-grid strong,
  .flow-grid p {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .fact-row,
  .transfer-row,
  .role-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px;
  }

  .side-index,
  .fact-row,
  .role-row,
  .transfer-row {
    grid-template-columns: 1fr;
  }

  .module-grid div {
    grid-template-columns: 34px minmax(0, 1fr);
  }
}
