:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: #10151d;
  --panel-2: #151b25;
  --text: #f6f8fb;
  --muted: #aab4c3;
  --line: rgba(255, 255, 255, 0.12);
  --cyan: #42d9ff;
  --green: #48e39b;
  --amber: #ffd166;
  --rose: #ff667f;
  --violet: #9b8cff;
  --shadow: rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 15% 10%, rgba(66, 217, 255, 0.12), transparent 32%),
    radial-gradient(circle at 86% 6%, rgba(72, 227, 155, 0.1), transparent 28%),
    linear-gradient(180deg, rgba(255, 209, 102, 0.05), transparent 460px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

.site-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px clamp(18px, 4vw, 52px);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 13, 0.86);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(66, 217, 255, 0.62);
  background: rgba(66, 217, 255, 0.12);
  color: var(--cyan);
  font-weight: 900;
}

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

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.site-top nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 18px;
  color: #dce8f7;
  font-size: 14px;
}

.site-top nav a {
  border-bottom: 1px solid transparent;
  padding-bottom: 3px;
}

.site-top nav a:hover {
  color: var(--cyan);
  border-color: var(--cyan);
}

main {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 34px 0 72px;
}

.hero,
.module-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(420px, 0.98fr);
  gap: 26px;
  align-items: stretch;
  min-height: 520px;
}

.hero-copy,
.hero-visual,
.system-section,
.modules-section,
.boundary-section,
.module-hero,
.module-visual,
.analysis-panel,
.flow-panel,
.source-panel,
.cv-defense {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.018)),
    var(--panel);
  box-shadow: 0 24px 78px var(--shadow);
}

.hero-copy,
.module-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 58px);
}

.eyebrow,
.boundary-label,
.stage {
  color: var(--green);
  font: 700 12px/1.4 Consolas, "SFMono-Regular", monospace;
  text-transform: uppercase;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 18px;
  font-size: 48px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 12px;
  font-size: 24px;
  line-height: 1.2;
}

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

.lead {
  max-width: 760px;
  color: #d6e1ef;
  font-size: 18px;
  line-height: 1.7;
}

.hero-actions,
.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.primary-action,
.secondary-action,
.page-links a,
.system-card a,
.module-card a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  font-weight: 700;
}

.primary-action {
  background: var(--cyan);
  color: #041017;
  border-color: var(--cyan);
}

.secondary-action,
.page-links a,
.module-card a {
  background: rgba(255, 255, 255, 0.05);
}

.hero-visual,
.module-visual {
  position: relative;
  min-height: 520px;
  overflow: hidden;
}

#x2-canvas,
.module-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 520px;
}

.visual-caption {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 18px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 12px/1.4 Consolas, "SFMono-Regular", monospace;
}

.visual-caption strong {
  color: var(--text);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 22px;
}

.section-head span {
  color: var(--amber);
  font: 800 12px/1 Consolas, "SFMono-Regular", monospace;
}

.section-head h2 {
  margin: 0;
}

.system-section,
.modules-section,
.boundary-section,
.analysis-panel,
.flow-panel,
.source-panel,
.cv-defense {
  margin-top: 26px;
  padding: clamp(22px, 4vw, 34px);
}

.system-grid,
.module-grid,
.analysis-grid,
.core-grid,
.risk-grid {
  display: grid;
  gap: 20px;
}

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

.module-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.analysis-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

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

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

.system-card,
.module-card,
.core-card,
.risk-card {
  min-height: 132px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  padding: 18px;
}

.system-card {
  min-height: 260px;
}

.system-card .pipeline-strip {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  margin: 16px 0;
}

.system-card p,
.module-card p,
.core-card p,
.risk-card {
  color: var(--muted);
  line-height: 1.6;
}

.pipeline-strip,
.flow-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pipeline-strip {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.pipeline-strip li,
.flow-list li {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  padding: 14px;
  color: #e9f2ff;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.flow-list li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.flow-list span {
  color: var(--amber);
  font: 800 12px/1 Consolas, "SFMono-Regular", monospace;
}

.module-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

code,
.module-meta code {
  border: 1px solid rgba(66, 217, 255, 0.28);
  background: rgba(66, 217, 255, 0.08);
  color: #c6f3ff;
  padding: 6px 8px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.module-stage {
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

.kind {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 209, 102, 0.4);
  background: rgba(255, 209, 102, 0.08);
  color: var(--amber);
  padding: 4px 8px;
  font: 800 11px/1 Consolas, "SFMono-Regular", monospace;
  text-transform: uppercase;
}

.line-ref {
  display: block;
  margin-top: 8px;
  color: var(--cyan);
  font: 12px/1 Consolas, "SFMono-Regular", monospace;
}

.concept-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.concept-chip {
  border: 1px solid rgba(72, 227, 155, 0.35);
  background: rgba(72, 227, 155, 0.08);
  color: #ccffe6;
  padding: 8px 10px;
  font: 700 12px/1.2 Consolas, "SFMono-Regular", monospace;
}

.cv-defense {
  color: #e9f2ff;
  font-size: 18px;
  line-height: 1.65;
}

.defend-window {
  margin-top: 26px;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(255, 209, 102, 0.34);
  background:
    linear-gradient(180deg, rgba(255, 209, 102, 0.075), rgba(72, 227, 155, 0.035)),
    var(--panel);
  box-shadow: 0 24px 78px var(--shadow);
}

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

.hdi-card,
.concept-defense-card,
.defend-script {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.hdi-card {
  min-height: 152px;
  padding: 16px;
}

.hdi-card span {
  color: var(--amber);
  font: 800 12px/1.2 Consolas, "SFMono-Regular", monospace;
  text-transform: uppercase;
}

.hdi-card p,
.defend-script p,
.concept-defense-card p {
  color: #dbe8f5;
  line-height: 1.65;
}

.defend-script,
.concept-defense-block {
  margin-top: 18px;
}

.defend-script {
  padding: 18px;
}

.defend-script h3,
.concept-defense-block h3 {
  margin-bottom: 12px;
  color: #fff2bf;
}

.concept-defense-card {
  min-height: 168px;
  padding: 16px;
}

.concept-defense-card strong {
  display: block;
  margin-bottom: 10px;
  color: var(--green);
}

.source-note {
  max-width: 860px;
  color: var(--muted);
  line-height: 1.65;
}

.source-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}

.source-toolbar span {
  border: 1px solid rgba(255, 102, 127, 0.38);
  background: rgba(255, 102, 127, 0.08);
  color: #ffd0d8;
  padding: 7px 10px;
  font: 800 12px/1 Consolas, "SFMono-Regular", monospace;
  text-transform: uppercase;
}

.code-window {
  overflow: hidden;
  border: 1px solid rgba(66, 217, 255, 0.22);
  background: #080b10;
}

.code-titlebar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(90deg, rgba(66, 217, 255, 0.09), transparent 46%),
    #10151d;
  padding: 0 14px;
}

.code-titlebar strong {
  color: #dcefff;
  font: 800 12px/1 Consolas, "SFMono-Regular", monospace;
}

.window-dots {
  display: inline-flex;
  gap: 6px;
}

.window-dots i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--rose);
}

.window-dots i:nth-child(2) {
  background: var(--amber);
}

.window-dots i:nth-child(3) {
  background: var(--green);
}

.source-code-lines {
  display: grid;
  max-height: 620px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 0;
  color: #eaf8ff;
  font: 13px/1.65 Consolas, "SFMono-Regular", monospace;
}

.source-line {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  padding: 0 18px 0 0;
}

.source-line:hover {
  background: rgba(66, 217, 255, 0.055);
}

.line-no {
  user-select: none;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(170, 180, 195, 0.56);
  padding-right: 12px;
  text-align: right;
}

.line-text {
  display: block;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.boundary-section {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 28px;
  align-items: start;
}

.boundary-section p {
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 980px) {
  .site-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-top nav {
    justify-content: flex-start;
  }

  .hero,
  .module-layout,
  .system-grid,
  .analysis-grid,
  .boundary-section,
  .hdi-grid,
  .concept-defense-grid {
    grid-template-columns: 1fr;
  }

  .module-grid,
  .pipeline-strip,
  .core-grid,
  .risk-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 38px;
  }
}

@media (max-width: 640px) {
  main {
    width: min(100% - 24px, 1440px);
    padding-top: 22px;
  }

  .module-grid,
  .pipeline-strip,
  .core-grid,
  .risk-grid {
    grid-template-columns: 1fr;
  }

  .hero,
  .module-layout,
  .hero-visual,
  .module-visual,
  #x2-canvas,
  .module-canvas {
    min-height: 420px;
  }

  h1 {
    font-size: 31px;
  }
}
