/* Shared site chrome: top nav bar, sidebar hide/unhide, wider desktop layout.
   Loaded after each page's own inline styles, so these rules win the cascade. */

:root{ --topbar-h: 50px; }

body{ padding-top: var(--topbar-h); }

.ccar-topbar{
  position:fixed; top:0; left:0; right:0; height:var(--topbar-h);
  background:var(--surface); border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:10px;
  padding:0 max(14px, env(safe-area-inset-left,0px)) 0 max(14px, env(safe-area-inset-left,0px));
  padding-right:max(14px, env(safe-area-inset-right,0px));
  z-index:9000;
  font-family:'Inter','Noto Sans SC',system-ui,-apple-system,sans-serif;
}
.ccar-topbar .ccar-burger,
.ccar-topbar .ccar-theme-toggle{
  background:none; border:1px solid var(--border); border-radius:8px;
  width:32px; height:32px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; color:var(--fg); font-size:15px; line-height:1;
}
.ccar-topbar .ccar-theme-toggle{ border-radius:999px; }
.ccar-topbar .ccar-burger:hover,
.ccar-topbar .ccar-theme-toggle:hover{ background:var(--surface-2); }
.ccar-topbar .ccar-brand{
  font-weight:700; font-size:13.5px; color:var(--fg); white-space:nowrap;
  font-family:'Source Serif 4','Noto Serif SC',Georgia,serif;
}
.ccar-topbar nav{ display:flex; gap:3px; overflow-x:auto; flex:1; scrollbar-width:none; }
.ccar-topbar nav::-webkit-scrollbar{ display:none; }
.ccar-topbar nav a{
  color:var(--muted); text-decoration:none; font-size:12.5px;
  padding:7px 10px; border-radius:6px; white-space:nowrap;
}
.ccar-topbar nav a:hover{ background:var(--surface-2); color:var(--fg); }
.ccar-topbar nav a.ccar-current{ background:var(--accent-soft); color:var(--accent-strong); font-weight:600; }

@media (max-width:640px){
  .ccar-topbar .ccar-brand{ display:none; }
  .ccar-topbar nav a{ font-size:11px; padding:6px 7px; }
}

/* --- Layout ---
   The page's own CSS kept .shell at a fixed 1180px while every piece of
   content inside it (paragraphs, callouts, diagrams) was independently
   capped at its own, smaller, mismatched width (68ch for <p>, 720px for
   figures, etc). That produced misaligned edges between blocks AND, once
   .shell is given more room on a wide monitor, a large dead gutter on the
   right that none of the content actually fills.
   Fix: widen .shell modestly (not edge-to-edge -- the sidebar should stay
   right next to the content, not float apart), and give every content
   block inside <main> the SAME width so they all line up and use the
   space that's actually there. */
@media (min-width:1000px){
  .shell{ max-width:1320px !important; }
}

main{ max-width: 900px !important; }
main p,
main p.cn,
main .callout,
main .callout p,
main .callout li,
main .callout div,
main figure.diagram,
main figure.diagram figcaption,
main header.masthead .lede{
  max-width: none !important;
}

/* Keep the sticky sidebar clear of the fixed top bar */
@media (min-width:861px){
  nav.rail{
    top: var(--topbar-h) !important;
    max-height: calc(100vh - var(--topbar-h)) !important;
  }
}

/* Left sidebar hide/unhide */
body.ccar-nav-hidden nav.rail{ display:none !important; }
body.ccar-nav-hidden .shell{ grid-template-columns:1fr !important; }
body.ccar-nav-hidden main{ max-width:1100px !important; }

/* The sidebar's "This page is the hub..." box used the muted/secondary grey,
   which reads as disabled/placeholder text. Use the main body text color. */
nav.rail .status{ color:var(--fg) !important; }

/* Chinese-language paragraphs (.cn) were styled in the muted/secondary grey
   as if they were captions, not main content. Use the same primary text
   color as the English paragraphs. */
p.cn,
header.masthead .lede.cn{
  color: var(--fg) !important;
}

/* Explicit, generous gap between the sidebar and the content column --
   don't rely solely on the sidebar's own internal padding for this. */
.shell{ column-gap: 48px !important; }
