:root {
  --bg: #faf9f6;
  --bg-elev: #ffffff;
  --bg-subtle: #f3f1ec;
  --border: #e8e4db;
  --border-strong: #d8d2c4;
  --text: #1a1816;
  --text-muted: #6b665e;
  --text-soft: #8a8478;
  --accent: #d4a843;
  --accent-soft: rgba(212, 168, 67, 0.12);
  --accent-strong: #b8902f;
  --shadow-sm: 0 1px 2px rgba(26, 24, 22, 0.04);
  --shadow-md: 0 4px 16px rgba(26, 24, 22, 0.06);

  --font-sans: "DM Sans", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --max-w: 1180px;
  --max-w-prose: 720px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #111111;
  --bg-elev: #181816;
  --bg-subtle: #1c1c1a;
  --border: #2a2925;
  --border-strong: #3a3833;
  --text: #e0e0e0;
  --text-muted: #999591;
  --text-soft: #6f6b66;
  --accent: #e0b44f;
  --accent-soft: rgba(224, 180, 79, 0.14);
  --accent-strong: #efc868;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  transition: background-color 0.18s ease, color 0.18s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* === Layout === */
.shell {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 32px;
}

@media (max-width: 640px) {
  .shell { padding: 0 20px; }
}

/* === Nav === */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.18s ease;
}

.nav.scrolled {
  border-bottom-color: var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 32px;
}

.logo {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  display: inline-flex;
  align-items: baseline;
  gap: 0;
}

.logo .cursor {
  display: inline-block;
  color: var(--accent);
  font-weight: 400;
  margin-left: 1px;
  animation: blink 1.05s steps(2, start) infinite;
}

@keyframes blink {
  to { visibility: hidden; }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

.nav-links a {
  position: relative;
  transition: color 0.15s ease;
  padding: 4px 0;
}

.nav-links a:hover {
  color: var(--accent);
}

.nav-links a.active {
  color: var(--text);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
  padding: 0;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--border-strong);
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 32px;
  cursor: pointer;
  color: var(--text);
  padding: 0;
  align-items: center;
  justify-content: center;
}

@media (max-width: 720px) {
  .nav-links { display: none; }
  .mobile-menu-btn { display: inline-flex; }
  .nav-mobile-open .nav-links {
    display: flex;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 20px;
    gap: 16px;
  }
}

/* === Hero === */
.hero {
  padding: 88px 0 64px;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 640px) {
  .hero { padding: 56px 0 40px; }
}

.hero h1 {
  font-family: var(--font-sans);
  font-size: clamp(40px, 6vw, 72px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.02;
  margin: 0 0 24px;
  color: var(--text);
}

.hero h1 .accent {
  color: var(--accent);
}

.hero .tagline {
  font-size: clamp(17px, 1.5vw, 20px);
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 0 32px;
  text-wrap: pretty;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #2da44e;
  box-shadow: 0 0 0 0 rgba(45, 164, 78, 0.5);
  animation: pulse 2.4s ease-out infinite;
}

[data-theme="dark"] .status-dot { background: #3fb950; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(45, 164, 78, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(45, 164, 78, 0); }
  100% { box-shadow: 0 0 0 0 rgba(45, 164, 78, 0); }
}

.status-pill .sep {
  color: var(--text-soft);
  margin: 0 2px;
}

.status-pill .num {
  color: var(--text);
  font-weight: 500;
}

/* === Section labels === */
.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.section-label h2 {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

.section-label .meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-soft);
}

/* === Featured grid === */
.featured {
  padding: 64px 0 32px;
}

.featured-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

@media (max-width: 800px) {
  .featured-grid { grid-template-columns: 1fr; gap: 24px; }
}

.feat-card {
  display: block;
  padding: 28px 28px 26px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.feat-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.feat-card:hover .feat-title {
  color: var(--accent-strong);
}

[data-theme="dark"] .feat-card:hover .feat-title {
  color: var(--accent-strong);
}

.feat-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 14px;
  display: inline-block;
}

[data-theme="dark"] .feat-tag { color: var(--accent); }

.feat-title {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.018em;
  margin: 0 0 12px;
  color: var(--text);
  transition: color 0.15s ease;
  text-wrap: balance;
}

.feat-excerpt {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0 0 20px;
  text-wrap: pretty;
}

.feat-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-soft);
}

.feat-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-soft);
}

/* === Recent posts list === */
.posts {
  padding: 56px 0 72px;
}

.posts-list {
  display: flex;
  flex-direction: column;
}

.post-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: baseline;
  gap: 24px;
  padding: 18px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.15s ease, padding-left 0.18s ease;
  border-radius: 4px;
}

.post-row:hover {
  background: var(--bg-subtle);
  padding-left: 12px;
}

.post-row:hover .post-title {
  color: var(--accent-strong);
}

[data-theme="dark"] .post-row:hover .post-title { color: var(--accent); }

.post-row .post-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.post-row .post-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  transition: color 0.15s ease;
}

.post-row .post-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: lowercase;
}

@media (max-width: 640px) {
  .post-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .post-row .post-tag { justify-self: start; }
}

/* === Subscribe === */
.subscribe {
  padding: 48px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.subscribe-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.subscribe-text {
  flex: 1 1 280px;
}

.subscribe-text h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.subscribe-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.subscribe-form {
  display: flex;
  gap: 8px;
  flex: 1 1 320px;
  max-width: 440px;
}

.subscribe-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.subscribe-form input::placeholder { color: var(--text-soft); }

.subscribe-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.subscribe-form button {
  padding: 10px 18px;
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

.subscribe-form button:hover { opacity: 0.85; }

.subscribe-form .ok {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-strong);
  align-self: center;
  padding: 0 6px;
}

[data-theme="dark"] .subscribe-form .ok { color: var(--accent); }

/* === Follow block (replaces subscribe form until SMTP wired) === */
.follow-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.follow-text {
  flex: 1 1 280px;
}

.follow-text h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.follow-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.follow-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.follow-btn {
  padding: 10px 18px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.follow-btn-primary {
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
}

.follow-btn-primary:hover { opacity: 0.85; }

.follow-btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.follow-btn-secondary:hover {
  border-color: var(--text);
  background: var(--bg-subtle);
}

/* === Footer === */
.footer {
  padding: 32px 0 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-soft);
}

.footer-links {
  display: flex;
  gap: 18px;
}

.footer-links a {
  transition: color 0.15s ease;
}

.footer-links a:hover { color: var(--accent); }

/* === Article view === */
.article {
  padding: 56px 0 96px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 40px;
  transition: color 0.15s ease;
  cursor: pointer;
}

.back-link:hover { color: var(--accent); }

.article-wrap {
  max-width: var(--max-w-prose);
  margin: 0 auto;
}

.article h1 {
  font-family: var(--font-sans);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 20px;
  text-wrap: balance;
}

@media (max-width: 640px) {
  .article h1 { font-size: 28px; }
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 48px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.article-meta .tag {
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

[data-theme="dark"] .article-meta .tag { color: var(--accent); }

.article-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-soft);
}

.prose {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
}

.prose p {
  margin: 0 0 1.4em;
  text-wrap: pretty;
}

.prose h2 {
  font-family: var(--font-sans);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 2em 0 0.7em;
}

.prose h3 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 1.8em 0 0.6em;
}

.prose a {
  color: var(--accent-strong);
  border-bottom: 1px solid var(--accent-soft);
  transition: border-color 0.15s ease;
}

[data-theme="dark"] .prose a { color: var(--accent); }

.prose a:hover { border-bottom-color: var(--accent); }

.prose strong { font-weight: 600; color: var(--text); }

.prose ul, .prose ol {
  margin: 0 0 1.4em;
  padding-left: 1.4em;
}

.prose li {
  margin-bottom: 0.5em;
}

.prose blockquote {
  margin: 1.8em 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--accent);
  font-style: italic;
  color: var(--text-muted);
  font-size: 17px;
}

.prose blockquote p:last-child { margin-bottom: 0; }

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-subtle);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--text);
}

.prose pre {
  background: var(--bg-subtle);
  padding: 18px 20px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.6em 0;
  border: 1px solid var(--border);
  line-height: 1.55;
}

.prose pre code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  background: none;
  padding: 0;
  color: var(--text);
  display: block;
  white-space: pre;
}

/* code highlighting (very subtle) */
.tok-kw { color: #8d4ec7; font-weight: 500; }
.tok-str { color: #4d8b3f; }
.tok-num { color: #b07515; }
.tok-com { color: var(--text-soft); font-style: italic; }
.tok-fn { color: #2c69b1; }
.tok-cls { color: #b8902f; }

[data-theme="dark"] .tok-kw { color: #c690e8; }
[data-theme="dark"] .tok-str { color: #7ec27a; }
[data-theme="dark"] .tok-num { color: #e0b06b; }
[data-theme="dark"] .tok-com { color: #6f6b66; }
[data-theme="dark"] .tok-fn { color: #6cb1ee; }
[data-theme="dark"] .tok-cls { color: #e0b44f; }

.article-tags {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.article-tags .label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-right: 6px;
}

.tag-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--bg-elev);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-pill:hover {
  color: var(--accent-strong);
  border-color: var(--accent);
}

[data-theme="dark"] .tag-pill:hover { color: var(--accent); }

/* === Density === */
[data-density="compact"] .featured { padding: 40px 0 16px; }
[data-density="compact"] .posts { padding: 36px 0 56px; }
[data-density="compact"] .post-row { padding: 12px 4px; }
[data-density="compact"] .feat-card { padding: 22px 22px 20px; }

/* === Page transitions === */
.page-enter {
  animation: fadeUp 0.32s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === Ticker === */
.ticker {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.ticker-num {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 500;
}

/* === Ghost Koenig editor cards === */
.kg-width-wide { max-width: min(1040px, 100vw - 40px); margin-left: auto; margin-right: auto; }
.kg-width-full { max-width: none; margin-left: calc(-50vw + 50%); margin-right: calc(-50vw + 50%); }

.kg-gallery-container { display: flex; flex-direction: column; gap: 4px; }
.kg-gallery-row { display: flex; gap: 4px; }
.kg-gallery-image img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }

.kg-bookmark-card { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin: 1.6em 0; }
.kg-bookmark-container { display: flex; text-decoration: none; color: inherit; }
.kg-bookmark-content { flex: 1; padding: 16px; }
.kg-bookmark-title { font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--text); }
.kg-bookmark-description { font-size: 13px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kg-bookmark-metadata { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--text-soft); }
.kg-bookmark-icon { width: 16px; height: 16px; border-radius: 2px; }
.kg-bookmark-author, .kg-bookmark-publisher { font-size: 12px; }
.kg-bookmark-thumbnail { flex-shrink: 0; width: 160px; }
.kg-bookmark-thumbnail img { display: block; width: 100%; height: 100%; object-fit: cover; }
