/* Tokens */
:root {
  --font-sans: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --header-h: 56px;
  --text: #0a0a0a;
  --muted: #6b7280;
  --canvas: #FAFAFC;
  --surface: #ffffff;
  --border: #e6e7eb;
  --accent: #0A84FF;

  /* Code colors */
  --code-bg: #f6f8fa;
  --code-bd: #e6e7eb;
  --code-fg: #0a0a0a;
  --sh-cmt: #6b7280;
  --sh-kw: #0b63d1;
  --sh-str: #0f7b0f;
  --sh-num: #b05a00;
  --sh-fn: #9d1bb2;
  --sh-ty: #0550ae;
  --sh-op: #6b7280;
  --sh-tag: #7a3e9d;

  /* Scrollbar for code blocks */
  --sb-track: var(--code-bg);
  --sb-thumb: color-mix(in oklab, var(--text) 18%, transparent);

  /* Light (specular) tuning */
  --specular-a1: 0.14; /* main streak */
  --specular-a2: 0.26; /* radial glint */

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --radius-1: 8px;
  --radius-2: 12px;
  --radius-3: 16px;

  --shadow-1: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.08);

  --container: clamp(1200px, 94vw, 1500px);

  /* Glass tokens */
  --glass-bg: color-mix(in oklab, var(--surface) 78%, transparent);
  --glass-blur: 14px;
  --glass-stroke: 1px solid color-mix(in oklab, var(--text) 8%, transparent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #f5f7fa;
    --muted: #a8b0be;
    --canvas: #0b0c0f;
    --surface: #111318;
    --border: #242833;
    --code-bg: #0f1116;
    --code-bd: #242833;
    --code-fg: #e8eef8;
    --sh-cmt: #8b93a7;
    --sh-kw: #7db7ff;
    --sh-str: #86e08f;
    --sh-num: #ffc78e;
    --sh-fn: #dba5ff;
    --sh-ty: #8fbfff;
    --sh-op: #b6bdc9;
    --sh-tag: #caa8ff;
    --sb-track: var(--code-bg);
    --sb-thumb: color-mix(in oklab, #ffffff 28%, transparent);

    --glass-bg: color-mix(in oklab, var(--surface) 70%, transparent);
    --glass-blur: 14px;
    --glass-stroke: 1px solid color-mix(in oklab, #ffffff 6%, transparent);

    --specular-a1: 0.12;
    --specular-a2: 0.22;
  }
}

/* Base */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle background gradients for liquid feel (very low intensity) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(900px 600px at 85% -10%, color-mix(in oklab, var(--accent) 10%, transparent), transparent 60%),
              radial-gradient(700px 500px at -10% 20%, color-mix(in oklab, var(--accent) 6%, transparent), transparent 55%);
  opacity: 0.035;
}

.container {
  max-width: var(--container);
  padding: 0 var(--space-5);
  margin: 0 auto;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: var(--space-5);
  top: var(--space-5);
  background: var(--surface);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-1);
  box-shadow: var(--shadow-1);
}

/* Header */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  background: color-mix(in oklab, var(--surface) 68%, transparent);
  transition: background 200ms ease, backdrop-filter 200ms ease, border-color 200ms ease;
  border-bottom: var(--glass-stroke);
}
body.scrolled .site-header {
  background: color-mix(in oklab, var(--surface) 82%, transparent);
}
@supports (backdrop-filter: blur(8px)) {
  .site-header { backdrop-filter: saturate(150%) blur(10px); }
  body.scrolled .site-header { backdrop-filter: saturate(160%) blur(var(--glass-blur)); }
}

/* Push content below fixed header */
.site-body { margin-top: var(--header-h); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.brand {
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}
.nav { display: flex; gap: 12px; }
.nav a { text-decoration: none; color: var(--text); padding: 6px 0; }
.nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 3px; }

/* Hero */
.hero { padding: var(--space-8) 0 var(--space-6); min-height: 240px; }
.hero { position: relative; }
.hero-3d { position: absolute; inset: 0; z-index: 1; pointer-events: auto; }
#hero3d { width: 100%; height: 100%; display: block; }
.hero-content { max-width: 720px; position: relative; z-index: 2; pointer-events: none; }
.hero h1 { font-size: clamp(32px, 6vw, 48px); letter-spacing: -0.02em; margin: 0 0 var(--space-3) 0; }
.subtitle { color: var(--muted); font-size: 18px; margin: 0; }
.hero .actions { margin-top: var(--space-4); display: flex; gap: 10px; flex-wrap: wrap; }

/* Sections */
.section { padding: var(--space-6) 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-4); }
.section-title { font-size: 20px; margin: 0; }
.text-link { color: var(--accent); text-decoration: none; }
.text-link:hover { text-decoration: underline; }

/* Cards */
.card-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { position: relative; background: color-mix(in oklab, var(--surface) 90%, transparent); border: 1px solid color-mix(in oklab, var(--text) 8%, transparent); border-radius: var(--radius-2); box-shadow: var(--shadow-1); transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, border-color 180ms ease, opacity 180ms ease; overflow: hidden; }
.card.is-tilting { filter: drop-shadow(var(--shx, 0px) var(--shy, 12px) 22px rgba(0,0,0,0.18)); }
/* Inner highlight stroke + subtle bevel guided by tilt */
.card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; border: 1px solid color-mix(in oklab, #ffffff 6%, transparent); background: linear-gradient(var(--edge-angle, 180deg), rgba(255,255,255,0.05), rgba(255,255,255,0) 30%); }
/* Gloss overlay (fixed light; card tilts) */
.card { will-change: transform; }
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(135deg,
      rgba(255,255,255,var(--specular-a1)) 0%,
      rgba(255,255,255,calc(var(--specular-a1) * 0.57)) 24%,
      rgba(255,255,255,0.00) 60%)
    , radial-gradient(520px 160px at -10% -10%, rgba(255,255,255,var(--specular-a2)), rgba(255,255,255,0.0) 60%);
  opacity: 0; /* only show on hover */
  transition: opacity 180ms ease;
}
.card-link { color: inherit; text-decoration: none; display: block; }
.card-body { padding: var(--space-4); }
.card-title { margin: 0 0 var(--space-2) 0; font-size: 18px; letter-spacing: -0.01em; }
.card-meta { margin: 0 0 var(--space-2) 0; color: var(--muted); font-size: 14px; }
.card-excerpt { margin: 0; color: color-mix(in oklab, var(--text) 80%, transparent); }
.card:hover { box-shadow: var(--shadow-2); background: color-mix(in oklab, var(--surface) 94%, transparent); }
.card:hover::after { opacity: 1; }
.card:focus-within { outline: none; box-shadow: 0 0 0 2px color-mix(in oklab, var(--text) 24%, transparent), var(--shadow-2); }
@supports (backdrop-filter: blur(2px)) {
  .card { backdrop-filter: blur(4px) saturate(120%); }
  .card:hover { backdrop-filter: blur(6px) saturate(140%); }
}

/* High contrast: reduce gloss, strengthen edges */
@media (prefers-contrast: more) {
  .card::after { opacity: 0.5; }
  .card::before { border-color: color-mix(in oklab, #ffffff 12%, transparent); }
}

/* Reduced motion: disable tilt, keep subtle hover only */
@media (prefers-reduced-motion: reduce) {
  .card { transform: none !important; }
  .card.is-tilting { filter: none; }
}

/* Pages & Posts */
.page-header, .post-header { margin: var(--space-6) 0 var(--space-4); }
.post-title { font-size: clamp(28px, 5vw, 40px); letter-spacing: -0.01em; margin: 0 0 var(--space-2) 0; }
.post-meta { color: var(--muted); margin: 0; }
/* Reading progress bar removed */


.prose { color: var(--text); line-height: 1.7; font-size: 17px; }
.prose p { margin: 1em 0; }
.prose h2 { font-size: 24px; margin: 2em 0 0.6em; }
.prose h3 { font-size: 20px; margin: 1.6em 0 0.6em; }
.prose h1, .prose h2, .prose h3 { position: relative; scroll-margin-top: calc(var(--header-h) + 12px); }
.heading-anchor { position: absolute; left: -1.2em; top: 50%; transform: translateY(-50%); opacity: 0; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.85em; }
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor, .heading-anchor:focus { opacity: 1; }
.prose a { color: var(--accent); text-underline-offset: 2px; }
.prose blockquote { margin: 1.2em 0; padding: 0.6em 1em; border-left: 3px solid var(--border); color: color-mix(in oklab, var(--text) 80%, transparent); }
.prose img, .prose video { max-width: 100%; border-radius: var(--radius-1); }
.prose code { background: color-mix(in oklab, var(--text) 6%, transparent); padding: 0.1em 0.4em; border-radius: 6px; font-size: 0.95em; font-family: var(--font-mono); }
.prose pre { overflow: auto; background: var(--code-bg); color: var(--code-fg); padding: var(--space-3); border-radius: var(--radius-2); border: 1px solid var(--code-bd); font-family: var(--font-mono); }
.prose pre code { background: transparent; padding: 0; }

/* Article tables */
.prose table {
  width: 100%;
  margin: 1.8em 0;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95em;
  border: 1px solid color-mix(in oklab, var(--border) 80%, transparent);
  border-radius: var(--radius-2);
  overflow: hidden; /* ensures rounded corners with separated rows */
  background: color-mix(in oklab, var(--surface) 98%, transparent);
}
.prose table caption {
  caption-side: bottom;
  padding: 0.8em 0 0;
  color: var(--muted);
  font-size: 0.88em;
  text-align: left;
}
.prose table thead th {
  background: color-mix(in oklab, var(--text) 5%, var(--surface));
  color: color-mix(in oklab, var(--text) 92%, transparent);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}
.prose table thead th,
.prose table tbody td {
  padding: 0.85em 1.1em;
  text-align: left;
  border-bottom: 1px solid color-mix(in oklab, var(--border) 90%, transparent);
}
.prose table tbody tr:last-child td { border-bottom: none; }
.prose table tbody tr:nth-child(odd) {
  background: color-mix(in oklab, var(--surface) 98%, transparent);
}
.prose table tbody tr:nth-child(even) {
  background: color-mix(in oklab, var(--surface) 96%, transparent);
}
.prose table th:first-child,
.prose table td:first-child { padding-left: 1.2em; }
.prose table th:last-child,
.prose table td:last-child { padding-right: 1.2em; }
/* Post grid with right TOC */
.post-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-7); align-items: start; }
.toc {
  position: sticky;
  top: calc(var(--header-h) + 12px);
  padding: calc(var(--space-4) + 4px) var(--space-4);
  border: 1px solid color-mix(in oklab, var(--text) 7%, transparent);
  border-radius: var(--radius-2);
  background: color-mix(in oklab, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-1);
  max-height: calc(100vh - var(--header-h) - 24px);
  overflow: auto;
  justify-self: end;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
}
.toc-head {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-3);
  padding-left: 2px;
}
.toc nav {
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.toc nav ul { margin: 0; padding: 0; list-style: none; }
.toc nav > ul { display: flex; flex-direction: column; gap: var(--space-3); }
.toc li { list-style: none; }
.toc-section {
  border: 1px solid color-mix(in oklab, var(--border) 85%, transparent);
  border-radius: var(--radius-1);
  background: color-mix(in oklab, var(--surface) 98%, transparent);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.toc-section:hover {
  border-color: color-mix(in oklab, var(--text) 14%, var(--border));
  background: color-mix(in oklab, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-1);
}
.toc-section-header { display: flex; align-items: center; gap: var(--space-2); }
.toc-section-header a {
  flex: 1;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.toc-section-header a:hover { text-decoration: underline; }
.toc-toggle {
  border: none;
  background: none;
  padding: 4px;
  margin: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
  transition: color 120ms ease, background 120ms ease;
}
.toc-toggle:hover { color: var(--text); background: color-mix(in oklab, var(--text) 8%, transparent); }
.toc-toggle:focus-visible { outline: 2px solid color-mix(in oklab, var(--accent) 60%, transparent); outline-offset: 2px; }
.toc-toggle-icon { display: inline-block; width: 12px; height: 12px; position: relative; }
.toc-toggle-icon::before,
.toc-toggle-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 200ms ease;
}
.toc-toggle-icon::after { transform: rotate(90deg); }
.toc-toggle[aria-expanded="false"] .toc-toggle-icon::after { transform: rotate(0deg); }
.toc-sublist {
  margin: 0;
  padding: 4px 0 0 16px;
  display: grid;
  gap: 8px;
}
.toc-sublist[hidden] { display: none !important; }
.toc-sublist a { color: var(--muted); text-decoration: none; font-size: 13px; line-height: 1.45; }
.toc-sublist a:hover { color: var(--text); text-decoration: underline; }
.toc-sublist li { margin: 0; }
.toc-sublist-nested {
  padding: 2px 0 0 14px;
  gap: 6px;
}
.toc-sublist-nested a { font-size: 12.5px; }

@media (max-width: 1100px) {
  .post-grid { grid-template-columns: 1fr; }
  .toc { display: none; }
}

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: var(--space-7); }
.footer-inner { padding: var(--space-5) 0; color: var(--muted); }
.footer-inner a { color: inherit; }

/* Chips */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-block; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 6px 10px; border-radius: 999px; text-decoration: none; font-size: 14px; }
.chip:hover { border-color: color-mix(in oklab, var(--accent) 20%, var(--border)); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-active { background: color-mix(in oklab, var(--accent) 10%, var(--surface)); }
.chip-inline { padding: 3px 8px; font-size: 13px; }

/* Breadcrumbs */
.breadcrumbs { color: var(--muted); font-size: 14px; margin-top: var(--space-5); }
.breadcrumbs a { color: inherit; text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }

/* Search */
.search { max-width: 760px; }
.search-input { width: 100%; font: inherit; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.search-input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.search-stats { margin-top: 10px; color: var(--muted); font-size: 14px; }
.search-results { margin-top: var(--space-4); }

/* Two-column layout with left sidebar */
.layout--with-sidebar { display: grid; grid-template-columns: 240px 1fr; gap: var(--space-5); align-items: start; }
.sidebar { position: sticky; top: 64px; align-self: start; border: 1px solid var(--border); border-radius: var(--radius-2); background: var(--surface); box-shadow: var(--shadow-1); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-3); border-bottom: 1px solid var(--border); }
.sidebar-title { font-size: 16px; margin: 0; }
.vnav { display: flex; flex-direction: column; padding: var(--space-3); gap: 8px; }
.btn-block { width: 100%; justify-content: flex-start; }
.vnav .is-active { background: color-mix(in oklab, var(--accent) 10%, var(--surface)); border-color: color-mix(in oklab, var(--accent) 22%, var(--border)); }
.main-column { min-width: 0; }
.page-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Mobile sidebar behavior */
@media (max-width: 860px) {
  .layout--with-sidebar { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 56px; left: 0; right: 0; max-width: 100%; transform: translateY(-120%); transition: transform 200ms ease; z-index: 30; border-radius: 0 0 var(--radius-2) var(--radius-2); }
  body.sidebar-open .sidebar { transform: translateY(0); }
}

/* Buttons (general purpose; avoid for categories) */
.btn { 
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  text-decoration: none;
  font-weight: 500;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
  box-shadow: var(--shadow-1);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); border-color: color-mix(in oklab, var(--accent) 20%, var(--btn-bd)); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: #fff; --btn-bd: var(--accent); }
.btn-outline { --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border); }
.btn-ghost { 
  --btn-bg: color-mix(in oklab, var(--accent) 10%, transparent);
  --btn-fg: var(--text);
  --btn-bd: color-mix(in oklab, var(--accent) 18%, var(--border));
}
.btn-sm { padding: 6px 10px; border-radius: 10px; font-weight: 500; }
.btn-white { --btn-bg: #ffffff; --btn-fg: #0a0a0a; --btn-bd: #e6e7eb; }

/* Topic cards inside Browse */
.topic-card .card-body { display: flex; flex-direction: column; gap: 12px; }
.topic-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Global site layout with persistent left sidebar */
.layout-site { display: grid; grid-template-columns: 220px 1fr; gap: var(--space-7); align-items: start; }
.sidebar-global {
  position: sticky;
  top: calc(var(--header-h) + 28px);
  align-self: start;
  padding: var(--space-4) var(--space-3);
  border-right: 1px solid var(--border);
  /* Consistent viewport-based height so it doesn't jump on short pages */
  height: calc(100vh - (var(--header-h) + 28px) - 24px);
  min-height: calc(100vh - (var(--header-h) + 28px) - 24px);
  overflow: auto;
  /* Extra visual offset below header regardless of sticky threshold */
  margin-top: var(--space-5);
}
.side-group { margin-bottom: var(--space-5); }
.side-heading { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: var(--space-2); }
.side-heading.active { color: var(--text); font-weight: 600; }
.side-heading.active::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: middle; }
.side-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.side-list a { color: var(--text); text-decoration: none; padding: 4px 0; display: inline-block; }
.side-list a.active { background: color-mix(in oklab, var(--accent) 12%, transparent); }
.side-list a:hover { text-decoration: underline; }
.main-column { min-width: 0; }

@media (max-width: 860px) {
  .layout-site { grid-template-columns: 1fr; }
  .sidebar-global {
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: auto;
    min-height: 0;
    overflow: visible;
  }
}

/* Post meta category link */
.cat-link { color: inherit; text-decoration: none; }
.cat-link:hover { text-decoration: underline; }

/* Syntax Highlighting (Rouge) */
.highlight, figure.highlight, .highlighter-rouge { margin: 1.2em 0 0; }
.highlight pre, figure.highlight pre, .highlighter-rouge pre {
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--code-bd);
  border-radius: var(--radius-2);
  padding: var(--space-3);
  line-height: 1.6;
  font-family: var(--font-mono);
  font-size: 0.95em;
}
.highlight pre code { background: transparent; padding: 0; }

/* Token colors (Rouge) */
.highlight .c, .highlight .cm, .highlight .c1, .highlight .cs { color: var(--sh-cmt); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt { color: var(--sh-kw); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .se, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .sh, .highlight .sx, .highlight .sr { color: var(--sh-str); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .il { color: var(--sh-num); }
.highlight .nf, .highlight .fm { color: var(--sh-fn); }
.highlight .nc, .highlight .nn, .highlight .no, .highlight .na, .highlight .nt, .highlight .bp { color: var(--sh-ty); }
.highlight .nt, .highlight .tag { color: var(--sh-tag); }
.highlight .o, .highlight .ow, .highlight .p { color: var(--sh-op); }
.highlight .err { border-bottom: 1px dotted #e00; }

/* Optional gutters (if line numbers enabled) */
.highlight table { width: 100%; border-collapse: collapse; }
.highlight td.gutter { user-select: none; opacity: 0.6; padding-right: var(--space-3); }
.highlight td.code { width: 100%; }

/* Unified scrollbars for code blocks */
.prose pre,
.highlight pre,
.highlighter-rouge pre,
.highlight table {
  scrollbar-width: thin;                /* Firefox */
  scrollbar-color: var(--sb-thumb) var(--sb-track);
}
.prose pre::-webkit-scrollbar,
.highlight pre::-webkit-scrollbar,
.highlighter-rouge pre::-webkit-scrollbar,
.highlight table::-webkit-scrollbar {
  height: 10px;                         /* horizontal */
  width: 10px;                          /* vertical (if any) */
}
.prose pre::-webkit-scrollbar-track,
.highlight pre::-webkit-scrollbar-track,
.highlighter-rouge pre::-webkit-scrollbar-track,
.highlight table::-webkit-scrollbar-track {
  background: var(--sb-track);
  border-radius: 8px;
}
.prose pre::-webkit-scrollbar-thumb,
.highlight pre::-webkit-scrollbar-thumb,
.highlighter-rouge pre::-webkit-scrollbar-thumb,
.highlight table::-webkit-scrollbar-thumb {
  background: var(--sb-thumb);
  border-radius: 999px;
  border: 2px solid var(--code-bg);     /* creates a pill on track */
}
.prose pre::-webkit-scrollbar-thumb:hover,
.highlight pre::-webkit-scrollbar-thumb:hover,
.highlighter-rouge pre::-webkit-scrollbar-thumb:hover,
.highlight table::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklab, var(--sb-thumb) 120%, var(--sb-track));
}

/* Inline copy button inside code block */
figure.highlight, .highlighter-rouge { position: relative; }
.copy-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border: 1px solid var(--code-bd);
  background: color-mix(in oklab, var(--surface) 60%, var(--code-bg));
  color: var(--text);
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  cursor: pointer;
}
figure.highlight:hover .copy-btn, .highlighter-rouge:hover .copy-btn {
  opacity: 1;
  transform: translateY(0);
}
/* Extra bottom padding so button doesn't cover code */
.highlight pre, figure.highlight pre, .highlighter-rouge pre { padding-bottom: calc(var(--space-3) + 30px); }

/* Media queries */
@media (max-width: 680px) {
  .header-inner { height: 52px; }
  :root { --header-h: 52px; }
  .nav a { padding: 8px 8px; margin-left: 2px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* Summarizer UI removed per request */
