:root {
  color-scheme: light;
  --bg: #f7f8f7;
  --paper: #ffffff;
  --ink: #18211f;
  --muted: #5d6a66;
  --line: #d8dfdc;
  --soft: #edf2f0;
  --deep: #173b37;
  --teal: #16736b;
  --red: #9b2635;
  --gold: #b7812f;
  --blue: #365f8c;
  --shadow: 0 16px 42px rgba(24, 33, 31, 0.11);
  --radius: 8px;
  --max: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Segoe UI", sans-serif;
  line-height: 1.65;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -5rem;
  z-index: 20;
  background: var(--ink);
  color: white;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.header-inner,
.section-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.header-inner {
  min-height: 72px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--deep);
  color: white;
  font-weight: 800;
}

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

.brand small {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: -0.2rem;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-size: 0.94rem;
  color: var(--muted);
}

.nav-links a {
  text-decoration: none;
  padding: 0.5rem 0.25rem;
}

.nav-links a:hover {
  color: var(--teal);
}

.language-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.48rem 0.7rem;
  cursor: pointer;
}

.lang-btn.is-active {
  background: var(--deep);
  color: white;
}

.section-band {
  padding: 5rem 0;
}

.section-band.muted {
  background: var(--soft);
}

.hero {
  padding-top: 4.5rem;
}

.hero-grid,
.two-column,
.concept-layout,
.explorer-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 3rem;
  align-items: center;
}

.hero-grid > *,
.two-column > *,
.concept-layout > *,
.explorer-grid > *,
.summary-grid > *,
.concept-cards > *,
.assumption-grid > *,
.software-architecture > *,
.software-bridge > *,
.software-code-grid > *,
.consistency-panel > *,
.formula-grid > *,
.workflow > *,
.glossary-grid > * {
  min-width: 0;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(2.15rem, 4vw, 4.25rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.lead {
  color: var(--muted);
  font-size: 1.15rem;
  max-width: 64ch;
}

.eyebrow {
  color: var(--red);
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 0.7rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.7rem;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.68rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 700;
}

.primary-link {
  background: var(--teal);
  color: white;
}

.secondary-link {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--deep);
}

.hero-visual,
.diagram-card,
.formula-card,
.summary-grid article,
.concept-cards article,
.assumption-grid article,
.control-panel,
.explorer-output {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-visual {
  padding: 1rem;
}

.hero-visual svg,
.diagram-card svg {
  width: 100%;
  height: auto;
  display: block;
}

.svg-panel {
  fill: #fbfcfb;
  stroke: var(--line);
}

.node {
  fill: #ffffff;
  stroke-width: 3;
}

.node-a {
  stroke: var(--teal);
}

.node-m {
  stroke: var(--gold);
}

.node-y {
  stroke: var(--red);
}

.node-label {
  font-size: 34px;
  font-weight: 800;
  text-anchor: middle;
  fill: var(--ink);
}

.path-direct,
.path-mediated,
.confounder-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
}

.path-mediated {
  stroke: var(--teal);
}

.confounder-line {
  stroke: var(--blue);
  stroke-width: 2;
}

.path-text,
.small-label {
  fill: var(--muted);
  font-size: 18px;
  text-anchor: middle;
}

.small-node {
  fill: #f7f8f7;
  stroke: var(--line);
}

.summary-band {
  padding: 2.25rem 0;
}

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

.summary-grid article,
.concept-cards article,
.assumption-grid article,
.software-architecture article,
.software-bridge article,
.code-card,
.consistency-panel,
.software-warning {
  padding: 1.25rem;
  box-shadow: none;
}

h2,
h3 {
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(1.75rem, 3vw, 2.55rem);
  margin: 0;
}

h3 {
  margin: 0 0 0.5rem;
}

p {
  margin: 0 0 1rem;
}

.prose {
  color: var(--muted);
  font-size: 1.04rem;
}

.prose p:last-child,
.summary-grid p,
.concept-cards p,
.assumption-grid p {
  margin-bottom: 0;
}

.section-heading {
  max-width: 780px;
  margin-bottom: 2rem;
}

.section-heading p:last-child {
  color: var(--muted);
  font-size: 1.05rem;
}

.concept-layout {
  align-items: stretch;
}

.diagram-card {
  padding: 1rem;
}

.dag circle {
  fill: white;
  stroke: var(--teal);
  stroke-width: 3;
}

.dag rect {
  fill: #f9fbfa;
  stroke: var(--line);
}

.dag text {
  text-anchor: middle;
  font-size: 32px;
  font-weight: 800;
  fill: var(--ink);
}

.dag .confounder {
  font-size: 16px;
  font-weight: 700;
  fill: var(--muted);
}

.dag path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
}

.dag .thin {
  stroke: var(--blue);
  stroke-width: 2;
}

.dag .post {
  stroke: var(--red);
  stroke-dasharray: 7 6;
  stroke-width: 2.5;
}

.concept-cards,
.assumption-grid,
.software-architecture,
.software-bridge {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

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

.formula-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.formula-card {
  padding: 1.25rem;
  box-shadow: none;
}

.formula {
  margin: 1rem 0;
  padding: 0.85rem;
  background: var(--soft);
  border-radius: var(--radius);
  overflow-x: auto;
}

.details-block {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.details-block summary {
  cursor: pointer;
  font-weight: 800;
}

.explorer-grid {
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  align-items: stretch;
}

.control-panel,
.explorer-output {
  padding: 1.25rem;
}

.control-panel label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.35rem;
}

.control-panel span {
  grid-column: 1 / -1;
  font-weight: 700;
}

.control-panel input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.control-panel output {
  font-variant-numeric: tabular-nums;
  color: var(--deep);
  font-weight: 800;
  text-align: right;
}

canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.metric-strip span {
  background: var(--soft);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.metric-strip strong,
.metric-strip small {
  display: block;
}

.metric-strip strong {
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.metric-strip small {
  color: var(--muted);
}

.tte-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.tte-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 540px;
  color: var(--ink);
}

.tte-table th,
.tte-table td {
  padding: 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.tte-table th {
  background: var(--deep);
  color: white;
}

.software-architecture article,
.software-bridge article,
.code-card,
.consistency-panel,
.software-warning {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

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

.software-doc-link {
  margin-top: 1rem;
}

.software-step {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--deep);
  color: white;
  font-weight: 800;
  margin-bottom: 0.8rem;
}

.software-code-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.code-card {
  min-width: 0;
}

.code-card pre {
  margin: 0.85rem 0 0;
}

.consistency-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.55fr) minmax(0, 1.45fr);
  gap: 1.25rem;
  margin-top: 1rem;
}

.consistency-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.consistency-table th,
.consistency-table td {
  padding: 0.8rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.consistency-table th {
  background: var(--deep);
  color: white;
}

.consistency-table td:last-child {
  color: var(--teal);
  font-weight: 800;
}

.software-warning {
  margin-top: 1rem;
  border-left: 4px solid var(--red);
  background: #fffafa;
}

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

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

.workflow-step {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 1rem;
  cursor: pointer;
  min-height: 158px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.workflow-step:hover,
.workflow-step:focus-within {
  transform: translateY(-2px);
  border-color: var(--teal);
}

.workflow-step button {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.workflow-step .step-number {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--deep);
  font-weight: 800;
}

.workflow-step h3 {
  margin-top: 0.75rem;
}

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

.workflow-detail {
  display: none;
  margin-top: 0.8rem;
  color: var(--deep);
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.workflow-step.is-open .workflow-detail {
  display: block;
}

.plain-list {
  padding-left: 1.25rem;
}

pre {
  background: #17211f;
  color: #f1f6f4;
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  white-space: pre;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.glossary-tools {
  margin-bottom: 1.25rem;
}

.glossary-tools label {
  display: grid;
  gap: 0.35rem;
  max-width: 420px;
}

.glossary-tools span {
  font-weight: 800;
}

.glossary-tools input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  background: white;
}

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

.glossary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 1rem;
}

.glossary-card h3 {
  font-size: 1rem;
}

.glossary-card .jp-term {
  color: var(--red);
  font-weight: 800;
}

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

.references-list {
  columns: 2;
  column-gap: 2rem;
  padding-left: 1.25rem;
}

.references-list li {
  break-inside: avoid;
  margin-bottom: 0.75rem;
}

.site-footer {
  background: var(--deep);
  color: white;
  padding: 2rem 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-inner p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
}

@media (max-width: 980px) {
  .header-inner {
    grid-template-columns: 1fr auto;
  }

  .nav-links {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.35rem;
  }

  .hero-grid,
  .two-column,
  .concept-layout,
  .explorer-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .workflow,
  .glossary-grid,
  .software-architecture,
  .software-bridge,
  .software-code-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .consistency-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .section-band {
    padding: 3.25rem 0;
  }

  .header-inner {
    min-height: auto;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .brand small {
    display: none;
  }

  .hero-copy h1 {
    font-size: 2.15rem;
  }

  .summary-grid,
  .concept-cards,
  .formula-grid,
  .assumption-grid,
  .software-architecture,
  .software-bridge,
  .software-code-grid,
  .workflow,
  .glossary-grid,
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .references-list {
    columns: 1;
  }

  .footer-inner {
    display: block;
  }
}
