:root {
  --bg0: #0b0c10;
  --bg1: #111421;
  --fg0: #f2f4ff;
  --fg1: #b7bed6;
  --line: rgba(255, 255, 255, 0.10);
  --a: #4df0c7;
  --a2: #7aa2ff;
  --shadow: rgba(0, 0, 0, 0.35);
  --warn: #ffca67;
  --bad: #ff5d6c;
  --hot: #ff3d9a;
  --good: #4df0c7;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* Prevent accidental horizontal overflow on mobile (tables/diagrams/long tokens). */
html { overflow-x: hidden; }
body { overflow-x: hidden; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--fg0);
  background:
    radial-gradient(1000px 700px at 15% 10%, rgba(122, 162, 255, 0.28), transparent 60%),
    radial-gradient(900px 650px at 80% 25%, rgba(77, 240, 199, 0.22), transparent 55%),
    radial-gradient(800px 560px at 50% 85%, rgba(255, 61, 154, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

a {
  color: var(--a);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

.wrap {
  max-width: 1260px;
  padding: 56px 18px;
  margin: 0 auto;
}

.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.side {
  position: sticky;
  top: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 10px 30px var(--shadow);
  padding: 12px;
}

.brand {
  padding: 10px 10px 4px;
}

.brand .name {
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

.nav {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.nav a {
  display: block;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--fg1);
  background: rgba(0, 0, 0, 0.10);
}

.nav a:hover {
  text-decoration: none;
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--fg0);
}

.nav a.active {
  border-color: rgba(122, 162, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(122, 162, 255, 0.18) inset;
  color: var(--fg0);
}

.nav .pillrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 10px 8px;
}

.langRow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 10px 4px;
  margin-bottom: 4px;
}

.pill {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  color: var(--fg1);
  cursor: pointer;
}

.pill[aria-pressed="true"] {
  border-color: rgba(77, 240, 199, 0.55);
  color: var(--fg0);
}

.content {
  min-width: 0;
}

.hero {
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 10px 30px var(--shadow);
}

.heroBiz {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 14px;
  align-items: start;
}

.imgFrame {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
  box-shadow: 0 10px 26px var(--shadow);
}

.imgFrame img {
  display: block;
  width: 100%;
  height: auto;
}

.zoomable {
  position: relative;
}

.zoomHint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: rgba(242, 244, 255, 0.92);
  font-size: 12px;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.zoomModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  z-index: 9999;
}

.zoomModal.open { display: grid; place-items: center; }

.zoomPanel {
  width: min(1120px, 96vw);
  height: min(760px, 86vh);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(10, 12, 16, 0.86);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.zoomBar {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  align-items: center;
}

.zoomBar .spacer { flex: 1; }

.zbtn {
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: rgba(242, 244, 255, 0.92);
  cursor: pointer;
  font-size: 13px;
}

.zbtn:hover { border-color: rgba(255, 255, 255, 0.24); }

.zoomStage {
  overflow: auto;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
}

.zoomInner {
  transform-origin: 0 0;
}

.badgeRow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.badge {
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.18);
  color: var(--fg1);
}

.badge.good { border-color: rgba(77,240,199,0.45); color: rgba(242,244,255,0.95); }
.badge.warn { border-color: rgba(255,202,103,0.45); color: rgba(242,244,255,0.95); }
.badge.hot  { border-color: rgba(255,61,154,0.45); color: rgba(242,244,255,0.95); }

.chip {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.20);
  color: var(--fg0);
}

.chip.good { border-color: rgba(77,240,199,0.5); }
.chip.warn { border-color: rgba(255,202,103,0.5); }
.chip.hot  { border-color: rgba(255,93,108,0.5); }

.kicker {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg1);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
}

h1 {
  margin: 14px 0 8px;
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.05;
}

.lead {
  margin: 0;
  color: var(--fg1);
  font-size: 16px;
  line-height: 1.6;
  max-width: 70ch;
}

.card {
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 8px 26px var(--shadow);
}

.card h2, .card h3 {
  margin: 0 0 8px;
}

.card p {
  margin: 8px 0 0;
  color: var(--fg1);
  line-height: 1.65;
}

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

/* Grid children must be allowed to shrink; otherwise long <pre> blocks can force horizontal overflow on mobile. */
.grid > * { min-width: 0; }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.muted { color: var(--fg1); }

.callout {
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.22);
}

.callout b { color: var(--fg0); }

.funnel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.funnel .step {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.2);
}

.funnel .step span {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.funnel .step small {
  color: var(--fg1);
  font-size: 12px;
}

.funnel .s1 { margin-right: 0; }
.funnel .s2 { margin-right: 14px; margin-left: 14px; }
.funnel .s3 { margin-right: 28px; margin-left: 28px; }
.funnel .s4 { margin-right: 42px; margin-left: 42px; }

ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--fg1);
  line-height: 1.65;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--fg0);
}

.footer {
  margin-top: 22px;
  padding: 16px 2px 0;
  color: var(--fg1);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.links a {
  display: inline-block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.links a:hover {
  text-decoration: none;
  border-color: rgba(255, 255, 255, 0.22);
}

pre {
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.32);
  overflow: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  box-shadow: 0 8px 20px var(--shadow);
}

pre code {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg0);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
}

.diagram {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
  box-shadow: 0 10px 26px var(--shadow);
}

.diagram svg {
  display: block;
  width: 100%;
  height: auto;
}

.processMap {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.18);
  padding: 8px;
  margin-top: 12px;
  box-shadow: 0 10px 26px var(--shadow);
}

.processMap svg {
  width: 100%;
  height: auto;
  display: block;
}

.layer-off {
  opacity: 0.14;
  filter: grayscale(90%);
}

.chart {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: 0 10px 26px var(--shadow);
  padding: 14px 16px 16px;
}

.bars {
  height: 120px;
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.bar {
  flex: 1;
  min-height: 4px;
  border-radius: 10px 10px 6px 6px;
  background: linear-gradient(180deg, rgba(122, 162, 255, 0.75), rgba(77, 240, 199, 0.40));
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
}

.barTip {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 100%;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--fg1);
  opacity: 0;
  transition: opacity 160ms ease;
  white-space: nowrap;
}

.bar:hover .barTip { opacity: 1; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  border: 1px solid var(--line);
}

th, td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  color: var(--fg1);
}

th { color: var(--fg0); background: rgba(255, 255, 255, 0.03); }

td.ok { color: var(--a); }
td.bad { color: var(--bad); }

.logFilter {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.logFilter input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--fg0);
  outline: none;
}

.logRow {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.22);
  margin-top: 10px;
}

.logRow .meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--fg1);
  margin-bottom: 8px;
}

.tag {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.pieGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.pieCard {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  padding: 14px 14px 12px;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: 0 10px 26px var(--shadow);
}

.pieTitle {
  margin: 0;
  font-size: 14px;
  color: var(--fg0);
}

.pieSub {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--fg1);
}

.pieRow {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.pie {
  width: 140px;
  height: 140px;
  display: block;
}

.legend {
  display: grid;
  gap: 6px;
}

.legendItem {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--fg1);
  font-size: 12px;
  flex-wrap: wrap;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.slide {
  margin-top: 18px;
  padding: 24px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 10px 30px var(--shadow);
  position: relative;
  overflow: hidden;
}

.slide::before {
  content: "";
  position: absolute;
  inset: -2px;
  background:
    radial-gradient(700px 360px at 20% 15%, rgba(122, 162, 255, 0.16), transparent 60%),
    radial-gradient(650px 340px at 80% 35%, rgba(77, 240, 199, 0.12), transparent 60%);
  pointer-events: none;
}

.slide > * { position: relative; }

.slideTitle {
  margin: 0 0 10px;
  font-size: clamp(22px, 2.8vw, 32px);
}

.slideLead {
  margin: 0;
  color: var(--fg1);
  font-size: 16px;
  line-height: 1.7;
  max-width: 85ch;
}

.statGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.stat {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  padding: 14px 14px 12px;
  background: rgba(0, 0, 0, 0.22);
}

.stat .k {
  font-size: 12px;
  color: var(--fg1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat .v {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.stat .s {
  margin-top: 6px;
  color: var(--fg1);
  font-size: 12px;
  line-height: 1.5;
}

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

.riskHead {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.22);
  font-weight: 600;
}

.riskCell {
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  min-height: 62px;
  display: flex;
  align-items: center;
}

.riskCell.low  { background: linear-gradient(135deg, rgba(77,240,199,0.18), rgba(77,240,199,0.06)); }
.riskCell.med  { background: linear-gradient(135deg, rgba(255,202,103,0.22), rgba(255,202,103,0.08)); }
.riskCell.high { background: linear-gradient(135deg, rgba(255,132,67,0.24), rgba(255,132,67,0.10)); }
.riskCell.crit { background: linear-gradient(135deg, rgba(255,93,108,0.28), rgba(255,93,108,0.12)); }

.fineprint {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 14px;
}

@media (max-width: 780px) {
  .wrap { padding: 36px 14px; }
  .grid { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; }
  .pieGrid { grid-template-columns: 1fr; }
  .pieRow { grid-template-columns: 1fr; }
  .heroBiz { grid-template-columns: 1fr; }
  .riskGrid { grid-template-columns: 1fr; }
  .funnel .s2, .funnel .s3, .funnel .s4 { margin-right: 0; margin-left: 0; }

  /* On mobile, horizontal code scrolling is awkward (browser gestures).
     Wrap long lines instead of forcing a horizontal scrollbar. */
  pre code { white-space: pre-wrap; word-break: break-word; }
}

/* Collapse the sidebar earlier for large phones / small tablets. */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; }
}
