:root {
  --thm-canvas: #F7F8FA;
  --thm-surface-tray: #ECEFF3;
  --thm-surface: #FFFFFF;
  --thm-ink: #1A2228;
  --thm-ink-muted: #475467;
  --thm-rule: #D0D7DE;
  --thm-moss: #3B5B13;
  --thm-moss-soft: #EEF3E6;
  --thm-slate-teal: #1F4E5F;
  --thm-safe: #2D6A2E;
  --thm-safe-soft: #EAF4EB;
  --thm-warn: #B54708;
  --thm-warn-soft: #FEF3C7;
  --thm-critical: #B42318;
  --thm-critical-soft: #FEE4E2;
  --font-display: 'Petrona', Georgia, serif;
  --font-sans: 'Onest', sans-serif;
  --font-mono: 'Geist Mono', monospace;
  --editorial-width: 76rem;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; background: var(--thm-surface-tray); color: var(--thm-ink); }
body {
  font-family: var(--font-sans);
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--thm-slate-teal); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--thm-moss); outline-offset: 2px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--thm-moss);
  color: #FFFFFF;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* Slate-Teal Operational Header (Direction B) */
.thm-top-band {
  background: var(--thm-slate-teal);
  color: #FFFFFF;
  border-bottom: 3px solid var(--thm-moss);
}
.thm-top-inner {
  max-width: var(--editorial-width);
  margin: 0 auto;
  padding: 0.9rem 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.thm-brand-lockup {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.thm-brand-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #FFFFFF;
}
.thm-brand-tag {
  font-size: 0.8125rem;
  color: #D7E5EA;
}
.thm-nav {
  display: flex;
  gap: 1.15rem;
  flex-wrap: wrap;
  font-size: 0.875rem;
  font-weight: 500;
}
.thm-nav a { color: #E2EEF2; padding: 0.2rem 0; }
.thm-nav a.is-active {
  color: #FFFFFF;
  font-weight: 600;
  border-bottom: 2px solid #C8E29E;
}

/* Two-Rail SOP Monograph Sheet */
.thm-sheet {
  max-width: var(--editorial-width);
  margin: 1.5rem auto 0;
  background: var(--thm-surface);
  border: 1px solid var(--thm-rule);
  display: grid;
  grid-template-columns: 255px minmax(0, 1fr);
}
.thm-sheet > * { min-width: 0; }
.thm-sheet--full {
  grid-template-columns: minmax(0, 1fr);
}

/* Persistent Left Protocol-Hierarchy Rail */
.thm-rail {
  background: var(--thm-canvas);
  border-right: 1px solid var(--thm-rule);
  padding: 1.65rem 1.35rem;
}
.thm-rail-sticky { position: sticky; top: 1.25rem; }
.thm-rail-toggle {
  display: none;
  appearance: none;
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  background: var(--thm-surface);
  border: 1px solid var(--thm-rule);
  color: var(--thm-ink);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.thm-rail-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--thm-slate-teal);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--thm-ink);
  margin-bottom: 0.75rem;
}
.thm-tree {
  list-style: none;
  font-size: 0.85rem;
  margin-bottom: 1.6rem;
}
.thm-tree li { border-bottom: 1px solid var(--thm-rule); }
.thm-tree a {
  display: block;
  padding: 0.5rem 0.4rem;
  color: var(--thm-ink);
  font-weight: 500;
}
.thm-tree a.is-current {
  background: var(--thm-moss-soft);
  color: var(--thm-moss);
  font-weight: 600;
  border-left: 3px solid var(--thm-moss);
  padding-left: 0.65rem;
}
.thm-rail-codes {
  list-style: none;
  font-size: 0.8125rem;
  color: var(--thm-ink-muted);
}
.thm-rail-codes li {
  padding: 0.45rem 0;
  border-bottom: 1px dotted var(--thm-rule);
}
.thm-rail-codes strong {
  display: block;
  font-family: var(--font-mono);
  color: var(--thm-ink);
  font-size: 0.78rem;
}

/* Monograph Main Column */
.thm-monograph {
  padding: 2.25rem 2.75rem 2.75rem;
  min-width: 0;
}
.thm-breadcrumb {
  font-size: 0.8125rem;
  color: var(--thm-ink-muted);
  margin-bottom: 0.65rem;
}
h1 {
  font-family: var(--font-display);
  font-size: clamp(1.95rem, 3.5vw, 2.85rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-wrap: balance;
  max-width: 24ch;
  margin-bottom: 0.85rem;
}
.thm-byline {
  font-size: 0.875rem;
  color: var(--thm-ink-muted);
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--thm-rule);
  margin-bottom: 1.35rem;
}
h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 2rem 0 0.6rem;
  padding-top: 1.45rem;
  border-top: 1px solid var(--thm-rule);
}
h3 {
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 1.35rem 0 0.45rem;
}
.thm-prose {
  max-width: 66ch;
  font-size: 0.975rem;
  color: var(--thm-ink);
  margin-bottom: 1rem;
}
.thm-prose-lead {
  color: var(--thm-ink-muted);
  max-width: 66ch;
  margin-bottom: 1.15rem;
  font-size: 0.96rem;
}
.thm-list {
  max-width: 64ch;
  margin: 0.5rem 0 1.25rem 1.25rem;
  font-size: 0.95rem;
}
.thm-list li { margin-bottom: 0.45rem; }

/* Link-Free GEO Answer Capsule */
.answer-box {
  background: var(--thm-surface-tray);
  border-left: 4px solid var(--thm-moss);
  padding: 1.1rem 1.35rem;
  max-width: 65ch;
  font-size: 0.95rem;
  color: var(--thm-ink);
}
.thm-capsule-src {
  margin-top: 0.45rem;
  font-size: 0.8125rem;
  color: var(--thm-ink-muted);
  margin-bottom: 1.6rem;
}

.thm-code:not(td):not(th) {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--thm-slate-teal);
}

/* Open Documentary Plate */
.thm-figure {
  margin: 0 0 1.85rem;
  border-top: 1px solid var(--thm-rule);
  border-bottom: 1px solid var(--thm-rule);
  padding: 1.15rem 0;
}
.thm-figure img {
  width: 100%;
  height: auto;
  display: block;
}
.thm-fig-caption {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  font-size: 0.8125rem;
  color: var(--thm-ink-muted);
}
.thm-fig-caption strong {
  color: var(--thm-moss);
  font-family: var(--font-mono);
  margin-right: 0.3rem;
}

/* Interactive Pills & Steppers */
.thm-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1rem;
}
.thm-pill-opt {
  appearance: none;
  border: 1px solid var(--thm-rule);
  background: var(--thm-canvas);
  color: var(--thm-ink);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.58rem 0.95rem;
  min-height: 44px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.thm-pill-opt:hover { border-color: var(--thm-moss); }
.thm-pill-opt[aria-pressed="true"] {
  background: var(--thm-moss-soft);
  border-color: var(--thm-moss);
  color: var(--thm-moss);
  font-weight: 600;
}

.thm-sop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--thm-rule);
  border: 1px solid var(--thm-rule);
  margin-bottom: 1.5rem;
}
.thm-sop-cell {
  background: var(--thm-canvas);
  padding: 0.9rem 1.05rem;
}
.thm-sop-k {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--thm-slate-teal);
  margin-bottom: 0.25rem;
}
.thm-sop-v { font-size: 0.885rem; color: var(--thm-ink); }

/* Embedded / Full Workbench Inset */
.thm-wb-inset {
  background: var(--thm-surface-tray);
  border-left: 4px solid var(--thm-slate-teal);
  padding: 1.35rem;
  margin-bottom: 1.5rem;
}
.thm-wb-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 1.25rem;
}
.thm-wb-grid > * { min-width: 0; }
.thm-wb-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.thm-stepper-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.85rem 0;
}
.thm-step-card {
  background: var(--thm-surface);
  border: 1px solid var(--thm-rule);
  padding: 0.55rem 0.65rem;
}
.thm-step-ctrl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.35rem;
}
.thm-step-btn {
  appearance: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--thm-rule);
  background: var(--thm-canvas);
  color: var(--thm-ink);
  font-family: var(--font-mono);
  font-size: 1rem;
  cursor: pointer;
}
.thm-step-btn:hover { border-color: var(--thm-moss); color: var(--thm-moss); }
.thm-step-val {
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.thm-readout-panel {
  background: var(--thm-surface);
  border: 1px solid var(--thm-rule);
  padding: 1.05rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
}
.thm-tier-box {
  padding: 0.75rem 0.9rem;
  border-left: 4px solid var(--thm-critical);
  background: var(--thm-critical-soft);
}
.thm-tier-box.is-warn { border-left-color: var(--thm-warn); background: var(--thm-warn-soft); }
.thm-tier-box.is-safe { border-left-color: var(--thm-safe); background: var(--thm-safe-soft); }
.thm-tier-code { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; }
.thm-tier-head { font-family: var(--font-display); font-size: 1.12rem; font-weight: 700; margin-top: 0.15rem; }
.thm-kv-pair {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--thm-rule);
  padding: 0.42rem 0;
  font-size: 0.85rem;
}
.thm-kv-pair strong { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.thm-wb-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.4rem;
}
.thm-reset-btn {
  appearance: none;
  border: 1px solid var(--thm-rule);
  background: var(--thm-canvas);
  color: var(--thm-ink);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  min-height: 44px;
  cursor: pointer;
}

/* Timeline Stepper (5-Gate SSbD / Wound Phases) */
.thm-stepper-list {
  list-style: none;
  border-top: 2px solid var(--thm-ink);
  margin: 1rem 0 1.75rem;
}
.thm-stepper-list li {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 1rem;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--thm-rule);
}
.thm-gate-id {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--thm-moss);
}
.thm-gate-title { font-weight: 600; font-size: 0.96rem; margin-bottom: 0.2rem; }
.thm-gate-desc { font-size: 0.89rem; color: var(--thm-ink-muted); }

/* Booktabs Table */
.table-responsive-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0 1.5rem;
}
table.thm-booktabs {
  width: 100%;
  border-collapse: collapse;
  border-top: 2px solid var(--thm-ink);
  border-bottom: 2px solid var(--thm-ink);
  font-size: 0.885rem;
  font-variant-numeric: tabular-nums;
  background: var(--thm-surface);
}
table.thm-booktabs thead th {
  text-align: left;
  padding: 0.75rem 0.8rem;
  background: var(--thm-canvas);
  border-bottom: 1.5px solid var(--thm-ink);
  font-weight: 600;
}
table.thm-booktabs tbody td {
  padding: 0.8rem;
  border-bottom: 1px solid var(--thm-rule);
  vertical-align: top;
}
table.thm-booktabs tbody tr:last-child td { border-bottom: 0; }
.thm-badge:not(td):not(th) {
  display: inline-block;
  white-space: nowrap;
  padding: 0.15rem 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
}
.thm-badge.is-critical { background: var(--thm-critical-soft); color: var(--thm-critical); }
.thm-badge.is-warn { background: var(--thm-warn-soft); color: var(--thm-warn); }
.thm-badge.is-safe { background: var(--thm-safe-soft); color: var(--thm-safe); }

/* SVG Diagrams */
.thm-svg-frame {
  border: 1px solid var(--thm-rule);
  background: var(--thm-canvas);
  padding: 1rem;
  margin: 1rem 0 1.5rem;
}
svg.thm-diagram { width: 100%; height: auto; display: block; font-family: var(--font-sans); }
.svg-axis { stroke: var(--thm-ink); stroke-width: 1.5; }
.svg-grid { stroke: var(--thm-rule); stroke-width: 1; stroke-dasharray: 4 4; }
.svg-zone { fill: var(--thm-safe-soft); }
.svg-over { fill: var(--thm-critical-soft); }
.svg-box { fill: var(--thm-surface); stroke: var(--thm-rule); stroke-width: 1.5; }
.svg-box-accent { fill: var(--thm-moss-soft); stroke: var(--thm-moss); stroke-width: 1.5; }
.svg-box-teal { fill: var(--thm-surface-tray); stroke: var(--thm-slate-teal); stroke-width: 1.5; }
.svg-curve-lal { fill: none; stroke: var(--thm-critical); stroke-width: 2.5; }
.svg-curve-rfc { fill: none; stroke: var(--thm-moss); stroke-width: 2.5; }
.svg-line { fill: none; stroke: var(--thm-slate-teal); stroke-width: 2; }
.svg-lbl { fill: var(--thm-ink); font-size: 12px; font-weight: 600; }
.svg-note { fill: var(--thm-ink-muted); font-size: 11px; }
.svg-mono { fill: var(--thm-slate-teal); font-family: var(--font-mono); font-size: 11px; font-weight: 600; }

/* Equation Block */
.thm-eq-box {
  background: var(--thm-canvas);
  border-left: 3px solid var(--thm-slate-teal);
  padding: 0.9rem 1.15rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  margin: 0.85rem 0 1.25rem;
  overflow-x: auto;
}

/* Silent Archive Disclosure */
details.ref-disclosure {
  margin-top: 1.5rem;
  background: var(--thm-canvas);
  border: 1px solid var(--thm-rule);
  padding: 0.9rem 1.15rem;
}
details.ref-disclosure summary { cursor: pointer; font-size: 0.875rem; font-weight: 600; color: var(--thm-ink); }
details.ref-disclosure p { margin-top: 0.6rem; font-size: 0.86rem; color: var(--thm-ink-muted); max-width: 70ch; }
.thm-disclosure-id {
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  border-top: 1px dotted var(--thm-rule);
}

/* Human-First 3-Part Institutional Footer */
.thm-footer {
  max-width: var(--editorial-width);
  margin: 0 auto 2rem;
  background: var(--thm-surface);
  border: 1px solid var(--thm-rule);
  border-top: 2px solid var(--thm-ink);
  padding: 1.75rem 2.5rem;
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.2fr;
  gap: 2rem;
  font-size: 0.85rem;
}
.thm-footer-heading { font-family: var(--font-display); font-size: 1rem; font-weight: 600; margin: 0 0 0.45rem; color: var(--thm-ink); }
.thm-footer p, .thm-footer li { color: var(--thm-ink-muted); line-height: 1.55; }
.thm-footer ul { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 0.85rem; }

@media (max-width: 980px) {
  .thm-sheet { grid-template-columns: minmax(0, 1fr); margin-top: 0; }
  .thm-rail { border-right: 0; border-bottom: 1px solid var(--thm-rule); padding: 0.85rem 1.15rem; }
  .thm-rail-sticky { position: static; }
  .thm-rail-toggle { display: block; }
  .thm-rail-body { display: none; margin-top: 0.85rem; }
  .thm-rail-body.is-open { display: block; }
  .thm-wb-grid, .thm-fig-caption, .thm-footer { grid-template-columns: minmax(0, 1fr); }
  .thm-stepper-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .thm-top-inner, .thm-monograph, .thm-footer { padding-left: 1.15rem; padding-right: 1.15rem; }
  .thm-sop-grid, .thm-footer ul, .thm-stepper-list li { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .skip-link, .thm-top-band, .thm-rail, .thm-pill-row, .thm-wb-actions, details.ref-disclosure { display: none; }
  .thm-sheet { grid-template-columns: 1fr; border: 0; }
  body { background: #FFFFFF; }
}
