/* Theme + base */
:root {
  --bg: #F5F1EA;
  --bg-elev: #FBF8F2;
  --ink: #1A1916;
  --ink-soft: #4A4842;
  --ink-mute: #82807A;
  --rule: #E6DFD2;
  --rule-soft: #EFE9DC;
  --accent: #B85A3C;   /* warm clay */
  --accent-soft: #E8C9BB;
  --tag-bg: #ECE5D6;
  --selection: #E8D8B8;
}

[data-theme="ink"] {
  --bg: #14130F;
  --bg-elev: #1C1B17;
  --ink: #F2EDE2;
  --ink-soft: #C7C2B5;
  --ink-mute: #8A867B;
  --rule: #2B2924;
  --rule-soft: #23211D;
  --accent: #E48865;
  --accent-soft: #4A2E25;
  --tag-bg: #26241F;
  --selection: #3A3326;
}

[data-theme="sage"] {
  --bg: #EEF0EA;
  --bg-elev: #F6F7F2;
  --ink: #1A1F1A;
  --ink-soft: #43483F;
  --ink-mute: #7A8077;
  --rule: #DDE2D3;
  --rule-soft: #E5E9DB;
  --accent: #4F7A4F;
  --accent-soft: #C9D9C5;
  --tag-bg: #DEE4D2;
  --selection: #CDDCC4;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--selection); color: var(--ink); }
a { color: inherit; text-decoration: none; }
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent-soft);
  transition: text-decoration-color .15s;
}
.prose a:hover { text-decoration-color: var(--accent); }

.serif { font-family: 'Instrument Serif', 'Iowan Old Style', Georgia, serif; font-weight: 400; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* Layout */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 48px;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 56px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.brand .dot {
  width: 9px; height: 9px; border-radius: 99px;
  background: var(--accent); display: inline-block;
  transform: translateY(1px);
}
.brand .sub { color: var(--ink-mute); font-weight: 400; font-size: 14px; }

.navlinks {
  display: flex; gap: 28px;
  font-size: 14px; color: var(--ink-soft);
}
.navlinks a { padding: 6px 0; position: relative; cursor: pointer; transition: color .15s; }
.navlinks a:hover { color: var(--ink); }
.navlinks .theme-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--rule); border-radius: 99px; padding: 6px 12px;
  background: var(--bg-elev); cursor: pointer; color: var(--ink-soft);
  font: inherit;
}
.navlinks .theme-btn:hover { color: var(--ink); }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 80px;
  align-items: start;
}

/* Header section */
.intro {
  margin-bottom: 56px;
}
.intro .eyebrow {
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-mute); margin-bottom: 14px;
}
.intro h1 {
  font-family: var(--title-font, 'Space Grotesk'), system-ui, sans-serif;
  font-weight: var(--title-weight, 600);
  font-size: clamp(48px, 6vw, 76px);
  line-height: 1.02;
  letter-spacing: var(--title-tracking, -0.035em);
  margin: 0 0 18px;
  color: var(--ink);
  text-wrap: balance;
}
.intro h1 em {
  font-style: var(--title-em-style, normal);
  color: var(--accent);
}
.intro p.lede {
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 600px;
  margin: 0;
  text-wrap: pretty;
}

/* Category filter */
.cats {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
}
.cat {
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 99px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.cat:hover { color: var(--ink); border-color: var(--ink-mute); }
.cat.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.cat .count {
  font-size: 11px; opacity: 0.55; margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* Post list */
.posts { display: flex; flex-direction: column; }
.post-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 32px;
  padding: 28px 0;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  align-items: baseline;
  transition: padding .25s ease;
}
.post-row:last-child { border-bottom: none; }
.post-row:hover { padding-left: 8px; }
.post-row:hover .post-title { color: var(--accent); }

[data-row-hover="tint"] .post-row:hover { padding-left: 0; background: var(--rule-soft); margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: 4px; }
[data-row-hover="none"] .post-row:hover { padding-left: 0; }
[data-row-hover="none"] .post-row:hover .post-title { color: var(--ink); }

/* Title-font tweak presets */
[data-title-font="grotesk"] {
  --title-font: 'Space Grotesk';
  --title-weight: 600;
  --title-tracking: -0.025em;
  --title-em-style: normal;
}
[data-title-font="inter-tight"] {
  --title-font: 'Inter Tight';
  --title-weight: 600;
  --title-tracking: -0.03em;
  --title-em-style: normal;
}
[data-title-font="fraunces"] {
  --title-font: 'Fraunces';
  --title-weight: 500;
  --title-tracking: -0.015em;
  --title-em-style: italic;
}
[data-title-font="instrument"] {
  --title-font: 'Instrument Serif';
  --title-weight: 400;
  --title-tracking: -0.015em;
  --title-em-style: italic;
}
[data-title-font="fraunces"] .post-title,
[data-title-font="instrument"] .post-title,
[data-title-font="fraunces"] .detail h1.post-h,
[data-title-font="instrument"] .detail h1.post-h,
[data-title-font="fraunces"] .prose h2,
[data-title-font="instrument"] .prose h2 {
  font-size: 28px;
  line-height: 1.15;
}
[data-title-font="fraunces"] .detail h1.post-h,
[data-title-font="instrument"] .detail h1.post-h {
  font-size: clamp(40px, 5vw, 60px);
  line-height: 1.05;
}
[data-title-font="fraunces"] .intro h1,
[data-title-font="instrument"] .intro h1 {
  letter-spacing: -0.02em;
}

.post-meta {
  font-size: 12px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.5;
}
.post-meta .date { display: block; color: var(--ink-soft); }
.post-meta .read { display: block; margin-top: 2px; }

.post-title {
  font-family: var(--title-font, 'Space Grotesk'), system-ui, sans-serif;
  font-weight: var(--title-weight, 600);
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: var(--title-tracking, -0.025em);
  color: var(--ink);
  margin: 0 0 8px;
  transition: color .15s;
  text-wrap: balance;
}
.post-excerpt {
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0;
  max-width: 56ch;
  text-wrap: pretty;
}

.post-tag {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--tag-bg);
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
  align-self: start;
  margin-top: 4px;
}

/* Sidebar profile */
.sidebar { position: sticky; top: 32px; }
.profile {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 24px;
}
.profile .name {
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}
.profile .role {
  font-size: 15px;
  color: var(--ink-mute);
  margin: 0 0 16px;
}
.profile .bio {
  font-size: 15.5px;
  color: var(--ink-soft);
  line-height: 1.58;
  margin: 0 0 20px;
  text-wrap: pretty;
}
.profile .links {
  display: flex; flex-direction: column; gap: 2px;
  border-top: 1px solid var(--rule); padding-top: 14px;
  margin-bottom: 4px;
}
.profile .link-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0;
  font-size: 15px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .15s;
}
.profile .link-row:hover { color: var(--accent); }
.profile .link-row .label { color: var(--ink-mute); font-size: 13px; }
.profile .link-row .val { font-variant-numeric: tabular-nums; }

.profile .status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.status .pulse {
  width: 7px; height: 7px; border-radius: 99px;
  background: #4F9D4F;
  box-shadow: 0 0 0 0 rgba(79, 157, 79, 0.55);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 157, 79, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(79, 157, 79, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 157, 79, 0); }
}

/* Side widget: subscribe */
.side-widget {
  margin-top: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 20px 22px;
}
.side-widget h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 500;
}
.side-widget p {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--ink-mute);
  line-height: 1.5;
}
.subscribe {
  display: flex; gap: 6px;
}
.subscribe input {
  flex: 1; min-width: 0;
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 8px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.subscribe input:focus { border-color: var(--ink-mute); }
.subscribe button {
  background: var(--ink);
  color: var(--bg);
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: opacity .15s;
}
.subscribe button:hover { opacity: 0.88; }
.subscribe button.done { background: var(--accent); }

/* Side widget: recent */
.side-recent { margin-top: 20px; }
.side-recent h4 {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0 0 14px;
  font-weight: 500;
}
.side-recent ul { list-style: none; padding: 0; margin: 0; }
.side-recent li {
  font-size: 13.5px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule-soft);
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1.4;
  transition: color .15s;
}
.side-recent li:last-child { border-bottom: none; }
.side-recent li:hover { color: var(--accent); }
.side-recent li .n {
  font-size: 11px; color: var(--ink-mute);
  margin-right: 10px; font-variant-numeric: tabular-nums;
}

/* Post detail view */
.detail {
  max-width: 720px;
}
.back {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-mute);
  cursor: pointer; margin-bottom: 40px;
  transition: color .15s;
}
.back:hover { color: var(--accent); }
.back svg { width: 14px; height: 14px; }

.detail .post-tag { margin-bottom: 18px; display: inline-block; }
.detail h1.post-h {
  font-family: var(--title-font, 'Space Grotesk'), system-ui, sans-serif;
  font-weight: var(--title-weight, 600);
  font-size: clamp(40px, 5vw, 58px);
  line-height: 1.08;
  letter-spacing: var(--title-tracking, -0.03em);
  margin: 8px 0 24px;
  text-wrap: balance;
}
.detail .post-meta-row {
  display: flex; gap: 18px;
  font-size: 13px; color: var(--ink-mute);
  padding-bottom: 28px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 36px;
}
.detail .post-meta-row .sep { color: var(--rule); }

.prose p, .prose h2, .prose .pull, .prose pre.code { max-width: 64ch; }

.prose pre.code {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 22px 0 28px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}
.prose pre.code code {
  font-family: inherit;
  background: none;
  border: 0;
  padding: 0;
}
.prose p code, .prose h2 code, .prose .pull code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.88em;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink);
}
.prose p {
  font-size: 19px;
  line-height: 1.7;
  color: var(--ink-soft);
  margin: 0 0 24px;
  text-wrap: pretty;
}
.prose h2 {
  font-family: var(--title-font, 'Space Grotesk'), system-ui, sans-serif;
  font-weight: var(--title-weight, 600);
  font-size: 27px;
  line-height: 1.25;
  letter-spacing: var(--title-tracking, -0.02em);
  color: var(--ink);
  margin: 48px 0 18px;
}
.prose .pull {
  font-family: var(--title-font, 'Space Grotesk'), system-ui, sans-serif;
  font-style: var(--title-em-style, normal);
  font-weight: var(--title-weight, 500);
  font-size: 24px;
  line-height: 1.4;
  letter-spacing: var(--title-tracking, -0.015em);
  color: var(--ink);
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 24px;
  margin: 36px 0;
  text-wrap: balance;
}

.detail .endmark {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
  display: flex; align-items: center; gap: 14px;
  color: var(--ink-mute); font-size: 13.5px;
}
.endmark .glyph {
  width: 10px; height: 10px; background: var(--accent);
  border-radius: 2px; transform: rotate(45deg);
}

footer.foot {
  margin-top: 96px;
  padding: 36px 0 56px;
  border-top: 1px solid var(--rule);
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: var(--ink-mute);
}
.foot .colophon { max-width: 360px; }

/* Responsive */
@media (max-width: 960px) {
  .grid { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .shell { padding: 0 28px; }
  .post-row { grid-template-columns: 1fr auto; }
  .post-row .post-meta { grid-column: 1 / -1; display: flex; gap: 14px; margin-bottom: 4px; }
  .post-meta .date, .post-meta .read { display: inline; margin: 0; }
}
