:root {
        --bg: #ffffff;
        --sidebar: #ffffff;
        --content-bg: #ffffff;
        --text: #1b1f27;
        --text-soft: #3d4350;
        --muted: #8b919e;
        --border: #ececf1;
        --border-soft: #f3f3f6;
        --accent: #6d4aff;
        --accent-soft: #f1edff;
        --accent-2: #16b8a0;
        --hover: #f7f7fa;
        --chip: #f4f4f7;
        --surface: #ffffff;
        --surface-2: #fcfcfe;
        --topbar-bg: rgba(255, 255, 255, 0.85);
        --callout-2: #eafaf6;
        --house-soft: #e9faf6;
      }
      [data-theme="dark"] {
        --bg: #0f1115;
        --sidebar: #0f1115;
        --content-bg: #0f1115;
        --text: #e9edf5;
        --text-soft: #bcc3d0;
        --muted: #828b9d;
        --border: #262c38;
        --border-soft: #1b2029;
        --accent: #8b6bff;
        --accent-soft: #211b3b;
        --accent-2: #1ac7ad;
        --hover: #1a1f29;
        --chip: #1a1f29;
        --surface: #161a22;
        --surface-2: #1a1f29;
        --topbar-bg: rgba(15, 17, 21, 0.82);
        --callout-2: #11231f;
        --house-soft: #102824;
      }
      * { box-sizing: border-box; }
      html, body { margin: 0; padding: 0; overflow-x: hidden; max-width: 100%; }
      body {
        background: var(--bg);
        color: var(--text);
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          Helvetica, Arial, sans-serif;
        font-size: 16px;
        line-height: 1.7;
        -webkit-font-smoothing: antialiased;
        transition: background-color 0.22s ease, color 0.22s ease;
      }
      a { color: inherit; text-decoration: none; }

      /* ---------- Top bar ---------- */
      .topbar {
        position: sticky;
        top: 0;
        z-index: 30;
        height: 60px;
        display: flex;
        align-items: center;
        gap: 16px;
        padding: 0 20px;
        background: var(--topbar-bg);
        backdrop-filter: saturate(180%) blur(10px);
        border-bottom: 1px solid var(--border);
      }
      .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.2px; }
      .brand .logo {
        width: 32px; height: 32px; border-radius: 7px;
        object-fit: contain; display: block;
      }
      .brand .sub { color: var(--muted); font-weight: 500; }
      .topbar .spacer { flex: 1; }
      .search {
        display: flex; align-items: center; gap: 8px;
        width: 320px; max-width: 38vw;
        padding: 7px 12px;
        background: var(--surface-2);
        border: 1px solid var(--border);
        border-radius: 9px;
        color: var(--muted);
        font-size: 14px;
        cursor: text;
      }
      .search input {
        border: 0; outline: 0; background: transparent; flex: 1;
        font-size: 14px; color: var(--text);
      }
      .search .kbd {
        font-size: 11px; color: var(--muted);
        background: var(--surface); border: 1px solid var(--border);
        border-radius: 5px; padding: 1px 6px;
      }
      .topbar .ext { font-size: 14px; color: var(--text-soft); font-weight: 500; }
      .topbar .ext:hover { color: var(--accent); }

      /* ---------- Shell ---------- */
      .shell { display: grid; grid-template-columns: 290px 1fr; }

      /* ---------- Sidebar ---------- */
      aside {
        position: sticky;
        top: 60px;
        align-self: start;
        height: calc(100vh - 60px);
        overflow-y: auto;
        border-right: 1px solid var(--border);
        padding: 18px 14px 28px;
      }
      .lang {
        display: flex; align-items: center; justify-content: space-between;
        padding: 9px 12px; margin-bottom: 14px;
        border: 1px solid var(--border); border-radius: 9px;
        font-size: 14px; font-weight: 500; color: var(--text-soft);
        cursor: pointer;
      }
      .lang:hover { background: var(--hover); }
      .lang .chev { color: var(--muted); }

      nav .group { margin: 18px 0 6px; }
      nav .group:first-of-type { margin-top: 4px; }
      nav .group-title {
        font-size: 11px; font-weight: 700; letter-spacing: 1.1px;
        text-transform: uppercase; color: var(--muted);
        padding: 6px 12px;
      }
      nav a.item, nav .item {
        display: flex; align-items: center; gap: 10px;
        padding: 7px 12px; border-radius: 8px;
        font-size: 14px; color: var(--text-soft);
        cursor: pointer; transition: background 0.12s, color 0.12s;
      }
      nav a.item:hover { background: var(--hover); color: var(--text); }
      nav a.item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; position: relative; }
      nav a.item.active::before {
        content: ""; position: absolute; left: 2px; top: 7px; bottom: 7px; width: 3px;
        border-radius: 2px; background: currentColor;
      }
      nav a.item .ico { width: 16px; text-align: center; opacity: 0.85; font-size: 13px; }
      nav a.item .chev { margin-left: auto; color: var(--muted); font-size: 12px; opacity: 0; }
      nav a.item:hover .chev { opacity: 0.7; }

      .poweredby {
        margin-top: 22px; padding: 11px 13px;
        border: 1px solid var(--border); border-radius: 10px;
        display: flex; align-items: center; gap: 9px;
        font-size: 13px; color: var(--muted);
      }
      .poweredby .pb-logo {
        width: 20px; height: 20px; border-radius: 5px;
        background: linear-gradient(135deg, var(--accent-2), var(--accent));
      }

      /* ---------- Main ---------- */
      main { min-width: 0; }
      .content {
        max-width: 820px;
        margin: 0 auto;
        padding: 0 40px 90px;
      }
      .hero {
        position: relative;
        height: 270px;
        margin: 26px 0 30px;
        border-radius: 16px;
        overflow: hidden;
        background:
          radial-gradient(circle at 18% 30%, rgba(255,255,255,0.18) 0 2px, transparent 2px) 0 0/22px 22px,
          linear-gradient(125deg, #5a2bd6 0%, #6d4aff 38%, #4e63ff 64%, #14b8a8 120%);
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
      }
      .hero .panels {
        position: absolute; inset: 0;
        background-image:
          linear-gradient(rgba(255,255,255,0.10) 1.5px, transparent 1.5px),
          linear-gradient(90deg, rgba(255,255,255,0.10) 1.5px, transparent 1.5px);
        background-size: 140px 135px;
        mask-image: linear-gradient(90deg, transparent, #000 30%, #000 100%);
      }
      .hero .speed {
        position: absolute; right: -60px; top: -40px; width: 60%; height: 150%;
        background: repeating-linear-gradient(115deg, rgba(255,255,255,0.16) 0 3px, transparent 3px 20px);
        transform: rotate(2deg);
        mask-image: radial-gradient(circle at 80% 30%, #000, transparent 70%);
      }
      .hero .hero-copy { position: absolute; left: 30px; bottom: 24px; right: 30px; color: #fff; }
      .hero .kicker {
        display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 1.5px;
        text-transform: uppercase; padding: 4px 11px; border-radius: 999px;
        background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.25);
        margin-bottom: 12px;
      }
      .hero h2 {
        margin: 0; font-size: 30px; line-height: 1.18; letter-spacing: -0.6px;
        font-weight: 800; text-shadow: 0 1px 18px rgba(0,0,0,0.25);
        max-width: 640px;
      }
      .hero .pow {
        position: absolute; right: 34px; top: 30px;
        font-family: "Arial Black", sans-serif; font-weight: 900; font-style: italic;
        font-size: 34px; color: #ffd24a; letter-spacing: -1px;
        text-shadow: 2px 2px 0 #1b1f27, -1px -1px 0 #1b1f27;
        transform: rotate(-8deg);
        opacity: 0.92;
      }

      .page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
      .page-head h1 {
        margin: 0; font-size: 34px; letter-spacing: -0.8px; font-weight: 800;
        text-transform: uppercase;
      }
      .copy-btn {
        margin-left: auto;
        display: inline-flex; align-items: center; gap: 7px;
        padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
        background: var(--surface); color: var(--text-soft); font-size: 13px; font-weight: 600;
        cursor: pointer;
      }
      .copy-btn:hover { background: var(--hover); }
      .copy-btn.done { color: var(--accent-2); border-color: var(--accent-2); }

      .content p { color: var(--text-soft); }
      .content h3 {
        margin: 34px 0 10px; font-size: 21px; font-weight: 750; letter-spacing: -0.3px; color: var(--text);
      }
      .content h4 { margin: 24px 0 8px; font-size: 16px; font-weight: 700; color: var(--text); }
      .content strong { color: var(--text); }
      .content p a, .content li a { color: var(--accent); font-weight: 600; }
      .content p a:hover, .content li a:hover { text-decoration: underline; }
      .lead { font-size: 18.5px; line-height: 1.65; color: var(--text) !important; }

      /* ladder visual */
      .ladder {
        display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px;
        margin: 22px 0 6px;
      }
      .ladder .rung {
        flex: 1 1 120px; min-width: 120px;
        padding: 14px 14px 13px; border-radius: 12px;
        border: 1px solid var(--border); background: var(--surface-2);
        position: relative;
      }
      .ladder .rung .em { font-size: 20px; }
      .ladder .rung .t { display: block; margin-top: 6px; font-weight: 700; font-size: 14px; color: var(--text); }
      .ladder .rung .d { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
      .ladder .arrow { align-self: center; color: var(--accent); font-weight: 800; font-size: 18px; }
      .ladder .rung.door { border-color: var(--accent); background: var(--accent-soft); }
      .ladder .rung.house { border-color: var(--accent-2); background: var(--house-soft); }

      .callout {
        position: relative;
        margin: 28px 0; padding: 18px 22px 18px 24px; border-radius: 12px;
        background: linear-gradient(120deg, var(--accent-soft), var(--callout-2));
        border: 1px solid var(--border); border-left: 4px solid var(--accent);
        font-size: 18px; font-weight: 600; color: var(--text); line-height: 1.55;
      }
      .callout .by { display: block; margin-top: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
      .content code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-size: 0.88em; }
      .steps { counter-reset: step; list-style: none; padding: 0; margin: 16px 0; }
      .steps li { counter-increment: step; position: relative; padding: 9px 0 9px 40px; border-bottom: 1px solid var(--border-soft); color: var(--text-soft); }
      .steps li:last-child { border-bottom: 0; }
      .steps li::before {
        content: counter(step); position: absolute; left: 0; top: 7px;
        width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff;
        font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center;
      }
      .note, .warn { margin: 18px 0; padding: 13px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 14.5px; color: var(--text-soft); }
      .note { border-left: 4px solid var(--accent-2); }
      .warn { border-left: 4px solid #e0892b; }
      .note .nh, .warn .nh { display: block; font-weight: 700; margin-bottom: 3px; color: var(--text); }
      .content table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
      .content th, .content td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
      .content th { background: var(--surface-2); color: var(--text); font-weight: 700; }
      .content td { color: var(--text-soft); }
      .content tr:last-child td { border-bottom: 0; }
      .codeblock {
        background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
        padding: 12px 14px; margin: 14px 0; overflow-x: auto; white-space: pre;
        font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; line-height: 1.55; color: var(--text);
      }
      .codeblock .cbt {
        display: block; white-space: normal; font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
        color: var(--muted); margin-bottom: 8px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      }
      .shot { margin: 18px 0; }
      .shot img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); }
      .shot figcaption { margin-top: 8px; font-size: 13px; color: var(--muted); }
      .shots-row { display: flex; flex-wrap: wrap; gap: 16px; margin: 18px 0; }
      .shots-row figure { margin: 0; }
      .shots-row img { max-width: 240px; }

      .engine {
        display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 12px; margin: 18px 0 6px;
      }
      .engine .box { padding: 15px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
      .engine .box h4 { margin: 0 0 5px; font-size: 14px; color: var(--accent); font-weight: 700; }
      .engine .box p { margin: 0; font-size: 14px; color: var(--text-soft); line-height: 1.55; }

      /* flywheel viz */
      .flywheel-viz {
        position: relative;
        width: 100%;
        max-width: 540px;
        margin: 30px auto 10px;
        aspect-ratio: 540 / 440;
      }
      .flywheel-viz svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
      .fw-node {
        position: absolute; transform: translate(-50%, -50%);
        width: 116px; padding: 11px 10px 10px; box-sizing: border-box;
        background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
        box-shadow: 0 4px 14px rgba(27, 31, 39, 0.07);
        text-align: center; transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
        z-index: 2;
      }
      .fw-node:hover {
        transform: translate(-50%, -50%) translateY(-3px);
        box-shadow: 0 12px 24px rgba(109, 74, 255, 0.18); border-color: var(--accent);
      }
      .fw-node .n {
        position: absolute; top: -9px; left: -9px; width: 22px; height: 22px;
        background: var(--accent); color: #fff; border-radius: 50%;
        font-size: 12px; font-weight: 700;
        display: flex; align-items: center; justify-content: center;
        box-shadow: 0 2px 6px rgba(109, 74, 255, 0.45);
      }
      .fw-node .em { font-size: 19px; line-height: 1; }
      .fw-node .lb { display: block; margin-top: 5px; font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.25; }
      .fw-hub {
        position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
        width: 124px; height: 124px; border-radius: 50%; z-index: 3;
        background: radial-gradient(circle at 35% 30%, #8e70ff, var(--accent) 55%, #4e63ff);
        color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
        box-shadow: 0 12px 32px rgba(109, 74, 255, 0.42), inset 0 0 0 6px rgba(255, 255, 255, 0.13);
      }
      .fw-hub .spin { font-size: 30px; line-height: 1; animation: fwspin 7s linear infinite; }
      @keyframes fwspin { to { transform: rotate(360deg); } }
      .fw-hub .t { font-size: 11px; font-weight: 800; letter-spacing: 1.4px; margin-top: 4px; }
      .fw-hub .s { font-size: 9.5px; opacity: 0.82; letter-spacing: 0.3px; }
      .fw-caption { text-align: center; max-width: 520px; margin: 8px auto 0; font-size: 14px; color: var(--muted); }
      .fw-caption em { color: var(--text-soft); font-style: italic; }
      @media (max-width: 560px) {
        .fw-node { width: 94px; padding: 8px 6px; border-radius: 11px; }
        .fw-node .lb { font-size: 11px; }
        .fw-node .em { font-size: 16px; }
        .fw-hub { width: 98px; height: 98px; }
        .fw-hub .spin { font-size: 24px; }
      }

      .next {
        margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--border);
        display: flex; justify-content: space-between; gap: 14px;
      }
      .next a {
        flex: 1; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
        background: var(--surface); transition: border-color 0.12s, background 0.12s;
      }
      .next a:hover { border-color: var(--accent); background: var(--accent-soft); }
      .next .dir { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
      .next .ttl { font-weight: 700; color: var(--text); margin-top: 2px; }

      .footnote { margin-top: 34px; font-size: 13px; color: var(--muted); }
      .site-foot {
        margin: 44px 0 10px; padding: 22px 0 8px;
        border-top: 1px solid var(--border);
        text-align: center; color: var(--muted); font-size: 14px;
      }
      .site-foot strong { color: var(--text); }
      .site-foot .dot { margin: 0 8px; opacity: 0.6; }
      .site-foot a { color: var(--accent); font-weight: 600; }
      .site-foot a:hover { text-decoration: underline; }

      /* scaffold / outline pages */
      .pg-kicker {
        display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 1.3px;
        text-transform: uppercase; color: var(--accent); background: var(--accent-soft);
        padding: 4px 11px; border-radius: 999px; margin: 28px 0 14px;
      }
      .pg-points { list-style: none; padding: 0; margin: 20px 0; }
      .pg-points li { position: relative; padding: 10px 0 10px 28px; border-bottom: 1px solid var(--border-soft); color: var(--text-soft); }
      .pg-points li:last-child { border-bottom: 0; }
      .pg-points li::before { content: "▸"; position: absolute; left: 6px; color: var(--accent); font-weight: 700; }
      .draft-badge {
        display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted);
        background: var(--chip); border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; margin-left: auto;
      }
      .pg-note { color: var(--muted); font-size: 14px; }
      .cta-btn {
        display: inline-flex; align-items: center; gap: 8px; margin: 10px 0 6px;
        padding: 12px 20px; background: var(--accent); color: #fff; border-radius: 11px;
        font-weight: 700; font-size: 14.5px; box-shadow: 0 4px 14px rgba(109, 74, 255, 0.35);
        transition: transform 0.12s, box-shadow 0.12s;
      }
      .cta-btn:hover { transform: translateY(-2px); box-shadow: 0 9px 22px rgba(109, 74, 255, 0.45); color: #fff; }

      /* search dropdown + theme toggle */
      .search-wrap { position: relative; }
      .search-results {
        position: absolute; top: calc(100% + 8px); right: 0; width: 420px; max-width: 80vw;
        max-height: 62vh; overflow-y: auto;
        background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
        box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18); padding: 6px; z-index: 50;
      }
      .search-results[hidden] { display: none; }
      .sr-item { display: block; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
      .sr-item:hover, .sr-item.sel { background: var(--hover); }
      .sr-sec { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); }
      .sr-title { font-size: 14px; font-weight: 600; color: var(--text); margin: 1px 0 2px; }
      .sr-snip { font-size: 12.5px; color: var(--text-soft); line-height: 1.4; }
      .sr-snip mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px; }
      .sr-empty { padding: 14px 12px; color: var(--muted); font-size: 13px; }
      .theme-btn {
        display: inline-flex; align-items: center; justify-content: center;
        width: 36px; height: 36px; border-radius: 9px; flex: none;
        border: 1px solid var(--border); background: var(--surface);
        color: var(--text-soft); font-size: 15px; cursor: pointer;
      }
      .theme-btn:hover { background: var(--hover); }
      /* flywheel theming */
      .fwd0 { stop-color: var(--surface); }
      .fwd1 { stop-color: var(--surface-2); }
      .fw-ring { stroke: var(--border); }
      .next .dir { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

      /* mobile */
      .menu-btn { display: none; }
      /* Drawer header (logo + close) and dimmed backdrop: mobile-only, hidden on desktop. */
      .aside-head { display: none; }
      .nav-backdrop {
        position: fixed; inset: 0; z-index: 55;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0; pointer-events: none;
        transition: opacity 0.22s ease;
      }
      .nav-backdrop.show { opacity: 1; pointer-events: auto; }
      body.nav-open { overflow: hidden; }
      @media (max-width: 940px) {
        .shell { grid-template-columns: 1fr; }
        /* Full-screen overlay drawer: covers both top bars. Overrides the desktop
           sidebar offset, which build.mjs now gates behind min-width:941px. */
        aside {
          position: fixed; inset: 0; left: 0; top: 0;
          width: 100%; max-width: 100%;
          height: 100vh; height: 100dvh;
          z-index: 60;
          background: var(--sidebar);
          transform: translateX(-100%);
          transition: transform 0.22s ease, background-color 0.22s ease;
          box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
        }
        aside.open { transform: translateX(0); }
        .aside-head {
          display: flex; align-items: center; gap: 10px;
          position: sticky; top: 0; z-index: 1;
          margin: -18px -14px 14px; padding: 12px 14px;
          background: var(--sidebar);
          border-bottom: 1px solid var(--border);
          font-weight: 700; font-size: 16px; color: var(--text);
        }
        .aside-head .logo {
          width: 30px; height: 30px; border-radius: 7px;
          object-fit: contain; display: block;
        }
        .aside-close {
          margin-left: auto;
          display: inline-flex; align-items: center; justify-content: center;
          width: 38px; height: 38px;
          background: var(--surface-2); border: 1px solid var(--border);
          border-radius: 9px; color: var(--text); font-size: 17px;
          cursor: pointer;
        }
        .aside-close:hover { background: var(--hover); }
        .menu-btn { display: inline-flex; }
        .search { width: 180px; }
        .content { padding: 0 22px 70px; }
        .hero h2 { font-size: 23px; }
      }
      .aside-close:focus-visible,
      .menu-btn:focus-visible {
        outline: 2px solid var(--accent); outline-offset: 2px;
      }
      @media (prefers-reduced-motion: reduce) {
        aside, .nav-backdrop { transition: none; }
      }
      /* phones: drop the brand, compress search, kill the Ctrl K hint */
      @media (max-width: 600px) {
        .topbar { gap: 10px; padding: 0 12px; }
        .brand, .topbar .spacer { display: none; }
        .search-wrap { flex: 1 1 auto; min-width: 0; }
        .search { width: auto; min-width: 0; }
        .search .kbd { display: none; }
        .topbar .ext { font-size: 13px; white-space: nowrap; }
      }

/* Shared Panel Haus ecosystem nav, pinned above the docs top bar. */
:root { --hausbar-h: 52px; }
haus-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 40; display: block; }
body { padding-top: var(--hausbar-h); }
.topbar { top: var(--hausbar-h); }
/* Desktop only: offset the sticky sidebar below the haus-bar + top bar. On mobile
   the sidebar becomes a full-screen overlay (styles.css), so this must NOT apply
   there — gating it at min-width:941px keeps it from forcing the drawer down. */
@media (min-width: 941px) {
  aside { top: calc(60px + var(--hausbar-h)); height: calc(100vh - 60px - var(--hausbar-h)); }
}
