/* ============ tokens ============ */
:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --ink: #1a1a17;
  --muted: #6b6b63;
  --faint: #9a9a90;
  --rule: #e4e2da;
  --bg: #fbfbf8;
  --elev: #f4f2ea;                /* elevated surface: footer, sits above bg */
  --accent: #a6532a;              /* warm rust, used once for the rail mark */
  --link-underline: #d0cec4;
}
:root[data-theme="dark"] {
  /* Apple-style dark: near-neutral base with a faint warm lean so it stays a
     sibling of the cream light mode; two surface tiers for depth (base recedes,
     elevated advances) instead of shadows; off-white text; desaturated accent
     so it doesn't vibrate on the dark ground. */
  --ink: #ececea;                 /* off-white label, never pure #fff */
  --muted: #9c9a95;
  --faint: #6a6862;
  --rule: #2c2b28;
  --bg: #18171a;                  /* base surface, recedes */
  --elev: #201f22;                /* elevated surface, advances */
  --accent: #d98b64;              /* desaturated terracotta */
  --link-underline: #423f3a;
}

/* ============ base ============ */
* { box-sizing: border-box; }
html {
  scrollbar-gutter: stable;       /* reserve space so pages never shift */
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  min-height: 100vh;              /* fallback */
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.62;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ============ two-column shell ============ */
/* left rail = masthead/nav, right = content. Asymmetric, book-margin feel. */
.shell {
  flex: 1 0 auto;                 /* grow so footer sits at bottom */
  display: grid;
  grid-template-columns: 12rem minmax(0, 40rem);
  gap: 3.5rem;
  width: 100%;
  max-width: 58rem;
  margin: 0 auto;
  padding: 5rem 2rem 3rem;
}
@media (max-width: 780px) {
  .shell {
    grid-template-columns: 1fr;
    gap: 2.5rem;
    padding: 2.75rem 1.5rem 2rem;
    max-width: 34rem;
  }
}

/* ============ rail / nav ============ */
.rail { position: relative; }
@media (min-width: 781px) {
  .rail { position: sticky; top: 5rem; align-self: start; height: min-content; }
}
.rail .name {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.rail .name::before {           /* the single accent: a small filled square */
  content: "";
  width: 0.6rem; height: 0.6rem;
  background: var(--accent);
  display: inline-block;
}
.rail .name:hover { color: var(--muted); }
.rail nav {
  margin-top: 1.4rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 2.1;
}
.rail nav a {
  display: block;
  width: fit-content;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.12s ease;
}
.rail nav a:hover { color: var(--ink); }
.rail nav a[aria-current="page"] { color: var(--ink); }
.rail nav a[aria-current="page"]::before {
  content: "→ ";
  color: var(--accent);
}

/* ============ content / prose ============ */
.content { min-width: 0; }
h1 {
  font-size: 1.8rem;
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 1.1rem;
}
p { margin: 0 0 1.15rem; }
p.lead { font-size: 1.08rem; color: var(--ink); }
.content a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.content a:hover { text-decoration-color: var(--accent); }

/* meta line */
.meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.9;
  margin: 1.6rem 0 0;
}
.meta b { color: var(--ink); font-weight: 600; }
.meta .sep { color: var(--faint); margin: 0 0.5rem; }
.meta a { color: var(--muted); }

/* section label */
.sec-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  margin: 2.8rem 0 0.85rem;
}

/* entry list */
.list { margin: 0; }
.entry {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.25rem;
  padding: 0.4rem 0;
}
.entry > div { min-width: 0; }
.entry .t {
  text-decoration: none;
  color: var(--ink);
  text-decoration-color: var(--link-underline);
}
.entry .t:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.entry .d {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  white-space: nowrap;
}
.entry .desc {
  display: block;
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 0.15rem;
  line-height: 1.5;
}

/* ============ footer ============ */
footer {
  flex-shrink: 0;
  background: var(--elev);
  border-top: 1px solid var(--rule);
}
.footer-inner {
  width: 100%;
  max-width: 58rem;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}
@media (max-width: 780px) {
  .footer-inner { padding: 1.25rem 1.5rem; max-width: 34rem; flex-wrap: wrap; }
}
.footer-inner a { color: var(--muted); text-decoration: none; }
.footer-inner a:hover { color: var(--ink); }
.footer-inner .sep { color: var(--faint); }
.footer-inner .spacer { flex: 1; }
.footer-inner .copy { color: var(--faint); }

/* theme toggle: shows current mode */
.theme {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.theme:hover { color: var(--ink); border-color: var(--faint); }
.theme .dot {
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  border: 1px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

/* ============ a11y / motion ============ */
a:focus-visible, .name:focus-visible, .theme:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}