/**
 * BattlePals site layout: safe area, iPhone Duo status rail, size classes and
 * the floating-widget dock. Spec: docs/IPHONE_DUO_DESIGN.md.
 *
 * Loaded by header.php, which also tags <html class="bp-site">; every rule is
 * scoped to html.bp-site so full-screen battle clients that share widget code
 * (battle/exploration) are untouched.
 *
 * Inputs (all optional, with fallbacks so pages without duo-head.php work):
 *   --rsat/--rsar/--rsab/--rsal  raw safe-area insets (js/duo-layout.js)
 *   --ctl/--ctr/--cbl/--cbr      keep-out box width per corner (js/duo-layout.js)
 *   --ph                         page height in px (js/duo-layout.js)
 *   --bp-nav-h / --bp-xp-h       nav + exp bar heights (js/mobile-nav.js)
 *
 * Size classes used here as media queries (same breakpoints as duo-layout.js):
 *   compact = cover sideways (landscape, h<=500) or cover upright (portrait, w<=560)
 *             — also ordinary phones in either orientation.
 *   roomy   = everything else up to 1024px wide (Duo inner screen both ways, iPad portrait).
 */

html.bp-site {
    /* HUD insets: 0 on the status-rail side, so the rail is usable. */
    --bp-t: var(--sat, env(safe-area-inset-top, 0px));
    --bp-b: var(--sab, env(safe-area-inset-bottom, 0px));
    --bp-sl: var(--sal, env(safe-area-inset-left, 0px));
    --bp-sr: var(--sar, env(safe-area-inset-right, 0px));
    /* Side clearance per band: only the keep-out box (dead zone) is avoided.
       lt/rt = top band, lb/rb = bottom band, lf/rf = full height. */
    --bp-lt: max(var(--bp-sl), var(--ctl, 0px));
    --bp-rt: max(var(--bp-sr), var(--ctr, 0px));
    --bp-lb: max(var(--bp-sl), var(--cbl, 0px));
    --bp-rb: max(var(--bp-sr), var(--cbr, 0px));
    --bp-lf: max(var(--bp-sl), var(--ctl, 0px), var(--cbl, 0px));
    --bp-rf: max(var(--bp-sr), var(--ctr, 0px), var(--cbr, 0px));
    --bp-hub: 44px;                         /* widget hub toggle */
    --bp-chip: 44px;                        /* minimized widget chip (compact sizes) */
    --bp-dock-b: calc(var(--bp-xp-h, 26px) + var(--bp-b) + 6px);
    --bp-under-nav: calc(var(--bp-t) + var(--bp-nav-h, 60px) + 8px);
    --bp-vh: var(--ph, 100vh);              /* page height; never trust 100vh on iOS */
    --bp-sticky-top: var(--bp-t);           /* where page-level sticky headers stick */
    --bp-panel-max: calc(var(--bp-vh) - var(--bp-under-nav) - var(--bp-xp-h, 26px) - var(--bp-b) - 8px);

    /* Page content runs into the status rail but never passes under the
       keep-out box: the scrolling column is padded by the box width on the
       box's side (full height, since content scrolls through every band).
       The nav row uses the rail where the box isn't (see below).
       Padding on <html> so per-page body padding survives. */
    padding-top: var(--bp-t);
    padding-left: var(--bp-lf);
    padding-right: var(--bp-rf);
    box-sizing: border-box;
    background-color: #000;
}

/* Inner screen upright: the rail runs across the top and the box is short
   (rail + 4px): the nav steps around it, the page doesn't. */
html.bp-site.rail-top {
    padding-right: var(--bp-sr);
}
html.bp-site.rail-top { --bp-sticky-top: var(--bp-nav-h, 85px); }
html.bp-site.rail-top .main-navigation {
    /* Sticky and opaque so page content scrolls under the bar, never into
       the box that shares its band. */
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #161616;
}
html.bp-site.rail-top .main-navigation {
    min-height: var(--cut-h, 0px);
}
html.bp-site.rail-top .nav-container {
    padding-right: calc(8px + var(--ctr, 0px)) !important;
}

/* Top rail on a page without a nav bar (landing, character forge): an opaque
   band the height of the box covers the rail; the page starts below it and
   scrolls under it (js/site-layout.js adds the element). */
html.bp-site.bp-topband {
    padding-top: var(--cut-h, 0px);
}
html.bp-site #bpTopBand {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--cut-h, 0px);
    background: #000;
    z-index: 2147482000;
}

/* Bezel patch: black over the top inset strip and the keep-out box (belt and
   braces; layout already keeps everything out of the box). Each box layer is
   0 wide unless the box is in that corner. */
html.bp-site::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2147483000;
    background:
        linear-gradient(#000, #000) left top / 100% var(--bp-t) no-repeat,
        linear-gradient(#000, #000) left top / var(--ctl, 0px) var(--cut-h, 0px) no-repeat,
        linear-gradient(#000, #000) right top / var(--ctr, 0px) var(--cut-h, 0px) no-repeat,
        linear-gradient(#000, #000) left bottom / var(--cbl, 0px) var(--cut-h, 0px) no-repeat,
        linear-gradient(#000, #000) right bottom / var(--cbr, 0px) var(--cut-h, 0px) no-repeat;
}

/* ---- Exp bar + footer (fixed at the bottom on touch sizes, mobile.css) ---- */
/* The bar runs into the rail and stops only at a keep-out box at the bottom. */
html.bp-site .exp-bar-cont {
    left: var(--bp-lb) !important;
    right: var(--bp-rb) !important;
    width: auto !important;
    padding-bottom: calc(3px + var(--bp-b)) !important;
}
html.bp-site footer {
    bottom: calc(5px + var(--bp-b));
    right: calc(20px + var(--bp-rb));
}
@media (max-width: 1024px) {
    html.bp-site footer {
        right: calc(8px + var(--bp-rb)) !important;
        bottom: var(--bp-b) !important;
    }
    html.bp-site wrapper {
        padding-bottom: calc(50px + var(--bp-b)) !important;
    }
    /* Exp track: leave the left end for the audio dot and the right end for
       the version label instead of running underneath it. */
    html.bp-site .exp-bar-cont .exp-bar {
        width: auto !important;
        max-width: 800px;
        margin: 0 118px 0 28px !important;
    }
}

/* Audio status dot (audio-init.js, inline-styled bottom-right): move it to
   the empty left end of the exp bar, clear of the version label, the rail
   and the keep-out box. */
html.bp-site #audioStatusIndicator {
    right: auto !important;
    left: calc(var(--bp-lb) + 8px) !important;
    bottom: calc(var(--bp-b) + 8px) !important;
}

/* =====================================================================
   Floating widget dock
   Minimized widgets: chat bottom-left; social + hub bottom-right;
   quests top-right under the nav. Positions here are not !important on
   desktop so a widget the player dragged keeps its spot.
   ===================================================================== */

html.bp-site #mobileWidgetHub {
    bottom: var(--bp-dock-b) !important;
    right: calc(var(--bp-rb) + 8px) !important;
}
html.bp-site #mobileWidgetHub .widget-hub-toggle {
    width: var(--bp-hub) !important;
    height: var(--bp-hub) !important;
    min-width: 0 !important;   /* page button rules (guild.css) widened it */
    min-height: 0 !important;
    padding: 0 !important;
}
html.bp-site #mobileWidgetHub .widget-hub-menu {
    box-sizing: border-box;
    max-height: calc(var(--bp-vh) - var(--bp-dock-b) - var(--bp-hub) - var(--bp-t) - 24px) !important;
    max-width: calc(100vw - var(--bp-lf) - var(--bp-rf) - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
}
html.bp-site #mobileWidgetHub .widget-hub-item {
    /* grid tiles (mobile-widget-hub.js): fill the column, never below a 44px tap target */
    min-width: 44px;
    min-height: 44px !important;
}
/* readable labels (were 7-9px) */
html.bp-site #mobileWidgetHub .widget-hub-group-label { font-size: 10px !important; }
html.bp-site #mobileWidgetHub .whi-label { font-size: 9.5px; opacity: 0.8; }

/* Keybindings modal (css/keybindings-modal.css, shared with the game): on the
   site the dialog sits inside the safe page — clear of the rail notch and
   the side bar — never taller than the screen, its list scrolling inside,
   and the close button a full tap target. */
html.bp-site .keybindings-modal-overlay,
html.bp-site .sw-modal-overlay,
html.bp-site .modal-overlay {
    box-sizing: border-box;
    padding: calc(var(--bp-t) + 8px) calc(var(--bp-rf) + 8px) calc(var(--bp-b) + 8px) calc(var(--bp-lf) + 8px);
    align-items: center;
    justify-content: center;
}
html.bp-site .keybindings-modal {
    width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}
html.bp-site .keybindings-modal-header { flex: 0 0 auto; padding-right: 56px; }
html.bp-site .keybindings-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
}
html.bp-site .keybindings-modal-close {
    top: 6px;
    right: 6px;
    width: 44px;
    height: 44px;
}
html.bp-site .sw-modal-overlay .sw-modal {
    width: 100%;
    max-height: 100%;
}
/* the buttons (Send / Cancel / OK) stay in view while the body scrolls */
html.bp-site .sw-modal-overlay .sw-modal-actions {
    position: sticky;
    bottom: -25px;      /* the dialog's own bottom padding */
    margin-bottom: -25px;
    padding: 10px 0 25px;
    background: linear-gradient(180deg, rgba(50, 50, 50, 0), rgba(45, 45, 45, 0.97) 30%);
}
@media (max-height: 500px), (max-width: 560px) {
    html.bp-site .sw-modal-overlay .sw-modal { padding: 14px; }
    html.bp-site .sw-modal-header { font-size: 17px; margin-bottom: 8px; padding-bottom: 6px; }
    html.bp-site .sw-modal-actions { margin-top: 10px; }
    html.bp-site .sw-modal-overlay .sw-modal-actions { bottom: -14px; margin-bottom: -14px; padding-bottom: 14px; }
    html.bp-site .keybindings-modal-header { padding: 8px 56px 8px 12px; }
    html.bp-site .keybindings-modal-title { font-size: 18px; }
    html.bp-site .keybindings-modal-subtitle { font-size: 12px; margin-top: 2px; }
    html.bp-site .keybindings-modal-body { padding: 10px; }
}

/* Desktop / iPad landscape: keep the original look, just clear the exp bar
   and the hub toggle. */
html.bp-site #social-widget {
    bottom: var(--bp-dock-b);
    right: calc(var(--bp-rb) + 8px + var(--bp-hub) + 10px);
}
html.bp-site #quest-widget.top-right {
    top: var(--bp-under-nav);
    right: calc(var(--bp-rt) + 20px);
}
/* Long dropdowns (Character) scroll instead of running off short screens. */
html.bp-site .nav-dropdown {
    max-height: calc(var(--bp-vh) - var(--bp-nav-h, 70px) - var(--bp-t) - max(var(--bp-b), var(--bp-box-bot-h, 0px)) - 12px);
    overflow-y: auto;
    overscroll-behavior: contain;
}
html.bp-site #global-chat-widget.minimized {
    bottom: var(--bp-dock-b);
    left: calc(var(--bp-lb) + 8px);
}

/* Toasts / notices: under the nav, inside the safe area, clear of the
   keep-out box. */
html.bp-site .bp-toast-container.top-right { top: var(--bp-under-nav); right: var(--bp-rt); }
html.bp-site .bp-toast-container.top-left { top: var(--bp-under-nav); left: var(--bp-lt); }
html.bp-site .bp-toast-container.top-center { top: var(--bp-under-nav); }
html.bp-site .bp-toast-container.bottom-right { bottom: calc(var(--bp-dock-b) + var(--bp-hub) + 4px); right: var(--bp-rb); }
html.bp-site .bp-toast-container.bottom-left { bottom: calc(var(--bp-dock-b) + var(--bp-hub) + 4px); left: var(--bp-lb); }
html.bp-site .bp-toast-container.bottom-center { bottom: calc(var(--bp-dock-b) + var(--bp-hub) + 4px); }
html.bp-site .bp-toast-container { max-width: min(380px, calc(100vw - var(--bp-lf) - var(--bp-rf))); }
html.bp-site .bp-notify-minor { right: calc(var(--bp-rb) + 12px) !important; bottom: calc(var(--bp-dock-b) + var(--bp-hub) + 8px) !important; }

/* Achievements panel (AchievementsWidget.js): under the nav, inside the safe area. */
html.bp-site .achievements-widget {
    top: var(--bp-under-nav);
    right: calc(var(--bp-rf) + 8px);
    max-width: calc(100vw - var(--bp-lf) - var(--bp-rf) - 16px) !important;
    max-height: calc(var(--bp-vh) - var(--bp-under-nav) - var(--bp-dock-b) - 8px);
}

/* ---------- Touch sizes up to 1024px wide ---------- */
@media (max-width: 1024px), (max-height: 700px) and (orientation: landscape) {
    html.bp-site .social-widget .control-btn,
    html.bp-site .global-chat-widget .control-btn,
    html.bp-site .quest-widget .control-btn {
        width: 40px !important;
        height: 40px !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }

    /* Minimized pills: one height, one row each, text truncates. */
    html.bp-site #social-widget.minimized,
    html.bp-site #global-chat-widget.minimized,
    html.bp-site #quest-widget.minimized {
        height: var(--bp-chip) !important;
        min-height: 0 !important;
        max-height: var(--bp-chip) !important;
        min-width: 0 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        top: auto !important;
        transform: none !important;
        resize: none !important;
    }
    html.bp-site #social-widget.minimized .social-header,
    html.bp-site #global-chat-widget.minimized .chat-header,
    html.bp-site #quest-widget.minimized .qw-header {
        height: 100% !important;
        min-height: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        box-sizing: border-box;
        display: flex !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        cursor: pointer !important;
    }
    html.bp-site #social-widget.minimized .social-title,
    html.bp-site #global-chat-widget.minimized .chat-title,
    html.bp-site #quest-widget.minimized .qw-title {
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    html.bp-site #global-chat-widget.minimized .chat-content {
        display: none !important;
    }

    /* Pills (roomy sizes): chat left, social left of the hub, quests top-right. */
    html.bp-site #global-chat-widget.minimized {
        left: calc(var(--bp-lb) + 8px) !important;
        right: auto !important;
        bottom: var(--bp-dock-b) !important;
        width: min(250px, calc((100vw - var(--bp-lb) - var(--bp-rb) - var(--bp-hub) - 42px) / 2)) !important;
        max-width: none !important;
    }
    html.bp-site #social-widget.minimized {
        left: auto !important;
        right: calc(var(--bp-rb) + 8px + var(--bp-hub) + 10px) !important;
        bottom: var(--bp-dock-b) !important;
        width: min(250px, calc((100vw - var(--bp-lb) - var(--bp-rb) - var(--bp-hub) - 42px) / 2)) !important;
        max-width: none !important;
    }
    html.bp-site #quest-widget.minimized {
        top: var(--bp-under-nav) !important;
        bottom: auto !important;
        left: auto !important;
        right: calc(var(--bp-rt) + 8px) !important;
        width: min(250px, calc(100vw - var(--bp-lt) - var(--bp-rt) - 16px)) !important;
        max-width: none !important;
    }

    /* Expanded panels stay on screen: inside the safe area, between the nav
       and the dock, scrolling inside. */
    html.bp-site #social-widget:not(.minimized),
    html.bp-site #global-chat-widget:not(.minimized),
    html.bp-site #quest-widget:not(.minimized) {
        width: min(380px, calc(100vw - var(--bp-lf) - var(--bp-rf) - 16px)) !important;
        max-width: none !important;
        min-width: 0 !important;
        max-height: calc(var(--bp-vh) - var(--bp-t) - var(--bp-dock-b) - 16px) !important;
        box-sizing: border-box !important;
    }
    html.bp-site #global-chat-widget:not(.minimized) {
        left: calc(var(--bp-lf) + 8px) !important;
        right: auto !important;
        bottom: var(--bp-dock-b) !important;
        height: min(480px, calc(var(--bp-vh) - var(--bp-t) - var(--bp-dock-b) - 16px)) !important;
    }
    html.bp-site #social-widget:not(.minimized) {
        left: auto !important;
        right: calc(var(--bp-rf) + 8px + var(--bp-hub) + 10px) !important;
        bottom: var(--bp-dock-b) !important;
        width: min(380px, calc(100vw - var(--bp-lf) - var(--bp-rf) - var(--bp-hub) - 34px)) !important;
    }
    html.bp-site #quest-widget:not(.minimized) {
        top: var(--bp-under-nav) !important;
        bottom: auto !important;
        left: auto !important;
        right: calc(var(--bp-rf) + 8px) !important;
        max-height: calc(var(--bp-vh) - var(--bp-under-nav) - var(--bp-dock-b) - 8px) !important;
        overflow-y: auto !important;
    }

    /* Generic dialogs: never taller or wider than the safe page. */
    html.bp-site .modal-content,
    html.bp-site .modal-dialog,
    html.bp-site .sw-modal,
    html.bp-site .dialog,
    html.bp-site .popup {
        max-height: calc(var(--bp-vh) - var(--bp-t) - var(--bp-b) - 16px);
        max-width: calc(100vw - var(--bp-lf) - var(--bp-rf) - 16px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ---------- Compact sizes: Duo cover screen both ways, phones ----------
   The nav becomes a sticky one-line top bar: hamburger on the left, and
   on the right the minimized widgets as 44px icon chips plus the widget-hub
   toggle (left of the rail and keep-out box). Nothing floats over the page
   at the bottom except the exp bar. Tapping a chip expands it; expanded
   panels drop down full-width under the bar. */
@media (orientation: landscape) and (max-height: 500px), (orientation: portrait) and (max-width: 560px) {
    html.bp-site {
        --bp-chip-top: calc(var(--bp-t) + (var(--bp-nav-h, 55px) - var(--bp-chip)) / 2);
        --bp-sticky-top: calc(var(--bp-t) + var(--bp-nav-h, 55px));
        /* room the chips + hub take at the right end of the bar */
        --bp-chip-strip: calc(4 * (var(--bp-chip) + 8px) + 8px);
    }
    html.bp-site .main-navigation {
        position: sticky;
        top: var(--bp-t);
        z-index: 1000;
        background-color: #161616; /* opaque under the translucent gradient */
    }
    html.bp-site .main-navigation .nav-container {
        min-height: 52px;
    }
    /* Inline row (when it fits) must stop short of the chips. */
    html.bp-site .main-navigation:not(.nav-fold) .nav-container {
        padding-right: var(--bp-chip-strip) !important;
    }

    html.bp-site #mobileWidgetHub {
        top: var(--bp-chip-top) !important;
        bottom: auto !important;
    }
    html.bp-site #mobileWidgetHub .widget-hub-menu {
        top: calc(var(--bp-chip) + 8px) !important;
        bottom: auto !important;
        /* hub sits at the rail edge; keep the menu clear of a bottom box */
        right: max(0px, calc(var(--cbr, 0px) - var(--bp-rt))) !important;
        max-height: var(--bp-panel-max) !important;
    }
    html.bp-site #mobileWidgetHub { right: calc(var(--bp-rt) + 8px) !important; }

    html.bp-site #social-widget.minimized,
    html.bp-site #global-chat-widget.minimized,
    html.bp-site #quest-widget.minimized {
        left: auto !important;
        top: var(--bp-chip-top) !important;
        bottom: auto !important;
    }
    html.bp-site #social-widget.minimized { right: calc(var(--bp-rt) + 8px + 1 * (var(--bp-hub) + 8px)) !important; }
    html.bp-site #global-chat-widget.minimized { right: calc(var(--bp-rt) + 8px + 2 * (var(--bp-hub) + 8px)) !important; }
    html.bp-site #quest-widget.minimized { right: calc(var(--bp-rt) + 8px + 3 * (var(--bp-hub) + 8px)) !important; }

    /* Expanded: full width, dropping down under the top bar. */
    html.bp-site #social-widget:not(.minimized),
    html.bp-site #global-chat-widget:not(.minimized),
    html.bp-site #quest-widget:not(.minimized) {
        left: calc(var(--bp-lf) + 8px) !important;
        right: calc(var(--bp-rf) + 8px) !important;
        top: var(--bp-under-nav) !important;
        bottom: auto !important;
        width: auto !important;
        max-height: var(--bp-panel-max) !important;
        transform: none !important;
    }
    html.bp-site #global-chat-widget:not(.minimized) {
        height: min(420px, var(--bp-panel-max)) !important;
    }
}

/* =====================================================================
   Widget chips (html.bp-chips, set by js/site-layout.js on compact sizes
   and wherever there is a side bar): minimized widgets are 44px icon
   chips; the count is a corner badge; tapping anywhere on the chip
   expands it.
   ===================================================================== */
html.bp-site.bp-chips #social-widget.minimized,
html.bp-site.bp-chips #global-chat-widget.minimized,
html.bp-site.bp-chips #quest-widget.minimized {
    width: var(--bp-chip) !important;
    height: var(--bp-chip) !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: var(--bp-chip) !important;
    border-radius: 12px !important;
}
/* Chip contents: icon + count badge; the expand button covers the chip. */
html.bp-site.bp-chips #social-widget.minimized .social-header,
html.bp-site.bp-chips #global-chat-widget.minimized .chat-header,
html.bp-site.bp-chips #quest-widget.minimized .qw-header {
    position: relative;
    justify-content: center !important;
    padding: 0 !important;
    border-radius: 10px !important;
}
html.bp-site.bp-chips #social-widget.minimized .social-text,
html.bp-site.bp-chips #social-widget.minimized .close-btn,
html.bp-site.bp-chips #global-chat-widget.minimized .chat-text,
html.bp-site.bp-chips #global-chat-widget.minimized .chat-settings-btn,
html.bp-site.bp-chips #global-chat-widget.minimized .close-btn,
html.bp-site.bp-chips #quest-widget.minimized .qw-text,
html.bp-site.bp-chips #quest-widget.minimized .qw-close-btn {
    display: none !important;
}
html.bp-site.bp-chips #social-widget.minimized .social-title,
html.bp-site.bp-chips #global-chat-widget.minimized .chat-title,
html.bp-site.bp-chips #quest-widget.minimized .qw-title {
    margin: 0 !important;
    font-size: 20px;
    overflow: visible;
}
html.bp-site.bp-chips #social-widget.minimized .social-icon,
html.bp-site.bp-chips #global-chat-widget.minimized .chat-icon,
html.bp-site.bp-chips #quest-widget.minimized .qw-icon {
    margin: 0 !important;
    font-size: 20px !important;
}
html.bp-site.bp-chips #social-widget.minimized .social-controls,
html.bp-site.bp-chips #global-chat-widget.minimized .chat-controls,
html.bp-site.bp-chips #quest-widget.minimized .qw-controls {
    position: absolute !important;
    inset: 0;
    margin: 0 !important;
    gap: 0 !important;
}
html.bp-site.bp-chips #social-widget.minimized .toggle-btn,
html.bp-site.bp-chips #global-chat-widget.minimized .toggle-btn,
html.bp-site.bp-chips #quest-widget.minimized .qw-toggle-btn {
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    opacity: 0;
    z-index: 2;
}
/* Counts as a corner badge */
html.bp-site.bp-chips #social-widget.minimized .friends-count,
html.bp-site.bp-chips #social-widget.minimized .notifications-badge,
html.bp-site.bp-chips #social-widget.minimized .pending-badge,
html.bp-site.bp-chips #global-chat-widget.minimized .unread-badge,
html.bp-site.bp-chips #quest-widget.minimized .qw-count {
    position: absolute !important;
    top: 2px;
    right: 2px;
    margin: 0 !important;
    min-width: 16px;
    height: 16px;
    padding: 0 4px !important;
    font-size: 10px !important;
    line-height: 16px !important;
    border-radius: 8px;
    box-sizing: border-box;
    z-index: 1;
}
html.bp-site.bp-chips #global-chat-widget.minimized .chat-status-dot {
    position: absolute !important;
    left: 4px;
    bottom: 4px;
    margin: 0 !important;
}


/* =====================================================================
   Side bar (html.bp-side-l / bp-side-r): the keep-out box is on a left or
   right edge. The page column stops at the box width on that edge
   (content scrolls through every band, so it can't share the edge), and
   the edge becomes a deliberate side bar: #bpRailStrip paints it in the
   nav colour with a frame line, the box is a black notch at one end
   (bezel patch above), and the hub + chips stand in it as a column below
   or above the notch. Panels open beside the bar.
   ===================================================================== */
/* The side bar owns its whole edge: everything else docks beside it. */
html.bp-site.bp-side-l { --bp-lt: var(--bp-lf); --bp-lb: var(--bp-lf); }
html.bp-site.bp-side-r { --bp-rt: var(--bp-rf); --bp-rb: var(--bp-rf); }

html.bp-site #bpRailStrip {
    position: fixed;
    /* stops at the notch; the bezel patch paints the notch itself black */
    top: var(--bp-col-top, 0px);
    bottom: var(--bp-box-bot-h, 0px);
    z-index: 40;   /* under the nav dropdowns, exp bar (50) and widgets */
    background:
        linear-gradient(180deg, rgba(40, 40, 40, 0.9), rgba(20, 20, 20, 0.95)),
        #161616;
}
html.bp-site.bp-side-r #bpRailStrip {
    right: 0;
    width: var(--bp-rf);
    box-shadow: inset 3px 0 0 #8B4513;
}
html.bp-site.bp-side-l #bpRailStrip {
    left: 0;
    width: var(--bp-lf);
    box-shadow: inset -3px 0 0 #8B4513;
}

/* No chip strip needed in the top bar: the chips live in the side bar. */
html.bp-site.bp-side-r .main-navigation:not(.nav-fold) .nav-container,
html.bp-site.bp-side-l .main-navigation:not(.nav-fold) .nav-container {
    padding-right: 8px !important;
}

html.bp-site.bp-side-r #mobileWidgetHub,
html.bp-site.bp-side-r #social-widget.minimized,
html.bp-site.bp-side-r #global-chat-widget.minimized,
html.bp-site.bp-side-r #quest-widget.minimized {
    right: max(2px, calc((var(--bp-rf) - var(--bp-chip)) / 2)) !important;
    left: auto !important;
    bottom: auto !important;
    transform: none !important;
}
html.bp-site.bp-side-l #mobileWidgetHub,
html.bp-site.bp-side-l #social-widget.minimized,
html.bp-site.bp-side-l #global-chat-widget.minimized,
html.bp-site.bp-side-l #quest-widget.minimized {
    left: max(2px, calc((var(--bp-lf) - var(--bp-chip)) / 2)) !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
}
html.bp-site.bp-side-r #mobileWidgetHub, html.bp-site.bp-side-l #mobileWidgetHub {
    top: calc(var(--bp-col-top, var(--bp-t)) + 8px) !important;
}
html.bp-site.bp-side-r #social-widget.minimized, html.bp-site.bp-side-l #social-widget.minimized {
    top: calc(var(--bp-col-top, var(--bp-t)) + 8px + 1 * (var(--bp-chip) + 8px)) !important;
}
html.bp-site.bp-side-r #global-chat-widget.minimized, html.bp-site.bp-side-l #global-chat-widget.minimized {
    top: calc(var(--bp-col-top, var(--bp-t)) + 8px + 2 * (var(--bp-chip) + 8px)) !important;
}
html.bp-site.bp-side-r #quest-widget.minimized, html.bp-site.bp-side-l #quest-widget.minimized {
    top: calc(var(--bp-col-top, var(--bp-t)) + 8px + 3 * (var(--bp-chip) + 8px)) !important;
}

html.bp-site.bp-side-r #mobileWidgetHub .widget-hub-menu,
html.bp-site.bp-side-l #mobileWidgetHub .widget-hub-menu {
    top: 0 !important;
    bottom: auto !important;
    max-height: calc(var(--bp-vh) - var(--bp-col-top, var(--bp-t)) - 16px - var(--bp-xp-h, 26px) - var(--bp-b)) !important;
}
/* opens beside the bar, clear of its whole width (and so of the notch) */
html.bp-site.bp-side-r #mobileWidgetHub .widget-hub-menu {
    right: calc((var(--bp-rf) + var(--bp-chip)) / 2 + 8px) !important;
    left: auto !important;
}
html.bp-site.bp-side-l #mobileWidgetHub .widget-hub-menu {
    left: calc((var(--bp-lf) + var(--bp-chip)) / 2 + 8px) !important;
    right: auto !important;
}

/* Expanded widgets open beside the side bar, under the nav. */
html.bp-site.bp-side-r #social-widget:not(.minimized),
html.bp-site.bp-side-r #global-chat-widget:not(.minimized),
html.bp-site.bp-side-r #quest-widget:not(.minimized),
html.bp-site.bp-side-l #social-widget:not(.minimized),
html.bp-site.bp-side-l #global-chat-widget:not(.minimized),
html.bp-site.bp-side-l #quest-widget:not(.minimized) {
    top: var(--bp-under-nav) !important;
    bottom: auto !important;
    width: min(420px, calc(100vw - var(--bp-lf) - var(--bp-rf) - 16px)) !important;
    max-width: none !important;
    min-width: 0 !important;
    max-height: var(--bp-panel-max) !important;
    transform: none !important;
    box-sizing: border-box !important;
}
html.bp-site.bp-side-r #social-widget:not(.minimized),
html.bp-site.bp-side-r #global-chat-widget:not(.minimized),
html.bp-site.bp-side-r #quest-widget:not(.minimized) {
    right: calc(var(--bp-rf) + 8px) !important;
    left: auto !important;
}
html.bp-site.bp-side-l #social-widget:not(.minimized),
html.bp-site.bp-side-l #global-chat-widget:not(.minimized),
html.bp-site.bp-side-l #quest-widget:not(.minimized) {
    left: calc(var(--bp-lf) + 8px) !important;
    right: auto !important;
}
html.bp-site.bp-side-r #global-chat-widget:not(.minimized),
html.bp-site.bp-side-l #global-chat-widget:not(.minimized) {
    height: min(480px, var(--bp-panel-max)) !important;
}

/* Music player (MusicControlPanel.js, draggable, inline-positioned): on touch
   sizes it docks under the nav beside the side bar, sized to the free area. */
@media (max-width: 1024px), (max-height: 700px) and (orientation: landscape) {
    html.bp-site #musicControlPanel {
        top: var(--bp-under-nav) !important;
        left: auto !important;
        right: calc(var(--bp-rf) + 8px) !important;
        max-width: calc(100vw - var(--bp-lf) - var(--bp-rf) - 16px) !important;
        min-width: 0 !important;
        max-height: var(--bp-panel-max) !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }
}

/* Achievements: below 540px wide the widget turns into a full-screen sheet
   (AchievementsWidget.js). Keep that, but inside the safe page and clear of
   the keep-out box / side bar. */
@media (max-width: 540px) {
    html.bp-site .achievements-widget {
        top: var(--bp-t) !important;
        bottom: var(--bp-b) !important;
        left: var(--bp-lf) !important;
        right: var(--bp-rf) !important;
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
    }
}
