@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400&display=swap');

:root {
  --bg: #FAF8F4;
  --bg-elev: rgba(250, 248, 244, 0.88);
  --surface: #F3F0E8;
  --ink: #191816;
  --ink-soft: #43403A;
  --muted: #7B766C;
  --faint: #B6B0A4;
  --rule: #E8E3D9;
  --accent: #A63D17;
  --accent-bg: rgba(166, 61, 23, 0.08);
  --code-bg: #F2EFE8;
  --syn-kw: #8B2F1D;
  --syn-str: #2D6A4F;
  --syn-com: #8C867B;
  --syn-fn: #1E4E79;
  --syn-num: #9A5B13;
  --syn-type: #5B3E85;
  --syn-op: #6E685F;
  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, monospace;
  --measure: 64ch;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --bg-elev: rgba(17, 17, 16, 0.88);
    --surface: #1A1917;
    --ink: #EAE6DD;
    --ink-soft: #C6C1B7;
    --muted: #868178;
    --faint: #4C4943;
    --rule: #242320;
    --accent: #E08E52;
    --accent-bg: rgba(224, 142, 82, 0.12);
    --code-bg: #181715;
    --syn-kw: #E08E52;
    --syn-str: #84B896;
    --syn-com: #6E6A62;
    --syn-fn: #7CAED6;
    --syn-num: #D9A75B;
    --syn-type: #B695D9;
    --syn-op: #9E988E;
  }
}
:root[data-theme="dark"] {
  --bg: #111110;
  --bg-elev: rgba(17, 17, 16, 0.88);
  --surface: #1A1917;
  --ink: #EAE6DD;
  --ink-soft: #C6C1B7;
  --muted: #868178;
  --faint: #4C4943;
  --rule: #242320;
  --accent: #E08E52;
  --accent-bg: rgba(224, 142, 82, 0.12);
  --code-bg: #181715;
  --syn-kw: #E08E52;
  --syn-str: #84B896;
  --syn-com: #6E6A62;
  --syn-fn: #7CAED6;
  --syn-num: #D9A75B;
  --syn-type: #B695D9;
  --syn-op: #9E988E;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: 19px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  line-height: 1.74;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

/* Hairline reading progress */
.progress-bar {
  position: fixed; top: 0; left: 0; height: 2px; width: 0%;
  background: var(--accent); z-index: 60; pointer-events: none;
  transition: width 0.08s linear;
}

/* Whisper-quiet floating header */
.chrome {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-elev);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s var(--ease), opacity 0.3s var(--ease);
}
.chrome.scrolled { border-bottom-color: var(--rule); }
.chrome-inner {
  max-width: 900px; margin: 0 auto; padding: 0.85rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  font-family: var(--font-sans);
}
.wordmark {
  display: inline-flex; align-items: baseline; gap: 0.65rem;
  color: var(--ink); text-decoration: none;
}
.wordmark-name {
  font-family: var(--font-serif); font-size: 1.05rem; font-weight: 500; letter-spacing: -0.015em;
}
.wordmark-span {
  font-family: var(--font-mono); font-size: 0.66rem; color: var(--muted); letter-spacing: 0.03em;
}
.chrome-actions { display: flex; align-items: center; gap: 0.35rem; }
.icon-btn {
  appearance: none; background: transparent; border: 1px solid transparent;
  color: var(--muted); font-family: var(--font-sans); font-size: 0.72rem; font-weight: 500;
  padding: 0.32rem 0.55rem; border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.38rem;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--ink); background: var(--surface); }
.kbd {
  font-family: var(--font-mono); font-size: 0.62rem; color: var(--muted);
  border: 1px solid var(--rule); border-radius: 4px; padding: 0.05rem 0.3rem; line-height: 1.3;
}

/* ================================================================
   HOME: LIVING 30-YEAR SCRUBBER & EDITORIAL STREAM
   ================================================================ */
.home-shell { max-width: 900px; margin: 0 auto; padding: 2.2rem 1.5rem 6rem; }

.scrubber-wrap {
  margin: 0 0 2.2rem;
  user-select: none;
}
.scrubber-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 0.65rem; min-height: 1.3rem;
  font-family: var(--font-sans); font-size: 0.74rem; color: var(--muted);
}
.scrubber-readout {
  display: flex; align-items: baseline; gap: 0.6rem;
  color: var(--ink); font-weight: 500;
}
.scrubber-readout .yr-big {
  font-family: var(--font-serif); font-size: 1.15rem; font-weight: 500; letter-spacing: -0.02em;
}
.scrubber-readout .yr-detail { font-size: 0.72rem; color: var(--muted); font-weight: 400; }
.scrubber-clear {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-family: var(--font-sans); font-size: 0.72rem; padding: 0; display: none;
}
.scrubber-clear.visible { display: inline; }

.scrubber-bars {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  align-items: end;
  gap: 3px;
  height: 68px;
  padding: 6px 0 0;
  border-bottom: 1px solid var(--rule);
  cursor: ew-resize;
  touch-action: none;
}
.sbar {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 0;
}
.sbar-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--faint);
  opacity: 0.48;
  transition: background 0.12s, opacity 0.12s, transform 0.12s;
}
.sbar.empty .sbar-fill { height: 2px !important; opacity: 0.18; }
.sbar:hover .sbar-fill, .sbar.hover .sbar-fill { background: var(--ink); opacity: 0.9; }
.sbar.selected .sbar-fill { background: var(--accent); opacity: 1; }
.sbar.in-range .sbar-fill { background: var(--accent); opacity: 0.78; }

.scrubber-ticks {
  display: flex; justify-content: space-between;
  margin-top: 0.35rem;
  font-family: var(--font-mono); font-size: 0.62rem; color: var(--muted);
}

/* Minimal editorial lenses */
.lenses {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.25rem;
  margin-bottom: 2.2rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.65rem;
  font-family: var(--font-sans); font-size: 0.76rem;
}
.lens {
  background: none; border: none; padding: 0.25rem 0; cursor: pointer;
  color: var(--muted); font-family: inherit; font-size: inherit; font-weight: 400;
  position: relative; transition: color 0.15s;
}
.lens:hover { color: var(--ink); }
.lens.active { color: var(--ink); font-weight: 500; }
.lens.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -0.71rem;
  height: 1.5px; background: var(--accent);
}
.lens-count {
  font-family: var(--font-mono); font-size: 0.62rem; color: var(--faint); margin-left: 0.25rem;
}
.lens.active .lens-count { color: var(--muted); }
.lens-spacer { flex: 1; }
.excerpt-toggle {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-family: var(--font-sans); font-size: 0.7rem; padding: 0.2rem 0;
}
.excerpt-toggle:hover, .excerpt-toggle.on { color: var(--ink); }

/* Year sections & airy essay rows */
.year-group {
  display: grid;
  grid-template-columns: 4.4rem 1fr;
  gap: 0 2rem;
  margin-bottom: 2.6rem;
}
.year-label {
  position: sticky; top: 3.6rem; align-self: start;
  font-family: var(--font-mono); font-size: 0.76rem; font-weight: 500;
  color: var(--muted); padding-top: 0.6rem; letter-spacing: 0.02em;
}
.year-items { list-style: none; margin: 0; padding: 0; }
.entry {
  border-top: 1px solid var(--rule);
}
.entry:last-child { border-bottom: 1px solid var(--rule); }
.entry a {
  display: block; padding: 0.62rem 0; text-decoration: none; color: inherit;
  transition: opacity 0.15s;
}
.entry-top {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 1rem;
}
.entry-title {
  font-family: var(--font-serif); font-size: 1.04rem; font-weight: 400; line-height: 1.38;
  color: var(--ink); transition: color 0.14s;
}
.entry.is-essay .entry-title { font-weight: 500; }
.entry a:hover .entry-title, .entry.kb-focus .entry-title { color: var(--accent); }
.entry-meta {
  display: inline-flex; align-items: center; gap: 0.65rem;
  font-family: var(--font-mono); font-size: 0.66rem; color: var(--muted);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.len-tick {
  display: inline-block; height: 2px; border-radius: 1px;
  background: var(--faint); vertical-align: middle; opacity: 0.7;
}
.entry.is-essay .len-tick { background: var(--accent); opacity: 0.65; }
.entry-excerpt {
  margin: 0.22rem 0 0.12rem;
  font-family: var(--font-serif); font-size: 0.84rem; line-height: 1.5;
  color: var(--muted); max-width: 62ch;
}
body.compact-stream .entry-excerpt { display: none; }

/* Guides shelf (when Guides lens is active) */
.guides-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}
.guide-card {
  display: block; text-decoration: none; color: inherit;
  padding: 1.25rem 1.35rem; border: 1px solid var(--rule); border-radius: 8px;
  transition: border-color 0.15s, transform 0.15s;
}
.guide-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.guide-card h3 {
  margin: 0 0 0.4rem; font-family: var(--font-serif); font-size: 1.08rem; font-weight: 500;
  line-height: 1.3; color: var(--ink);
}
.guide-card p {
  margin: 0 0 0.6rem; font-size: 0.82rem; line-height: 1.5; color: var(--muted);
}
.guide-card .gmeta { font-family: var(--font-mono); font-size: 0.65rem; color: var(--faint); }

/* ================================================================
   ARTICLE READING SANCTUARY
   ================================================================ */
.article-layout {
  max-width: 1120px; margin: 0 auto; padding: 3.4rem 1.5rem 6rem;
  display: grid; grid-template-columns: 1fr minmax(0, var(--measure)) 1fr; gap: 0 2.5rem;
}
.article-col { grid-column: 2; min-width: 0; }

/* Quiet margin TOC (desktop wide only) */
.margin-toc {
  grid-column: 1; justify-self: end; width: 190px;
  position: sticky; top: 5.5rem; align-self: start;
  font-family: var(--font-sans); font-size: 0.68rem; line-height: 1.45;
  padding-right: 0.5rem;
}
.margin-toc-title {
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.6rem;
  color: var(--faint); margin-bottom: 0.6rem; font-weight: 600;
}
.margin-toc ul { list-style: none; margin: 0; padding: 0; }
.margin-toc li { margin-bottom: 0.4rem; }
.margin-toc li.lvl-3 { padding-left: 0.7rem; }
.margin-toc a {
  color: var(--muted); text-decoration: none; display: block;
  transition: color 0.15s;
}
.margin-toc a:hover, .margin-toc a.active { color: var(--ink); }
.margin-toc a.active { color: var(--accent); font-weight: 500; }

header.essay-head { margin-bottom: 2.8rem; }
header.essay-head h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.95rem, 4.4vw, 2.75rem);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -0.025em;
  text-wrap: balance;
  margin: 0 0 0.9rem;
}
.essay-byline {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* Prose typography */
article.prose {
  hanging-punctuation: first last;
  hyphens: auto;
  -webkit-hyphens: auto;
}
article.prose p { margin: 0 0 1.28rem; }
article.prose h2 {
  font-family: var(--font-serif);
  font-size: 1.42rem; font-weight: 500; line-height: 1.28;
  letter-spacing: -0.018em; margin: 2.75rem 0 0.85rem;
  scroll-margin-top: 4.5rem;
}
article.prose h3 {
  font-family: var(--font-sans);
  font-size: 0.95rem; font-weight: 600; line-height: 1.38;
  letter-spacing: -0.005em; margin: 2.1rem 0 0.65rem;
  color: var(--ink-soft); scroll-margin-top: 4.5rem;
}
article.prose h4 {
  font-family: var(--font-sans); font-size: 0.85rem; font-weight: 600;
  margin: 1.6rem 0 0.5rem; color: var(--muted);
}
article.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.14s, text-decoration-color 0.14s;
}
article.prose a:hover { color: var(--accent); text-decoration-color: var(--accent); }
article.prose a.dead-link {
  color: var(--muted); text-decoration-style: dotted; text-decoration-color: var(--faint);
}
article.prose ul, article.prose ol { margin: 0 0 1.35rem; padding-left: 1.4rem; }
article.prose li { margin-bottom: 0.42rem; }
article.prose li::marker { color: var(--muted); }
article.prose blockquote {
  margin: 1.75rem 0; padding: 0.1rem 0 0.1rem 1.35rem;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft); font-style: italic;
}
article.prose blockquote p:last-child { margin-bottom: 0; }
article.prose hr {
  border: none; height: 1px; background: var(--rule);
  margin: 2.8rem auto; max-width: 120px;
}
article.prose img {
  display: block; max-width: 100%; height: auto;
  margin: 2.1rem auto; border-radius: 4px;
  cursor: zoom-in;
}
article.prose table {
  width: 100%; border-collapse: collapse; margin: 1.8rem 0;
  font-family: var(--font-sans); font-size: 0.78rem; line-height: 1.5;
}
article.prose th, article.prose td {
  border-bottom: 1px solid var(--rule); padding: 0.55rem 0.65rem; text-align: left;
}
article.prose th { font-weight: 600; color: var(--muted); border-bottom-width: 1.5px; }

/* Code & Pygments warm editorial palette */
article.prose code {
  font-family: var(--font-mono); font-size: 0.79em;
  background: var(--code-bg); padding: 0.1em 0.34em; border-radius: 4px;
  hyphens: none; -webkit-hyphens: none;
}
article.prose .codehilite, article.prose pre {
  position: relative;
  background: var(--code-bg);
  border-radius: 6px;
  margin: 1.7rem 0;
  overflow-x: auto;
}
article.prose .codehilite pre {
  margin: 0; padding: 1.1rem 1.25rem; background: transparent;
  font-family: var(--font-mono); font-size: 0.74rem; line-height: 1.6;
  hyphens: none; -webkit-hyphens: none;
}
article.prose > pre {
  padding: 1.1rem 1.25rem;
  font-family: var(--font-mono); font-size: 0.74rem; line-height: 1.6;
}
article.prose pre code { background: none; padding: 0; font-size: inherit; }
.codehilite .k, .codehilite .kd, .codehilite .kn, .codehilite .kp, .codehilite .kr, .codehilite .kt { color: var(--syn-kw); font-weight: 500; }
.codehilite .s, .codehilite .s1, .codehilite .s2, .codehilite .sb, .codehilite .sc, .codehilite .sd, .codehilite .se, .codehilite .si { color: var(--syn-str); }
.codehilite .c, .codehilite .c1, .codehilite .cm, .codehilite .cs, .codehilite .cp { color: var(--syn-com); font-style: italic; }
.codehilite .nf, .codehilite .fm, .codehilite .na { color: var(--syn-fn); }
.codehilite .nc, .codehilite .nn, .codehilite .nt { color: var(--syn-type); }
.codehilite .m, .codehilite .mi, .codehilite .mf, .codehilite .mh, .codehilite .mo { color: var(--syn-num); }
.codehilite .o, .codehilite .ow { color: var(--syn-op); }

/* Collapsible archived comments — serene by default */
details.comments-fold {
  margin-top: 3.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
}
details.comments-fold summary {
  cursor: pointer; list-style: none;
  font-family: var(--font-sans); font-size: 0.76rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: 0.45rem;
  transition: color 0.15s;
}
details.comments-fold summary::-webkit-details-marker { display: none; }
details.comments-fold summary:hover { color: var(--ink); }
details.comments-fold summary::before { content: "+"; font-family: var(--font-mono); color: var(--faint); }
details.comments-fold[open] summary::before { content: "−"; }
.comments-body { margin-top: 1.6rem; font-size: 0.88rem; color: var(--ink-soft); }
.comments-body h3 {
  font-family: var(--font-sans); font-size: 0.76rem; font-weight: 500;
  color: var(--muted); margin: 1.8rem 0 0.4rem;
}
.comments-body p { margin: 0 0 0.9rem; }

/* Minimal essay pagination */
nav.essay-nav {
  margin-top: 4rem; padding-top: 1.6rem; border-top: 1px solid var(--rule);
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
  font-family: var(--font-serif); font-size: 0.9rem;
}
nav.essay-nav a {
  text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 0.2rem;
}
nav.essay-nav a.next { text-align: right; align-items: flex-end; }
nav.essay-nav .nav-dir {
  font-family: var(--font-mono); font-size: 0.64rem; color: var(--muted); letter-spacing: 0.04em;
}
nav.essay-nav a:hover .nav-title { color: var(--accent); }

/* ================================================================
   UNIVERSAL CMD+K FULL-TEXT COMMAND PALETTE
   ================================================================ */
.cmdk-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 14, 12, 0.42);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center;
  padding: min(14vh, 110px) 1rem 2rem;
}
.cmdk-backdrop.open { display: flex; }
.cmdk-panel {
  width: 100%; max-width: 620px;
  background: var(--bg); border: 1px solid var(--rule);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  font-family: var(--font-sans);
}
.cmdk-input-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.85rem 1.05rem; border-bottom: 1px solid var(--rule);
}
.cmdk-input-row input {
  flex: 1; border: none; outline: none; background: transparent;
  color: var(--ink); font-family: var(--font-sans); font-size: 0.92rem;
}
.cmdk-input-row input::placeholder { color: var(--muted); }
.cmdk-results { max-height: 54vh; overflow-y: auto; padding: 0.35rem; }
.cmdk-item {
  display: block; text-decoration: none; color: inherit;
  padding: 0.6rem 0.75rem; border-radius: 7px; cursor: pointer;
}
.cmdk-item:hover, .cmdk-item.active { background: var(--surface); }
.cmdk-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; }
.cmdk-item-title { font-family: var(--font-serif); font-size: 0.96rem; font-weight: 500; color: var(--ink); }
.cmdk-item-date { font-family: var(--font-mono); font-size: 0.66rem; color: var(--muted); white-space: nowrap; }
.cmdk-item-snip {
  margin-top: 0.18rem; font-size: 0.74rem; line-height: 1.45; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cmdk-item-snip mark {
  background: var(--accent-bg); color: var(--accent); padding: 0 2px; border-radius: 2px;
}
.cmdk-foot {
  padding: 0.5rem 0.9rem; border-top: 1px solid var(--rule);
  display: flex; justify-content: space-between; font-size: 0.66rem; color: var(--muted);
}

/* Lightbox for zoomed images */
.lightbox {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(12, 12, 11, 0.9);
  display: none; align-items: center; justify-content: center;
  padding: 2rem; cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 4px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }

/* Responsive */
@media (max-width: 1140px) {
  .article-layout { display: block; max-width: calc(var(--measure) + 3rem); }
  .margin-toc { display: none; }
}
@media (max-width: 680px) {
  html { font-size: 17px; }
  .year-group { grid-template-columns: 1fr; gap: 0.35rem; }
  .year-label { position: static; padding-top: 0; }
  .scrubber-bars { height: 52px; gap: 2px; }
  .len-tick { display: none; }
  .wordmark-span { display: none; }
  nav.essay-nav { grid-template-columns: 1fr; }
}
