/* ============================================================
   BUNKROS — APP SHELL + DESIGN TOKENS (2026-09-27)
   Loaded LAST by includes/header.php (after bunkrosnexus.css and
   page CSS). Owns the chrome and the shared UI language:

     phone    ≤ 767px     compact top bar + floating bottom bar
                          (Menu · Chat · Theme · Prev · Next) + bottom sheet
     iPad     768–1199px  floating side rail (no top bar) + side drawer,
                          Underground tab right, pager bottom centre
     desktop  ≥ 1200px    glass top bar with inline nav + drawer,
                          Underground tab right, pager bottom centre

   The LOC/SYS "huts" stay bottom-left on every device.
   Palette = the existing Underground (dark) / Above Ground (light)
   tokens from bunkrosnexus.css.
   ============================================================ */

:root {
    --sh-accent: var(--primary-accent, #ff005a);
    --sh-accent-rgb: var(--primary-accent-rgb, 255, 0, 90);
    --sh-cyan: var(--secondary-accent, #00eeff);
    --sh-violet: var(--tertiary-accent, #9d00ff);
    --sh-grad: linear-gradient(135deg, #ff005a 0%, #d400a8 55%, #9d00ff 100%);
    --sh-text: var(--text-primary, #f0f0f8);
    --sh-muted: #a9a9bd;
    --sh-glass: rgba(12, 12, 18, 0.74);
    --sh-glass-strong: rgba(14, 14, 21, 0.95);
    --sh-surface: rgba(255, 255, 255, 0.04);
    --sh-surface-2: rgba(255, 255, 255, 0.08);
    --sh-border: rgba(255, 255, 255, 0.09);
    --sh-border-2: rgba(255, 255, 255, 0.18);
    --sh-tint: rgba(255, 0, 90, 0.13);
    --sh-shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.75), 0 2px 6px rgba(0, 0, 0, 0.3);

    --sh-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --sh-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --sh-safe-t: env(safe-area-inset-top, 0px);
    --sh-safe-b: env(safe-area-inset-bottom, 0px);
    --sh-safe-l: env(safe-area-inset-left, 0px);
    --sh-safe-r: env(safe-area-inset-right, 0px);

    --sh-top-h: 72px;
    --sh-rail-w: 0px;
    --sh-bot-h: 0px;

    /* ---- shared type scale ---- */
    --fs-display: clamp(2.3rem, 1.4rem + 4.4vw, 5.2rem);
    --fs-h1: clamp(2rem, 1.3rem + 3vw, 3.6rem);
    --fs-h2: clamp(1.6rem, 1.15rem + 1.9vw, 2.6rem);
    --fs-h3: clamp(1.15rem, 1rem + 0.6vw, 1.45rem);
    --fs-body: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
    --fs-small: 0.9rem;
    --fs-label: 0.75rem;
    --measure: 68ch;
    --gutter: clamp(16px, 4vw, 48px);
    --radius: 18px;
    --radius-sm: 12px;
}

[data-theme="light"] {
    --sh-accent-rgb: 255, 51, 102;
    --sh-grad: linear-gradient(135deg, #ff3366 0%, #e0409f 55%, #7c3aed 100%);
    --sh-text: #1a1816;
    --sh-muted: #5a554e;
    --sh-glass: rgba(250, 248, 245, 0.82);
    --sh-glass-strong: rgba(252, 250, 247, 0.97);
    --sh-surface: rgba(26, 24, 22, 0.035);
    --sh-surface-2: rgba(26, 24, 22, 0.07);
    --sh-border: rgba(26, 24, 22, 0.1);
    --sh-border-2: rgba(26, 24, 22, 0.2);
    --sh-tint: rgba(255, 51, 102, 0.1);
    --sh-shadow: 0 18px 50px -22px rgba(80, 40, 60, 0.35), 0 2px 6px rgba(80, 40, 60, 0.08);
}

@media (max-width: 767px) {
    :root { --sh-top-h: calc(60px + var(--sh-safe-t)); --sh-bot-h: calc(84px + var(--sh-safe-b)); }
}
@media (min-width: 768px) and (max-width: 1199px) {
    :root { --sh-top-h: 0px; --sh-rail-w: calc(104px + var(--sh-safe-l)); }
}

/* Theme cross-fade only while toggling */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
    transition: background-color .5s var(--sh-ease), color .5s var(--sh-ease), border-color .5s var(--sh-ease) !important;
}

/* ------------------------------------------------------------
   0. BASE
   ------------------------------------------------------------ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: clip; -webkit-tap-highlight-color: transparent; text-rendering: optimizeLegibility; }
img, video, svg, canvas, iframe { max-width: 100%; }
img, video { height: auto; }
:focus-visible { outline: 2px solid var(--sh-accent); outline-offset: 3px; border-radius: 6px; }
.skip-link {
    position: fixed; left: -9999px; top: 12px; z-index: 10001;
    padding: .8rem 1.1rem; border-radius: 12px;
    background: var(--sh-glass-strong); color: var(--sh-text);
    font: 700 .9rem var(--font-heading);
}
.skip-link:focus { left: 12px; }
#main-content { display: block; height: 0; outline: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Loader: first page of a visit only */
html.is-returning #loading-screen { display: none !important; }
#loading-screen { transition: opacity .6s var(--sh-ease), visibility .6s var(--sh-ease) !important; }

.icon-btn {
    position: relative; width: 46px; height: 46px; flex: none;
    display: grid; place-items: center; padding: 0; cursor: pointer;
    border-radius: 14px; border: 1px solid var(--sh-border);
    background: var(--sh-surface); color: var(--sh-text); font-size: 1.1rem;
    transition: transform .35s var(--sh-spring), background-color .25s, border-color .25s, color .25s;
}
.icon-btn:hover { border-color: rgba(var(--sh-accent-rgb), .6); color: var(--sh-accent); }
.icon-btn:active { transform: scale(.9); }

/* ------------------------------------------------------------
   1. TOP BAR (desktop + phone). Reuses the old <header> styles
   ------------------------------------------------------------ */
header.topbar {
    position: fixed; z-index: 1000; top: 0; left: 0; right: 0; width: auto;
    height: var(--sh-top-h); padding: var(--sh-safe-t) clamp(16px, 2.6vw, 36px) 0;
    display: flex; align-items: center; gap: 1rem;
    -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%);
    border-bottom: 1px solid var(--sh-border);
    transition: transform .45s var(--sh-ease), background-color .4s, box-shadow .4s;
}
[data-theme="dark"] header.topbar { background: rgba(10, 10, 15, 0.72); }
[data-theme="dark"] header.topbar[data-solid="true"] { background: rgba(10, 10, 15, 0.92); box-shadow: 0 10px 30px -20px #000; }
header.topbar::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(var(--sh-accent-rgb), .8) 30%, var(--sh-cyan) 50%, rgba(var(--sh-accent-rgb), .8) 70%, transparent);
    background-size: 200% 100%; animation: shLine 6s linear infinite; opacity: .55;
}
@keyframes shLine { from { background-position: 200% 0; } to { background-position: 0 0; } }
header.topbar .logo { margin-right: auto; min-height: 44px; }
header.topbar .logo-highlight { margin: 0; letter-spacing: .12em; }

.topnav { display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 16px; background: var(--sh-surface); border: 1px solid var(--sh-border); }
.topnav a {
    position: relative; padding: .62rem .9rem; border-radius: 12px;
    font: 600 .86rem/1 var(--font-heading); letter-spacing: .04em; text-transform: uppercase;
    color: var(--sh-muted); text-decoration: none; white-space: nowrap;
    transition: color .25s, background-color .25s;
}
.topnav a:hover { color: var(--sh-text); background: var(--sh-surface-2); }
.topnav a[aria-current="page"] { color: var(--sh-text); background: var(--sh-tint); box-shadow: inset 0 0 0 1px rgba(var(--sh-accent-rgb), .35); }
.topnav a[aria-current="page"]::after {
    content: ''; position: absolute; left: 50%; bottom: 3px; width: 14px; height: 2px; margin-left: -7px;
    border-radius: 2px; background: var(--sh-accent); box-shadow: 0 0 10px var(--sh-accent);
}
.topbar-tools { display: flex; align-items: center; gap: 10px; }
header.topbar .nav-toggle { width: 46px; height: 46px; border-radius: 14px; }

@media (min-width: 1200px) and (max-width: 1399px) { .topnav a { padding: .6rem .62rem; font-size: .8rem; } }
@media (max-width: 1199px) { .topnav { display: none !important; } }

/* phone top bar: compact, auto-hides while scrolling down */
@media (max-width: 767px) {
    header.topbar { padding-inline: 16px; }
    header.topbar[data-hidden="true"] { transform: translateY(-105%); }
    header.topbar .nav-toggle { display: none; } /* Menu lives in the bottom bar */
    header.topbar .logo { font-size: 1.15rem; }
}
/* iPad: rail instead of a top bar */
@media (min-width: 768px) and (max-width: 1199px) { header.topbar { display: none !important; } }

/* ------------------------------------------------------------
   2. iPAD SIDE RAIL
   ------------------------------------------------------------ */
.rail { display: none; }
@media (min-width: 768px) and (max-width: 1199px) {
    .rail {
        position: fixed; z-index: 1000;
        left: calc(12px + var(--sh-safe-l)); top: calc(12px + var(--sh-safe-t)); bottom: calc(12px + var(--sh-safe-b));
        width: 80px; padding: 12px 7px;
        display: flex; flex-direction: column; align-items: center; gap: 6px;
        border-radius: 26px; border: 1px solid var(--sh-border);
        background: var(--sh-glass);
        -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
        box-shadow: var(--sh-shadow);
    }
    .rail::after {
        content: ''; position: absolute; top: 24px; bottom: 24px; right: -1px; width: 1px; pointer-events: none;
        background: linear-gradient(180deg, transparent, var(--sh-accent), var(--sh-cyan), transparent);
        opacity: .6;
    }
    body.shell { padding-left: var(--sh-rail-w); }
}
.rail-brand {
    width: 50px; height: 50px; flex: none; display: grid; place-items: center; margin-bottom: 6px;
    border-radius: 16px; text-decoration: none; background: var(--sh-grad);
    box-shadow: 0 10px 26px -10px rgba(var(--sh-accent-rgb), .8), inset 0 1px 0 rgba(255,255,255,.3);
    transition: transform .5s var(--sh-spring);
}
.rail-brand span { font: 900 1.45rem/1 var(--font-heading); color: #fff; letter-spacing: 0; }
.rail-brand:hover { transform: rotate(-8deg) scale(1.06); }
.rail-nav { display: flex; flex-direction: column; gap: 3px; width: 100%; overflow-y: auto; scrollbar-width: none; flex: 1 1 auto; min-height: 0; }
.rail-nav::-webkit-scrollbar { display: none; }
.rail-tools { width: 100%; padding-top: 8px; border-top: 1px solid var(--sh-border); }

.tab {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
    min-height: 58px; width: 100%; padding: 6px 2px;
    border: 0; border-radius: 16px; background: none; cursor: pointer;
    font: 700 .7rem/1.1 var(--font-heading); letter-spacing: .04em; text-transform: uppercase;
    color: var(--sh-muted); text-decoration: none; text-align: center;
    transition: color .25s, background-color .25s, transform .35s var(--sh-spring);
}
.tab i { font-size: 1.12rem; transition: transform .45s var(--sh-spring), color .25s; }
.tab:hover { color: var(--sh-text); background: var(--sh-surface-2); }
.tab:active { transform: scale(.9); }
.tab[aria-current="page"] { color: var(--sh-text); background: var(--sh-tint); box-shadow: inset 0 0 0 1px rgba(var(--sh-accent-rgb), .3); }
.tab[aria-current="page"] i { color: var(--sh-accent); transform: scale(1.1); }
.rail .tab[aria-current="page"]::before {
    content: ''; position: absolute; left: -7px; top: 50%; width: 4px; height: 26px; margin-top: -13px;
    border-radius: 0 4px 4px 0; background: var(--sh-accent); box-shadow: 0 0 12px var(--sh-accent);
}
@media (min-width: 768px) and (max-width: 1199px) and (max-height: 860px) {
    .rail .tab { min-height: 50px; gap: 3px; }
    .rail .tab span { font-size: .62rem; }
}
@media (min-width: 768px) and (max-width: 1199px) and (max-height: 700px) {
    .rail .tab span { display: none; }
    .rail .tab { min-height: 46px; }
}

/* ------------------------------------------------------------
   3. UNDERGROUND / ABOVE GROUND side tab (iPad + desktop)
   ------------------------------------------------------------ */
.theme-toggle { right: calc(12px + var(--sh-safe-r)); z-index: 990; }
.theme-toggle-btn {
    min-width: 46px; min-height: 132px; padding: 16px 12px; border-radius: 14px;
    font-size: .72rem; letter-spacing: .2em;
    background: var(--sh-glass); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-color: var(--sh-border);
}
.theme-toggle-btn::before {
    content: ''; display: inline-block; width: 8px; height: 8px; margin-bottom: 10px; border-radius: 50%;
    background: var(--sh-accent); box-shadow: 0 0 0 4px rgba(var(--sh-accent-rgb), .18), 0 0 12px var(--sh-accent);
}
[data-theme="light"] .theme-toggle-btn::before { background: #ffb400; box-shadow: 0 0 0 4px rgba(255,180,0,.2), 0 0 12px #ffb400; }
.theme-toggle.is-bounce { animation: shBounce .6s var(--sh-spring); }
@keyframes shBounce { 40% { transform: translateY(-50%) scale(1.08); } }
@media (max-width: 767px) { .theme-toggle { display: none !important; } }

/* ------------------------------------------------------------
   4. HUD — the two huts, bottom-left on every device
   ------------------------------------------------------------ */
.hud-container {
    left: calc(16px + var(--sh-safe-l) + var(--sh-rail-w)); right: auto;
    top: auto !important; bottom: calc(20px + var(--sh-safe-b)) !important;
    z-index: 980; pointer-events: none; transform: none;
    transition: opacity .4s var(--sh-ease), transform .5s var(--sh-ease);
}
.hud-badge {
    min-width: 150px; padding: .55rem .85rem; border-radius: 9px;
    font-size: .72rem; letter-spacing: .12em; font-variant-numeric: tabular-nums;
    background: var(--sh-glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border: 1px solid var(--sh-border); color: var(--sh-text);
}
.hud-badge-label { color: var(--sh-accent); font-weight: 700; }
.time-badge { display: block; }
@media (max-width: 767px) {
    .hud-container { bottom: calc(var(--sh-bot-h) + 10px) !important; left: 14px; flex-direction: row; gap: 6px; }
    .hud-badge { min-width: 0; padding: .45rem .65rem; font-size: .68rem; }
    .hud-container[data-away="true"] { opacity: 0; transform: translateY(12px); }
}
@media (min-width: 768px) {
    body.has-pager .hud-container { bottom: calc(22px + var(--sh-safe-b)) !important; }
}
body.menu-open .hud-container { opacity: 0; }
@media print { .hud-container { display: none !important; } }

/* ------------------------------------------------------------
   5. SECTION PAGER — bottom centre (iPad + desktop)
   ------------------------------------------------------------ */
.viewpoint-nav[hidden] { display: none !important; }
.viewpoint-nav {
    left: calc(50% + var(--sh-rail-w) / 2); bottom: calc(18px + var(--sh-safe-b));
    padding: 5px; gap: 2px; border-radius: 999px; z-index: 985;
    background: var(--sh-glass); -webkit-backdrop-filter: blur(18px) saturate(170%); backdrop-filter: blur(18px) saturate(170%);
    border-color: var(--sh-border); box-shadow: var(--sh-shadow);
}
.viewpoint-btn { width: 46px; height: 46px; color: var(--sh-text); }
.viewpoint-indicator { min-width: 58px; font-size: .95rem; font-variant-numeric: tabular-nums; }
.viewpoint-indicator em { font-style: normal; opacity: .5; margin: 0 2px; }
.viewpoint-indicator #totalViewpoints { font-size: .78rem; color: var(--sh-muted); }
body.menu-open .viewpoint-nav { opacity: 0; pointer-events: none; }

/* ------------------------------------------------------------
   6. PHONE BOTTOM BAR (existing concept: Menu · Theme · Prev · Next, + Chat)
   ------------------------------------------------------------ */
@media (max-width: 767px) {
    .mobile-bottom-bar {
        left: 10px; right: 10px; width: auto; bottom: calc(8px + var(--sh-safe-b));
        height: 68px; padding: 6px;
        display: grid !important; grid-template-columns: repeat(5, 1fr); gap: 2px; align-items: stretch;
        border-radius: 24px; border: 1px solid var(--sh-border);
        background: var(--sh-glass);
        -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
        box-shadow: var(--sh-shadow); z-index: 1000;
    }
    .mobile-bottom-bar::before {
        content: ''; position: absolute; top: 0; left: 24px; right: 24px; height: 1px;
        background: linear-gradient(90deg, transparent, var(--sh-accent), var(--sh-cyan), transparent); opacity: .7;
    }
    .mobile-bar-btn {
        min-width: 0; padding: 4px 0; border-radius: 18px; gap: 5px; justify-content: center;
        color: var(--sh-muted); text-decoration: none;
        transition: color .2s, background-color .2s, transform .3s var(--sh-spring), opacity .2s;
    }
    .mobile-bar-btn i { font-size: 1.15rem; }
    .mobile-bar-btn span { font: 700 .68rem/1 var(--font-heading); letter-spacing: .06em; }
    .mobile-bar-btn:active { transform: scale(.88); }
    .mobile-bar-btn[aria-current="page"], body.menu-open #mobileMenuBtn { color: var(--sh-text); background: var(--sh-tint); }
    .mobile-bar-btn[aria-current="page"] i, body.menu-open #mobileMenuBtn i { color: var(--sh-accent); }
    .mobile-bar-btn.is-theme i { color: var(--sh-accent); }
    .mobile-bar-btn:disabled { opacity: .32; }
    body.shell { padding-bottom: var(--sh-bot-h); }
}

/* ------------------------------------------------------------
   7. MENU: bottom sheet (phone) / drawer (iPad + desktop)
   ------------------------------------------------------------ */
.sheet-scrim {
    position: fixed; inset: 0; z-index: 1990;
    background: rgba(5, 5, 10, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    opacity: 0; transition: opacity .4s var(--sh-ease);
}
body.menu-open .sheet-scrim { opacity: 1; }
body.menu-open { overflow: hidden; }

.menu-overlay.sheet {
    position: fixed; z-index: 2000; inset: auto;
    top: calc(12px + var(--sh-safe-t)); right: 12px; bottom: calc(12px + var(--sh-safe-b)); left: auto;
    width: min(440px, calc(100vw - 24px)); height: auto; padding: 0; margin: 0;
    display: flex; flex-direction: column;
    border-radius: 28px; border: 1px solid var(--sh-border);
    background: var(--sh-glass-strong) !important;
    -webkit-backdrop-filter: blur(28px) saturate(180%); backdrop-filter: blur(28px) saturate(180%);
    box-shadow: 0 40px 100px -30px rgba(0,0,0,.8);
    color: var(--sh-text); opacity: 1; visibility: hidden;
    transform: translateX(calc(100% + 24px));
    transition: transform .55s var(--sh-ease), visibility 0s linear .55s;
    overflow: hidden;
}
.menu-overlay.sheet.active { visibility: visible; transform: none; transition: transform .55s var(--sh-ease), visibility 0s; }
.sheet-grip { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 18px 18px 10px 24px; flex: none; }
.sheet-title { font: 800 1.2rem/1 var(--font-heading); letter-spacing: .08em; text-transform: uppercase; }
.sheet-title .logo-highlight { color: var(--sh-accent); margin-right: .25em; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px 22px; -webkit-overflow-scrolling: touch; }
.sheet-row { margin-bottom: 12px; }
.seg { display: flex; width: 100%; gap: 3px; padding: 4px; border-radius: 16px; background: var(--sh-surface); border: 1px solid var(--sh-border); }
.seg button {
    flex: 1; min-height: 48px; padding: 0 .5rem; border: 0; border-radius: 12px; background: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    font: 700 .78rem/1.1 var(--font-heading); letter-spacing: .08em; text-transform: uppercase; color: var(--sh-muted);
    transition: background-color .3s, color .3s, box-shadow .3s;
}
.seg button[aria-pressed="true"] { background: var(--sh-tint); color: var(--sh-text); box-shadow: inset 0 0 0 1px rgba(var(--sh-accent-rgb), .45); }
.seg button[aria-pressed="true"] i { color: var(--sh-accent); }
.header-translator { position: static !important; transform: none !important; max-width: none !important; min-width: 0 !important; width: auto !important; }
.header-translator:empty { display: none; }
.sheet-group { margin-top: 18px; }
.sheet-group h3 { margin: 0 0 10px 4px; font: 700 .72rem/1 var(--font-heading); letter-spacing: .2em; text-transform: uppercase; color: var(--sh-accent); }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-link {
    display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
    min-height: 84px; padding: 13px; border-radius: 16px;
    background: var(--sh-surface); border: 1px solid var(--sh-border);
    color: var(--sh-text) !important; text-decoration: none;
    font: 600 .86rem/1.25 var(--font-body);
    transition: transform .35s var(--sh-spring), border-color .25s, background-color .25s;
}
.sheet-link i { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--sh-tint); color: var(--sh-accent); font-size: .95rem; }
.sheet-link:hover { border-color: rgba(var(--sh-accent-rgb), .5); background: var(--sh-surface-2); }
.sheet-link:active { transform: scale(.96); }
.sheet-link[aria-current="page"] { border-color: rgba(var(--sh-accent-rgb), .6); background: var(--sh-tint); }
.sheet-link.is-danger, .sheet-link.is-danger i { color: #ff6b6b !important; }
.menu-overlay.sheet .sheet-group, .menu-overlay.sheet .sheet-row { opacity: 0; transform: translateY(10px); transition: opacity .4s, transform .5s var(--sh-ease); }
.menu-overlay.sheet.active .sheet-group, .menu-overlay.sheet.active .sheet-row { opacity: 1; transform: none; }
.menu-overlay.sheet.active .sheet-group:nth-of-type(2) { transition-delay: .06s; }
.menu-overlay.sheet.active .sheet-group:nth-of-type(3) { transition-delay: .1s; }
.menu-overlay.sheet.active .sheet-group:nth-of-type(4) { transition-delay: .14s; }
.menu-overlay.sheet.active .sheet-group:nth-of-type(5) { transition-delay: .18s; }
.menu-overlay.sheet.active .sheet-group:nth-of-type(6) { transition-delay: .22s; }
@media (min-width: 768px) and (max-width: 1199px) {
    .menu-overlay.sheet { left: calc(104px + var(--sh-safe-l)); right: auto; transform: translateX(calc(-100% - 140px)); }
}
@media (max-width: 767px) {
    .menu-overlay.sheet {
        top: auto; left: 0; right: 0; bottom: 0; width: 100%;
        max-height: calc(90dvh - var(--sh-safe-t));
        border-radius: 28px 28px 0 0; border-bottom: 0; transform: translateY(105%);
    }
    .sheet-grip { display: block; width: 42px; height: 5px; border-radius: 3px; margin: 10px auto 0; background: var(--sh-border-2); flex: none; }
    .sheet-head { padding: 8px 14px 8px 20px; }
    .sheet-body { padding: 4px 14px calc(24px + var(--sh-safe-b)); }
    .sheet-link { min-height: 78px; }
}

/* ------------------------------------------------------------
   8. SHARED UI LANGUAGE — buttons, type, scenes
   ------------------------------------------------------------ */
.bk-btn, .cta-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
    min-height: 52px; padding: 0 1.6rem; border-radius: 14px;
    font: 700 .86rem/1 var(--font-accent); letter-spacing: .12em; text-transform: uppercase;
    text-decoration: none; cursor: pointer; border: 1.5px solid transparent;
    transition: transform .3s var(--sh-spring), box-shadow .3s, background-color .25s, border-color .25s, color .25s;
}
.bk-btn:active, .cta-btn:active { transform: scale(.96); }
.bk-btn--primary, .cta-primary { background: var(--sh-grad); color: #fff !important; box-shadow: 0 12px 30px -10px rgba(var(--sh-accent-rgb), .7); }
.bk-btn--primary:hover, .cta-primary:hover { box-shadow: 0 16px 40px -10px rgba(var(--sh-accent-rgb), .9); transform: translateY(-2px); }
.bk-btn--secondary, .cta-secondary { background: rgba(10,10,15,.35); color: var(--sh-text) !important; border-color: rgba(var(--sh-accent-rgb), .8); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
[data-theme="light"] .bk-btn--secondary, [data-theme="light"] .cta-secondary { background: rgba(255,255,255,.55); }
.bk-btn--secondary:hover, .cta-secondary:hover { background: rgba(var(--sh-accent-rgb), .14); }
.bk-btn--ghost { background: var(--sh-surface); color: var(--sh-text) !important; border-color: var(--sh-border-2); }
.bk-btn--ghost:hover { border-color: var(--sh-accent); color: var(--sh-accent) !important; }
.bk-btn--danger { background: #2a0b12; color: #ff6b7d !important; border-color: rgba(255,80,100,.45); }
.bk-btn--sm { min-height: 44px; padding: 0 1.1rem; font-size: .76rem; border-radius: 12px; }
.bk-btn[disabled] { opacity: .45; pointer-events: none; }

.bk-eyebrow { display: inline-flex; align-items: center; gap: .6rem; font: 700 var(--fs-label)/1 var(--font-accent); letter-spacing: .24em; text-transform: uppercase; color: var(--sh-accent); }
.bk-eyebrow::before { content: ''; width: 22px; height: 2px; background: currentColor; box-shadow: 0 0 10px currentColor; }
.bk-h1 { font: 800 var(--fs-h1)/1.02 var(--font-heading); letter-spacing: -.01em; margin: 0; }
.bk-h2 { font: 800 var(--fs-h2)/1.08 var(--font-heading); letter-spacing: 0; margin: 0; }
.bk-lead { font-size: clamp(1.02rem, .95rem + .35vw, 1.22rem); line-height: 1.65; color: var(--text-secondary); max-width: 60ch; }
.bk-wrap { width: min(1320px, 100% - 2 * var(--gutter)); margin-inline: auto; }
.bk-chip {
    display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: 0 1rem; border-radius: 999px;
    font: 700 .76rem/1 var(--font-accent); letter-spacing: .1em; text-transform: uppercase;
    background: var(--sh-surface); border: 1px solid var(--sh-border-2); color: var(--sh-text); cursor: pointer;
    transition: background-color .2s, border-color .2s, color .2s, transform .3s var(--sh-spring);
}
.bk-chip:active { transform: scale(.95); }
.bk-chip[aria-pressed="true"], .bk-chip.is-active { background: var(--sh-grad); border-color: transparent; color: #fff; }

/* [data-reveal] gentle entrance */
[data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--sh-ease), transform .8s var(--sh-ease); }
[data-reveal].is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { [data-reveal] { opacity: 1; transform: none; } }

/* ------------------------------------------------------------
   9. FOOTER
   ------------------------------------------------------------ */
footer.site-footer { padding: clamp(44px, 6vw, 80px) var(--gutter) 28px !important; }
.site-footer .footer-content { max-width: 1240px; margin: 0 auto; display: grid !important; grid-template-columns: minmax(240px, 1.2fr) 3fr; gap: clamp(28px, 4vw, 64px) !important; }
.site-footer .footer-links { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px !important; }
.site-footer .footer-column-title { font: 700 .75rem/1 var(--font-heading) !important; letter-spacing: .2em; text-transform: uppercase; color: var(--sh-accent) !important; margin-bottom: 12px !important; }
.site-footer .footer-column-list { list-style: none; margin: 0; padding: 0; }
.site-footer .footer-column-list li { margin: 0; }
.site-footer .footer-column-list a { display: inline-flex; align-items: center; min-height: 40px; font-size: .95rem; }
.site-footer .footer-bottom { max-width: 1240px; margin: 32px auto 0 !important; padding-top: 18px !important; border-top: 1px solid var(--sh-border); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.site-footer .social-link, .site-footer .back-to-top { width: 46px; height: 46px; border-radius: 14px !important; }
@media (min-width: 768px) {
    body.has-pager .site-footer .footer-bottom { padding-bottom: 70px !important; }
    .site-footer { padding-right: calc(var(--gutter) + 50px) !important; }
}
@media (min-width: 768px) and (max-width: 1199px) { .site-footer .footer-content { grid-template-columns: 1fr; } }
@media (max-width: 767px) {
    .site-footer .footer-content { grid-template-columns: 1fr; }
    .site-footer .footer-links { grid-template-columns: 1fr 1fr; gap: 18px 14px !important; }
    .site-footer .footer-links .footer-column:last-child { grid-column: 1 / -1; }
}

/* ------------------------------------------------------------
   10. GLOBAL NICETIES
   ------------------------------------------------------------ */
[data-viewpoint], section[id] { scroll-margin-top: var(--sh-top-h); }
@media (hover: none), (pointer: coarse) { .cursor-dot { display: none !important; } }
@media (pointer: coarse) {
    input[type="checkbox"], input[type="radio"] { width: 24px; height: 24px; }
    .swiper-button-next, .swiper-button-prev { width: 44px !important; height: 44px !important; }
}
input, select, textarea { font-size: max(16px, 1em); } /* no iOS zoom on focus */

@media (prefers-reduced-motion: reduce) {
    header.topbar::after { animation: none; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
    header.topbar, .rail, .mobile-bottom-bar, .viewpoint-nav, .sheet, .sheet-scrim, .skip-link, .theme-toggle, #loading-screen, .cursor-dot { display: none !important; }
    body.shell { padding: 0 !important; }
}

/* Specificity guards: page CSS that styles every <a> must not recolour the chrome */
body .rail .tab, body .mobile-bottom-bar .mobile-bar-btn { color: var(--sh-muted); }
body .rail .tab[aria-current="page"], body .rail .tab:hover { color: var(--sh-text); }
body header.topbar .topnav a { color: var(--sh-muted); }
body header.topbar .topnav a:hover, body header.topbar .topnav a[aria-current="page"] { color: var(--sh-text); }

/* Old bunkrosnexus breakpoints used 768px for "phone"; iPad starts at 768 here */
@media (min-width: 768px) {
    .mobile-bottom-bar { display: none !important; }
    .theme-toggle { display: flex !important; }
    .viewpoint-nav { display: flex; }
}

/* The LOC/SYS huts belong to the landing page. Elsewhere they only show on
   desktop, where there is room beside the content. */
@media (max-width: 1199px) {
    body.shell:not(.section-home) .hud-container { display: none !important; }
}

/* Pages with fixed backdrops (chat, music, photos) must never paint over the footer */
footer.site-footer { position: relative; z-index: 1; background-color: var(--bg-base); }

/* Learning modules (.bk-mod, 10 pages): align their sticky rails with the shell chrome */
.bk-mod { padding-top: var(--sh-top-h) !important; }
.bk-mod .bk-left-nav { top: var(--sh-top-h) !important; }
@media (min-width: 1081px) { .bk-mod .bk-left-nav { height: calc(100vh - var(--sh-top-h)) !important; } }
.bk-mod .bk-right-inner { top: calc(var(--sh-top-h) + 24px) !important; }
.bk-mod .bk-section { scroll-margin-top: calc(var(--sh-top-h) + 24px) !important; }
@media (max-width: 1080px) { .bk-mod .bk-section { scroll-margin-top: calc(var(--sh-top-h) + 80px) !important; } }
@media (min-width: 768px) and (max-width: 1199px) { .bk-mod { padding-right: 60px; } }

/* No page may ever pan sideways (iOS ignores body overflow-x:hidden when it propagates) */
html { overflow-x: clip; }

.hud-container[data-away="true"] { opacity: 0 !important; transform: translateY(12px); pointer-events: none; }
/* Friends + Members gates: clear the fixed chrome, centre in the viewport */
.friends-stage { padding-top: calc(var(--sh-top-h) + 28px) !important; min-height: 100svh; box-sizing: border-box; }
@media (min-width: 768px) and (max-width: 1199px) { .friends-stage { padding-right: 76px !important; } }
/* Above Ground: hero copy stays readable over photos */
[data-theme="light"] .hero-subtitle { color: #1a1816 !important; font-weight: 500; text-shadow: 0 0 18px rgba(255,255,255,.95), 0 0 4px rgba(255,255,255,.9); }
[data-theme="light"] .hero-overlay { background: linear-gradient(180deg, rgba(250,248,245,.55) 0%, rgba(250,248,245,.45) 45%, rgba(250,248,245,.9) 100%) !important; }
[data-theme="light"] .hero-subtitle { opacity: 1 !important; background: rgba(250,248,245,.78); border-radius: 14px; padding: .6rem .9rem; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
