/* ============================================================
   FLEXOKI GHOST THEME — MAIN STYLESHEET
   palette: Flexoki Dark  |  accent: green-400 #879a39
   ============================================================ */

/* FONTS */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600&family=Geist+Mono:wght@400;500&display=swap');

/* TOKENS */
:root {
  --base:        #100f0f;
  --surface:     #1c1b1a;
  --overlay:     #282726;
  --muted:       #343331;
  --subtle:      #575653;
  --fg-dim:      #6f6e69;
  --fg:          #cecdc3;
  --fg-bright:   #fffcf0;
  --accent:      #879a39;
  --accent-dim:  #66800b;
  --accent-hi:   #a6b53d;
  --red:         #d14d41;
  --orange:      #da702c;
  --yellow:      #d0a215;
  --blue:        #4385be;
  --purple:      #8b7ec8;
  --cyan:        #3aa99f;

  --font-sans:  'Geist', system-ui, sans-serif;
  --font-mono:  'Geist Mono', 'Fira Code', monospace;

  --measure:    68ch;
  --sidebar-w:  220px;
  --gap:        1.5rem;
  --gap-sm:     1rem;
  --radius:     3px;
  --header-h:   52px;
  --transition: 150ms ease;
}

/* LIGHT MODE OVERRIDES */
[data-theme="light"] {
  --base:      #fffcf0;
  --surface:   #f2f0e5;
  --overlay:   #e6e4d9;
  --muted:     #dad8ce;
  --subtle:    #b7b5ac;
  --fg-dim:    #878580;
  --fg:        #403e3c;
  --fg-bright: #100f0f;
  --accent:    #66800b;
  --accent-dim:#879a39;
  --accent-hi: #4d6305;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background:  var(--base);
  color:       var(--fg);
  font-family: var(--font-sans);
  font-size:   1rem;
  line-height: 1.7;
  min-height:  100vh;
  overflow-x:  hidden;
}

/* body lock when mobile nav/toc open */
body.nav-open,
body.toc-open { overflow: hidden; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--subtle); }

/* SELECTION */
::selection { background: var(--accent); color: var(--base); }

/* LINKS */
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hi); }

/* ============================================================
   SITE HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--base);
  border-bottom: 1px solid var(--muted);
  padding: 0 var(--gap);
}

.site-header-inner {
  max-width: 960px;
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-logo {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-bright);
  white-space: nowrap;
  flex-shrink: 0;
}
.site-logo:hover { color: var(--accent-hi); }
.site-logo img { height: 28px; width: auto; vertical-align: middle; }

/* DESKTOP NAV */
.site-nav {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  margin-left: auto;
}
.site-nav a {
  color: var(--fg-dim);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}
.site-nav a:hover,
.site-nav a.active { color: var(--fg-bright); background: var(--overlay); }

/* HEADER ACTIONS */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--muted);
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-dim);
  padding: 0.4rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
  line-height: 1;
  min-width: 36px;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover,
.icon-btn:focus-visible { color: var(--fg-bright); background: var(--overlay); outline: none; }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.rss-link {
  color: var(--fg-dim);
  display: flex;
  align-items: center;
  padding: 0.4rem;
  border-radius: var(--radius);
  min-width: 36px;
  min-height: 36px;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.rss-link:hover { color: var(--orange); background: var(--overlay); }
.rss-link svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

/* HAMBURGER — mobile only */
.nav-toggle {
  display: none;
}

/* ============================================================
   MOBILE NAV DRAWER
   ============================================================ */
.mobile-nav {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
}

.mobile-nav-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16,15,15,0.7);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 250ms ease;
}

.mobile-nav-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(280px, 85vw);
  background: var(--surface);
  border-left: 1px solid var(--muted);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.mobile-nav-close {
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-close svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.mobile-nav-drawer a {
  color: var(--fg);
  font-size: 1rem;
  font-weight: 500;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius);
  display: block;
  transition: color var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-drawer a:hover,
.mobile-nav-drawer a.active { color: var(--fg-bright); background: var(--overlay); }

.mobile-nav-divider {
  height: 1px;
  background: var(--muted);
  margin: 0.75rem 0;
}

.mobile-nav-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.mobile-nav.is-open { pointer-events: all; }
.mobile-nav.is-open .mobile-nav-backdrop { opacity: 1; }
.mobile-nav.is-open .mobile-nav-drawer { transform: translateX(0); }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.site-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem var(--gap);
}

/* ============================================================
   POST INDEX — flat chronological
   ============================================================ */
.post-feed { list-style: none; }

.post-feed-item {
  border-bottom: 1px solid var(--muted);
}
.post-feed-item:first-of-type { border-top: 1px solid var(--muted); }

.post-feed-link {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.85rem 0;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.post-feed-link:hover { color: inherit; }
.post-feed-link:hover .post-feed-title { color: var(--accent-hi); }

.post-feed-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-dim);
  white-space: nowrap;
  padding-top: 0.1rem;
}

.post-feed-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--fg-bright);
  transition: color var(--transition);
  line-height: 1.4;
}

.post-feed-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--fg-dim);
  white-space: nowrap;
}

.post-feed-reading-time { font-family: var(--font-mono); }

.post-feed-tag {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 0.1rem 0.4rem;
}

/* YEAR SEPARATOR */
.year-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  text-transform: uppercase;
}
.year-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--muted);
}

/* ============================================================
   POST / ARTICLE
   ============================================================ */
.post-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
}

/* POST HEADER */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--muted);
}

.post-title {
  font-size: clamp(1.3rem, 3.5vw, 2rem);
  font-weight: 600;
  color: var(--fg-bright);
  line-height: 1.25;
  margin-bottom: 1rem;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  font-size: 0.78rem;
  color: var(--fg-dim);
  font-family: var(--font-mono);
}

.post-meta-sep { color: var(--muted); }

.post-tag {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 0.15rem 0.45rem;
  font-family: var(--font-sans);
  transition: background var(--transition), color var(--transition);
}
.post-tag:hover { background: var(--accent-dim); color: var(--fg-bright); }

/* POST CONTENT */
.post-content {
  min-width: 0; /* prevent grid blowout */
  font-size: 1rem;
  line-height: 1.8;
  color: var(--fg);
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  color: var(--fg-bright);
  font-weight: 600;
  line-height: 1.3;
  margin: 2.5rem 0 0.75rem;
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.post-content h2 {
  font-size: 1.25rem;
  border-bottom: 1px solid var(--muted);
  padding-bottom: 0.4rem;
}
.post-content h3 { font-size: 1.05rem; }
.post-content h4 { font-size: 0.95rem; color: var(--fg); }

.post-content p { margin-bottom: 1.25rem; }

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent-dim);
}
.post-content a:hover { color: var(--accent-hi); text-decoration-color: var(--accent-hi); }

.post-content ul,
.post-content ol { margin: 0 0 1.25rem 1.5rem; }
.post-content li { margin-bottom: 0.35rem; }
.post-content li::marker { color: var(--accent); }

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg-dim);
  font-style: italic;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--muted);
  margin: 2rem 0;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 1.5rem 0;
  font-family: var(--font-mono);
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.post-content th,
.post-content td { padding: 0.5rem 0.75rem; border: 1px solid var(--muted); text-align: left; white-space: nowrap; }
.post-content th { background: var(--surface); color: var(--fg-bright); font-weight: 500; }
.post-content tr:nth-child(even) td { background: var(--surface); }

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--muted);
}

/* CODE */
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface);
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  padding: 0.15em 0.4em;
  color: var(--cyan);
  word-break: break-word;
}

.post-content pre {
  background: var(--surface);
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
}
.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--fg);
  word-break: normal;
}

/* ============================================================
   MOBILE TOC DRAWER
   ============================================================ */
.toc-mobile-bar {
  display: none; /* shown via media query */
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--muted);
}

.toc-mobile-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.toc-mobile-btn:hover { color: var(--fg-bright); background: var(--overlay); border-color: var(--subtle); }
.toc-mobile-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* TOC FULL-SCREEN DRAWER (mobile) */
.toc-drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
}

.toc-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16,15,15,0.75);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 250ms ease;
}

.toc-drawer-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--muted);
  border-radius: 12px 12px 0 0;
  padding: 1.25rem 1.5rem 2rem;
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.toc-drawer-handle {
  width: 40px;
  height: 4px;
  background: var(--muted);
  border-radius: 2px;
  margin: 0 auto 1.25rem;
}

.toc-drawer-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 0.75rem;
}

.toc-drawer.is-open { pointer-events: all; }
.toc-drawer.is-open .toc-drawer-backdrop { opacity: 1; }
.toc-drawer.is-open .toc-drawer-panel { transform: translateY(0); }

/* SHARED TOC LIST STYLES */
.toc-list {
  list-style: none;
  font-size: 0.85rem;
  line-height: 1.5;
}
.toc-list li { margin-bottom: 0.15rem; }
.toc-list a {
  color: var(--fg-dim);
  display: block;
  padding: 0.25rem 0.5rem;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.toc-list a:hover { color: var(--fg-bright); background: var(--overlay); }
.toc-list a.active { color: var(--accent); border-left-color: var(--accent); }
.toc-list .toc-h3 > a { padding-left: 1.25rem; }

/* TOC DESKTOP SIDEBAR */
.toc-sidebar {
  display: none;
}

/* ============================================================
   GHOST CARD ASSETS
   ============================================================ */
.kg-card { margin: 1.5rem 0; }
.kg-image-card img { border-radius: var(--radius); border: 1px solid var(--muted); max-width: 100%; }

.kg-bookmark-card { border: 1px solid var(--muted); border-radius: var(--radius); overflow: hidden; }
.kg-bookmark-container { display: flex; color: var(--fg); background: var(--surface); text-decoration: none; }
.kg-bookmark-container:hover { background: var(--overlay); }
.kg-bookmark-content { padding: 1rem; flex: 1; min-width: 0; }
.kg-bookmark-title { font-weight: 500; color: var(--fg-bright); margin-bottom: 0.25rem; }
.kg-bookmark-description { font-size: 0.8rem; color: var(--fg-dim); }
.kg-bookmark-url { font-size: 0.72rem; color: var(--fg-dim); font-family: var(--font-mono); margin-top: 0.5rem; word-break: break-all; }
.kg-bookmark-thumbnail { width: 120px; flex-shrink: 0; }
.kg-bookmark-thumbnail img { width: 100%; height: 100%; object-fit: cover; }

.kg-callout-card {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--muted);
  border-radius: var(--radius);
}
.kg-callout-emoji { font-size: 1.25rem; flex-shrink: 0; }

.kg-video-card video { max-width: 100%; border-radius: var(--radius); }

.kg-toggle-card {
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  overflow: hidden;
}
.kg-toggle-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  color: var(--fg-bright);
}
.kg-toggle-content { padding: 0.75rem 1rem; }

/* ============================================================
   TAG PAGE
   ============================================================ */
.tag-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--muted);
}
.tag-header h1 { font-size: 1.5rem; font-weight: 600; color: var(--fg-bright); }
.tag-header h1 span { color: var(--accent); font-family: var(--font-mono); font-size: 0.9em; }
.tag-description { color: var(--fg-dim); margin-top: 0.5rem; font-size: 0.9rem; }
.tag-count { font-family: var(--font-mono); font-size: 0.75rem; color: var(--fg-dim); margin-top: 0.25rem; }

/* ============================================================
   AUTHOR PAGE
   ============================================================ */
.author-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--muted);
}

.author-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--accent-dim);
  flex-shrink: 0;
  object-fit: cover;
}

.author-avatar-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.5rem;
  color: var(--fg-dim);
  font-family: var(--font-mono);
}

.author-info { flex: 1; min-width: 0; }

.author-name {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--fg-bright);
  margin-bottom: 0.25rem;
}

.author-handle {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.author-bio {
  color: var(--fg-dim);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  max-width: 52ch;
}

.author-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}
.author-links a {
  color: var(--fg-dim);
  transition: color var(--transition);
}
.author-links a:hover { color: var(--accent); }

.author-post-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-dim);
  margin-bottom: 1.5rem;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--fg-dim);
}
.pagination a {
  color: var(--accent);
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.pagination a:hover { background: var(--accent-dim); color: var(--fg-bright); }

/* ============================================================
   MEMBERS / PRIVATE PAGE
   ============================================================ */
.access-card {
  max-width: 420px;
  margin: 4rem auto;
  text-align: center;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--muted);
  border-radius: var(--radius);
}
.access-card h2 { font-size: 1.25rem; color: var(--fg-bright); margin-bottom: 0.75rem; }
.access-card p { color: var(--fg-dim); font-size: 0.9rem; margin-bottom: 1.5rem; }
.access-card .btn {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--fg-bright);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.access-card .btn:hover { background: var(--accent); }

/* ============================================================
   POST NAVIGATION (prev/next)
   ============================================================ */
.post-nav {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--muted);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.post-nav-link {
  color: var(--fg-dim);
  font-size: 0.85rem;
  line-height: 1.4;
  transition: color var(--transition);
}
.post-nav-link:hover { color: var(--fg-bright); }

.post-nav-link.next { text-align: right; }

.post-nav-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 0.2rem;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--muted);
  padding: 1.5rem var(--gap);
}

.site-footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--fg-dim);
}

.site-footer a { color: var(--fg-dim); }
.site-footer a:hover { color: var(--accent); }

/* ============================================================
   ERROR / 404
   ============================================================ */
.error-page { text-align: center; padding: 5rem 1rem; }
.error-code {
  font-family: var(--font-mono);
  font-size: clamp(3rem, 12vw, 5rem);
  font-weight: 300;
  color: var(--muted);
  line-height: 1;
  margin-bottom: 1rem;
}
.error-message { color: var(--fg-dim); margin-bottom: 2rem; }
.error-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  transition: background var(--transition);
}
.error-link:hover { background: var(--accent-dim); color: var(--fg-bright); }

/* ============================================================
   PRISM OVERRIDES — Flexoki palette
   ============================================================ */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--fg-dim); }
.token.punctuation { color: var(--fg); }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol { color: var(--orange); }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin { color: var(--accent-hi); }
.token.operator, .token.entity, .token.url, .language-css .token.string { color: var(--cyan); }
.token.atrule, .token.attr-value, .token.keyword { color: var(--purple); }
.token.function, .token.class-name { color: var(--yellow); }
.token.regex, .token.important, .token.variable { color: var(--red); }

/* ============================================================
   UTILITIES
   ============================================================ */
.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;
}

/* ============================================================
   RESPONSIVE — DESKTOP (≥820px)
   TOC sidebar visible, mobile controls hidden
   ============================================================ */
@media (min-width: 820px) {
  .post-layout {
    grid-template-columns: 1fr var(--sidebar-w);
    align-items: start;
    gap: 2.5rem;
  }

  .toc-sidebar {
    display: block;
    position: sticky;
    top: calc(var(--header-h) + 12px);
    max-height: calc(100vh - var(--header-h) - 24px);
    overflow-y: auto;
    padding-left: 1.5rem;
    border-left: 1px solid var(--muted);
  }

  .toc-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg-dim);
    margin-bottom: 0.75rem;
    font-family: var(--font-mono);
  }

  /* hide mobile controls on desktop */
  .toc-mobile-bar  { display: none !important; }
  .toc-drawer      { display: none !important; }
  .mobile-nav      { display: none !important; }
  .nav-toggle      { display: none !important; }
}

/* ============================================================
   RESPONSIVE — TABLET (640–819px)
   TOC as bottom sheet, nav still inline if space allows
   ============================================================ */
@media (max-width: 819px) {
  :root { --gap: 1rem; }

  .post-feed-link {
    grid-template-columns: 88px 1fr;
    gap: 1rem;
  }
  .post-feed-meta { display: none; }

  .toc-mobile-bar { display: flex; }
  .toc-drawer     { display: block; }
  .toc-sidebar    { display: none !important; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤640px)
   Hamburger nav, bottom-sheet TOC
   ============================================================ */
@media (max-width: 640px) {
  :root { --gap: 0.875rem; }

  .site-main { padding-top: 1.75rem; padding-bottom: 1.75rem; }

  /* hide desktop nav links, show hamburger */
  .site-nav    { display: none; }
  .nav-toggle  { display: flex; }

  /* show mobile nav drawer */
  .mobile-nav  { display: block; }

  .post-feed-link {
    grid-template-columns: 76px 1fr;
    gap: 0.6rem;
  }

  .post-feed-date { font-size: 0.68rem; }
  .post-feed-title { font-size: 0.9rem; }

  .post-title { font-size: clamp(1.15rem, 5vw, 1.5rem); }

  .post-meta { font-size: 0.72rem; gap: 0.4rem 0.75rem; }

  /* author page stacks on mobile */
  .author-header { flex-direction: column; }

  /* post nav stacks on mobile */
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-link.next { text-align: left; }

  /* footer stacks */
  .site-footer-inner { flex-direction: column; align-items: flex-start; gap: 0.35rem; }

  /* bookmark card thumbnail hidden on very small */
  .kg-bookmark-thumbnail { display: none; }
}

/* ============================================================
   FOCUS STYLES — keyboard nav
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* ============================================================
   KOENIG EDITOR — REQUIRED CARD WIDTH CLASSES
   Ghost validator requires .kg-width-wide and .kg-width-full
   ============================================================ */

/* wide cards break out of the content column slightly */
.kg-width-wide {
  position: relative;
  width: calc(100% + 6rem);
  margin-left: -3rem;
  margin-right: -3rem;
  max-width: none;
}

/* full-bleed cards stretch to site-main edges */
.kg-width-full {
  position: relative;
  width: calc(100vw - var(--scrollbar-w, 0px));
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  max-width: none;
}

/* images inside wide/full cards */
.kg-width-wide img,
.kg-width-full img {
  width: 100%;
  height: auto;
  display: block;
  border: none;
  border-radius: 0;
}

[data-theme="light"] .site-logo img { filter: invert(1) hue-rotate(180deg); }

/* on mobile, wide/full collapse back to full content width */
@media (max-width: 640px) {
  .kg-width-wide {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
  .kg-width-full {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
  .site-nav    { display: none; }
  .nav-toggle  { display: flex; }
  .header-actions { 
    margin-left: auto; 
    border-left: none; 
    padding-left: 0; 
  }
  .site-footer-inner { 
    flex-direction: column; 
    align-items: center; 
    text-align: center; 
    gap: 0.75rem; 
  }
}

/* ============================================================
   AUTHOR AVATAR INITIAL — CSS fallback (no substr helper)
   Clips the full name text to show only the first character
   ============================================================ */
.author-avatar-placeholder {
  overflow: hidden;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--fg-dim);
  display: flex;
  align-items: center;
  justify-content: center;
}

.author-initial {
  display: block;
  /* clip text to a single character width via container overflow */
  width: 1ch;
  overflow: hidden;
  white-space: nowrap;
  text-transform: uppercase;
  font-family: var(--font-mono);
  line-height: 1;
}
