/* The frame: rail, top bar, page, and the layer above them. */

.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

/* ---------- Rail ---------- */

.rail {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-right: 1px solid var(--line);
    overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; height: var(--bar); padding: 0 16px; text-decoration: none; flex: none; }
.brand-mark { display: grid; grid-template-columns: 9px 9px; gap: 3px; }
.brand-mark i { width: 9px; height: 9px; border-radius: 2px; background: var(--ok); }
.brand-mark i:first-child { background: var(--warn-fill); }
.brand-mark i:last-child { background: var(--brand); }
.brand-text { display: grid; line-height: 1.1; }
.brand-text b { font: 700 1.125rem var(--display); letter-spacing: 0.04em; }
.brand-text span { font-size: 0.75rem; color: var(--ink-soft); }

.nav { padding: 6px 10px 12px; flex: 1; }
.nav hr { margin: 8px 6px; }
.nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    height: 34px;
    padding: 0 10px;
    border-radius: var(--r);
    color: var(--ink-soft);
    font-weight: 500;
    text-decoration: none;
}
.nav a:hover { color: var(--ink); background: var(--well); }
.nav a.on { color: var(--ink); background: var(--brand-wash); font-weight: 600; }
.nav a.on .i { color: var(--brand); }
/* The page you are on is marked at the edge of the rail, like a tab. */
.nav > a.on::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 7px;
    bottom: 7px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--brand);
}
.nav .count {
    margin-left: auto;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--warn-fill);
    color: var(--on-warn);
    font: 700 0.75rem/1.4 var(--display);
    text-align: center;
}
.nav-sites { margin: 2px 0 2px 17px; padding-left: 10px; border-left: 1px solid var(--line-soft); }
.nav-sites a { height: 30px; gap: 8px; padding-right: 8px; font-size: 0.8125rem; font-family: var(--mono); }
.nav-sites a.on { background: var(--well); color: var(--ink); }
.nav-sites .dot { margin-left: auto; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); flex: none; }
.dot.down { background: var(--down); border-radius: 1px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--down) 18%, transparent); }
.dot.off { background: none; box-shadow: inset 0 0 0 1.5px var(--off); }

.rail-foot {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 0 10px 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--well);
    color: var(--ink-soft);
    font: 400 0.78125rem/1.3 var(--sans);
    text-align: left;
    cursor: pointer;
    flex: none;
}
.rail-foot:hover { border-color: var(--ink-faint); color: var(--ink); }
.rail-foot b { display: block; color: var(--ink); font-size: 0.8125rem; }
.rail-foot .tri {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--ink);
    color: var(--desk);
    flex: none;
}
.rail-foot .tri .i { width: 14px; height: 14px; fill: currentColor; stroke: none; }

/* A line of the ribbon runs across the top while Vercel is being asked. */
.progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 3px;
    background: var(--ribbon);
    background-size: 200% 100%;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.busy .progress { opacity: 1; animation: ribbon 1.1s linear infinite; }
@keyframes ribbon { to { background-position: -200% 0; } }

/* ---------- Top bar ---------- */

.stage { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--bar);
    padding: 0 32px;
    background: color-mix(in srgb, var(--desk) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line-soft);
}
.topbar-end { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.nav-toggle { display: none; }

.jump {
    display: flex;
    align-items: center;
    gap: 9px;
    width: min(360px, 100%);
    height: 34px;
    padding: 0 8px 0 11px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    color: var(--ink-faint);
    font: 400 0.8125rem var(--sans);
    cursor: pointer;
}
.jump:hover { border-color: var(--ink-faint); }
.jump span { flex: 1; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.avatar {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-fill), var(--c5));
    color: #fff;
    font: 700 0.8125rem var(--display);
    letter-spacing: 0.04em;
    box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--line);
    cursor: pointer;
}

/* ---------- Page ---------- */

main { flex: 1; padding: 28px 32px 64px; }
.page { display: grid; gap: 20px; max-width: 1280px; margin: 0 auto; }
.page > * { min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; color: var(--ink-soft); max-width: 62ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-title { display: flex; align-items: center; gap: 12px; }
.page-ic {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--brand-wash);
    color: var(--brand);
    flex: none;
}
.page-ic .i { width: 19px; height: 19px; }

.lead { display: grid; gap: 8px; padding: 12px 0 4px; }
.lead::before { content: ""; width: 64px; height: 4px; margin-bottom: 8px; border-radius: 2px; background: var(--ribbon); }
.lead h1 { font-size: clamp(1.75rem, 1rem + 2.4vw, 2.75rem); max-width: 36ch; }
.lead p { color: var(--ink-soft); font-size: 0.9375rem; }
.lead-actions { margin-top: 8px; }

.loading { display: flex; align-items: center; gap: 10px; padding: 48px 0; color: var(--ink-soft); }
.loading .i, .busy .topbar [data-action="refresh"] .i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.crumbs { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 0.8125rem; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .i { width: 12px; height: 12px; }

.site-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.site-head > div:first-child { display: flex; align-items: center; gap: 16px; min-width: 0; }
.site-head h1 .host { font-size: clamp(1.625rem, 1rem + 2vw, 2.375rem); }
.site-head p { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; color: var(--ink-soft); }
.site-head .site-about { color: var(--ink); max-width: 62ch; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.8125rem;
    text-decoration: none;
    white-space: nowrap;
}
.tabs a .i { width: 14px; height: 14px; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.tab-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.tab-actions:empty { display: none; }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 20px; }
.cols > * { min-width: 0; }
.cols.wide-first { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.narrow { display: grid; gap: 20px; max-width: 720px; }
.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.filters.inset { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); justify-content: space-between; }

/* ---------- Layer ---------- */

.scrim { position: fixed; inset: 0; z-index: 30; background: var(--scrim); }

.menu {
    position: fixed;
    z-index: 60;
    min-width: 230px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--raised);
    box-shadow: var(--shadow);
}
.menu.wide { width: min(360px, calc(100vw - 16px)); }
.menu > a, .menu > button:not(.link) {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--r);
    background: none;
    color: var(--ink);
    font: 400 0.875rem var(--sans);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.menu > a:hover, .menu > button:not(.link):hover { background: var(--well); }
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px 10px; }
.menu-head small { display: block; }
.menu-alert { align-items: flex-start !important; }
.menu-alert span { display: grid; gap: 1px; }
.menu-alert b { font-weight: 400; }
.menu-alert.unread b { font-weight: 600; }
.menu-alert .state { margin-top: 5px; }
.menu-all { justify-content: center; color: var(--brand) !important; font-weight: 600 !important; font-size: 0.8125rem !important; }

.dialog, .palette {
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    box-shadow: var(--shadow);
}
.dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); }
.dialog.wide { width: min(640px, calc(100vw - 24px)); }
.dialog::backdrop, .palette::backdrop { background: var(--scrim); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100dvh - 50px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 14px 20px; border-bottom: 1px solid var(--line-soft); }
.dialog-head h2 { font-size: 1.125rem; }
.dialog-head .btn { border-color: transparent; background: none; }
.dialog-body { display: grid; gap: 16px; padding: 20px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-soft); }
.dialog-text { color: var(--ink-soft); }
.prose { display: grid; gap: 12px; max-width: 60ch; }

.palette { width: min(560px, calc(100vw - 24px)); margin-top: 14vh; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line-soft); }
.palette-input input { border: 0; background: none; min-height: 50px; padding: 0; font-size: 1rem; outline: none; }
.palette-list { padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette-list li { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r); cursor: pointer; }
.palette-list li.on { background: var(--brand-wash); }
.palette-list li span { flex: 1; }
.palette-list .i { color: var(--ink-soft); }
.palette-none { color: var(--ink-soft); cursor: default !important; }
.palette-foot { padding: 9px 16px; border-top: 1px solid var(--line-soft); color: var(--ink-soft); font-size: 0.75rem; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast {
    max-width: min(420px, calc(100vw - 40px));
    padding: 11px 14px;
    border-radius: 6px;
    background: var(--ink);
    color: var(--desk);
    font-size: 0.8125rem;
    box-shadow: var(--shadow);
    animation: toast-in 0.2s ease-out;
}
.toast.warn { background: var(--warn-fill); color: var(--on-warn); }
.toast.out { opacity: 0; transition: opacity 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.tip {
    position: fixed;
    z-index: 90;
    max-width: 280px;
    padding: 6px 9px;
    border-radius: var(--r);
    background: var(--ink);
    color: var(--desk);
    font-size: 0.78125rem;
    line-height: 1.35;
    pointer-events: none;
}

/* ---------- Log in ---------- */

.gate {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(640px 420px at 50% -10%, var(--glow), transparent 70%);
}
.gate-card {
    position: relative;
    display: grid;
    gap: 16px;
    width: min(380px, 100%);
    padding: 32px 28px 28px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.gate-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--ribbon); }
.gate-card .brand { height: auto; padding: 0; }
.gate-card h1 { margin-top: 8px; }
.gate-card h1 + p { margin-top: -10px; color: var(--ink-soft); }
.gate-note { display: flex; gap: 9px; color: var(--ink-soft); font-size: 0.8125rem; }
.gate-note .i { margin-top: 2px; }

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .rail {
        position: fixed;
        z-index: 40;
        left: 0;
        width: min(var(--rail), 84vw);
        transform: translateX(-100%);
        transition: transform 0.2s ease-out;
        visibility: hidden;
    }
    .shell.nav-open .rail { transform: none; visibility: visible; box-shadow: var(--shadow); }
    .nav-toggle { display: inline-flex; }
    .topbar { padding: 0 16px; }
    .topbar .btn.primary span, .jump kbd { display: none; }
    .topbar .btn.primary { width: 28px; padding: 0; }
    main { padding: 20px 16px 56px; }
    .cols.wide-first { grid-template-columns: minmax(0, 1fr); }
    .toasts { right: 12px; left: 12px; bottom: 12px; justify-items: stretch; }
}
