:root {
  --bg: #0c0a10;
  --bg-card: rgba(22, 16, 28, 0.82);
  --ink: #f2e8e4;
  --ink-soft: #b8a8b0;
  --crimson: #e84a5f;
  --crimson-dim: rgba(232, 74, 95, 0.35);
  --gold: #d4a853;
  --violet: #9b7ed9;
  --violet-dim: rgba(155, 126, 217, 0.2);
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Outfit", system-ui, sans-serif;
  --mono: "JetBrains Mono", monospace;
  --radius: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
  overflow-y: auto;
}

#matrix-canvas,
#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
}

.bloom-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(232, 74, 95, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 90% 60%, rgba(155, 126, 217, 0.08), transparent),
    radial-gradient(ellipse 50% 30% at 10% 80%, rgba(212, 168, 83, 0.06), transparent);
}

.mist {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, rgba(12, 10, 16, 0.4) 70%, var(--bg) 100%);
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.5);
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ── Hero ─────────────────────────────────────── */

.hero {
  position: relative;
  padding: 56px 0 48px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 340px);
  gap: 40px;
  align-items: center;
  max-width: 1100px;
  margin: 0 auto;
}

.hero-copy {
  text-align: left;
}

.hero-figure {
  margin: 0;
}

.hero-frame {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(212, 168, 83, 0.35);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(232, 74, 95, 0.12);
  background: rgba(0, 0, 0, 0.4);
}

.hero-frame img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}

.hero-figure figcaption {
  margin-top: 12px;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
  text-align: center;
}

.hero-figure figcaption strong {
  color: var(--gold);
}

.caption-sub {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.75;
}

.torii {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 120px;
  margin-bottom: 32px;
  opacity: 0.7;
}

.torii::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, 80vw);
  height: 8px;
  background: linear-gradient(90deg, transparent, var(--crimson), transparent);
  border-radius: 4px;
}

.torii span {
  display: block;
  width: 12px;
  height: 48px;
  background: linear-gradient(180deg, var(--crimson), #8a2030);
  border-radius: 2px 2px 0 0;
}

.hero-kicker {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}

.hero-title {
  font-family: var(--sans);
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 0.95;
  background: linear-gradient(135deg, var(--ink) 30%, var(--crimson) 70%, var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 20px;
}

.hero-lead {
  max-width: 560px;
  margin: 0 auto 28px;
  font-size: 1.15rem;
  color: var(--ink-soft);
}

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

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}

.chip {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-soft);
}

.chip.accent {
  border-color: var(--crimson-dim);
  color: var(--crimson);
}

.chip.btn {
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.chip.btn:hover,
.chip.btn.active {
  background: var(--violet-dim);
  border-color: var(--violet);
  color: var(--ink);
}

/* ── Layout ───────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 260px;
  gap: 32px;
  align-items: start;
}

.toc {
  position: sticky;
  top: 24px;
  font-family: var(--sans);
  font-size: 13px;
}

.toc h2 {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}

.toc a {
  display: block;
  padding: 8px 0;
  color: var(--ink-soft);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 12px;
  transition: color 0.2s, border-color 0.2s;
}

.toc a:hover,
.toc a.active {
  color: var(--ink);
  border-left-color: var(--crimson);
}

.toc .toc-act {
  font-size: 10px;
  color: var(--gold);
  margin-right: 6px;
}

.rail-card.sticky {
  position: sticky;
  top: 24px;
}

.rail-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.rail-card h2 {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 20px 0 10px;
}

.rail-card h2:first-child {
  margin-top: 0;
}

.rail-card p {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.rail-card code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--crimson);
}

.link-fact {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.link-fact:last-child {
  border-bottom: none;
}

.link-label {
  display: block;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}

.link-value {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}

.rail-note {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.rail-note strong {
  color: var(--crimson);
}

.hero-lead code {
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--crimson);
}

.ca-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--crimson-dim);
  background: rgba(232, 74, 95, 0.06);
}

.ca-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.ca-address {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  word-break: break-all;
  flex: 1 1 200px;
  min-width: 0;
}

.ca-address--rail {
  display: block;
  font-size: 10px;
  line-height: 1.45;
  margin-bottom: 8px;
}

.rail-ca {
  margin-bottom: 4px;
}

.ca-copy,
.ca-link {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.ca-copy:hover,
.ca-link:hover {
  background: var(--violet-dim);
  border-color: var(--violet);
  color: var(--ink);
}

.ca-copy.copied {
  border-color: var(--gold);
  color: var(--gold);
}

.ca-copy--rail {
  width: 100%;
}

/* ── Sections ───────────────────────────────── */

.section {
  margin-bottom: 48px;
  scroll-margin-top: 24px;
}

.section-header {
  margin-bottom: 24px;
}

.section-act {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.section-title {
  font-family: var(--sans);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.section-about {
  font-size: 1.05rem;
  color: var(--ink-soft);
  font-style: italic;
}

.article {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.article-title {
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.article-about {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.callout {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--violet);
  background: var(--violet-dim);
  border-left: 3px solid var(--violet);
  padding: 10px 14px;
  margin-bottom: 20px;
  border-radius: 0 8px 8px 0;
}

.prose h3 {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin: 24px 0 12px;
}

.prose h3:first-child {
  margin-top: 0;
}

.prose p {
  margin-bottom: 14px;
  color: var(--ink-soft);
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose ul {
  margin: 12px 0 16px 0;
  padding-left: 0;
  list-style: none;
}

.prose li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 8px;
  color: var(--ink-soft);
}

.prose li::before {
  content: "·";
  position: absolute;
  left: 4px;
  color: var(--crimson);
  font-weight: 700;
}

.prose strong {
  color: var(--ink);
  font-weight: 600;
}

.code-panel {
  margin: 20px 0;
}

.code-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--violet);
  margin-bottom: 8px;
  display: block;
}

.code-panel pre {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: #c8b8e0;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(155, 126, 217, 0.25);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  white-space: pre-wrap;
}

.figure {
  margin: 24px 0;
  text-align: center;
}

.figure pre {
  display: inline-block;
  text-align: left;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.35;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.5);
  border: 1px dashed rgba(212, 168, 83, 0.3);
  border-radius: 10px;
  padding: 20px 24px;
  overflow-x: auto;
}

.figure figcaption {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 10px;
  letter-spacing: 0.04em;
}

.article-figure {
  margin: 24px 0;
  text-align: center;
}

.article-figure img {
  max-width: 100%;
  width: min(360px, 100%);
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(212, 168, 83, 0.3);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.article-figure figcaption {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin-top: 12px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.gallery-grid .figure {
  margin: 0;
}

.gallery-grid .figure pre {
  width: 100%;
  font-size: 11px;
}

.footer {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
}

.footer-note {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.6;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 8px;
  }

  .toc h2 {
    width: 100%;
  }

  .toc a {
    border-left: none;
    padding-left: 0;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 999px;
    font-size: 12px;
  }

  .rail {
    order: -1;
  }

  .rail-card.sticky {
    position: static;
  }
}

@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .hero-copy {
    text-align: center;
  }

  .hero-chips {
    justify-content: center;
  }

  .hero-figure {
    max-width: 320px;
    margin: 0 auto;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 0 16px 48px;
  }

  .article {
    padding: 20px 18px;
  }

  .hero {
    padding: 40px 0 32px;
  }
}