:root {
  color-scheme: dark;
  --ink: #090c10;
  --ink-raised: #10161c;
  --panel: #151d24;
  --paper: #e7e0d1;
  --muted: #929da5;
  --line: #33404a;
  --line-hot: rgba(255, 176, 0, 0.42);
  --accent: #ffb000;
  --accent-2: #38d9ff;
  --positive: #73d49b;
  --warning: #ff6b57;
  --display: "Chakra Petch", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--ink); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--paper);
  background:
    linear-gradient(rgba(56, 217, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 217, 255, 0.018) 1px, transparent 1px),
    var(--ink);
  background-size: 36px 36px;
  font: 400 15px/1.7 var(--mono);
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  content: "";
  opacity: 0.1;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(0, 0, 0, 0.22) 3px 4px);
}

a { color: inherit; }
img { display: block; max-width: 100%; }
code { color: var(--accent-2); font-family: var(--mono); }
.code-copy-enhanced { padding: 0 !important; overflow: hidden !important; }
.code-copy-content { display: block; max-width: 100%; padding: 1.2rem 1.4rem; overflow-x: auto; white-space: pre; }
.code-copy-toolbar { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.55rem 0.7rem 0.55rem 1rem; border-color: var(--line); color: var(--muted); background: color-mix(in srgb, var(--bg) 82%, var(--paper)); font: 600 8px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; white-space: normal; }
.code-copy-toolbar-top { border-bottom: 1px solid var(--line); }
.code-copy-toolbar-bottom { border-top: 1px solid var(--line); }
.code-copy-button { flex: 0 0 auto; border: 1px solid var(--line-hot); padding: 0.55rem 0.7rem; color: var(--accent); background: transparent; font: 700 8px/1 var(--mono); letter-spacing: 0.1em; cursor: pointer; }
.code-copy-button:hover,
.code-copy-button:focus-visible { color: var(--ink); background: var(--accent); outline: none; }
.code-copy-button.done { color: var(--ink); background: var(--accent); }
.code-copy-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.reading-progress { position: fixed; z-index: 80; top: 0; left: 0; width: 100%; height: 3px; transform: scaleX(0); transform-origin: left; background: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 70%, transparent); }

.site-head,
.project-share,
.report-hero,
.report-layout,
.report-footer { width: min(1500px, calc(100% - 64px)); margin-inline: auto; }

.site-head {
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.site-head a { text-decoration: none; }
.site-head a:last-child { justify-self: end; color: var(--accent-2); }
.site-head strong { color: var(--paper); font-weight: 600; }
.site-head a:hover,
.site-head a:focus-visible { color: var(--paper); }

.project-share {
  position: relative;
  min-height: 82px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) auto;
  align-items: stretch;
  border-bottom: 1px solid var(--line-hot);
}

.project-share-bottom { border-top: 1px solid var(--line-hot); }
.project-share::before { position: absolute; top: -1px; left: 0; width: 96px; height: 2px; background: var(--accent); content: ""; }
.project-share-label { display: flex; flex-direction: column; justify-content: center; gap: 0.35rem; }
.project-share-label span { color: var(--accent); font-size: 9px; font-weight: 600; letter-spacing: 0.14em; }
.project-share-label strong { color: var(--muted); font-size: 8px; letter-spacing: 0.11em; }
.project-share-url { min-width: 0; display: flex; align-items: center; padding-inline: 1.2rem; border-inline: 1px solid var(--line); color: var(--muted); font-size: 10px; text-decoration: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.project-share-actions { display: flex; align-items: stretch; }
.project-share-anonymous { width: 48px; border: 0; border-right: 1px solid color-mix(in srgb, var(--ink) 24%, transparent); color: var(--ink); background: var(--accent); cursor: pointer; }
.project-share-anonymous svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.project-share-anonymous:hover,
.project-share-anonymous:focus-visible,
.project-share-anonymous[aria-pressed="true"] { color: var(--paper); background: color-mix(in srgb, var(--accent) 38%, var(--bg)); outline: none; }
.project-share-copy { border: 0; padding-inline: 1.4rem; color: var(--ink); background: var(--accent); font: 700 9px/1 var(--mono); letter-spacing: 0.1em; cursor: pointer; }
.project-share-copy:hover,
.project-share-copy:focus-visible { background: var(--paper); outline: none; }
.project-share-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.report-hero {
  min-height: 680px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  border-bottom: 1px solid var(--line);
}

.hero-copy { align-self: center; padding: clamp(5rem, 9vw, 9rem) clamp(2rem, 6vw, 7rem) 5rem 0; }
.kicker { margin: 0 0 1.2rem; color: var(--accent); font-size: 10px; font-weight: 600; letter-spacing: 0.17em; text-transform: uppercase; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3, h4 { font-family: var(--display); }
h1 { max-width: 900px; margin-bottom: 2rem; font-size: clamp(4rem, 7.3vw, 8.2rem); font-weight: 700; line-height: 0.84; letter-spacing: -0.06em; text-transform: uppercase; }
h1 em { color: var(--accent); font-style: normal; }
.hero-dek { max-width: 760px; color: #bbc2c6; font-size: clamp(1rem, 1.35vw, 1.22rem); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2.3rem; }
.hero-meta span { padding: 0.55rem 0.7rem; border: 1px solid var(--line); color: var(--muted); font-size: 8px; letter-spacing: 0.1em; text-transform: uppercase; }
.hero-meta .hot { border-color: var(--line-hot); color: var(--accent); }

.hero-signal {
  position: relative;
  min-height: 680px;
  display: grid;
  place-items: center;
  border-left: 1px solid var(--line);
  overflow: hidden;
  background: radial-gradient(circle at center, color-mix(in srgb, var(--accent-2) 9%, transparent), transparent 46%), var(--ink-raised);
}
.hero-signal::before,
.hero-signal::after { position: absolute; border: 1px solid var(--line); border-radius: 50%; content: ""; }
.hero-signal::before { width: min(34vw, 500px); aspect-ratio: 1; }
.hero-signal::after { width: min(25vw, 360px); aspect-ratio: 1; border-color: var(--line-hot); }
.signal-core { z-index: 1; width: min(56%, 260px); aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--accent); background: var(--ink); color: var(--accent); font: 700 clamp(2rem, 5vw, 5rem)/1 var(--display); clip-path: polygon(50% 0, 100% 26%, 100% 74%, 50% 100%, 0 74%, 0 26%); }

.report-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); align-items: start; }
.report-toc { position: sticky; top: 20px; padding: 4rem 2rem 4rem 0; }
.report-toc p { margin-bottom: 1rem; color: var(--accent); font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase; }
.report-toc ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.report-toc li { border-bottom: 1px solid var(--line); }
.report-toc a { display: grid; grid-template-columns: 32px 1fr; padding: 0.85rem 0; color: var(--muted); font-size: 10px; line-height: 1.35; text-decoration: none; }
.report-toc a span { color: #5c6972; }
.report-toc a:hover,
.report-toc a:focus-visible,
.report-toc a[aria-current="location"] { color: var(--paper); }
.report-toc a[aria-current="location"] span { color: var(--accent); }

.report-article { min-width: 0; border-left: 1px solid var(--line); }
.report-section { padding: clamp(4.5rem, 7vw, 7.5rem) clamp(2rem, 6vw, 7rem); border-bottom: 1px solid var(--line); scroll-margin-top: 30px; }
.section-head { display: grid; grid-template-columns: 0.6fr 1.4fr; gap: clamp(2rem, 5vw, 5rem); margin-bottom: 3.5rem; }
.section-index { color: var(--accent-2); font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
h2 { max-width: 950px; margin: 0; font-size: clamp(3rem, 5.2vw, 6rem); font-weight: 700; line-height: 0.88; letter-spacing: -0.045em; text-transform: uppercase; }
h3 { margin-bottom: 0.85rem; font-size: clamp(1.55rem, 2.6vw, 2.6rem); font-weight: 650; line-height: 0.98; letter-spacing: -0.025em; }
h4 { margin-bottom: 0.55rem; color: var(--accent); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; }
.section-intro { max-width: 840px; margin: -1.5rem 0 3.5rem auto; color: var(--muted); font-size: 1.02rem; }

.executive-summary { display: grid; grid-template-columns: minmax(180px, 0.45fr) 1.55fr; border-block: 1px solid var(--line-hot); }
.executive-summary > strong { padding: 1.5rem 1.5rem 1.5rem 0; color: var(--accent); font: 600 10px/1.5 var(--mono); letter-spacing: 0.13em; text-transform: uppercase; }
.executive-summary > div { padding: 1.5rem 0 1.5rem 2rem; border-left: 1px solid var(--line); }
.executive-summary p:last-child { margin-bottom: 0; }

.finding-grid,
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin-block: 2.5rem; border: 1px solid var(--line); }
.finding-grid article,
.metric-grid article { min-height: 230px; padding: 1.5rem; }
.finding-grid article + article,
.metric-grid article + article { border-left: 1px solid var(--line); }
.finding-grid span,
.metric-grid span { color: var(--accent-2); font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase; }
.finding-grid h3 { margin-top: 3rem; }
.finding-grid p { color: var(--muted); font-size: 0.87rem; }
.metric-grid strong { display: block; margin: 2.7rem 0 0.7rem; color: var(--accent); font: 700 clamp(2.2rem, 4vw, 4.5rem)/1 var(--display); }
.metric-grid p { color: var(--muted); font-size: 0.8rem; }

.diagram-board { margin: 2.5rem 0; border: 1px solid var(--line); background: linear-gradient(145deg, color-mix(in srgb, var(--accent-2) 4%, transparent), transparent 55%), #0b1015; }
.diagram-bar { display: flex; justify-content: space-between; gap: 20px; padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase; }
.diagram-bar strong { color: var(--accent-2); }
.mermaid { margin: 0; padding: clamp(1.5rem, 4vw, 3.5rem); overflow: auto; background: transparent; text-align: center; }
.mermaid svg { min-width: 680px; max-width: none !important; height: auto; }
.mermaid-error { color: var(--warning); white-space: normal; text-align: left; }

.spec-table { width: 100%; margin-block: 2rem; border-collapse: collapse; font-size: 0.86rem; }
.spec-table th,
.spec-table td { padding: 1rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.spec-table th { color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent); font-size: 9px; letter-spacing: 0.11em; text-transform: uppercase; }
.spec-table td { color: #b9c0c5; }
.spec-table td strong { color: var(--paper); }

.callout { margin-block: 2rem; padding: 1.35rem 1.5rem; border-left: 4px solid var(--accent-2); background: color-mix(in srgb, var(--accent-2) 4.5%, transparent); }
.callout.warning { border-color: var(--warning); background: color-mix(in srgb, var(--warning) 5.5%, transparent); }
.callout strong { color: var(--accent-2); }
.callout.warning strong { color: var(--warning); }
.callout p { margin: 0.5rem 0 0; color: #bac2c7; }

.recommendations { list-style: none; margin: 2rem 0; padding: 0; counter-reset: recommendation; border-top: 1px solid var(--line); }
.recommendations li { counter-increment: recommendation; display: grid; grid-template-columns: 70px 1fr auto; gap: 1.5rem; align-items: start; padding: 1.5rem 0; border-bottom: 1px solid var(--line); }
.recommendations li::before { color: var(--accent-2); font: 700 2rem/1 var(--display); content: counter(recommendation, decimal-leading-zero); }
.recommendations p { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.86rem; }
.priority { padding: 0.3rem 0.5rem; color: var(--ink); background: var(--accent); font-size: 8px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.source-list { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line); }
.source-list a { display: grid; grid-template-columns: 90px 1fr; gap: 1rem; padding: 1rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; text-decoration: none; }
.source-list a:nth-child(odd) { border-right: 1px solid var(--line); }
.source-list a:hover,
.source-list a:focus-visible { color: var(--paper); background: color-mix(in srgb, var(--accent) 4%, transparent); }
.source-list span { color: var(--accent); font-weight: 600; letter-spacing: 0.1em; }

.report-footer { min-height: 120px; display: flex; align-items: center; justify-content: space-between; gap: 2rem; color: var(--muted); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; }
.report-footer a { color: var(--accent-2); text-decoration: none; }

@media (max-width: 980px) {
  .report-hero { grid-template-columns: 1fr; }
  .hero-signal { min-height: 480px; border-left: 0; border-top: 1px solid var(--line); }
  .report-layout { grid-template-columns: 1fr; }
  .report-toc { position: static; padding-right: 0; }
  .report-toc ol { display: grid; grid-template-columns: repeat(2, 1fr); }
  .report-toc li:nth-child(odd) { border-right: 1px solid var(--line); }
  .report-toc a { padding-inline: 1rem; }
  .report-article { border-left: 0; }
  .finding-grid,
  .metric-grid { grid-template-columns: 1fr; }
  .finding-grid article + article,
  .metric-grid article + article { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 680px) {
  .site-head,
  .project-share,
  .report-hero,
  .report-layout,
  .report-footer { width: min(100% - 32px, 1500px); }
  .site-head { grid-template-columns: minmax(0, 1fr) auto; }
  .site-head strong,
  .site-head a:last-child { display: none; }
  .project-share { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  .project-share-label { padding-block: 1.1rem; }
  .project-share-label strong { white-space: normal; }
  .project-share-url { order: 2; width: 100%; min-height: 52px; border: 1px solid var(--line); }
  .project-share-actions { order: 3; width: 100%; min-height: 48px; }
  .project-share-anonymous { flex: 0 0 52px; }
  .project-share-copy { flex: 1; min-height: 48px; padding-inline: 0.7rem; font-size: 8px; }
  h1 { font-size: clamp(3.3rem, 17vw, 5.8rem); }
  h2 { font-size: clamp(2.6rem, 12vw, 4.2rem); }
  .hero-copy { padding-block: 5rem; }
  .hero-signal { min-height: 360px; }
  .hero-signal::before { width: 340px; }
  .hero-signal::after { width: 240px; }
  .report-toc ol { grid-template-columns: 1fr; }
  .report-toc li:nth-child(odd) { border-right: 0; }
  .report-section { padding-inline: 0; }
  .section-head,
  .executive-summary { grid-template-columns: 1fr; gap: 1.3rem; }
  .section-intro { margin-top: 0; }
  .executive-summary > div { padding-left: 0; border-left: 0; }
  .recommendations li { grid-template-columns: 52px 1fr; }
  .recommendations .priority { grid-column: 2; justify-self: start; }
  .source-list { grid-template-columns: 1fr; }
  .source-list a:nth-child(odd) { border-right: 0; }
  .report-footer { min-height: 160px; flex-direction: column; justify-content: center; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reading-progress { display: none; }
}

@media print {
  body { color: #151515; background: #fff; }
  body::after,
  .reading-progress,
  .project-share,
  .report-toc { display: none; }
  .site-head,
  .report-hero,
  .report-layout,
  .report-footer { width: 100%; }
  .report-layout,
  .report-hero { display: block; }
  .hero-signal { min-height: 240px; border: 1px solid #bbb; }
  .report-article { border: 0; }
  .report-section { break-inside: avoid; padding: 2rem 0; border-color: #bbb; }
  .diagram-board,
  .finding-grid,
  .metric-grid { break-inside: avoid; }
}

/* Head actions: the sources link and the markdown-export button share the
   right-hand grid cell so the 3-column head survives the extra control. */
.head-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 18px;
}
.head-actions a { color: var(--accent-2); text-decoration: none; }
.md-copy {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  padding: 7px 11px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.md-copy:hover { background: rgba(255, 176, 0, 0.12); }
.md-copy.done { background: var(--accent); color: #090c10; }

@media (max-width: 680px) {
  .site-head { gap: 10px; font-size: 9px; }
  .head-actions { gap: 10px; }
  .head-actions a { display: none; } /* SOURCES ↓ is in the toc anyway */
}

/* ── owner controls (emitted server-side only for the passphrase holder) ── */
.owner-tools { display: inline-flex; gap: 8px; }
.owner-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  padding: 7px 11px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.owner-btn:hover { background: rgba(255, 176, 0, 0.12); }
.owner-btn.done { background: var(--accent); color: #090c10; }
.owner-btn.danger { border-color: var(--warning); color: var(--warning); }
.owner-btn.danger:hover { background: rgba(255, 107, 87, 0.12); }
.owner-btn.armed { background: var(--warning); color: #090c10; }

/* second owner toolbar at the end of the article */
.owner-tools-end {
  display: flex;
  justify-content: flex-end;
  margin: 26px 0 6px;
}
