:root {
  --bg: #f6f4ef;
  --fg: #1a1916;
  --muted: #7a756a;
  --rule: #d9d4c7;
  --hi: #1a1916;
  --logo-invert: 1;       /* logo is white PNG → invert in light mode */
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0d0b;
    --fg: #e9e5da;
    --muted: #7a7566;
    --rule: #24231f;
    --hi: #e9e5da;
    --logo-invert: 0;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.shell {
  position: fixed;
  inset: 0;
  height: 100dvh;
  padding: 22px 28px;
  overflow: hidden;
}

/* Header */
header {
  position: absolute;
  z-index: 10;
  top: 22px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 0 28px 14px;
  background: var(--bg);
  background: linear-gradient(to bottom, var(--bg) 56%, color-mix(in srgb, var(--bg) 0%, transparent));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--fg);
  letter-spacing: 0.04em;
  height: 22px;
}
.brand .logo {
  height: 20px;
  width: auto;
  display: block;
  filter: invert(var(--logo-invert));
  opacity: 0.9;
  padding: 2px 0;
}
.brand .name {
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  padding-left: 5px;
  line-height: 1;
}
.nav {
  display: flex;
  gap: 22px;
  align-items: center;
}
.nav .links {
  display: flex;
  gap: 22px;
  color: var(--muted);
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color .2s ease;
  font-weight: 400;
}
.nav a:hover { color: var(--fg); }
.nav a.active { color: var(--fg); }

/* (corner-logo removed — logo now lives in the top-left brand) */

/* Main / hero */
main {
  display: grid;
  align-items: safe center;
  justify-items: center;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 74px 0 62px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  transition: opacity .28s ease, transform .28s ease;
}
main::-webkit-scrollbar { display: none; }
.hero {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  width: min(760px, 94vw);
}
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.eyebrow::before, .eyebrow::after {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--rule);
}

.ascii {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-weight: 500;
  font-size: clamp(6px, 0.9vw, 10px);
  line-height: 1.0;
  white-space: pre;
  color: var(--fg);
  user-select: none;
  letter-spacing: 0;
  margin: 0;
  text-align: center;
  opacity: 0.95;
}

/* Orrery — replaces the ASCII globe. Sized to feel like a quiet centerpiece. */
.orrery {
  width: clamp(320px, 46vw, 540px);
  /* SVG viewBox is anamorphic to hug the tilted content tightly, so no
     extra margin trickery needed. */
  aspect-ratio: 360 / 184;
  margin: 0 auto;
  display: block;
  pointer-events: none;
}
.orrery svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.tagline {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(14px, 1.3vw, 16px);
  color: var(--fg);
  line-height: 1.55;
  max-width: 48ch;
}
.tagline .sub {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 10px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0;
  max-width: 100%;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.pill-row a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 16px;
  transition: color .2s ease;
}
.pill-row a:hover { color: var(--fg); }
.pill-row .sep {
  width: 1px;
  height: 10px;
  background: var(--rule);
}

/* Footer */
footer {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  font-weight: 500;
  padding: 18px 28px 0;
  background: var(--bg);
  background: linear-gradient(to top, var(--bg) 56%, color-mix(in srgb, var(--bg) 0%, transparent));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
footer .meta {
  display: flex;
  gap: 18px;
}
footer .meta span,
footer .meta a {
  color: var(--muted);
  text-decoration: none;
}
footer .meta a:hover { color: var(--fg); }

footer .tickers {
  display: flex;
  gap: 14px;
}
footer .tickers a {
  color: var(--muted);
  text-decoration: none;
  transition: color .2s ease;
}
footer .tickers a:hover { color: var(--fg); }

/* subtle vignette */
main::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, var(--bg) 90%);
  pointer-events: none;
}

/* ========== Page transitions ========== */
@keyframes flits-enter {
  0%   { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0);   }
}
@keyframes flits-enter-soft {
  0%   { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0);   }
}
@keyframes flits-rule {
  0%   { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}

/* Header/footer ease in on every page load, just a hair behind the content */
header, footer {
  animation: flits-enter-soft .5s ease-out both;
  animation-delay: 0s;
}

/* Hero (home) stagger */
.hero > * {
  animation: flits-enter .7s cubic-bezier(.2,.6,.2,1) both;
}
.hero > .eyebrow  { animation-delay: .02s; }
.hero > .ascii,
.hero > .orrery   { animation-delay: .10s; }
.hero > .tagline  { animation-delay: .22s; }
.hero > .pill-row { animation-delay: .34s; }

/* Subpages: side (kicker / title / description) and body stagger in */
.page .side > * {
  animation: flits-enter .6s cubic-bezier(.2,.6,.2,1) both;
}
.page .side > .back-link { animation-delay: .02s; }
.page .side > .kicker    { animation-delay: .10s; }
.page .side > h1         { animation-delay: .18s; }
.page .side > p          { animation-delay: .28s; }
.page .side > p + p      { animation-delay: .34s; }

.page .body {
  animation: flits-enter .7s cubic-bezier(.2,.6,.2,1) both;
  animation-delay: .24s;
}
.article-page .body {
  animation: flits-enter .7s cubic-bezier(.2,.6,.2,1) both;
  animation-delay: .08s;
}
.ledger .row, .notes article, .contact-grid .field {
  animation: flits-enter-soft .55s cubic-bezier(.2,.6,.2,1) both;
}
.ledger .row:nth-child(1), .notes article:nth-child(1), .contact-grid .field:nth-child(1) { animation-delay: .30s; }
.ledger .row:nth-child(2), .notes article:nth-child(2), .contact-grid .field:nth-child(2) { animation-delay: .36s; }
.ledger .row:nth-child(3), .notes article:nth-child(3), .contact-grid .field:nth-child(3) { animation-delay: .42s; }
.ledger .row:nth-child(4), .notes article:nth-child(4), .contact-grid .field:nth-child(4) { animation-delay: .48s; }
.ledger .row:nth-child(5), .notes article:nth-child(5), .contact-grid .field:nth-child(5) { animation-delay: .54s; }
.ledger .row:nth-child(6), .notes article:nth-child(6), .contact-grid .field:nth-child(6) { animation-delay: .60s; }
.ledger .row:nth-child(7), .notes article:nth-child(7), .contact-grid .field:nth-child(7) { animation-delay: .66s; }
.ledger .row:nth-child(8), .notes article:nth-child(8), .contact-grid .field:nth-child(8) { animation-delay: .72s; }

/* Leaving transition, orchestrated by JS adding .is-leaving to <body>.
   Only the central content moves; the fixed shell stays visually anchored. */
body.is-leaving main { opacity: 0; transform: translateY(-4px); }
body.is-navigating main { pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .hero > *, .page .side > *, .page .body, .article-page .body,
  .ledger .row, .notes article, .contact-grid .field,
  header, footer { animation: none !important; }
  main { transition: none; }
  body.is-leaving main { opacity: 1; transform: none; }
}

/* ========== Back link (above subpage kicker) ========== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: start;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  padding: 4px 0;
  margin-bottom: 2px;
  transition: color .2s ease, gap .2s ease;
  line-height: 1;
}
.back-link .arrow {
  display: inline-block;
  width: 20px;
  height: 8px;
  flex: 0 0 auto;
  color: var(--rule);
  transition: width .2s ease, color .2s ease;
}
.back-link .arrow svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.back-link:hover { color: var(--fg); gap: 14px; }
.back-link:hover .arrow { width: 26px; color: var(--fg); }

/* ========== Subpage layout (Index / Contact / etc.) ========== */
.page {
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: 64px;
  width: min(980px, 94vw);
  min-width: 0;
  max-height: none;
  overflow: visible;
}
.page .side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.page .side h1 {
  margin: 0;
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(26px, 2.6vw, 34px);
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--fg);
}
.page .side .kicker {
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.page .side p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  font-weight: 400;
  max-width: 32ch;
}
.page .side p:empty { display: none; }
.page .body {
  min-width: 0;
  padding-right: 8px;
}
.page .body::-webkit-scrollbar { width: 6px; }
.page .body::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.article-page {
  width: min(620px, 94vw);
  min-width: 0;
  align-self: start;
  padding-top: 10px;
}
.article-page .body {
  padding-right: 0;
}

/* Index / ledger list */
.ledger {
  display: grid;
  gap: 0;
}
.ledger .row {
  display: grid;
  grid-template-columns: 40px 1fr auto 90px;
  gap: 20px;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px dashed var(--rule);
  font-size: 12px;
}
.ledger .row:last-child { border-bottom: none; }
.ledger .row .num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 500;
}
.ledger .row .name {
  color: var(--fg);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.ledger .row .desc {
  color: var(--muted);
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
}
.ledger .row .status {
  text-align: right;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
}
.ledger .row.active .status { color: var(--muted); }

/* Contact block */
.contact-grid {
  display: grid;
  gap: 26px;
  max-width: 520px;
}
.contact-grid .field {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 20px;
  align-items: baseline;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--rule);
}
.contact-grid .field .label {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 500;
}
.contact-grid .field .value {
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.contact-grid .field .value a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--rule); }
.contact-grid .field .value a:hover { border-bottom-color: var(--fg); }
.contact-grid .field .value .meta {
  display: block;
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

/* Notes */
.notes {
  display: grid;
  gap: 0;
}
.notes article {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px dashed var(--rule);
}
.notes article:last-child { border-bottom: none; }
.notes .date {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  padding-top: 3px;
}
.notes .title {
  display: inline-block;
  color: var(--fg);
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.notes a.title:hover { border-bottom-color: var(--rule); }
.notes .excerpt {
  color: var(--muted);
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
  line-height: 1.55;
}

/* Markdown-rendered page content */
.markdown-body {
  color: var(--fg);
  font-size: 13px;
  line-height: 1.65;
}
.markdown-body .loading,
.markdown-body .error {
  color: var(--muted);
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
  margin: 0;
}
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table,
.markdown-body figure {
  margin: 0 0 18px;
}
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 28px 0 10px;
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  line-height: 1.15;
}
.markdown-body h2 { font-size: 24px; }
.markdown-body h3 { font-size: 19px; }
.markdown-body h4 { font-size: 15px; }
.markdown-body a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.markdown-body a:hover { border-bottom-color: var(--fg); }
.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px 0;
  border: 1px solid var(--rule);
}
.markdown-body .principal-portrait {
  margin: 0 0 24px;
  max-width: 420px;
}
.markdown-body .principal-portrait img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center;
  margin: 0;
}
.markdown-body code {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-size: 0.92em;
}
.markdown-body pre {
  overflow-x: auto;
  padding: 12px 0;
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
}
.markdown-body blockquote {
  padding-left: 18px;
  border-left: 1px solid var(--rule);
  color: var(--muted);
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
}
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
}
.markdown-body th {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  text-align: left;
  padding: 0 20px 8px 0;
}
.markdown-body td {
  padding: 14px 20px 14px 0;
  border-bottom: 1px dashed var(--rule);
  vertical-align: baseline;
}
.markdown-body tbody tr:last-child td { border-bottom: none; }
.markdown-body .md-ledger thead,
.markdown-body .md-notes thead,
.markdown-body .md-contact thead { display: none; }
.markdown-body .md-ledger td:first-child {
  width: 40px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 500;
}
.markdown-body .md-ledger td:nth-child(2) {
  color: var(--fg);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.markdown-body .md-ledger td:nth-child(3) {
  color: var(--muted);
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
  font-size: 13px;
}
.markdown-body .md-ledger td:nth-child(4) {
  width: 90px;
  text-align: right;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  padding-right: 0;
}
.markdown-body .md-ledger tr.active td:nth-child(4) { color: var(--muted); }
.markdown-body .md-notes td:first-child {
  width: 90px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  padding-top: 17px;
}
.markdown-body .md-notes td:nth-child(2) {
  color: var(--fg);
  font-weight: 500;
  font-size: 13px;
}
.markdown-body .md-notes td:nth-child(3) {
  color: var(--muted);
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
  font-size: 13px;
  line-height: 1.55;
}
.markdown-body .md-contact td:first-child {
  width: 120px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 500;
}
.markdown-body .md-contact td:nth-child(2) {
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.markdown-body .md-contact .meta {
  display: block;
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}
.article { max-width: 620px; }
.article .article-back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .2s ease, border-color .2s ease, gap .2s ease;
  line-height: 1;
}
.article .article-back .arrow {
  display: inline-block;
  width: 20px;
  height: 8px;
  flex: 0 0 auto;
  color: var(--rule);
  transition: width .2s ease, color .2s ease;
}
.article .article-back .arrow svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.article .article-back:hover {
  color: var(--fg);
  border-bottom-color: var(--rule);
  gap: 14px;
}
.article .article-back:hover .arrow { width: 26px; color: var(--fg); }
.article .date {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 8px;
}
.article h2 {
  margin-top: 0;
  font-size: clamp(24px, 2.4vw, 34px);
}

@media (max-width: 720px) {
  .shell { padding: 16px 18px; }
  header {
    top: 16px;
    padding: 0 18px 12px;
  }
  main { padding: 66px 0 76px; }
  footer {
    bottom: 16px;
    align-items: flex-end;
    padding: 18px 18px 0;
  }
  .nav { gap: 14px; }
  .nav .links { gap: 14px; }
  .corner-logo { padding-left: 14px; margin-left: 14px; }
  footer .meta {
    flex-direction: column;
    gap: 4px;
  }
  footer .tickers { gap: 10px; }
  .eyebrow::before, .eyebrow::after { width: 14px; }
  .hero { width: 100%; }
  .pill-row {
    row-gap: 4px;
    font-size: 10px;
    letter-spacing: 0.12em;
  }
  .pill-row a { padding: 6px 10px; }
  .pill-row .sep { display: none; }
  .page {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    width: 100%;
  }
  .article-page {
    width: 100%;
    max-width: 620px;
  }
  .page .body { padding-right: 0; }
  .article-page .body { overflow-wrap: anywhere; }
  .page .side p { max-width: none; }
  .ledger .row {
    grid-template-columns: 32px minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 6px;
    align-items: baseline;
  }
  .ledger .row .desc,
  .ledger .row .status {
    grid-column: 2;
  }
  .ledger .row .status {
    text-align: left;
    padding-top: 0;
  }
  .contact-grid .field { grid-template-columns: 1fr; gap: 6px; }
  .markdown-body .md-ledger,
  .markdown-body .md-ledger tbody {
    display: block;
    width: 100%;
  }
  .markdown-body .md-ledger tr {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 6px;
    align-items: baseline;
    padding: 14px 0;
    border-bottom: 1px dashed var(--rule);
  }
  .markdown-body .md-ledger tr:last-child { border-bottom: none; }
  .markdown-body .md-ledger td {
    min-width: 0;
    padding: 0;
    border-bottom: none;
  }
  .markdown-body .md-ledger td:first-child { width: auto; }
  .markdown-body .md-ledger td:nth-child(3) {
    display: block;
    grid-column: 2;
    line-height: 1.45;
  }
  .markdown-body .md-ledger td:nth-child(4) {
    grid-column: 2;
    width: auto;
    text-align: left;
  }
  .markdown-body .md-contact,
  .markdown-body .md-contact tbody,
  .markdown-body .md-contact tr,
  .markdown-body .md-contact td {
    display: block;
    width: 100%;
  }
  .markdown-body .md-contact td {
    padding: 0;
    border-bottom: none;
  }
  .markdown-body .md-contact td:first-child {
    width: 100%;
    margin-bottom: 6px;
    white-space: nowrap;
  }
  .markdown-body .md-contact tr {
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px dashed var(--rule);
  }
}
