/* AFL Profile theme */
:root {
  --bg: #0e1311;
  --surface: #151c19;
  --surface-2: #1a2420;
  --border: #26322d;
  --border-strong: #4a5c53;
  --text: #e9eeea;
  --muted: #a3b0a8;
  --faint: #8c9a92;
  --accent: #c8f169;
  --accent-ink: #0e1311;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --radius: 16px;
  --header-h: 72px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f8f5;
  --surface: #ffffff;
  --surface-2: #eef2ee;
  --border: #d9e0db;
  --border-strong: #8ea096;
  --text: #141a17;
  --muted: #4b5a52;
  --faint: #5c6b63;
  --accent: #3f6a00;
  --accent-ink: #ffffff;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -0.01em; line-height: 1.15; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.inline-list { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 12px; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 8px; font-weight: 600; }
.skip-link:focus { left: 8px; }

.eyebrow, .mono-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.eyebrow { color: var(--accent); font-size: 13px; letter-spacing: 0.12em; }
.mono-label { color: var(--faint); }
.mono-label.accent { color: var(--accent); }
.text-link { color: var(--accent); font-weight: 500; }
.text-link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 22px; border-radius: 999px;
  font: 600 15px var(--font-body); cursor: pointer; border: 1px solid transparent;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { border-color: var(--border-strong); color: var(--text); font-weight: 500; }
.btn-ghost:hover { border-color: var(--accent); }
.btn-outline { border-color: var(--accent); color: var(--accent); font-weight: 500; }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn:hover { transform: none; } }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 12px; }
.mono-badge {
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font: 500 13px var(--font-mono);
}
.brand-name { font: 600 18px var(--font-display); }
.site-nav { display: flex; align-items: center; gap: 20px; }
.site-nav ul { display: flex; align-items: center; gap: 4px 4px; list-style: none; margin: 0; padding: 0; }
.site-nav li a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; color: var(--muted); font-size: 15px; }
.site-nav li a:hover, .site-nav li a[aria-current="page"] { color: var(--text); }
.nav-tools { display: flex; align-items: center; gap: 8px; }
.theme-toggle, .nav-toggle {
  width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.theme-toggle:hover, .nav-toggle:hover { border-color: var(--accent); }
.nav-toggle { display: none; }
:root[data-theme="dark"] .icon-moon, :root:not([data-theme="light"]) .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
.progress { height: 2px; background: transparent; }
.progress span { display: block; height: 2px; width: 0; background: var(--accent); }

@media (max-width: 1080px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none; position: absolute; left: 0; right: 0; top: var(--header-h);
    flex-direction: column; align-items: stretch; gap: 8px;
    background: var(--bg); border-bottom: 1px solid var(--border); padding: 12px 24px 20px;
  }
  .site-nav.open { display: flex; }
  .site-nav ul { flex-direction: column; align-items: stretch; }
  .nav-tools { justify-content: space-between; padding-top: 8px; }
}

/* Sections */
.section { padding-top: 88px; padding-bottom: 24px; }
.section-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }
.section-head.split { flex-direction: row; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.section-title { font-size: clamp(30px, 3.6vw, 44px); }
.sub-title { font-size: 20px; margin: 48px 0 20px; }
.page-head { padding-top: 72px; padding-bottom: 32px; display: flex; flex-direction: column; gap: 20px; }
.page-title { font-size: clamp(36px, 5vw, 60px); line-height: 1.05; letter-spacing: -0.02em; max-width: 880px; }
.page-body { padding-bottom: 24px; }
.lead { font-size: 19px; max-width: 640px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* Hero */
.hero { display: flex; flex-wrap: wrap; align-items: center; gap: 48px; padding-top: 72px; padding-bottom: 32px; }
.hero-copy { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.pill { align-self: flex-start; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; font: 400 13px var(--font-mono); color: var(--muted); }
.hero h1 { font-size: clamp(40px, 5.6vw, 76px); line-height: 1.04; letter-spacing: -0.025em; }
.hero-sub { color: var(--muted); }
.hero .lead { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-media { flex: 1 1 280px; max-width: 420px; margin: 0; }
.hero-media img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 20px; border: 1px solid var(--border); background: var(--surface-2); }

/* About */
.about-grid { display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-start; }
.about-media { flex: 0 1 300px; margin: 0; }
.about-media img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.about-copy { flex: 1 1 400px; font-size: 18px; color: var(--muted); }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.skill { padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; }
.skill > span:last-child { color: var(--text); font-size: 15.5px; }

/* Experience */
.timeline { display: flex; flex-direction: column; }
.timeline-row { display: flex; flex-wrap: wrap; gap: 12px 40px; padding: 32px 0; border-top: 1px solid var(--border); }
.timeline-row:last-child { border-bottom: 1px solid var(--border); }
.timeline-meta { flex: 0 0 240px; display: flex; flex-direction: column; gap: 6px; }
.company { font: 600 20px var(--font-display); }
.timeline-body { flex: 1 1 360px; min-width: 0; }
.timeline-body h3 { font-size: 20px; margin-bottom: 12px; }

/* Education / projects */
.edu { padding: 28px; }
.edu-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-bottom: 16px; }
.edu h3 { font-size: 22px; }
.edu-meta { margin-top: 6px; }
.project { display: flex; flex-direction: column; overflow: hidden; transition: border-color .15s ease; }
.project:hover { border-color: var(--border-strong); }
.project-media { aspect-ratio: 2 / 1; background: var(--surface-2); overflow: hidden; }
.project-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.project-body { display: flex; flex-direction: column; gap: 12px; padding: 24px; flex: 1; }
.project-body h3 { font-size: 22px; line-height: 1.2; }
.project-body .more { margin-top: auto; padding-top: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font: 400 12px var(--font-mono); color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }

/* Rows (blog) */
.rows { display: flex; flex-direction: column; }
.row-link { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 32px; padding: 28px 0; border-top: 1px solid var(--border); }
.row-link:last-child { border-bottom: 1px solid var(--border); }
.row-link:hover .row-title { color: var(--accent); }
.row-meta { flex: 0 0 160px; display: flex; flex-direction: column; gap: 4px; }
.row-main { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.row-title { font: 600 clamp(20px, 2.2vw, 24px) var(--font-display); line-height: 1.25; }
.row-thumb { width: 160px; height: 100px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
@media (max-width: 720px) { .row-thumb { display: none; } .row-meta { flex-basis: 100%; flex-direction: row; flex-wrap: wrap; gap: 4px 16px; } }
.chips { display: flex; flex-wrap: wrap; gap: 10px; padding-bottom: 28px; }
.chip {
  min-height: 44px; padding: 0 20px; border-radius: 999px; background: transparent; color: var(--text);
  border: 1px solid var(--border); font: 500 14px var(--font-body); cursor: pointer; text-transform: capitalize;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.empty { padding: 24px 0; }

/* Play teaser / contact */
.play-teaser { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px; padding: 40px; }
.play-teaser > div { display: flex; flex-direction: column; gap: 12px; max-width: 600px; }
.contact { padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; gap: 20px; align-items: flex-start; }
.contact-form { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 560px; margin-top: 16px; }
.contact-form label { font-size: 14px; color: var(--muted); margin-top: 8px; }
.contact-form input[type="email"], .contact-form textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 12px 14px; font: inherit; min-height: 44px;
}
.contact-form button { align-self: flex-start; margin-top: 12px; }

/* Prose */
.prose { line-height: 1.7; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .35em; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose h2 { font-size: 30px; margin: 2em 0 .6em; }
.prose h3 { font-size: 22px; margin: 1.6em 0 .5em; }
.prose h4 { font-size: 18px; margin: 1.4em 0 .4em; }
.prose img { border-radius: 10px; }
.prose blockquote { margin: 1.4em 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent); color: var(--muted); }
.prose code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.prose pre { overflow-x: auto; padding: 16px 18px; border-radius: 12px; border: 1px solid var(--border); font-size: 14px; line-height: 1.55; }
.prose pre code { background: none; padding: 0; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; margin: 1.2em 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.post { max-width: 820px; padding-top: 72px; padding-bottom: 48px; }
.post-head { display: flex; flex-direction: column; gap: 18px; margin-bottom: 32px; }
.post-cover { margin: 0 0 32px; }
.post-cover img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); display: block; }
.post-body { font-size: 17.5px; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 16px; }
.gallery li[hidden] { display: none; }
/* No-crop frame: the whole photo sits inside a fixed frame over a blurred copy of itself.
   Frame shape comes from `frame:` in gallery.md: landscape (default, 4:3), square or portrait (3:4). */
.gallery a { position: relative; isolation: isolate; display: block; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); aspect-ratio: 4 / 3; }
.frame-square a { aspect-ratio: 1 / 1; }
.frame-portrait a { aspect-ratio: 3 / 4; }
.frame-main { position: relative; z-index: 1; display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .35)); transition: transform .3s ease; }
.frame-blur { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.3); filter: blur(22px) saturate(1.25) brightness(.7); pointer-events: none; }
:root[data-theme="light"] .frame-blur { filter: blur(22px) saturate(1.15) brightness(.95); opacity: .85; }
.gallery a:hover .frame-main { transform: scale(1.03); }
/* Caption: dark gradient across the bottom of the frame, with title and a short description */
.frame-cap { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; flex-direction: column; gap: 2px; padding: 44px 14px 12px; color: #fff; text-align: left; pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, .86) 0%, rgba(0, 0, 0, .6) 42%, rgba(0, 0, 0, 0) 100%); }
.cap-title { font: 600 15px/1.25 var(--font-display); }
.cap-desc { font-size: 13px; line-height: 1.4; color: rgba(255, 255, 255, .82); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .frame-main { transition: none; } .gallery a:hover .frame-main { transform: none; } }
.lightbox { border: 0; padding: 0; background: transparent; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; color: #fff; }
.lightbox::backdrop { background: rgba(0, 0, 0, .94); backdrop-filter: blur(6px); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lb-stage { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: center; gap: 32px; width: min(94vw, 1500px); max-height: 92vh; padding: 0 56px; box-sizing: border-box; }
.lb-img { justify-self: center; width: auto; height: auto; max-width: 100%; max-height: 86vh; object-fit: contain; border-radius: 8px; }
.lb-side { display: flex; flex-direction: column; gap: 12px; max-height: 86vh; overflow-y: auto; text-align: left; }
.lb-tag { margin: 0; align-self: flex-start; padding: 3px 10px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; color: #d0d8d3; font-size: 12px; }
.lb-tag[hidden] { display: none; }
.lb-title { margin: 0; font: 600 26px/1.2 var(--font-display); color: #fff; }
.lb-desc { margin: 0; font-size: 16px; line-height: 1.65; color: #d0d8d3; white-space: pre-line; }
.lightbox.no-cap .lb-stage { grid-template-columns: minmax(0, 1fr); }
.lightbox.no-cap .lb-side { display: none; }
@media (max-width: 820px) {
  .lb-stage { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 56px 14px 64px; max-height: 100vh; align-content: center; }
  .lb-img { max-height: 56vh; }
  .lb-side { max-height: 24vh; }
  .lb-title { font-size: 21px; }
  .lb-desc { font-size: 15px; }
  .lightbox .lb-prev, .lightbox .lb-next { top: auto; bottom: 16px; transform: none; }
}
.lb-btn { position: absolute; width: 48px; height: 48px; border-radius: 999px; border: 1px solid rgba(255,255,255,.4); background: rgba(0,0,0,.5); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
.lb-btn:hover { border-color: #fff; }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #d0d8d3; }

/* Game */
.game-wrap > * { max-width: 840px; }
.game-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; margin-bottom: 14px; font: 500 18px var(--font-display); }
.game-bar output { font-family: var(--font-mono); color: var(--accent); margin-left: 6px; }
.game-bar .btn { margin-left: auto; }
#game {
  display: block; width: 100%; height: auto; aspect-ratio: 3 / 2;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  touch-action: none; cursor: none; user-select: none; -webkit-user-select: none;
}
#game:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius); }
.game-help { margin-top: 14px; font-size: 14px; }

/* Footer */
.site-footer { margin-top: 96px; border-top: 1px solid var(--border); padding: 48px 0 56px; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 32px; }
.footer-col { display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.footer-col .plain-list li { padding: 3px 0; }

@media (max-width: 640px) {
  .container { padding-left: 16px; padding-right: 16px; }
  .section { padding-top: 64px; }
  .site-nav { padding-left: 16px; padding-right: 16px; }
  .play-teaser { padding: 28px 24px; }
}

/* ===== Work section ===== */
[hidden] { display: none !important; }
:root { --font-read: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif; }

.work-tools { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 24px; padding-bottom: 28px; }
.work-tools .chips { padding-bottom: 0; }
.chip-n { font: 400 12px var(--font-mono); opacity: .7; margin-left: 4px; }
.search input {
  min-height: 44px; width: min(100%, 320px); padding: 0 16px; border-radius: 999px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border-strong); font: inherit; font-size: 15px;
}
.work-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.work-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color .15s ease; }
.work-card:hover { border-color: var(--border-strong); }
.work-card:hover .work-title { color: var(--accent); }
.work-media { aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.work-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Label tile: the post type, large, on a tinted panel. One tint per type; unknown types use the accent. */
.work-media.is-label { --fc: var(--accent); aspect-ratio: 16 / 7; justify-content: flex-start; align-items: flex-end; padding: 18px 22px;
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--fc) 7%, transparent) 14px 15px),
    linear-gradient(135deg, color-mix(in srgb, var(--fc) 20%, var(--surface-2)), var(--surface-2) 70%); }
.work-media.is-label[data-format="tutorial"] { --fc: #8ab4ff; }
.work-media.is-label[data-format="thought"] { --fc: #ffb454; }
:root[data-theme="light"] .work-media.is-label[data-format="tutorial"] { --fc: #2f5fb3; }
:root[data-theme="light"] .work-media.is-label[data-format="thought"] { --fc: #9a5b00; }
.work-ph { font: 600 clamp(26px, 3vw, 34px)/1 var(--font-display); letter-spacing: .02em; text-transform: capitalize; color: var(--faint); }
.is-label .work-ph { color: var(--fc); }
.work-body-card { display: flex; flex-direction: column; gap: 10px; padding: 22px 24px 26px; flex: 1; }
.work-title { font-size: 21px; line-height: 1.25; }
.work-body-card .mono-label .accent { text-transform: uppercase; }

/* Article shell */
.post-shell { max-width: 1128px; padding-top: 72px; padding-bottom: 48px; }
.post-shell .post-head { max-width: 740px; display: flex; flex-direction: column; gap: 18px; margin-bottom: 32px; }
.post-shell .post-cover { max-width: 740px; margin: 0 0 40px; }
.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.format-badge { color: var(--accent); border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 10px; }
.post-layout { display: flex; align-items: flex-start; gap: 64px; }
.post-main { flex: 1 1 0; min-width: 0; max-width: 740px; }
.post-foot { margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border); }

/* Table of contents */
.toc nav ul { list-style: none; margin: 0; padding: 0; }
.toc nav ul ul { padding-left: 14px; }
.toc a { display: block; padding: 5px 0 5px 12px; color: var(--muted); font-size: 14px; line-height: 1.4; border-left: 2px solid var(--border); }
.toc a:hover { color: var(--text); }
.toc a[aria-current="true"] { color: var(--accent); border-left-color: var(--accent); }
.toc-side { flex: 0 0 248px; position: sticky; top: calc(var(--header-h) + 24px); max-height: calc(100vh - var(--header-h) - 48px); overflow-y: auto; }
.toc-side .mono-label { margin-bottom: 10px; }
.toc-inline { display: none; margin-bottom: 28px; border: 1px solid var(--border); border-radius: 12px; padding: 4px 16px; background: var(--surface); }
.toc-inline summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font: 500 13px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.toc-inline nav { padding-bottom: 12px; }
@media (max-width: 1100px) {
  .toc-side { display: none; }
  .toc-inline { display: block; }
  .post-layout { gap: 0; }
}

/* Reading typography */
.work-body { font-family: var(--font-read); font-size: 19.5px; line-height: 1.75; color: var(--text); font-optical-sizing: auto; }
.work-body.sans { font-family: var(--font-body); font-size: 17.5px; line-height: 1.7; }
.work-body h2, .work-body h3, .work-body h4 { font-family: var(--font-display); letter-spacing: -0.01em; position: relative; scroll-margin-top: calc(var(--header-h) + 16px); }
.work-body h2 { font-size: 32px; margin: 2.2em 0 .6em; padding-top: .2em; }
.work-body h3 { font-size: 23px; margin: 1.8em 0 .5em; }
.work-body h4 { font-size: 18px; margin: 1.6em 0 .4em; }
.work-body .anchor { margin-left: .4em; color: var(--accent); opacity: 0; font-weight: 400; text-decoration: none; transition: opacity .15s ease; }
.work-body h2:hover .anchor, .work-body h3:hover .anchor, .work-body h4:hover .anchor, .work-body .anchor:focus-visible { opacity: 1; }
.work-body > p:first-of-type { font-size: 1.06em; }
.work-body strong { font-weight: 600; }
.work-body a { text-decoration-thickness: 1px; }
.work-body blockquote { font-style: italic; border-left: 3px solid var(--accent); margin: 1.6em 0; padding: 2px 0 2px 22px; color: var(--muted); }
.work-body blockquote p:last-child { margin-bottom: 0; }
.work-body kbd { font: 500 .8em var(--font-mono); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; padding: 1px 7px; background: var(--surface); }
.work-body mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; padding: 0 3px; border-radius: 3px; }
.work-body ul:has(> li > input[type="checkbox"]) { list-style: none; padding-left: 0; }
.work-body li > input[type="checkbox"] { margin-right: 10px; accent-color: var(--accent); width: 1em; height: 1em; vertical-align: -2px; }
.work-body figure { margin: 2em 0; }
.work-body figure img { width: 100%; border: 1px solid var(--border); }
.work-body figcaption { font: 400 14px var(--font-body); color: var(--faint); margin-top: 10px; text-align: center; }
.work-body table { font-family: var(--font-body); font-size: 15.5px; width: 100%; }
.work-body th { background: var(--surface); font-weight: 600; }
.work-body details { font-family: var(--font-body); font-size: 16px; border: 1px solid var(--border); border-radius: 12px; padding: 4px 18px; margin: 1.4em 0; background: var(--surface); }
.work-body details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 500; }
.work-body details[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.work-body .footnotes { font-size: .85em; color: var(--muted); border-top: 1px solid var(--border); margin-top: 3em; padding-top: 1em; }
.work-body sup a { text-decoration: none; }
.work-body :not(pre) > code { font-size: .82em; }

/* Code blocks */
.codeblock { margin: 1.6em 0; border-radius: 12px; overflow: hidden; border: 1px solid #2f3a35; background: #272822; }
.codeblock-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 8px 4px 16px; background: #1d1f1b; border-bottom: 1px solid #2f3a35; }
.codeblock-lang { font: 400 12px var(--font-mono); letter-spacing: .06em; color: #a3b0a8; }
.copy-btn { min-height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid #3c4943; background: transparent; color: #e9eeea; font: 500 12px var(--font-mono); cursor: pointer; }
.copy-btn:hover { border-color: #c8f169; }
.codeblock .highlight { margin: 0; }
.codeblock pre, .work-body .codeblock pre { margin: 0; border: 0; border-radius: 0; padding: 18px 20px; font-family: var(--font-mono); font-size: 14px; line-height: 1.6; overflow-x: auto; tab-size: 4; }
.codeblock pre code { font-size: inherit; background: none; padding: 0; }
.work-body :not(pre) > code { font-family: var(--font-mono); }

/* Callouts */
.callout { --c: var(--accent); font-family: var(--font-body); font-size: 16.5px; line-height: 1.6; margin: 1.8em 0; padding: 16px 20px 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); position: relative; }
.callout::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--c); }
.callout-tip { --c: #4cc38a; }
.callout-warning { --c: #f2a93b; }
.callout-important { --c: #ef6f6c; }
:root[data-theme="light"] .callout-tip { --c: #1b7f4f; }
:root[data-theme="light"] .callout-warning { --c: #a8620a; }
:root[data-theme="light"] .callout-important { --c: #b3312e; }
.callout-title { font: 500 12px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--c); margin-bottom: 6px; }
.callout-body > :last-child { margin-bottom: 10px; }

/* Math + diagrams */
.math-block { margin: 1.6em 0; overflow-x: auto; text-align: center; font-size: 1.1em; }
.math-block:not(:has(.katex)) { font-family: var(--font-mono); font-size: 14px; white-space: pre-wrap; color: var(--muted); }
.math-inline:not(:has(.katex)) { font-family: var(--font-mono); font-size: .85em; }
pre.mermaid { margin: 1.8em 0; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; text-align: center; overflow-x: auto; font-family: var(--font-body); }
pre.mermaid:not([data-processed]) { white-space: pre-wrap; text-align: left; font: 13px var(--font-mono); color: var(--muted); }
@media (max-width: 640px) {
  .work-body { font-size: 18px; }
  .work-body h2 { font-size: 27px; }
  .post-shell { padding-top: 48px; }
}
