/* Pontifex console — base layout: rail + topbar + content. Glass · Split. */
@layer base {
    @font-face {
        font-family: "Inter";
        src: url("/static/fonts/InterVariable.woff2") format("woff2");
        font-weight: 100 900;
        font-style: normal;
        font-display: swap;
    }

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }
    html {
        height: 100%;
        -webkit-text-size-adjust: 100%;
    }
    body {
        margin: 0;
        min-height: 100%;
        font: var(--fs) / var(--lh) var(--font);
        font-feature-settings:
            "tnum" 1,
            "cv11" 1,
            "ss01" 0;
        color: var(--ink-2);
        background:
            radial-gradient(
                1200px 700px at 8% -10%,
                rgba(108, 140, 255, 0.16),
                transparent 60%
            ),
            radial-gradient(
                900px 600px at 100% 0%,
                rgba(160, 96, 255, 0.12),
                transparent 55%
            ),
            linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 60%, var(--bg-3) 100%);
        background-attachment: fixed;
    }
    a {
        color: var(--accent);
        text-decoration: none;
    }
    a:hover {
        text-decoration: underline;
        text-underline-offset: 2px;
    }
    button {
        font: inherit;
        color: inherit;
    }
    svg {
        display: block;
    }
    h1,
    h2,
    h3 {
        margin: 0;
        font-weight: 600;
        color: var(--ink);
        letter-spacing: -0.01em;
    }
    h1 {
        font-size: 17px;
    }
    h2 {
        font-size: 13px;
    }
    h3 {
        font-size: 12px;
        color: var(--muted);
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }
    .num,
    .tnum,
    td.n,
    .n {
        font-variant-numeric: tabular-nums;
    }
    .muted {
        color: var(--muted);
    }
    .dim {
        color: var(--dim);
    }
    .ink {
        color: var(--ink);
    }
    .profit {
        color: var(--profit);
    }
    .loss {
        color: var(--loss);
    }
    ::selection {
        background: var(--accent-soft);
    }

    /* ---- shell ---- */
    .shell {
        display: grid;
        grid-template-columns: var(--rail-w) minmax(0, 1fr);
        grid-template-rows: var(--topbar-h) minmax(0, 1fr);
        grid-template-areas: "rail top" "rail main";
        min-height: 100dvh;
        transition: grid-template-columns 160ms ease;
    }
    body.rail-collapsed .shell {
        grid-template-columns: var(--rail-w-min) minmax(0, 1fr);
    }

    .rail {
        grid-area: rail;
        position: sticky;
        top: 0;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        padding: 12px 10px;
        border-right: 1px solid var(--line);
        background: rgba(255, 255, 255, 0.03);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        overflow: hidden;
    }
    .brand {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 4px 8px 14px;
        color: var(--ink);
        font-weight: 600;
        font-size: 14px;
        letter-spacing: 0.01em;
    }
    .brand:hover {
        text-decoration: none;
    }
    .brand .mark {
        width: 22px;
        height: 22px;
        border-radius: 6px;
        box-shadow: 0 0 10px rgba(108, 140, 255, 0.45);
    }
    .nav {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
    .nav a {
        display: flex;
        align-items: center;
        gap: 10px;
        height: var(--row);
        padding: 0 8px;
        border-radius: var(--radius-s);
        color: var(--muted);
        font-weight: 500;
        white-space: nowrap;
    }
    .nav a:hover {
        color: var(--ink);
        background: var(--glass);
        text-decoration: none;
    }
    .nav a.active {
        color: var(--ink);
        background: var(--accent-soft);
        box-shadow: inset 2px 0 0 var(--accent);
    }
    .nav .ico {
        width: 16px;
        height: 16px;
        flex: none;
    }
    .nav .ico svg {
        width: 16px;
        height: 16px;
    }
    /* External tools (Grafana): pinned to the bottom of the rail, above the
       footer chips, and still shown as an icon when the rail is collapsed. */
    .nav-tools {
        margin-top: auto;
        padding-top: 8px;
        border-top: 1px solid var(--line);
    }
    .nav-tools .ext {
        margin-left: auto;
        color: var(--dim);
        font-size: 11px;
    }
    body.rail-collapsed .nav-tools .ext {
        display: none;
    }
    .rail-foot {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px;
        color: var(--dim);
        font-size: 11px;
    }
    .signout {
        margin: 0 0 0 auto;
    }
    .signout button {
        padding: 0;
        border: 0;
        background: none;
        color: var(--dim);
        font-size: 11px;
        cursor: pointer;
    }
    .signout button:hover {
        color: var(--ink);
    }
    .rail-toggle {
        position: absolute;
        right: 8px;
        top: 10px;
        width: 24px;
        height: 24px;
        padding: 0;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: var(--glass);
        color: var(--muted);
        cursor: pointer;
        display: grid;
        place-items: center;
    }
    .rail-toggle svg {
        width: 12px;
        height: 12px;
        transition: transform 160ms ease;
    }
    .rail-toggle:hover {
        color: var(--ink);
        border-color: var(--line-2);
    }
    body.rail-collapsed .rail .word,
    body.rail-collapsed .rail .lbl,
    body.rail-collapsed .rail-foot {
        display: none;
    }
    body.rail-collapsed .rail {
        padding: 12px 8px;
    }
    body.rail-collapsed .rail-toggle {
        right: 16px;
        top: 44px;
    }
    body.rail-collapsed .rail-toggle svg {
        transform: rotate(180deg);
    }
    body.rail-collapsed .brand {
        padding: 4px 9px 44px;
    }
    body.rail-collapsed .nav a {
        justify-content: center;
        padding: 0;
    }

    .topbar {
        grid-area: top;
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 0 16px;
        border-bottom: 1px solid var(--line);
        background: rgba(5, 7, 15, 0.55);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }
    .crumbs {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        color: var(--muted);
        font-weight: 500;
    }
    .crumbs > * {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .crumbs .sep {
        color: var(--dim);
    }
    .crumbs .here {
        color: var(--ink);
    }
    .topbar-right {
        margin-left: auto;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .clock {
        color: var(--dim);
        font-size: 11px;
        font-variant-numeric: tabular-nums;
    }
    .burger {
        display: none;
        width: 32px;
        height: 32px;
        padding: 0;
        border: 0;
        background: none;
        color: var(--muted);
        cursor: pointer;
    }
    .burger svg {
        width: 16px;
        height: 16px;
        margin: auto;
    }

    .content {
        grid-area: main;
        padding: var(--pad);
        min-width: 0;
    }

    /* ---- phone ---- */
    @media (max-width: 900px) {
        .shell {
            grid-template-columns: minmax(0, 1fr);
            grid-template-areas: "top" "main";
        }
        body.rail-collapsed .shell {
            grid-template-columns: minmax(0, 1fr);
        }
        .rail {
            position: fixed;
            inset: 0 auto 0 0;
            width: min(280px, 84vw);
            z-index: 40;
            transform: translateX(-100%);
            transition: transform 180ms ease;
            background: rgba(8, 11, 24, 0.92);
        }
        body.rail-open .rail {
            transform: none;
        }
        body.rail-collapsed .rail .word,
        body.rail-collapsed .rail .lbl,
        body.rail-collapsed .rail-foot {
            display: revert;
        }
        body.rail-collapsed .nav a {
            justify-content: flex-start;
            padding: 0 8px;
        }
        .rail-toggle {
            display: none;
        }
        .burger {
            display: grid;
        }
        .content {
            padding: 10px;
        }
        .topbar {
            padding: 0 10px;
            gap: 8px;
        }
        .clock {
            display: none;
        }
        .crumbs {
            flex: 1;
        }
        .scrim {
            position: fixed;
            inset: 0;
            z-index: 30;
            background: rgba(0, 0, 0, 0.5);
            display: none;
        }
        body.rail-open .scrim {
            display: block;
        }
    }
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            transition: none !important;
            animation: none !important;
        }
    }
}
