:root {
  color-scheme: dark;
  --bg: #050816;
  --bg-elevated: #0b1220;
  --fg: #e5e7eb;
  --fg-muted: #9ca3af;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --border: rgba(148, 163, 184, 0.22);
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow: 0 18px 45px rgba(2, 6, 23, 0.55);
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, Segoe UI,
    Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, Segoe UI,
    Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap");

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --fg: #0b1220;
  --fg-muted: #475569;
  --accent: #0ea5e9;
  --accent-2: #7c3aed;
  --accent-soft: rgba(14, 165, 233, 0.12);
  --border: rgba(2, 6, 23, 0.12);
  --shadow: 0 18px 45px rgba(2, 6, 23, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--fg);
  background:
    radial-gradient(800px 420px at 18% 0%, rgba(56, 189, 248, 0.22), transparent 60%),
    radial-gradient(900px 520px at 86% 18%, rgba(167, 139, 250, 0.2), transparent 55%),
    linear-gradient(180deg, rgba(2, 6, 23, 0.35), transparent 40%),
    var(--bg);
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
}

::selection {
  background: rgba(56, 189, 248, 0.28);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg-elevated) 78%, transparent);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  width: 100%;
  margin: 0;
  padding: 0.9rem 1.6rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  min-width: 0;
}

.site-logo {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 18px rgba(2, 6, 23, 0.35));
}

.site-title {
  font-weight: 750;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-brand:hover .site-title {
  color: color-mix(in srgb, var(--accent) 75%, var(--fg));
}

.site-nav {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.25rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--fg-muted);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.site-nav a:hover {
  color: var(--fg);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.theme-toggle {
  margin-left: auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  color: var(--fg);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 10px 25px rgba(2, 6, 23, 0.25);
}

.theme-toggle:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.site-main {
  flex: 1;
  min-width: 0;
  padding: 1.8rem 1.6rem 2.6rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 1.1rem 1.1rem 1.6rem;
  text-align: center;
  font-size: 0.9rem;
}

.footer-links {
  margin-top: 0.4rem;
  display: flex;
  justify-content: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--fg-muted);
  text-decoration: none;
}

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

h1 {
  font-size: clamp(1.7rem, 1.3rem + 1.3vw, 2.35rem);
  margin: 0 0 1.1rem;
  letter-spacing: -0.02em;
  font-family: var(--font-display);
}

.page-lead {
  margin: -0.6rem 0 1.2rem;
  color: var(--fg-muted);
  line-height: 1.7;
  max-width: 70ch;
}

/* Index */

.hero {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.2rem 1.15rem;
  background:
    radial-gradient(140px 140px at 12% 18%, rgba(255, 255, 255, 0.07), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0, rgba(255, 255, 255, 0.03) 1px, transparent 1px, transparent 22px),
    radial-gradient(900px 340px at 20% 0%, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(900px 420px at 85% 10%, rgba(167, 139, 250, 0.18), transparent 55%),
    color-mix(in srgb, var(--bg-elevated) 86%, transparent);
  box-shadow: var(--shadow);
}

.hero-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.4rem;
  align-items: center;
}

.hero-copy {
  min-width: 0;
}

.hero-logo {
  width: 180px;
  height: 135px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg-elevated) 75%, transparent);
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.35);
  margin-bottom: 0.75rem;
}

.hero-logo-right {
  margin: 0;
  justify-self: end;
}

.hero-logo img {
  width: 180px;
  height: 135px;
  border-radius: 18px;
  object-fit: contain;
}

@media (min-width: 900px) {
  .hero-split {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .hero-logo {
    width: 280px;
    height: 210px;
  }

  .hero-logo img {
    width: 280px;
    height: 210px;
  }
}

.hero-topline {
  font-weight: 650;
  color: var(--fg-muted);
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
}

.hero-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 1.6rem 0 1.2rem;
}

.hero-subtitle {
  margin: 0.7rem 0 0;
  color: var(--fg-muted);
  line-height: 1.65;
  max-width: 60ch;
}

.hero-actions {
  margin-top: 1.05rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  font-weight: 650;
}

.btn-primary {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent-soft) 90%, transparent);
}

.btn-primary:hover {
  border-color: color-mix(in srgb, var(--accent) 75%, transparent);
}

.btn-ghost {
  color: var(--fg-muted);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
}

.btn-ghost:hover {
  color: var(--fg);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.index-meta {
  margin: 1rem 0 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 86%, transparent);
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.empty {
  margin-top: 1.2rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
}

.empty-title {
  margin: 0 0 0.3rem;
  font-size: 1.15rem;
}

.empty-subtitle {
  margin: 0;
  color: var(--fg-muted);
}

.layout {
  flex: 1;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
}

.sidebar {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
}

.sidebar-inner {
  padding: 1.1rem 1.1rem 1.4rem;
}

.sidebar-title {
  font-weight: 750;
  letter-spacing: 0.02em;
  color: var(--fg);
  margin-bottom: 0.65rem;
}

.sidebar-inner > .sidebar-title:not(:first-child) {
  margin-top: 1.3rem;
}

.sidebar-empty {
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.sidebar-tree {
  display: grid;
  gap: 0.6rem;
}

.sidebar-section {
  margin-top: 1.2rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.sidebar-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.sidebar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tree-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  overflow: hidden;
}

.tree-year {
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-weight: 700;
  color: var(--fg);
  list-style: none;
}

.tree-year::-webkit-details-marker {
  display: none;
}

.tree-year::after {
  content: "▾";
  float: right;
  color: var(--fg-muted);
}

.tree-group:not([open]) .tree-year::after {
  content: "▸";
}

.tree-list {
  list-style: none;
  margin: 0;
  padding: 0 0.35rem 0.55rem;
}

.tree-item {
  margin: 0.2rem 0;
}

.tree-link {
  display: block;
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--fg-muted);
  border: 1px solid transparent;
}

.tree-link:hover {
  color: var(--fg);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.tree-link[aria-current="page"] {
  color: var(--fg);
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.tag-bar {
  margin: 0.2rem 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-cloud {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.post-card-tags {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 86%, transparent);
  color: var(--fg-muted);
  font-size: 0.9rem;
  text-decoration: none;
  user-select: none;
}

.tag-chip-count {
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.tag-chip:hover {
  color: var(--fg);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.tag-chip-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.82rem;
}

.tag-chip-btn {
  cursor: pointer;
  font: inherit;
}

.tag-chip-btn.is-active {
  color: var(--fg);
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent);
}

.post-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.post-card {
  background:
    radial-gradient(800px 300px at 15% 10%, rgba(56, 189, 248, 0.14), transparent 55%),
    color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.2rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.post-card:hover {
  transform: translateY(-3px) rotateX(2deg);
  box-shadow: 0 24px 55px rgba(2, 6, 23, 0.55);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

.post-card-title {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
}

.post-card-title a {
  text-decoration: none;
}

.post-card-title a:hover {
  color: var(--accent);
}

.post-card-meta {
  margin: 0.35rem 0 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.post-card-excerpt {
  margin: 0.7rem 0 0;
  color: var(--fg-muted);
  line-height: 1.6;
}

.inline-link,
.sidebar-link {
  display: inline-flex;
  margin-top: 0.6rem;
  color: var(--fg-muted);
  text-decoration: none;
}

.inline-link:hover,
.sidebar-link:hover {
  color: var(--fg);
}

article.post {
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.2rem;
  box-shadow: var(--shadow);
}

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

.post-aside {
  display: none;
}

article.post header {
  margin-bottom: 1rem;
}

article.post h1 {
  margin-bottom: 0.35rem;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.6rem 0 0;
}

.post-meta {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

article.post :is(p, li) {
  line-height: 1.75;
}

article.post a {
  color: color-mix(in srgb, var(--accent) 90%, white 10%);
}

.takeaways {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  background: color-mix(in srgb, var(--accent-soft) 40%, var(--bg-elevated));
  margin: 0 0 1.2rem;
}

.takeaways h2 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
}

.takeaways ul {
  margin: 0;
  padding-left: 1.2rem;
}

.toc {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  margin: 0 0 1.2rem;
}

.toc-aside {
  margin: 0;
}

.toc-title {
  font-weight: 650;
  margin-bottom: 0.6rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.toc-item a {
  text-decoration: none;
  color: var(--fg-muted);
  display: inline-flex;
  gap: 0.5rem;
  align-items: baseline;
}

.toc-item a:hover {
  color: var(--fg);
}

.toc-item a.is-active {
  color: var(--fg);
  font-weight: 600;
}

.toc-number {
  min-width: 1.6rem;
  color: color-mix(in srgb, var(--accent) 70%, var(--fg-muted));
  font-variant-numeric: tabular-nums;
}

.toc-item-sub {
  padding-left: 0.9rem;
}

/* Prose */

.prose {
  font-size: 1.03rem;
}

.prose :is(h2, h3, h4) {
  letter-spacing: -0.01em;
  margin: 1.4rem 0 0.6rem;
}

.prose h2 {
  font-size: 1.35rem;
}

.prose h3 {
  font-size: 1.15rem;
}

.prose p {
  margin: 0.9rem 0;
  color: color-mix(in srgb, var(--fg) 92%, var(--fg-muted));
}

.prose :is(ul, ol) {
  padding-left: 1.25rem;
  margin: 0.8rem 0 1rem;
}

.prose li {
  margin: 0.35rem 0;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.6rem 0;
}

.prose blockquote {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border-left: 3px solid color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--bg-elevated) 85%, transparent);
  border-radius: var(--radius-md);
  color: var(--fg-muted);
}

.prose :not(pre) > code {
  padding: 0.15rem 0.35rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
  border: 1px solid var(--border);
}

.prose img,
.post-image {
  max-width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin: 1rem 0;
}

.post-image {
  cursor: zoom-in;
}

pre,
code {
  font-family: var(--font-mono);
}

pre {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 1rem;
  overflow: auto;
  background: rgba(2, 6, 23, 0.55);
}

code {
  font-size: 0.95em;
}

/* Search */

.search-box {
  margin: 1rem 0 1.4rem;
}

.search-input {
  width: min(680px, 100%);
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.7rem 1rem;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  color: var(--fg);
  font-size: 1rem;
}

.search-meta {
  margin-top: 0.5rem;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.search-results {
  display: grid;
  gap: 1rem;
}

.search-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
}

.search-card-title {
  margin: 0 0 0.35rem;
}

.search-card-title a {
  text-decoration: none;
}

.search-card-meta {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.search-card-excerpt {
  margin: 0.6rem 0 0.7rem;
  color: var(--fg-muted);
}

.search-empty {
  color: var(--fg-muted);
}

/* Lightbox */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
  padding: 2rem;
}

.lightbox-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-image {
  max-width: min(1100px, 100%);
  max-height: 85vh;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

@media (min-width: 760px) {
  .layout {
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 0;
    align-items: start;
  }

  .sidebar {
    position: sticky;
    top: 64px;
    max-height: calc(100vh - 64px);
    overflow: auto;
    border-bottom: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
  }

  .site-main {
    padding: 2.2rem 2rem 2.6rem;
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .post-layout {
    grid-template-columns: minmax(0, 1fr) 260px;
    align-items: start;
  }

  .post-aside {
    display: block;
    position: sticky;
    top: 96px;
    align-self: start;
  }

  .post-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
