:root {
  --bg: #07131f;
  --bg-elev-1: rgba(255, 255, 255, 0.045);
  --bg-elev-2: rgba(255, 255, 255, 0.03);
  --text: #dce9f2;
  --text-strong: #f3f8fb;
  --text-muted: #94adbd;
  --line: rgba(255, 255, 255, 0.16);
  --line-soft: rgba(255, 255, 255, 0.1);
  --accent-gold: #ffbf47;
  --accent-cyan: #5ed9ff;
  --doctrine-bg: rgba(255, 191, 71, 0.08);
  --implementation-bg: rgba(94, 217, 255, 0.08);
  --notice-bg: rgba(255, 191, 71, 0.12);
  --radius-sm: 0.42rem;
  --radius-md: 0.54rem;
  --radius-pill: 999px;
  --content-width: 90vw;
  --reading-measure: 66ch;
  --shadow-lg: 0 18px 34px rgba(0, 0, 0, 0.24);
  --focus-ring: 0 0 0 2px rgba(94, 217, 255, 0.45);
  --header-block-size: 72px;
  --anchor-gap: 12px;
  --anchor-offset: calc(var(--header-block-size) + var(--anchor-gap));
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
  scroll-padding-top: var(--anchor-offset);
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.62;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 85% -100px, #1f4f7b 0%, rgba(31, 79, 123, 0) 62%),
    radial-gradient(900px 700px at -20% 80%, #0f5367 0%, rgba(15, 83, 103, 0) 60%),
    var(--bg);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: fixed;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 1000;
  width: auto;
  height: auto;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: rgba(7, 19, 31, 0.95);
  color: var(--text-strong);
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at 20% 30%, black 0 35%, transparent 70%);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.72rem;
  width: 100%;
  padding: 0.92rem 5vw;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 19, 31, 0.76);
  backdrop-filter: blur(10px);
}

.brand {
  flex-shrink: 0;
  color: var(--text-strong);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.88rem;
  font-weight: 700;
}

.current-chapter-chip {
  display: none;
  color: var(--accent-gold);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.62rem;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--bg-elev-2);
  padding: 0.2rem 0.48rem;
  max-width: 40vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--bg-elev-2);
  color: var(--text-strong);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.34rem 0.66rem;
  cursor: pointer;
}

.site-header nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem 0.88rem;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}

.site-header nav a {
  flex-shrink: 0;
  color: var(--text-muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.64rem;
  font-weight: 700;
  border-bottom: 1px solid transparent;
  padding: 0.12rem 0 0.18rem;
  min-height: 1.8rem;
  display: inline-flex;
  align-items: center;
}

.site-header nav a:hover {
  color: var(--text-strong);
  border-bottom-color: var(--accent-gold);
}

.site-header nav a[aria-current="true"] {
  color: var(--text-strong);
  border-bottom-color: var(--accent-cyan);
}

nav a:focus-visible,
.brand:focus-visible,
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 0.2rem;
}

main,
.site-footer {
  width: var(--content-width);
  margin-left: auto;
  margin-right: auto;
}

main {
  margin-top: 2rem;
  margin-bottom: 2.8rem;
  display: grid;
  gap: 1.1rem;
}

h1,
h2,
h3 {
  margin-top: 0;
  margin-bottom: 0.56rem;
  line-height: 1.22;
  color: var(--text-strong);
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 4.8vw, 3.2rem);
}

h2 {
  font-size: clamp(1.3rem, 2.4vw, 1.86rem);
}

h3 {
  font-size: clamp(1rem, 1.6vw, 1.22rem);
}

h1 span {
  color: var(--accent-gold);
}

p {
  margin: 0.48rem 0 0.72rem;
  max-width: var(--reading-measure);
  text-wrap: pretty;
}

ul {
  margin: 0.45rem 0 0;
  padding-left: 1.16rem;
  max-width: var(--reading-measure);
}

li + li {
  margin-top: 0.24rem;
}

a {
  color: var(--accent-cyan);
}

[id] {
  scroll-margin-top: var(--anchor-offset);
}

.hero,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-elev-1);
}

.hero {
  padding: 1.72rem 1.62rem;
  box-shadow: var(--shadow-lg);
}

.panel {
  padding: 1.22rem 1.25rem;
}

.eyebrow,
.chapter {
  margin: 0 0 0.28rem;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.eyebrow {
  font-size: 0.7rem;
}

.chapter {
  font-size: 0.68rem;
}

.small {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.chapter-block {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  padding: 0.66rem 0.74rem;
  margin-bottom: 0.66rem;
}

.chapter-block h3 {
  margin-bottom: 0.32rem;
  font-size: 0.94rem;
}

.chapter-block p {
  margin-top: 0.28rem;
  margin-bottom: 0.48rem;
}

.evidence-list {
  margin-top: 0.42rem;
}

.decision-note {
  margin-top: 0.68rem;
  border-left: 3px solid var(--accent-gold);
  padding: 0.38rem 0.58rem;
  background: rgba(255, 191, 71, 0.12);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.related-links {
  margin-top: 0.55rem;
  font-size: 0.82rem;
}

.equation-card {
  margin-top: 0.62rem;
  padding: 0.86rem 0.96rem;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
}

.equation {
  margin: 0;
  color: var(--accent-cyan);
  font-weight: 700;
  letter-spacing: 0.01em;
  font-size: clamp(1.24rem, 2.4vw, 1.8rem);
}

.hero-actions {
  margin-top: 0.88rem;
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--bg-elev-2);
  color: var(--text-strong);
  padding: 0.42rem 0.8rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.doctrine {
  background: linear-gradient(170deg, var(--doctrine-bg), var(--bg-elev-1));
}

.implementation {
  background: linear-gradient(170deg, var(--implementation-bg), var(--bg-elev-1));
}

.notice {
  background: linear-gradient(170deg, var(--notice-bg), var(--bg-elev-1));
}

.table-wrap {
  margin-top: 0.6rem;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
  line-height: 1.47;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.56rem 0.64rem;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

th {
  color: var(--accent-gold);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tau-machine {
  margin-top: 0.82rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  padding: 0.74rem;
}

.tau-surface {
  margin-top: 0.5rem;
  min-height: 112px;
  border: 1px solid rgba(94, 217, 255, 0.45);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, rgba(94, 217, 255, 0.1), rgba(255, 191, 71, 0.08));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.52rem;
  cursor: pointer;
  transition: transform 170ms ease, border-color 170ms ease, box-shadow 170ms ease;
}

.tau-surface.is-t2 {
  transform: translateY(-1px);
  border-color: rgba(255, 191, 71, 0.9);
  box-shadow: 0 9px 18px rgba(255, 191, 71, 0.2);
}

.tau-surface.is-tinf {
  border-color: rgba(94, 217, 255, 0.95);
  box-shadow: 0 0 0 2px rgba(94, 217, 255, 0.26), 0 10px 22px rgba(94, 217, 255, 0.14);
}

.tau-orb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent-gold);
  transition: transform 170ms ease, background 170ms ease;
}

.tau-surface.is-t2 .tau-orb {
  transform: scale(1.2);
}

.tau-surface.is-tinf .tau-orb {
  background: var(--accent-cyan);
}

.tau-text {
  color: var(--text-strong);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tau-controls {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tau-readout {
  margin-top: 0.62rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
}

.state-code {
  color: var(--accent-cyan);
  font-size: 1rem;
  font-weight: 700;
}

.state-label {
  color: var(--text-strong);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.state-detail {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.tau-timeline {
  margin-top: 0.65rem;
}

.timeline-track {
  height: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.timeline-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-cyan));
  transition: width 170ms ease;
}

.timeline-steps {
  margin-top: 0.35rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.34rem;
}

.timeline-step {
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.16rem 0.25rem;
}

.timeline-step.active {
  color: var(--text-strong);
  border-color: rgba(94, 217, 255, 0.72);
  background: rgba(94, 217, 255, 0.14);
}

.site-footer {
  margin-bottom: 2rem;
  padding-top: 0.72rem;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.meta-line {
  margin: 0.12rem 0;
}

.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 460ms ease, transform 460ms ease;
}

.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

.chapter-pager {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.chapter-pager-link,
.chapter-pager-spacer {
  min-height: 2rem;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.34rem 0.58rem;
}

.chapter-pager-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-elev-2);
}

.chapter-pager-link.next {
  justify-content: flex-end;
  text-align: right;
}

.chapter-pager-spacer {
  opacity: 0;
}

@media (max-width: 1080px) {
  main,
  .site-footer {
    width: 94vw;
  }
}

@media (max-width: 760px) {
  .site-header {
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
  }

  .current-chapter-chip {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .site-header nav {
    width: 100%;
    flex-basis: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.18rem;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    padding-top: 0;
    transition: max-height 180ms ease, opacity 180ms ease, padding-top 180ms ease;
  }

  .site-header.nav-open nav {
    max-height: 70vh;
    opacity: 1;
    overflow-y: auto;
    pointer-events: auto;
    padding-top: 0.4rem;
    touch-action: pan-y;
  }

  .site-header nav a {
    min-height: 1.7rem;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    padding: 0.24rem 0;
  }

  .hero,
  .panel {
    padding: 0.95rem;
  }

  .chapter-pager {
    grid-template-columns: 1fr;
  }

  .chapter-pager-link.next {
    justify-content: flex-start;
    text-align: left;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap th,
  .table-wrap td {
    display: block;
  }

  .table-wrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .table-wrap tr {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin-bottom: 0.56rem;
    background: var(--bg-elev-2);
    overflow: hidden;
  }

  .table-wrap td {
    border-bottom: 1px solid var(--line-soft);
    padding: 0.46rem 0.58rem;
  }

  .table-wrap td:last-child {
    border-bottom: none;
  }

  .table-wrap td::before {
    content: attr(data-label);
    display: block;
    color: var(--text-muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.18rem;
  }

  .table-wrap td:first-child {
    text-align: right;
    color: var(--accent-gold);
    font-weight: 700;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
