/* Dark reference variables for the study/code templates (from the source site). */
.hub-body:has(.study-main){
  --bg:#050505; --surface:#101010; --card:#0b0b0b; --fg:#e8e7e4; --ink:#f3f3f3;
  --muted:#bcbcbc; --dim:#85817e; --brand:#f5f5f3; --accent:#ad3f39;
  --gold:#b64b45; --up:#54d6a0; --down:#ff6b66; --line:rgba(238,236,232,.13); --line-2:rgba(238,236,232,.25);
  --font:Geist,system-ui,sans-serif; --mono:"Geist Mono",ui-monospace,Consolas,monospace;
  color-scheme:dark; background:#050505;
}
.ref-dark{--bg:#050505;--surface:#101010;--card:#0b0b0b;--fg:#e8e7e4;--ink:#f3f3f3;--muted:#bcbcbc;--dim:#85817e;--brand:#f5f5f3;--accent:#ad3f39;--up:#54d6a0;--down:#ff6b66;--line:rgba(238,236,232,.13);--line-2:rgba(238,236,232,.25);--font:Geist,system-ui,sans-serif;--mono:"Geist Mono",ui-monospace,Consolas,monospace}

/* Hub-context fixes: the hub shell already constrains width; keep reference tiles inside. */
.hub-main .lib-grid, .hub-main .study-main { max-width:100%; }
.hub-main .tile, .hub-main .study-tile { min-width:0; max-width:100%; }
.hub-main .code-peek { overflow:hidden; white-space:pre; text-overflow:ellipsis; }
.hub-main .study-tile-preview { width:100%; height:auto; }

/* Study images are black FORCED, never theme-dependent (operator: black, not
   grey). Transparent PNGs must never show grey or white behind them. */
.study-main figure.study-visual,
.study-main .study-visual a,
.study-main .study-visual img { background-color:#000 !important; }
.study-main .study-visual img { border-radius:6px; }
.study-main #source-view { background-color:#000; }
.hub-main .study-tile-preview,
.hub-main .study-tile { background-color:#000 !important; }
.hub-main .hub-thumb { background-color:#000 !important; }

/* Full catalog page (hub/code.php): contain the reference wrapper in the hub shell. */
section.lib .wrap { max-width:100%; }
section.lib .lib-bar { flex-wrap:wrap; }
section.lib .lib-grid { max-width:100%; }
section.lib .tile, section.lib .tile-body, section.lib .tile-top { min-width:0; max-width:100%; }
section.lib .code-peek { max-width:100%; overflow:hidden; }

/* Detail/source code blocks never widen the page. */
.hp-body--study pre, #source-scroll, .hp-body--code pre { max-width:100%; overflow:auto; }
.hp-body--study pre code, .hp-body--code pre code { white-space:pre; }

/* The full reference stylesheet defaults to LIGHT. Force its DARK variables
   on the catalog page, exactly as the reference does with data-theme="dark". */
.hub-body:has(.lib-grid){
  color-scheme:dark;
  --bg:#151515; --surface:#202020; --card:#202020; --fg:#e8e7e4; --ink:#f3f3f3;
  --muted:#bcbcbc; --dim:#85817e; --brand:#f5f5f3; --accent:#ad3f39;
  --gold:#b64b45; --up:#54d6a0; --down:#ff6b66; --line:rgba(238,236,232,.13); --line-2:rgba(238,236,232,.25);
  --font:Geist,system-ui,sans-serif; --mono:"Geist Mono",ui-monospace,Consolas,monospace;
  background:#151515; color:#e8e7e4;
}
.hub-body:has(.lib-grid) section.lib .wrap{max-width:1180px;margin:0 auto;padding:0 22px}
.hub-body:has(.lib-grid) .lib-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
