:root {
  --bg: #ffffff;
  --surface: #f7f8f8;
  --ink: #0f1419;
  --muted: #66707a;
  --line: #e1e4e8;
  --accent: #cc3333;
  --maxw: 600px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root, [data-theme="auto"], [data-theme="blog"] {
    --bg: #16181c;
    --surface: #1c1f24;
    --ink: #e7e9ea;
    --muted: #8b98a5;
    --line: #2a2e35;
    --accent: #ff6c60;
  }
}

[data-theme="light"] {
  --bg: #ffffff; --surface: #f7f8f8; --ink: #0f1419;
  --muted: #66707a; --line: #e1e4e8; --accent: #cc3333;
}
[data-theme="dark"] {
  --bg: #16181c; --surface: #1c1f24; --ink: #e7e9ea;
  --muted: #8b98a5; --line: #2a2e35; --accent: #ff6c60;
}
[data-theme="substack"] {
  --bg: #fbfaf8; --surface: #f3efe7; --ink: #1a1a1a;
  --muted: #6f6f6f; --line: #e6e0d4; --accent: #ff6719;
}
[data-theme="sepia"] {
  --bg: #f4ecd8; --surface: #ece2c8; --ink: #43341f;
  --muted: #8a7a5a; --line: #dccfae; --accent: #9a3b2f;
}
[data-theme="dim"] {
  --bg: #15202b; --surface: #1c2732; --ink: #f7f9f9;
  --muted: #8899a6; --line: #38444d; --accent: #1d9bf0;
}

* { box-sizing: border-box; }

html { scroll-padding-top: 3.5rem; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.muted a { color: var(--muted); }
img { max-width: 100%; height: auto; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { color: var(--accent); font-weight: 700; font-size: 1.1rem; }
.search { display: flex; margin-left: auto; width: min(24rem, 55%); }
.search input {
  flex: 1; min-width: 0;
  padding: 5px 8px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
}
.search button {
  padding: 0 10px;
  font: inherit;
  cursor: pointer;
  color: var(--bg);
  background: var(--accent);
  border: 1px solid var(--accent);
}

main {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 12px;
  flex: 1;
}

.hero { padding: 2rem 0; }
.hero h1 { font-size: 1.6rem; margin: 0 0 .4rem; }
.lede { color: var(--muted); margin: 0 0 1rem; }
.search.big { width: 100%; margin: 0 0 .75rem; }
.search.big input { padding: 8px 10px; }
.hint { font-size: .85rem; }
code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .85em;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0 .3em;
}

.pubhead, .profilehead {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.pubhead h1, .profilehead h1 { font-size: 1.25rem; margin: 0; }
.publogo { width: 72px; height: 72px; border-radius: 3px; object-fit: cover; flex: none; }
.avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; flex: none; }
.bio { margin: .3rem 0 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a {
  padding: 8px 12px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }

.section {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 1rem 0 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.cards { list-style: none; margin: 0; padding: 0; }
.card { border-bottom: 1px solid var(--line); }
.card-link { display: flex; gap: 10px; padding: 12px 0; color: var(--ink); }
.card-link:hover { text-decoration: none; }
.cover { width: 140px; height: 79px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.card-body { flex: 1; min-width: 0; }
.card h2 { font-size: 1rem; margin: 0 0 .2rem; line-height: 1.25; }
.card .sub { margin: 0 0 .3rem; color: var(--muted); font-size: .9rem; }
.card .meta { font-size: .8rem; margin: 0; }
.tag {
  display: inline-block;
  font-size: .7rem;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--line);
  padding: 0 .3em;
  margin-bottom: .2rem;
}
.tag.paid { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.pubsearch { width: 100%; margin: 8px 0; }
.empty { padding: 1.5rem 0; }
.pager { display: flex; justify-content: space-between; padding: 12px 0; }

.post { padding: 12px 0; }
.eyebrow { margin: 0 0 .3rem; font-size: .85rem; }
.post > h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 .3rem; }
.deck { color: var(--muted); margin: 0 0 .5rem; }
.byline { font-size: .85rem; margin: 0 0 1rem; }
.byline a { color: var(--muted); }
.hero-img { width: 100%; border: 1px solid var(--line); margin: 0 0 1rem; }

.prose { font-family: var(--serif); font-size: 1.05rem; line-height: 1.6; }
.prose p { margin: 0 0 1rem; }
.mention { color: var(--accent); font-weight: 500; text-decoration: none; }
.prose img { display: block; margin: 1rem 0; border: 1px solid var(--line); }
.prose h1, .prose h2, .prose h3 { line-height: 1.25; margin: 1.5rem 0 .5rem; }
.prose blockquote {
  margin: 1rem 0;
  padding-left: 12px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.prose pre {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 10px;
  overflow: auto;
  font-size: .85rem;
}
.prose hr { border: none; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.prose figcaption { font-family: var(--sans); font-size: .8rem; color: var(--muted); text-align: center; }

.prose .footnote-anchor { font-size: .7em; vertical-align: super; line-height: 0; text-decoration: none; color: var(--accent); padding: 0 1px; }
.prose .footnotes { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); font-family: var(--sans); font-size: .9rem; }
.prose .footnote { display: flex; gap: .5rem; margin: .5rem 0; scroll-margin-top: 3.5rem; }
.prose .footnote-number { flex: none; color: var(--accent); text-decoration: none; font-weight: 600; }
.prose .footnote-content { min-width: 0; }
.prose .footnote-content > :first-child { margin-top: 0; }
.prose .footnote-content > :last-child { margin-bottom: 0; }
.image-link-expand { display: none; }
.subscription-widget-wrap-editor,
.subscription-widget-wrap,
.subscription-widget,
.paywall-jump { display: none; }
.postfoot { margin-top: 1rem; padding-top: 10px; border-top: 1px solid var(--line); font-size: .85rem; }
.podcast { width: 100%; margin: 0 0 1rem; }
.podmeta { font-size: .8rem; margin: -.5rem 0 1rem; }
.tags { margin: 1rem 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.react { display: inline-block; margin-right: .4rem; }
.authors { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: .75rem; }
.author { display: flex; gap: .6rem; }
.author .pav { width: 40px; height: 40px; }
.author p { margin: .2rem 0 0; font-size: .9rem; }

.publist, .people, .notes { list-style: none; margin: 0; padding: 0; }
.publist li { border-bottom: 1px solid var(--line); }
.publist a { display: flex; gap: 8px; align-items: center; padding: 10px 0; color: var(--ink); }
.publist img { width: 40px; height: 40px; border-radius: 3px; object-fit: cover; flex: none; }

.person { display: flex; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pav { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; }
.pmeta { flex: 1; min-width: 0; }
.pname { font-size: .95rem; }
.pbody { margin-top: .2rem; }
.pbody p { margin: 0 0 .3rem; }

.note { padding: 12px 0; border-bottom: 1px solid var(--line); }
.note-body p { margin: 0 0 .5rem; }
.note-body p:last-child { margin-bottom: .3rem; }
.note .meta { font-size: .8rem; margin: 0; }
.note-img { max-width: 100%; max-height: 420px; border: 1px solid var(--line); border-radius: 4px; margin: .5rem 0; display: block; }
.cmt-pub { font-size: .8rem; text-decoration: none; }

.linkcard { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 4px; padding: 8px; margin: .5rem 0; color: var(--ink); }
.linkcard:hover { border-color: var(--accent); text-decoration: none; }
.linkcard img { width: 72px; height: 72px; object-fit: cover; border-radius: 3px; flex: none; }
.lc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lc-desc { font-size: .85rem; }
.lc-host { font-size: .72rem; }

.comments { margin-top: 1rem; }
.automod { margin-top: 1rem; }
.automod > summary { cursor: pointer; color: var(--muted); padding: 8px 0; border-top: 1px solid var(--line); }
.automod[open] > summary { color: var(--accent); }
.cmt-list, .cmt-children { list-style: none; margin: 0; padding: 0; }
.cmt { padding: 10px 0; border-top: 1px solid var(--line); }
.cmt-children {
  margin: 8px 0 0 4px;
  padding-left: 10px;
  border-left: 2px solid var(--line);
}
.cmt-children .cmt { border-top: none; padding: 6px 0; }
.cmt-head { display: flex; align-items: center; gap: 6px; margin-bottom: .25rem; }
.cmt-av { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.cmt-name { font-weight: 600; font-size: .9rem; }
.cmt-meta { font-size: .75rem; }
.cmt-body { font-size: .95rem; }
.cmt-body p { margin: 0 0 .4rem; }
.cmt-body p:last-child { margin-bottom: 0; }

.foot {
  border-top: 1px solid var(--line);
  padding: 12px;
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
}
.foot span { margin: 0 .4rem; }
.themes { margin-top: .5rem; display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; }
.themes a { color: var(--muted); text-transform: capitalize; padding: 0 .3rem; }
.themes a.on { color: var(--accent); font-weight: 600; }
