/* lab-article.css — shared stylesheet for /lab/<slug> article pages.
   Visual language matches lab.html (same vars, same nav/footer). */

:root {
  --bg: #09090b;
  --bg-alt: #111113;
  --surface: #18181b;
  --surface-2: #1c1c20;
  --surface-hover: #1f1f23;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #34d399;
  --accent-hover: #6ee7b7;
  --accent-dim: rgba(52,211,153,0.08);
  --accent-glow: rgba(52,211,153,0.15);
  --accent-glow-strong: rgba(52,211,153,0.28);
  --accent-2: #a78bfa;
  --radius: 18px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --max-w: 760px;
  --max-w-wide: 1400px;
  --transition: 0.2s ease;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden; max-width: 100vw; }
body {
  font-family: 'Heebo', sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.7; overflow-x: hidden; max-width: 100vw;
}
html[lang="en"] body { font-family: 'Inter', sans-serif; }
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; cursor: pointer; }

[data-en] { display: none; }
html[lang="en"] [data-he] { display: none; }
html[lang="en"] [data-en] { display: inline; }

body::before {
  content: ''; position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none; z-index: 0;
  mask-image: radial-gradient(ellipse at top, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at top, #000 0%, transparent 75%);
}

/* ===== NAV (same as lab.html) ===== */
.nav {
  position: fixed; top: 0; right: 0; left: 0; z-index: 100;
  background: rgba(9,9,11,0.72);
  backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s, border-color 0.3s;
}
.nav-inner {
  max-width: var(--max-w-wide); margin: 0 auto; padding: 0 24px;
  height: 64px; display: flex; align-items: center; justify-content: space-between;
}
.nav-brand img { height: 34px; width: auto; display: block; }
.nav-links { display: flex; gap: 28px; align-items: center; }
.nav-links a { color: var(--text-secondary); font-size: 14px; font-weight: 500; transition: color var(--transition); }
.nav-links a:hover { color: var(--text); }
.lang-toggle {
  display: inline-flex; gap: 0;
  border: 1px solid var(--border-hover); border-radius: 100px; padding: 3px;
  background: rgba(0,0,0,0.3);
}
.lang-toggle button {
  background: none; border: none; color: var(--text-muted);
  padding: 5px 12px; border-radius: 100px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.4px;
  transition: all var(--transition);
}
.lang-toggle button.active { background: var(--accent); color: #000; }
.nav-cta {
  background: var(--accent) !important; color: #000 !important;
  padding: 8px 22px; border-radius: 100px; font-weight: 700 !important;
  font-size: 14px !important; transition: all var(--transition);
}
.nav-cta:hover {
  background: var(--accent-hover) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow-strong);
}
.nav-mobile { display: none; background: none; border: none; color: var(--text); font-size: 24px; padding: 4px; }

/* ===== ARTICLE ===== */
.article-main {
  max-width: var(--max-w-wide); margin: 0 auto;
  padding: 120px 24px 80px;
  position: relative; z-index: 1;
}

.article {
  max-width: var(--max-w); margin: 0 auto;
}

.article-head { margin-bottom: 48px; }

.article-back {
  display: inline-block; color: var(--text-muted); font-size: 14px;
  margin-bottom: 32px; transition: color var(--transition);
}
.article-back:hover { color: var(--accent); }

.article-meta {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 24px; font-size: 13px; color: var(--text-muted);
}
.article-meta .lab-tag { padding: 4px 12px; border-radius: 100px; font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.article-meta .article-cat { padding: 4px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 100px; color: var(--text-secondary); }
.article-meta .article-time::before { content: '·'; margin-inline-end: 8px; color: var(--text-muted); }
.article-meta .article-date::before { content: '·'; margin-inline-end: 8px; color: var(--text-muted); }
.article-meta time { color: var(--text-muted); }

/* Tag color variants — same palette as lab.html */
.tag-anti     { background: rgba(248,113,113,0.12); color: #fca5a5; border: 1px solid rgba(248,113,113,0.22); }
.tag-arch     { background: rgba(96,165,250,0.12);  color: #93c5fd; border: 1px solid rgba(96,165,250,0.22); }
.tag-fund     { background: rgba(74,222,128,0.12);  color: #86efac; border: 1px solid rgba(74,222,128,0.22); }
.tag-play     { background: rgba(251,146,60,0.12);  color: #fdba74; border: 1px solid rgba(251,146,60,0.22); }
.tag-pattern  { background: rgba(167,139,250,0.12); color: #c4b5fd; border: 1px solid rgba(167,139,250,0.22); }
.tag-ops      { background: rgba(52,211,153,0.12);  color: var(--accent); border: 1px solid rgba(52,211,153,0.22); }
.tag-lib      { background: rgba(34,211,238,0.12);  color: #67e8f9; border: 1px solid rgba(34,211,238,0.22); }

.article-title {
  font-size: clamp(32px, 4.4vw, 48px); font-weight: 900;
  line-height: 1.15; letter-spacing: -1px;
  margin-bottom: 20px;
}
html[lang="en"] .article-title { letter-spacing: -1.4px; }

.article-lede {
  font-size: 19px; color: var(--text-secondary); line-height: 1.7;
  border-inline-start: 3px solid var(--accent);
  padding-inline-start: 18px;
}

/* article body — inherits the <p data-he/en>, <pre>, <code>, .lab-takeaway from lab.html */
.article-body { font-size: 17px; line-height: 1.85; color: #e5e7eb; overflow-wrap: anywhere; word-wrap: break-word; }
.art-section-body { overflow-wrap: anywhere; word-wrap: break-word; }
.article-body pre, .article-body pre[class*="language-"] { max-width: 100%; }
.related-card h3, .related-card p, .art-sources li { overflow-wrap: anywhere; }
.article-body p {
  margin-bottom: 22px;
}
.article-body p:last-child { margin-bottom: 0; }
.article-body code {
  background: rgba(255,255,255,0.05);
  padding: 2px 8px; border-radius: var(--radius-xs);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  color: var(--accent-hover);
  border: 1px solid var(--border);
}
.article-body pre {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 18px 20px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px; line-height: 1.65;
  overflow-x: auto;
  margin: 28px 0;
  color: #d4d4d8;
  direction: ltr; text-align: left;
}
.article-body pre code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }

.article-body .lab-takeaway {
  background: var(--accent-dim);
  border: 1px solid rgba(52,211,153,0.22);
  border-inline-start: 3px solid var(--accent);
  padding: 18px 22px; border-radius: var(--radius-sm);
  font-size: 16px; color: var(--text);
  margin: 36px 0 0;
}
.article-body .lab-takeaway b { color: var(--accent); font-weight: 700; }

/* article footer */
.article-foot {
  margin-top: 56px; padding-top: 32px;
  border-top: 1px solid var(--border);
  display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.article-share {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  color: var(--text-muted); font-size: 13px;
}
.article-share code {
  background: var(--surface); padding: 6px 12px; border-radius: 100px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--text-secondary); border: 1px solid var(--border);
}
.article-cta {
  background: var(--accent); color: #000;
  padding: 12px 26px; border-radius: 100px;
  font-size: 14px; font-weight: 700;
  transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 8px;
}
.article-cta:hover {
  background: var(--accent-hover); transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow-strong);
}

/* related */
.article-related {
  max-width: var(--max-w-wide); margin: 96px auto 0;
  border-top: 1px solid var(--border); padding-top: 56px;
}
.article-related h2 {
  font-size: 22px; font-weight: 800; margin-bottom: 28px;
  letter-spacing: -0.4px;
}
.related-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(3, 1fr);
}
.related-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  transition: all var(--transition);
  display: flex; flex-direction: column; gap: 12px;
}
.related-card:hover { border-color: var(--accent); transform: translateY(-3px); background: var(--surface-2); }
.related-card .lab-tag { align-self: flex-start; padding: 3px 10px; border-radius: 100px; font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.related-card h3 { font-size: 16px; font-weight: 700; line-height: 1.35; }
.related-card p { font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }

/* footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 48px 24px;
  margin-top: 96px;
  position: relative; z-index: 1;
}
.footer-inner {
  max-width: var(--max-w-wide); margin: 0 auto;
  display: flex; gap: 28px; justify-content: space-between; align-items: center; flex-wrap: wrap;
}
.footer-brand img { height: 28px; }
.footer-copy { color: var(--text-muted); font-size: 13px; margin-top: 12px; }
.footer-links { display: flex; gap: 22px; flex-wrap: wrap; }
.footer-links a { color: var(--text-secondary); font-size: 13.5px; transition: color var(--transition); }
.footer-links a:hover { color: var(--accent); }

/* ===== Long-form layout (clean single column; TOC is a floating overlay) ===== */
.article-layout { display: block; }
.article-layout.has-toc { display: block; }

/* TOC — floating overlay panel (closed by default, opened via #tocToggle) */
.art-toc {
  position: fixed;
  top: 80px;
  inset-inline-end: 24px;
  width: min(320px, calc(100vw - 48px));
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  z-index: 80;
  background: rgba(13,13,16,0.96);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  font-size: 13.5px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transition: opacity .18s ease, transform .18s ease;
}
.art-toc.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
/* Floating toggle button — bottom-end, always visible on long-form articles */
.toc-toggle {
  position: fixed;
  bottom: 28px;
  inset-inline-end: 28px;
  z-index: 81;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px;
  background: var(--accent-dim);
  color: var(--text);
  border: 1px solid rgba(52,211,153,0.35);
  border-radius: 100px;
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(52,211,153,0.05) inset;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .15s ease, background .2s ease, box-shadow .2s ease;
}
.toc-toggle:hover { transform: translateY(-2px); background: rgba(52,211,153,0.18); }
.toc-toggle:active { transform: translateY(0); }
.toc-toggle .toc-toggle-icon {
  display: inline-block; width: 14px; height: 14px;
  background: linear-gradient(to bottom,
    currentColor 0 2px, transparent 2px 4px,
    currentColor 4px 6px, transparent 6px 8px,
    currentColor 8px 10px, transparent 10px 12px,
    currentColor 12px 14px);
  opacity: 0.85;
}
.toc-toggle[aria-expanded="true"] { background: rgba(52,211,153,0.22); }
.art-toc-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.8px;
  color: var(--text-muted); text-transform: uppercase;
  margin-bottom: 14px;
}
.art-toc ol { list-style: none; counter-reset: tocn; display: flex; flex-direction: column; gap: 10px; }
.art-toc li { counter-increment: tocn; }
.art-toc li::before {
  content: counter(tocn, decimal-leading-zero);
  color: var(--text-muted); font-family: 'JetBrains Mono', monospace;
  font-size: 11px; margin-inline-end: 10px;
}
.art-toc a {
  color: var(--text-secondary); transition: color var(--transition);
  line-height: 1.45;
}
.art-toc a:hover, .art-toc a.active { color: var(--accent); }

/* TL;DR */
.art-tldr {
  background: linear-gradient(135deg, var(--accent-dim), rgba(167,139,250,0.06));
  border: 1px solid rgba(52,211,153,0.18);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 44px;
  font-size: 16px; line-height: 1.7;
  color: var(--text);
}
.art-tldr-label {
  font-size: 11px; font-weight: 800; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 10px;
}

/* Sections */
.art-section { margin-bottom: 56px; scroll-margin-top: 96px; }
.art-section h2 {
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.4px; line-height: 1.25;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.art-section h3 {
  font-size: 18px; font-weight: 700;
  margin: 32px 0 12px;
  color: var(--text);
}
.art-section-body p { margin-bottom: 18px; }
.art-section-body ul, .art-section-body ol {
  margin: 0 0 22px; padding-inline-start: 24px;
}
.art-section-body li { margin-bottom: 8px; line-height: 1.7; }
.art-section-body strong, .art-section-body b { color: var(--text); font-weight: 700; }

/* Sources box */
.art-sources {
  margin-top: 64px; padding: 22px 26px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.art-sources-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.8px;
  color: var(--text-muted); text-transform: uppercase; margin-bottom: 12px;
}
.art-sources ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.art-sources li { color: var(--text-secondary); }
.art-src-type {
  display: inline-block; padding: 1px 8px; border-radius: 100px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  margin-inline-end: 8px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}
.art-src-type.internal  { background: rgba(52,211,153,0.10); color: #6ee7b7; border-color: rgba(52,211,153,0.22); }
.art-src-type.anthropic { background: rgba(167,139,250,0.10); color: #c4b5fd; border-color: rgba(167,139,250,0.22); }
.art-src-type.external  { background: rgba(96,165,250,0.10); color: #93c5fd; border-color: rgba(96,165,250,0.22); }

/* Prism overrides — match dark surface */
.article-body pre[class*="language-"] {
  background: var(--surface) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px; margin: 28px 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13.5px; line-height: 1.65;
  direction: ltr; text-align: left;
}
.article-body code[class*="language-"] {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: none; border: none; padding: 0;
}

/* Callout boxes inside sections */
.art-section-body .callout {
  border-inline-start: 3px solid var(--accent-2);
  background: rgba(167,139,250,0.06);
  padding: 14px 18px; border-radius: var(--radius-xs);
  margin: 22px 0;
  font-size: 15px;
}
.art-section-body .callout.warn {
  border-color: #f87171; background: rgba(248,113,113,0.06);
}
.art-section-body .callout.win {
  border-color: var(--accent); background: var(--accent-dim);
}
.art-section-body .callout-label {
  display: block; font-size: 11px; font-weight: 800;
  letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--accent-2); margin-bottom: 6px;
}
.art-section-body .callout.warn .callout-label { color: #fca5a5; }
.art-section-body .callout.win .callout-label { color: var(--accent); }

/* ===== responsive — 4 tiers ===== */

/* === Tier 1: Laptop / small desktop (≤1280) === */
@media (max-width: 1280px) {
  .article-main { padding: 112px 32px 72px; }
  .article-related { padding: 0 32px; }
  .footer { padding: 44px 32px; }
}

/* === Tier 2: Tablet landscape (≤1100) === */
@media (max-width: 1100px) {
  .article-title { font-size: clamp(30px, 4vw, 42px); }
}

/* === Tier 3: Tablet portrait / iPad (701–900) — TOC collapses,
   nav stays horizontal but compact === */
@media (max-width: 900px) {
  .nav-inner { padding: 0 22px; height: 62px; }
  .nav-links { gap: 22px; }
  .nav-links a { font-size: 13.5px; }
  .nav-cta { padding: 7px 18px; }

  .article-main { padding: 104px 28px 64px; }
  .article { max-width: 720px; width: 100%; }
  .article-body { width: 100%; max-width: 100%; }

  .related-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .article-related { margin-top: 80px; padding: 56px 28px 0; max-width: 100%; }
  .article-title { font-size: clamp(28px, 4.6vw, 38px); }
  .art-section h2 { font-size: 24px; }
}

/* === Tier 4: Phone / small tablet (≤700) — drawer nav, single column === */
@media (max-width: 700px) {
  .nav-inner { padding: 0 16px; height: 60px; }
  .nav-mobile { display: inline-flex; }

  /* drawer */
  .nav-links {
    position: absolute; top: 60px; right: 0; left: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: rgba(9,9,11,0.96);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px;
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: transform .2s, opacity .2s;
  }
  .nav-links.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav-links a {
    padding: 12px 4px; font-size: 16px;
    border-bottom: 1px solid var(--border);
  }
  .nav-links a:last-of-type { border-bottom: none; }
  .nav-links .nav-cta {
    margin-top: 10px; text-align: center;
    padding: 12px 22px !important; font-size: 15px !important;
  }
  .lang-toggle { align-self: flex-start; margin-top: 8px; }

  .article-main { padding: 92px 18px 56px; }
  .article-head { margin-bottom: 32px; }
  .article-back { margin-bottom: 22px; font-size: 13.5px; }
  .article-meta { gap: 8px; row-gap: 8px; font-size: 12.5px; }
  .article-meta .article-time::before,
  .article-meta .article-date::before { display: none; }

  .art-section { margin-bottom: 40px; }
  .art-section h2 { font-size: 21px; margin-bottom: 14px; padding-bottom: 10px; }
  .art-section h3 { font-size: 17px; margin: 22px 0 10px; }

  .art-tldr { padding: 18px 20px; margin-bottom: 30px; font-size: 15.5px; }
  .art-sources { padding: 18px 20px; margin-top: 44px; }
  .article-related { margin-top: 64px; padding: 40px 18px 0; }
  .article-related h2 { font-size: 20px; margin-bottom: 20px; }
  .related-grid { grid-template-columns: 1fr; gap: 14px; }

  .article-foot { flex-direction: column; align-items: stretch; gap: 14px; margin-top: 40px; padding-top: 24px; }
  .article-share { justify-content: flex-start; flex-wrap: wrap; }
  .article-share code { font-size: 11px; padding: 5px 10px; word-break: break-all; max-width: 100%; }
  .article-cta { justify-content: center; padding: 13px 22px; }

  .footer { padding: 36px 18px; margin-top: 64px; }
  .footer-inner { flex-direction: column; gap: 18px; align-items: flex-start; }
  .footer-links { gap: 14px; }
}

/* === Tier 5: Small phone (≤540) — tighter type & edge-to-edge code === */
@media (max-width: 540px) {
  html { font-size: 15px; }
  .article-main { padding: 86px 14px 48px; }
  .article-title { font-size: 26px; line-height: 1.2; letter-spacing: -0.6px; }
  .article-lede { font-size: 16px; padding-inline-start: 14px; }
  .article-body { font-size: 16px; line-height: 1.75; }
  .article-body p { margin-bottom: 18px; }
  .article-body pre,
  .article-body pre[class*="language-"] {
    font-size: 12.5px; padding: 12px 14px; margin: 22px -14px;
    border-radius: 0; border-inline: none;
    line-height: 1.55;
  }
  .article-body code { font-size: 0.88em; padding: 1px 6px; word-break: break-word; }
  .article-body .lab-takeaway { padding: 14px 16px; font-size: 15px; margin-top: 28px; }

  .art-tldr { padding: 16px 18px; font-size: 15px; border-radius: var(--radius-sm); margin-bottom: 26px; }
  .art-section { margin-bottom: 36px; }
  .art-section h2 { font-size: 19px; }
  .art-section h3 { font-size: 16px; }
  .art-section-body p { margin-bottom: 16px; }
  .art-section-body ul, .art-section-body ol { padding-inline-start: 20px; }
  .art-section-body .callout { padding: 12px 14px; font-size: 14.5px; margin: 18px 0; }

  .related-card { padding: 18px; }
  .related-card h3 { font-size: 15px; }
  .related-card p { font-size: 13px; }

  .art-sources { padding: 16px 18px; font-size: 13px; }
  .art-sources li { line-height: 1.55; }
}

/* === Tier 6: Tiny phone (≤380) — last squeeze === */
@media (max-width: 380px) {
  .article-main { padding: 80px 12px 40px; }
  .article-title { font-size: 23px; }
  .nav-brand img { height: 26px; }
  .nav-inner { padding: 0 12px; }
  .lang-toggle button { padding: 4px 10px; font-size: 11px; }
  .art-tldr { padding: 14px 16px; }
}

/* ===== Article reading column — clean, centered, single column on every
   screen. The TOC is now a floating overlay (see .art-toc + .toc-toggle
   above) so the article body never has to share width with anything. ===== */
@media (min-width: 901px) {
  .article { max-width: 760px; margin-inline: auto; }
}

/* ===== Wide-screen meta rail (≥1536px) — fills the gutter beside the
   reading column with date / reading time / tags as a sticky-feel column.
   Vercel/Substack pattern. The reading column itself stays 760px (~70 chars)
   to preserve readability — only the previously empty side gets used. ===== */
@media (min-width: 1536px) {
  .article { position: relative; }
  .article-head { position: relative; min-height: 200px; }
  .article-meta {
    position: absolute;
    top: 56px;
    inset-inline-end: calc(100% + 40px);
    width: 200px;
    margin: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding-inline-start: 20px;
    border-inline-start: 1px solid var(--border);
    font-size: 12.5px;
  }
  .article-meta .article-time::before,
  .article-meta .article-date::before { display: none; }
  .article-meta .lab-tag,
  .article-meta .article-cat { white-space: nowrap; }
  .article-meta .article-time,
  .article-meta .article-date { color: var(--text-muted); letter-spacing: 0.2px; }
}

/* TOC overlay & toggle — mobile sizing */
@media (max-width: 700px) {
  .art-toc {
    top: 70px;
    inset-inline-end: 14px; inset-inline-start: 14px;
    width: auto;
    max-height: calc(100vh - 110px);
    padding: 18px 18px;
    font-size: 14px;
  }
  .toc-toggle {
    bottom: 18px; inset-inline-end: 18px;
    padding: 10px 16px; font-size: 12.5px;
  }
}

/* ===== Hard guarantee: no horizontal overflow on phone =====
   Some elements (long URLs in sources, JSON-LD-ish strings, RTL+pre)
   have caused phantom horizontal scroll. Belt + suspenders. */
@media (max-width: 900px) {
  html, body { overflow-x: clip; max-width: 100vw; width: 100%; }
  .article-main, .article, .article-layout, .article-related, .footer-inner {
    max-width: 100%; width: 100%; box-sizing: border-box;
  }
  .article-body img, .article-body iframe, .article-body video,
  .art-section-body img, .related-card img { max-width: 100%; height: auto; }
  .article-body pre, .art-section-body pre,
  .article-body pre[class*="language-"] {
    max-width: 100%; width: 100%; box-sizing: border-box;
    /* override the negative-margin trick from tier 5 — that was the
       extender that pushed the page wider than the viewport when the
       parent had less padding than -14px. */
    margin-inline: 0;
  }
  .art-sources li, .article-share code { word-break: break-word; max-width: 100%; }
}
