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

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

.lucide {
  width: 1em;
  height: 1em;
  stroke-width: 1.5;
}

:root {
  --font-sans:
    "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    sans-serif;
  --font-mono:
    "Geist Mono", ui-monospace, "SF Mono", "Cascadia Code", monospace;

  --background: #fafafa;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #18181b;
  --accent: #18181b;
  --accent-hover: #09090b;
  --radius: 0.625rem;

  --content-width: 44rem;
  --nav-width: 44rem;
}

:root.dark {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #0c0c0e;
  --card-foreground: #fafafa;
  --muted: #18181b;
  --muted-foreground: #a1a1aa;
  --border: #1e1e22;
  --input: #27272a;
  --ring: #d4d4d8;
  --accent: #d4d4d8;
  --accent-hover: #fafafa;
}

::selection {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}

html {
  font-size: clamp(15px, 0.85vw + 10px, 18px);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  color: var(--foreground);
  background: var(--background);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

/* ── Fade in ──────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.content {
  animation: fadeIn 0.35s ease both;
}

/* ── Nav ──────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--background) 80%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--border);
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.nav-inner {
  max-width: var(--nav-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--foreground);
  text-decoration: none;
  letter-spacing: -0.02em;
  transition: opacity 0.15s ease;
}
.site-title:hover {
  opacity: 0.7;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}

.nav-link {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted-foreground);
  text-decoration: none;
  padding: 0.3rem 0.625rem;
  border-radius: calc(var(--radius) - 2px);
  transition:
    color 0.1s ease,
    background-color 0.1s ease;
}
.nav-link:hover {
  color: var(--foreground);
  background: var(--muted);
}
.nav-link.active {
  color: var(--accent);
  font-weight: 500;
}

.nav-toggle {
  display: none;
  appearance: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  line-height: 1;
}

.theme-toggle {
  appearance: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  margin-left: 0.375rem;
  line-height: 1;
  transition:
    color 0.1s ease,
    background-color 0.1s ease,
    border-color 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
}
.theme-toggle:hover {
  color: var(--foreground);
  background: var(--muted);
}

/* ── Content ──────────────────────────────── */
.content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  width: 100%;
  flex: 1;
}

/* ── Hero ─────────────────────────────────── */
.hero {
  margin-bottom: 2.5rem;
}

.hero-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: 0.625rem;
}

.hero-desc {
  font-size: 0.9375rem;
  color: var(--muted-foreground);
  line-height: 1.55;
}
.hero-desc a,
.listing-desc a {
  color: var(--foreground);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--muted-foreground);
  transition: text-decoration-color 0.15s ease;
}
.hero-desc a:hover,
.listing-desc a:hover {
  text-decoration-color: var(--foreground);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ── Section label ────────────────────────── */
.section-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  letter-spacing: 0.02em;
  margin-bottom: 0.75rem;
}

/* ── Post rows ────────────────────────────── */
.post-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-card {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  text-decoration: none;
  color: var(--foreground);
  padding: 0.6875rem 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.1s ease;
}
.post-card:first-child {
  border-top: 1px solid var(--border);
}
.post-card:hover {
  opacity: 0.6;
}

.post-card-title {
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.post-card-date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.post-card-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.post-card-excerpt {
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  line-height: 1.5;
  margin-top: 0.125rem;
}

.see-all {
  display: inline-block;
  margin-top: 0.875rem;
  font-size: 0.8rem;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: color 0.1s ease;
}
.see-all:hover {
  color: var(--foreground);
}

/* ── Listing header ───────────────────────── */
.listing-header {
  margin-bottom: 2rem;
}
.listing-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.listing-desc {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  margin-top: 0.375rem;
}
.listing-search {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s ease;
}
.listing-search::placeholder {
  color: var(--muted-foreground);
}
.listing-search:focus {
  border-color: var(--accent);
}

/* ── Article ──────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted-foreground);
  text-decoration: none;
  margin-bottom: 1.5rem;
  transition: color 0.1s ease;
}
.back-link:hover {
  color: var(--foreground);
}
.back-link .lucide {
  width: 14px;
  height: 14px;
}

.article-header {
  margin-bottom: 2rem;
}

.article-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.article-meta time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: -0.02em;
}

.meta-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--muted-foreground);
  opacity: 0.5;
}

/* ── Prose ─────────────────────────────────── */
.prose {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--foreground);
}

.prose > * + * {
  margin-top: 1.25em;
}

.prose h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2.25em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

.prose h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 1.75em;
  margin-bottom: 0.375em;
  line-height: 1.35;
}

.prose h4 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1.5em;
  margin-bottom: 0.375em;
  color: var(--muted-foreground);
}

.prose p {
  margin-top: 0;
  margin-bottom: 0;
}

.prose a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transition:
    text-decoration-color 0.15s ease,
    color 0.15s ease;
}
.prose a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent);
}

.prose strong {
  font-weight: 600;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  background: var(--muted);
  color: var(--foreground);
  padding: 0.125em 0.325em;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border);
  font-weight: 400;
}

.prose pre {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2em 1.3em 1.1em;
  overflow-x: auto;
  margin-top: 1.25em;
  margin-bottom: 1.25em;
  font-size: 0.8rem;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}
:root.dark .prose pre {
  background: var(--muted);
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  border-radius: 0;
  display: block;
}
.prose pre code.hljs {
  background: transparent;
  padding: 0;
}
.code-lang {
  position: absolute;
  top: 9px;
  left: 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-foreground);
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-foreground);
  background: none;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  padding: 4px;
  opacity: 0.5;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.code-copy-btn .lucide {
  width: 14px;
  height: 14px;
}
.code-copy-btn:hover {
  opacity: 1;
  color: var(--foreground);
}

.prose blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 0.875rem;
  color: var(--muted-foreground);
  font-style: italic;
  margin-top: 1.25em;
  margin-bottom: 1.25em;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.prose li {
  margin-bottom: 0.25em;
  padding-left: 0.25em;
}
.prose li::marker {
  color: var(--muted-foreground);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 1.25em;
  margin-bottom: 1.25em;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
}

.prose th {
  font-weight: 500;
  background: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.01em;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 1.25em;
  margin-bottom: 1.25em;
}

.prose input[type="checkbox"] {
  margin-right: 0.4rem;
  accent-color: var(--accent);
  position: relative;
  top: 1px;
}

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

.prose .task-list {
  list-style: none;
  padding-left: 0;
}
.prose .task-list li {
  padding-left: 0;
}

.drawing-embed {
  margin: 1.5rem 0;
}
.drawing-embed a {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
  text-decoration: none;
}
.drawing-embed a:hover {
  background: var(--muted);
  border-color: var(--input);
}
.drawing-embed svg {
  max-width: 100%;
  height: auto;
  display: block;
}
.drawing-embed .drawing-light {
  display: block;
}
.drawing-embed .drawing-dark {
  display: none !important;
}
:root.dark .drawing-embed .drawing-light {
  display: none !important;
}
:root.dark .drawing-embed .drawing-dark {
  display: block !important;
}

/* ── Footer ───────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  transition: border-color 0.15s ease;
}

.footer-inner {
  max-width: var(--nav-width);
  margin: 0 auto;
  padding: 1.125rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.footer-inner a {
  color: var(--muted-foreground);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--muted-foreground);
  transition:
    text-decoration-color 0.15s ease,
    color 0.15s ease;
}
.footer-inner a:hover {
  text-decoration-color: var(--muted-foreground);
}

/* ── Mobile ───────────────────────────────── */
@media (max-width: 600px) {
  html {
    font-size: 14px;
  }
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
  }
  .nav-right {
    display: none;
    position: absolute;
    top: 3.25rem;
    right: 0;
    left: 0;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.375rem;
    gap: 0;
    align-items: stretch;
  }
  .nav-right.open {
    display: flex;
  }
  .nav-link {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
  }
  .theme-toggle {
    margin: 0.375rem 0.75rem 0.5rem;
    width: auto;
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
  }
  .content {
    padding: 1.75rem 1.25rem 3rem;
  }
  .hero-title,
  .listing-header h1,
  .article-header h1 {
    font-size: 1.25rem;
  }
  .footer-inner {
    flex-direction: column;
    gap: 0.375rem;
    text-align: center;
  }
}

/* Lightbox */
.prose img {
  cursor: zoom-in;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  opacity: 0;
  transition: opacity 0.2s ease;
  cursor: zoom-out;
}
.lightbox.active {
  opacity: 1;
}
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
}
