:root {
  /* Dark by default */
  --bg: #0b0f14;
  --paper: #0b0f14;
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --line: #1f2937;
  --accent: #e5e7eb;
  --accent-strong: #e5e7eb;
  --accent-2: #e5e7eb;
  --radius: 12px;
  --shadow: none;
}

/* Light theme override */
:root[data-theme="light"] {
  --bg: #ffffff;
  --paper: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #111827;
  --accent-strong: #111827;
  --accent-2: #111827;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

a {
  color: inherit;
}

.page-shell {
  width: min(860px, 92vw);
  margin: 0 auto;
  padding: 1.2rem 0 2.2rem;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}

.site-nav {
  margin-left: auto;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: 0.5rem;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.brand span {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.88rem;
  font-weight: 600;
}

.site-nav {
  display: flex;
  gap: 0.9rem;
}

.theme-toggle,
.site-nav a {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.95rem;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.theme-toggle {
  padding: 0.35rem 0.55rem;
  line-height: 0;
}

.theme-toggle .icon {
  width: 18px;
  height: 18px;
  display: block;
}

.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-nav a[aria-current="page"] {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.theme-toggle {
  appearance: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: "IBM Plex Mono", monospace;
}

.site-nav a:hover,
.theme-toggle:hover {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

/* Light-specific chip backgrounds */
:root[data-theme="light"] .site-nav a[aria-current="page"] {
  background: #f3f4f6;
}

:root[data-theme="light"] .site-nav a:hover,
:root[data-theme="light"] .theme-toggle:hover {
  background: #f9fafb;
}

.nav-toggle {
  color: inherit;
  display: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink);
  padding: 0.4rem 0.75rem;
  font-family: "IBM Plex Mono", monospace;
  cursor: pointer;
}

.hero {
  margin-top: 1.4rem;
  padding: 0;
}

.hero h1 {
  font-size: clamp(2rem, 4.6vw, 2.7rem);
  line-height: 1.12;
  margin: 0;
}

.hero p {
  margin: 0;
  max-width: 66ch;
  color: var(--muted);
}

.lede {
  margin-top: 0.7rem;
}

.controls {
  margin-top: 1.3rem;
}

.search-label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--muted);
}

#post-search {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  padding: 0.72rem 0.85rem;
  font-size: 0.97rem;
}

#post-search:focus {
  outline: 2px solid rgba(255, 255, 255, 0.18);
  outline-offset: 2px;
  border-color: var(--ink);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.tag-filter {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.37rem 0.78rem;
  cursor: pointer;
  font-size: 0.88rem;
}

.tag-filter:hover {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.tag-filter.active {
  border-color: var(--ink);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.09);
}

/* Light theme: keep the same layout, but use light surfaces. */
:root[data-theme="light"] #post-search:focus {
  outline: 2px solid rgba(17, 24, 39, 0.18);
  outline-offset: 2px;
  border-color: var(--ink);
}

:root[data-theme="light"] .tag-filter:hover {
  background: #f9fafb;
}

:root[data-theme="light"] .tag-filter.active {
  background: #f3f4f6;
}

.post-section {
  margin-top: 1.5rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.7rem;
}

.section-head h2 {
  margin: 0;
  font-size: 1.42rem;
}

.section-head a {
  color: var(--accent-strong);
  font-family: "IBM Plex Mono", monospace;
  text-decoration: none;
  font-size: 0.9rem;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.8rem;
}

.post-card {
  grid-column: span 4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.post-card.featured {
  grid-column: span 12;
}

.post-meta {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  color: var(--accent-strong);
  font-size: 0.8rem;
}

.post-card h3 {
  margin: 0;
  line-height: 1.25;
}

.post-card p {
  margin: 0;
  color: var(--muted);
}

.read-link {
  margin-top: auto;
  align-self: flex-start;
  font-size: 0.89rem;
  font-family: "IBM Plex Mono", monospace;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.9rem;
  background: var(--paper);
  color: var(--muted);
}

.site-footer {
  margin-top: 1.8rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

.post-page {
  margin-top: 1.4rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.8vw, 2rem);
}

.post-page h1 {
  margin: 0.3rem 0 0.6rem;
  line-height: 1.1;
}

.post-page h2 {
  margin-top: 1.6rem;
}

.post-page pre {
  margin: 1rem 0;
  background: #112028;
  color: #e4eee8;
  border-radius: 12px;
  padding: 0.8rem;
  overflow: auto;
}

.post-page code {
  font-family: "IBM Plex Mono", monospace;
}

.post-page ul {
  padding-left: 1.05rem;
}

.post-body {
  margin-top: 1rem;
}

.post-body a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-body img {
  max-width: 100%;
  height: auto;
  display: block;
}

.post-body figure {
  margin: 1rem 0;
}

.post-body figcaption {
  color: var(--muted);
  font-size: 0.9rem;
}

.post-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.25rem 0;
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.reveal.in {
  opacity: 1;
  transform: none;
}

@media (max-width: 900px) {
  .post-card {
    grid-column: span 6;
  }
}

@media (max-width: 680px) {
  .header-actions {
    order: 2;
    margin-left: auto;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    order: 3;
    flex-basis: 100%;
    margin-left: 0;
    width: 100%;
    display: none;
    flex-wrap: wrap;
  }

  .site-nav.open {
    display: flex;
  }

  .post-card,
  .post-card.featured {
    grid-column: span 12;
  }

  .page-shell {
    width: min(1080px, 94vw);
  }
}
