/* ════════════════════════════════════════════════════════════════
   Studio rail — shared left-rail chrome for signed-in pages.
   Two modes (set via window.STUDIO_RAIL before studio-rail.js):
     collapsed (default here): 56px icon strip; the full rail opens
     as an overlay via the expand chevron. Used on pages that carry
     their own local nav (help.html's Documentation list).
   Desktop-only (≥901px): on phones the shared top nav remains the
   only navigation, so the rail renders nothing there.
   Chrome follows the crafted recipe: cool-neutral pills matching the card white, 1.5px
   icon strokes, sentence-case labels, hairlines over shadows.
   ════════════════════════════════════════════════════════════════ */

#studio-rail-root { display: none; }

@media (min-width: 901px) {
    #studio-rail-root { display: block; font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif; }

    /* ── collapsed icon strip ── */
    .sr-strip {
        position: fixed; top: 0; left: 0; bottom: 0; width: 56px;
        background: #ffffff; border-right: 1px solid #e6e8ee;
        display: flex; flex-direction: column; align-items: center;
        padding: 12px 0 10px; gap: 2px; z-index: 95;
    }
    .sr-mono {
        width: 30px; height: 30px; border-radius: 8px; border: 0; cursor: pointer;
        display: grid; place-items: center; font-size: 14px; font-weight: 700;
        color: #17181c; background: #e9ebf1; margin-bottom: 6px;
        font-family: inherit;
    }
    .sr-ic {
        width: 36px; height: 34px; border-radius: 8px; border: 0; background: none;
        display: grid; place-items: center; color: #848a96; cursor: pointer;
        text-decoration: none;
    }
    .sr-ic:hover { background: #f4f5f8; color: #17181c; }
    .sr-ic.on { background: #e9ebf1; color: #17181c; }
    .sr-ic svg { width: 16px; height: 16px; stroke-width: 1.5; }
    .sr-sep { width: 24px; height: 1px; background: #e6e8ee; margin: 6px 0; flex: none; }
    .sr-strip-flex { flex: 1; }
    .sr-av {
        width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer;
        background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff;
        font-size: 11px; font-weight: 700; display: grid; place-items: center;
        font-family: inherit;
    }

    /* ── account menu (opens up-right from the strip avatar) ── */
    .sr-menu {
        display: none;
        position: fixed; left: 62px; bottom: 12px; width: 210px;
        z-index: 99;   /* above the open panel (z 97), which paints later in the DOM */
        background: #fff; border: 1px solid #e5e8ef; border-radius: 10px;
        box-shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
        padding: 5px;
    }
    #studio-rail-root.menu-open .sr-menu { display: block; }
    .sr-menu-id { padding: 7px 9px 8px; border-bottom: 1px solid #eceef2; margin-bottom: 4px; }
    .sr-menu-id b { display: block; font-size: 12.5px; font-weight: 600; color: #17181c;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sr-menu-id s { display: block; text-decoration: none; font-size: 11px; color: #848a96; margin-top: 1px; }
    .sr-menu-item {
        display: flex; align-items: center; gap: 9px; width: 100%;
        padding: 7px 9px; border: 0; background: none; cursor: pointer;
        font-family: inherit; font-size: 13px; color: #545864; text-align: left;
        border-radius: 7px; text-decoration: none;
    }
    .sr-menu-item:hover { background: #f4f5f8; color: #17181c; }
    .sr-menu-item svg { width: 15px; height: 15px; flex: none; stroke-width: 1.5; stroke: #848a96; }
    .sr-menu-sep { height: 1px; background: #eceef2; margin: 4px 6px; }

    /* ── expanded overlay ── */
    .sr-backdrop { display: none !important; }   /* retired: hover surface needs no dim */
    /* Measured from Supabase Studio (Sidebar.tsx + shadcn sidebar.tsx):
       hover has NO delay in either direction, and the motion is a WIDTH
       expansion at 100ms linear — the rail grows out of the icon strip
       rather than a second panel fading in. Children hold a fixed 220px
       width so labels are revealed by the growing edge, not reflowed. */
    .sr-panel {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 56px; visibility: hidden; overflow: hidden;
        background: #ffffff; border-right: 1px solid #e6e8ee;
        box-shadow: 0 12px 40px rgba(17, 24, 39, 0.12);
        z-index: 97; display: flex; flex-direction: column; padding: 14px 10px 12px;
        transition: width 0.1s linear, visibility 0s linear 0.1s;
    }
    #studio-rail-root.open .sr-panel {
        width: 240px; visibility: visible;
        transition: width 0.1s linear;
    }
    .sr-panel > * { width: 220px; flex-shrink: 0; }
    .sr-panel .sr-scroll { flex: 1; }

    .sr-brand { display: flex; align-items: center; padding: 2px 10px 12px; flex: none; }
    .sr-brand b { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; color: #111827; }
    .sr-brand b span { font-weight: 400; color: #6b7280; }
    .sr-collapse {
        margin-left: auto; border: 0; background: none; cursor: pointer;
        color: #9ba0aa; width: 26px; height: 26px; border-radius: 7px;
        display: grid; place-items: center;
    }
    .sr-collapse:hover { background: #f4f5f8; color: #17181c; }
    .sr-collapse svg { width: 14px; height: 14px; stroke-width: 1.5; }

    /* On hover-capable devices the panel closes itself on mouse-out, and the
       dashboard rail has no collapse control — hide it there so the open
       panel is a visual twin of the dashboard. */
    @media (hover: hover) and (pointer: fine) {
        .sr-collapse { display: none; }
    }

    .sr-search {
        display: flex; align-items: center; gap: 7px; flex: none;
        margin: 0 2px 12px; padding: 7px 10px;
        background: #f6f7f9; border: 1px solid #e5e8ef; border-radius: 10px; color: #9ba0aa;
    }
    .sr-search svg { width: 14px; height: 14px; flex: none; stroke-width: 1.5; }
    .sr-search input {
        border: 0; outline: 0; background: transparent; width: 100%;
        font: inherit; font-size: 13px; color: #17181c;
    }
    .sr-search input::placeholder { color: #9ba0aa; }

    .sr-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
    .sr-grp { font-size: 11.5px; font-weight: 500; color: #9ba0aa; margin: 12px 0 3px; padding: 2px 12px; line-height: 1.2; }
    .sr-div { height: 1px; border-top: 1px solid #eceef2; margin: 10px 11px; }
    .sr-it {
        display: flex; align-items: center; gap: 9px;
        padding: 6px 12px; border-radius: 8px;
        font-size: 13px; color: #545864; text-decoration: none;
    }
    .sr-it:hover { background: #f4f5f8; color: #17181c; }
    .sr-it.on { background: #e9ebf1; color: #17181c; font-weight: 500; }
    .sr-it svg { width: 16px; height: 16px; flex: none; stroke-width: 1.5; stroke: #848a96; }
    .sr-it.on svg { stroke: #17181c; }

    .sr-foot { flex: none; border-top: 1px solid #e6e8ee; padding-top: 8px; }
    .sr-acct {
        display: flex; align-items: center; gap: 9px; padding: 8px;
        border-radius: 10px; cursor: pointer;
    }
    .sr-acct:hover { background: #f4f5f8; }
    .sr-acct .sr-av { width: 26px; height: 26px; cursor: default; }
    .sr-acct-em { font-size: 12.5px; color: #545864; overflow: hidden; text-overflow: ellipsis;
        white-space: nowrap; min-width: 0; flex: 1; }
    .sr-acct-plan { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: #848a96;
        border: 1px solid #e5e8ef; border-radius: 6px; padding: 2px 6px; flex: none;
        text-transform: uppercase; }
    .sr-acct-chev { width: 13px; height: 13px; flex: none; color: #9ba0aa;
        transition: transform 0.15s ease; }
    #studio-rail-root.menu-open .sr-acct-chev { transform: rotate(180deg); }

    /* ── library quick-add affix (reveals on row hover) ── */
    .sr-it-lb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sr-plus {
        width: 22px; height: 22px; border-radius: 6px; border: 0; background: none;
        display: none; place-items: center; color: #848a96; cursor: pointer;
        flex: none; padding: 0;
    }
    .sr-it:hover .sr-plus { display: grid; }
    .sr-plus:hover { background: #e0e3ea; color: #17181c; }
    .sr-plus svg { width: 13px; height: 13px; stroke-width: 1.5; }

    /* ── full mode: persistent 240px rail for pages without a local panel ──
       Same surface as the dashboard rail: card-white, hairline right edge,
       no strip, no hover morph, account row toggles the menu above itself. */
    #studio-rail-root.full .sr-strip,
    #studio-rail-root.full .sr-backdrop { display: none !important; }
    #studio-rail-root.full .sr-panel {
        visibility: visible; width: 240px;
        transition: none; box-shadow: none;
    }
    #studio-rail-root.full .sr-menu { left: 12px; bottom: 58px; width: 216px; }
    /* opened from the expanded panel's account row: anchor to the panel, not the strip */
    #studio-rail-root.open .sr-menu { left: 12px; bottom: 58px; width: 216px; }
}
