:root {
    --bg: #ffffff;
    --bg-soft: #fafaf9;
    --bg-elev: #ffffff;
    --fg: #0e0e10;
    --fg-soft: #2a2a2e;
    --muted: #6b6b72;
    --muted-strong: #4a4a52;
    --rule: #e6e4df;
    --rule-soft: #f0eeea;
    --accent: #1a3a8c;
    --accent-strong: #0e2566;
    --accent-soft: #f0f3fa;
    --warn: #8a1f1f;
    --pulse-alive: #2ea043;
    --pulse-dead: #c93434;
    --pulse-unborn: #b8b4ad;

    --serif: "EB Garamond", "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;
    --sans: "Inter", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", "IBM Plex Mono", "SF Mono", Menlo, monospace;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 88px;
    background: var(--bg);
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--serif);
    font-size: 18.5px;
    line-height: 1.7;
    font-feature-settings: "kern", "liga", "onum";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    position: relative;
    overflow-x: hidden;
}

::selection {
    background: var(--accent);
    color: #ffffff;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ── Top bar ───────────────────────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: saturate(160%) blur(4px);
    -webkit-backdrop-filter: saturate(160%) blur(4px);
    border-bottom: 1px solid var(--rule-soft);
}

.topbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    height: 56px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--sans);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: block;
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-text em {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    font-size: 15px;
    color: var(--fg);
}

.brand-tag {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted-strong);
    letter-spacing: 0.01em;
}

.pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pulse-unborn);
}

.pulse.alive {
    background: var(--pulse-alive);
    animation: pulse 2.2s ease-out infinite;
}

.pulse.dead {
    background: var(--pulse-dead);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(46, 160, 67, 0.5);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(46, 160, 67, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(46, 160, 67, 0);
    }
}

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

.layout {
    display: grid;
    grid-template-columns: 268px minmax(0, 828px);
    gap: 80px;
    max-width: 1240px;
    margin: 0 auto;
    padding: 56px 32px 144px;
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: minmax(0, 720px);
        padding: 40px 24px 96px;
        gap: 0;
        justify-content: center;
    }
    .sidebar {
        display: none;
    }
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */

.sidebar {
    position: sticky;
    top: 88px;
    align-self: start;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--rule) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--rule);
    border-radius: 3px;
}

.sidebar-inner {
    font-family: var(--sans);
    padding-right: 12px;
}

.sidebar-meta {
    font-family: var(--sans);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    line-height: 1.6;
    margin: 0 0 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--rule-soft);
}

nav.toc {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

nav.toc a {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 5px 12px 5px 14px;
    margin-left: -14px;
    color: var(--muted-strong);
    text-decoration: none;
    font-size: 13.5px;
    line-height: 1.45;
    border-left: 2px solid transparent;
    transition:
        color 0.12s,
        background 0.12s,
        border-color 0.12s;
}

nav.toc a .n {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    min-width: 26px;
    flex-shrink: 0;
}

nav.toc a.sub {
    padding-left: 26px;
    font-size: 13px;
    color: var(--muted);
}

nav.toc a.sub .n {
    min-width: 24px;
}

nav.toc a:hover {
    color: var(--fg);
    background: var(--bg-soft);
}

nav.toc a.active {
    color: var(--accent-strong);
    border-left-color: var(--accent);
    background: var(--accent-soft);
}

nav.toc a.active .n {
    color: var(--accent);
}

.toc-divider {
    display: block;
    height: 1px;
    background: var(--rule-soft);
    margin: 12px 0;
}

.sidebar-foot {
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--rule-soft);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-vital {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--sans);
    font-size: 12px;
}

.sidebar-vital .k {
    color: var(--muted);
    letter-spacing: 0.02em;
}

.sidebar-vital .v {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--fg);
    font-variant-numeric: tabular-nums;
}

/* ── Content ───────────────────────────────────────────────────────────── */

.content {
    max-width: 828px;
    hyphens: auto;
    text-align: justify;
}

@media (max-width: 720px) {
    .content {
        font-size: 17px;
        text-align: left;
        hyphens: none;
    }
}

/* ── Title block ───────────────────────────────────────────────────────── */

header.title {
    margin-bottom: 72px;
    text-align: left;
    position: relative;
}

.metaline {
    font-family: var(--sans);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin: 0 0 28px;
    text-align: left;
    hyphens: none;
}

header.title h1 {
    font-family: var(--serif);
    font-weight: 500;
    font-style: italic;
    font-size: 64px;
    line-height: 1;
    letter-spacing: -0.018em;
    margin: 0 0 18px;
    text-align: left;
    color: var(--fg);
}

@media (max-width: 720px) {
    header.title h1 {
        font-size: 44px;
    }
}

header.title .subtitle {
    font-family: var(--serif);
    font-size: 19.5px;
    color: var(--fg-soft);
    margin: 0 0 24px;
    text-align: left;
    line-height: 1.5;
    max-width: 580px;
    hyphens: none;
}

.authorline {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    font-family: var(--sans);
    font-size: 12.5px;
    color: var(--muted-strong);
    padding-top: 18px;
    border-top: 1px solid var(--rule-soft);
    hyphens: none;
}

.authorline em {
    font-family: var(--serif);
    font-style: italic;
    font-size: 14px;
    color: var(--fg);
}

.authorline .sep {
    color: var(--rule);
}

.addr {
    font-family: var(--mono);
    font-size: 13px;
    padding: 1px 6px;
    border: 1px solid var(--rule);
    background: var(--bg-soft);
    color: var(--fg-soft);
    word-break: break-all;
    hyphens: none;
}

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

section {
    margin-top: 56px;
    scroll-margin-top: 88px;
}

section + section {
    border-top: 1px solid var(--rule-soft);
    padding-top: 48px;
}

h2 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 28px;
    line-height: 1.25;
    margin: 0 0 24px;
    letter-spacing: -0.012em;
    text-align: left;
    color: var(--fg);
    display: flex;
    align-items: baseline;
    gap: 16px;
}

h2 .num {
    font-family: var(--sans);
    font-weight: 500;
    font-size: 14px;
    color: var(--muted);
    letter-spacing: 0.03em;
    min-width: 28px;
}

h2.unnumbered {
    font-style: italic;
}

h3 {
    font-family: var(--serif);
    font-weight: 500;
    font-style: italic;
    font-size: 19px;
    margin: 36px 0 12px;
    color: var(--fg);
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: 14px;
    scroll-margin-top: 88px;
}

h3 .num {
    font-family: var(--sans);
    font-style: normal;
    font-weight: 500;
    font-size: 12.5px;
    color: var(--muted);
    letter-spacing: 0.03em;
    min-width: 32px;
}

p {
    margin: 0 0 16px;
    color: var(--fg-soft);
}

p + p {
    text-indent: 1.6em;
}

em {
    font-style: italic;
}

code {
    font-family: var(--mono);
    font-size: 0.82em;
    background: var(--bg-soft);
    padding: 1.5px 6px;
    border-radius: 3px;
    border: 1px solid var(--rule-soft);
    color: var(--fg);
    hyphens: none;
    font-variant-ligatures: none;
}

sub {
    font-size: 0.72em;
    vertical-align: sub;
    line-height: 0;
}

sup {
    font-size: 0.7em;
    vertical-align: super;
    line-height: 0;
}

a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    text-decoration-color: rgba(26, 58, 140, 0.35);
    transition: text-decoration-color 0.12s;
}

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

.authorline a {
    color: inherit;
    text-decoration-color: var(--rule);
}

.authorline a:hover {
    text-decoration-color: var(--muted);
}

sup a {
    color: var(--accent);
    text-decoration: none;
    font-family: var(--sans);
}

sup a:hover {
    text-decoration: underline;
}

/* ── Specimen plate ────────────────────────────────────────────────────── */

figure.plate {
    margin: 44px -48px;
    padding: 0;
    text-align: left;
}

@media (max-width: 720px) {
    figure.plate {
        margin: 32px 0;
    }
}

.plate-head {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 18px;
    padding: 0 4px;
    font-family: var(--sans);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    hyphens: none;
}

.plate-head .plate-num {
    font-family: var(--serif);
    font-style: italic;
    font-size: 14px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--fg);
    flex-shrink: 0;
}

.plate-head .plate-rule {
    flex: 1;
    height: 1px;
    background: var(--fg);
    max-width: 32px;
}

.plate-head .plate-title {
    flex: 1;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
    color: var(--fg-soft);
    font-family: var(--serif);
    font-style: italic;
}

.plate-image {
    position: relative;
    border-top: 1px solid var(--fg);
    border-bottom: 1px solid var(--fg);
    padding: 24px 0;
    background: var(--bg);
    overflow: visible;
}

.plate-image img {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.plate-image .anno {
    position: absolute;
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    font-size: 17px;
    color: var(--fg);
    background: rgba(255, 255, 255, 0.86);
    padding: 0 4px;
    border-radius: 2px;
    line-height: 1;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.plate-image .anno em {
    font-style: italic;
}

ol.plate-legend {
    list-style: none;
    counter-reset: none;
    margin: 18px 0 0;
    padding: 0;
    font-family: var(--serif);
    font-size: 14px;
    line-height: 1.6;
    color: var(--fg-soft);
    columns: 2;
    column-gap: 36px;
    text-align: left;
    hyphens: none;
}

@media (max-width: 720px) {
    ol.plate-legend {
        columns: 1;
    }
}

ol.plate-legend li {
    margin: 0 0 10px;
    break-inside: avoid;
    text-indent: 0;
}

ol.plate-legend em {
    font-style: italic;
    color: var(--fg);
    margin-right: 2px;
}

.plate-caption {
    font-family: var(--sans);
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--muted-strong);
    margin: 18px 4px 0;
    padding-top: 14px;
    border-top: 1px solid var(--rule-soft);
    text-align: left;
    hyphens: none;
}

/* ── Equations ─────────────────────────────────────────────────────────── */

.equation {
    font-family: var(--serif);
    font-style: italic;
    text-align: center;
    margin: 28px 0;
    text-indent: 0;
    font-size: 19px;
    letter-spacing: 0.01em;
    color: var(--fg);
    line-height: 1.4;
    padding: 10px 0;
}

.equation code {
    font-style: normal;
    background: transparent;
    border: none;
    padding: 0;
}

/* ── Parameters table ─────────────────────────────────────────────────── */

table.parameters {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-family: var(--serif);
    font-size: 16px;
}

table.parameters thead th {
    font-family: var(--sans);
    font-weight: 500;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-align: left;
    padding: 0 16px 12px 0;
    border-bottom: 1px solid var(--fg-soft);
}

table.parameters tbody td {
    border-bottom: 1px solid var(--rule-soft);
    padding: 11px 16px 11px 0;
    vertical-align: baseline;
    color: var(--fg-soft);
}

table.parameters tbody tr:last-child td {
    border-bottom: 1px solid var(--rule);
}

table.parameters td:first-child {
    width: 4.5em;
    font-family: var(--serif);
    font-style: italic;
    hyphens: none;
    color: var(--fg);
}

table.parameters td:nth-child(2) {
    color: var(--fg-soft);
}

table.parameters td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: var(--mono);
    font-size: 13px;
    font-style: normal;
    color: var(--fg);
    hyphens: none;
    padding-right: 0;
}

/* ── Vitals table ─────────────────────────────────────────────────────── */

table.vitals {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    font-family: var(--sans);
    font-size: 13.5px;
    border-top: 1px solid var(--fg-soft);
    border-bottom: 1px solid var(--fg-soft);
}

table.vitals th,
table.vitals td {
    border-bottom: 1px solid var(--rule-soft);
    padding: 10px 14px 10px 0;
    text-align: left;
    font-weight: 400;
    hyphens: none;
    color: var(--fg-soft);
}

table.vitals th {
    color: var(--muted);
    width: 55%;
    font-style: normal;
    text-transform: lowercase;
    letter-spacing: 0.01em;
}

table.vitals td {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--fg);
    padding-right: 0;
}

table.vitals tr:last-child th,
table.vitals tr:last-child td {
    border-bottom: none;
}

#v-state.dead {
    color: var(--warn);
    font-weight: 500;
}

/* ── Captions ──────────────────────────────────────────────────────────── */

.caption {
    font-family: var(--sans);
    color: var(--muted-strong);
    font-size: 13px;
    margin: 0 0 18px;
    text-align: left;
    line-height: 1.5;
    hyphens: none;
}

/* ── Verb definitions ──────────────────────────────────────────────────── */

dl.verbs {
    margin: 18px 0;
}

dl.verbs dt {
    margin-top: 16px;
    margin-bottom: 6px;
}

dl.verbs dt code {
    font-style: normal;
    font-size: 14px;
    padding: 2px 8px;
}

dl.verbs dd {
    margin: 0 0 12px 0;
    text-indent: 0;
    color: var(--fg-soft);
}

/* ── Observations ──────────────────────────────────────────────────────── */

ol.observations {
    list-style: none;
    counter-reset: obs;
    margin: 0;
    padding: 0;
}

ol.observations li {
    counter-increment: obs;
    border-top: 1px solid var(--rule-soft);
    padding: 18px 0 4px;
    margin-top: 0;
    text-indent: 0;
    text-align: left;
    hyphens: none;
}

ol.observations li:first-child {
    border-top: 1px solid var(--fg-soft);
}

ol.observations li::before {
    content: "§5." counter(obs);
    display: inline-block;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    margin-right: 14px;
    letter-spacing: 0.04em;
    vertical-align: baseline;
    min-width: 36px;
}

ol.observations time {
    display: inline;
    font-family: var(--sans);
    font-size: 11.5px;
    color: var(--muted);
    letter-spacing: 0.02em;
}

ol.observations .body {
    display: block;
    margin-top: 8px;
    line-height: 1.55;
    font-family: var(--serif);
    color: var(--fg);
}

#poly-status {
    color: var(--muted);
    font-style: italic;
    font-family: var(--sans);
    font-size: 13px;
    padding: 24px 0 0;
    border-top: 1px solid var(--rule-soft);
}

#poly-posts:empty + #poly-status {
    border-top: 1px solid var(--fg-soft);
}

/* ── References & footnotes ────────────────────────────────────────────── */

ol.references,
ol.footnotes {
    padding-left: 1.6em;
    font-family: var(--serif);
    font-size: 15.5px;
    line-height: 1.55;
    text-align: left;
    hyphens: none;
    color: var(--fg-soft);
}

ol.references li,
ol.footnotes li {
    margin-bottom: 12px;
    text-indent: 0;
}

ol.footnotes {
    font-size: 14.5px;
}

ol.footnotes li {
    scroll-margin-top: 88px;
}

ol.footnotes li:target {
    background: var(--accent-soft);
    padding: 6px 10px;
    margin-left: -10px;
    border-radius: 3px;
    border-left: 2px solid var(--accent);
}

.note {
    font-size: 13.5px;
    color: var(--muted);
    font-style: italic;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

.page-footer {
    margin-top: 72px;
    padding-top: 28px;
    border-top: 1px solid var(--rule-soft);
    font-family: var(--sans);
    font-size: 12.5px;
    color: var(--muted);
    text-align: center;
    line-height: 1.6;
}

.page-footer p {
    margin: 0 0 4px;
    color: inherit;
    text-indent: 0;
}

.page-footer a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--rule);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.page-footer a:hover {
    text-decoration-color: var(--muted);
}

.page-footer .sep {
    color: var(--rule);
    margin: 0 4px;
}
