/* ============================================================================
   MOBILE SHELL — authoritative mobile chrome. Loads LAST so it wins.
   Owns: the mobile top bar (hamburger + logo + avatar), the slide-in drawer,
   and the single source of truth for top spacing (kills the double-60px gap).
   Desktop is untouched (everything is inside @media (max-width:768px) or the
   .mobile-* elements which are display:none on desktop).
   ============================================================================ */

/* Hamburger + drawer are mobile-only; hide on desktop. */
.mobile-hamburger,
.mobile-drawer,
.mobile-drawer-overlay { display: none; }

@media (max-width: 768px) {
    :root { --ms-topbar-h: 54px; }

    /* ---- Top bar: [hamburger][logo] .......... [avatar] -------------------- */
    .app-header {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        height: calc(var(--ms-topbar-h) + env(safe-area-inset-top, 0px)) !important;
        padding: env(safe-area-inset-top, 0px) 0.75rem 0 0.75rem !important;
        padding-right: 6rem !important; /* room for the pinned bell + hamburger on the right */
        gap: 0.5rem !important;
    }
    .app-header-left {
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem !important;
        min-width: 0;
    }

    .mobile-hamburger {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 40px; height: 40px;
        flex-shrink: 0;
        background: transparent;
        border: none;
        border-radius: 10px;
        color: #fff;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        position: absolute !important;
        right: 0.5rem !important;
        top: calc(env(safe-area-inset-top, 0px) + (var(--ms-topbar-h, 54px) / 2)) !important;
        transform: translateY(-50%) !important;
        z-index: 4 !important;
    }
    .mobile-hamburger:active { background: rgba(255,255,255,0.08); }

    /* Logo: top-LEFT. The hamburger now lives at the right end of the header. */
    .app-header { position: relative !important; }
    .app-header .app-logo {
        position: static !important;
        transform: none !important;
        min-width: 0;
        max-width: 60%;
        display: flex; align-items: center; justify-content: flex-start;
        pointer-events: auto;
    }
    .app-header .logo-text { font-size: 1.05rem !important; white-space: nowrap; }
    .app-header .logo-tagline { display: none !important; }
    .app-header .header-org-logo { max-height: 30px !important; }

    /* Avatar top-right — un-hide (a patch file hides .app-header-right on mobile) */
    .app-header-right {
        display: flex !important;
        align-items: center;
        flex-shrink: 0;
    }
    .app-header-right .profile-nav {
        display: inline-flex !important;
        align-items: center; justify-content: center;
        width: 40px; height: 40px; padding: 0 !important;
        background: transparent; border: none; cursor: pointer;
    }
    .app-header-right .header-profile-img {
        width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
        border: 1.5px solid var(--gold, #c8a03c);
    }
    .app-header-right .profile-avatar {
        width: 34px; height: 34px; border-radius: 50%;
        display: inline-flex; align-items: center; justify-content: center;
        background: var(--gold, #c8a03c); color: #0a1628; font-weight: 700; font-size: 0.95rem;
    }

    /* ---- Top spacing: SINGLE source of truth (kills the double-60px gap) ----
       The header is fixed; content clears exactly one header height. We zero the
       container padding and the per-page top paddings that older patches set. */
    /* Higher specificity (#app > .app-container) to beat the patch's `#app > div`. */
    #app > .app-container,
    .app-container { padding-top: 0 !important; }
    /* The header is position:relative (in normal flow), so #page-content must NOT also
       reserve a header-height of top padding — that was the gap. Zero it. */
    #page-content,
    main#page-content {
        padding-top: 0 !important;
    }
    /* Trim each page's own header top padding too. */
    .page-header { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
    .dashboard-page,
    .nutrition-page,
    .training-page,
    .rehab-page,
    .assessment-page,
    .timetable-page,
    .profile-page,
    .coach-page {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* ---- Bottom spacing: SINGLE source of truth (kills the dead footer strip)
       No bottom nav is rendered. Older patches floated the footer 60px up and
       padded content 95px to clear a nav that does not exist, leaving a 3-5cm
       dead strip below the footer. Pin the footer flush to the bottom (its own
       padding already adds the home-indicator inset) and clear content by just
       the footer height, not a phantom 60px nav. */
    .app-footer { bottom: 0 !important; }
    #page-content,
    main#page-content {
        padding-bottom: calc(2.75rem + env(safe-area-inset-bottom, 0px)) !important;
    }
    /* Inner page wrappers must NOT also reserve nav space, or it stacks. */
    .dashboard-page,
    .nutrition-page,
    .training-page,
    .rehab-page,
    .assessment-page,
    .timetable-page,
    .profile-page,
    .coach-page,
    .community-page,
    .page,
    .page-content,
    .main-content {
        padding-bottom: 0 !important;
    }
    /* Community fills to just above the footer, not 60px+footer. */
    .dc-layout {
        bottom: calc(2.25rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* ---- Slide-in drawer ---------------------------------------------------- */
    .mobile-drawer-overlay {
        display: block;
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.5);
        opacity: 0; pointer-events: none;
        transition: opacity 0.25s ease;
        z-index: 1400;
    }
    .mobile-drawer-overlay.open { opacity: 1; pointer-events: auto; }

    .mobile-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0; bottom: 0; right: 0;
        width: min(82vw, 320px);
        background: #0d1424;
        border-left: 1px solid rgba(255,255,255,0.08);
        transform: translateX(100%);
        transition: transform 0.32s cubic-bezier(.32,.72,0,1);
        z-index: 1401;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: -4px 0 32px rgba(0,0,0,0.4);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .mobile-drawer.open { transform: translateX(0); }

    .md-userbar {
        display: flex; align-items: center; gap: 0.75rem;
        padding: 1.1rem 1.1rem;
        border-bottom: 1px solid rgba(255,255,255,0.08);
        cursor: pointer;
    }
    .md-avatar, .md-avatar-img {
        width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
    }
    .md-avatar {
        display: inline-flex; align-items: center; justify-content: center;
        background: var(--gold, #c8a03c); color: #0a1628; font-weight: 700; font-size: 1.1rem;
    }
    .md-avatar-img { object-fit: cover; border: 1.5px solid var(--gold, #c8a03c); }
    .md-userinfo { min-width: 0; }
    .md-username { color: #fff; font-weight: 600; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .md-userrole { color: rgba(255,255,255,0.5); font-size: 0.8rem; }

    .md-nav { display: flex; flex-direction: column; padding: 0.5rem; gap: 2px; flex: 1; }
    .md-item {
        display: flex; align-items: center; gap: 0.85rem;
        width: 100%;
        min-height: 48px;
        padding: 0 0.9rem;
        background: transparent; border: none; border-radius: 10px;
        color: rgba(255,255,255,0.82); font-size: 0.98rem; font-weight: 500;
        cursor: pointer; text-align: left;
        -webkit-tap-highlight-color: transparent;
    }
    .md-item:active { background: rgba(255,255,255,0.06); }
    .md-item.active { background: rgba(200,160,60,0.14); color: var(--gold, #c8a03c); }
    .md-item-icon { display: inline-flex; flex-shrink: 0; }
    .md-item-label { flex: 1; }
    .md-item-badge {
        background: var(--gold, #c8a03c); color: #0a1628;
        font-size: 0.7rem; font-weight: 700; min-width: 20px; height: 20px;
        border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
        padding: 0 6px;
    }
    .md-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 0.5rem 0.6rem; }

    .md-logout {
        display: flex; align-items: center; gap: 0.85rem;
        margin: 0.5rem; min-height: 48px; padding: 0 0.9rem;
        background: transparent; border: none; border-radius: 10px;
        color: #ff6b6b; font-size: 0.98rem; font-weight: 600; cursor: pointer;
        /* Pinned to the bottom of the drawer, always visible even if the nav list scrolls. */
        margin-top: auto;
        position: sticky;
        bottom: 0;
        background: #0d1424;
        border-top: 1px solid rgba(255,255,255,0.06);
    }
    .md-logout:active { background: rgba(255,107,107,0.1); }

    /* When the drawer is open, lock background scroll. */
    body.drawer-open { overflow: hidden; }

    /* When a full-screen modal/sheet is open, hide the app chrome so the sheet
       owns the screen (its own header has the close button). body.modal-open is
       toggled by mobile-shell.js. This also sidesteps the #page-content stacking
       context that would otherwise trap the modal under the header. */
    body.modal-open .app-header,
    body.modal-open .bottom-nav,
    body.modal-open .app-footer { display: none !important; }
    body.modal-open #page-content { padding-top: 0 !important; }

    /* ========================================================================
       MODAL CONTRACT — on mobile, content modals become full-screen pages.
       One rule replaces the per-file modal-sizing war. Loads after theme-pioneer
       so equal-specificity !important wins. Small confirm dialogs use a separate
       class (.pioneer-confirm-modal) and are intentionally NOT matched here.
       ======================================================================== */
    .modal-overlay,
    .modal-backdrop {
        align-items: stretch !important;
        justify-content: stretch !important;
        padding: 0 !important;
    }
    .modal-content,
    .modal-content.modal-sm,
    .modal-content.modal-md,
    .modal-content.modal-lg,
    .modal-content.modal-xl,
    .modal.modal-large,
    .food-modal-content,
    .admin-modal-content,
    .assessment-modal-content,
    .injury-modal-content,
    .rpe-modal-content,
    .post-composer-sheet,
    .ce-modern-journal,
    .chip-edit-sheet,
    /* Catch-all: ANY modal box inside an overlay goes full-screen on mobile, so
       feature modals with bespoke classes still follow the contract. Small confirm
       dialogs (.pioneer-confirm-modal) are deliberately excluded and stay centred. */
    .modal-overlay > div:not(.pioneer-confirm-modal):not(.modal-close),
    .modal-backdrop > div:not(.pioneer-confirm-modal):not(.modal-close) {
        position: fixed !important;
        inset: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        padding-top: env(safe-area-inset-top, 0px) !important;
        transform: none !important;
        /* Fallback scroll: if a modal has no inner .modal-body, the content itself
           must still scroll within the full-screen sheet rather than clip off-screen. */
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
    }
    /* The body scrolls; header/footer pin. */
    .modal-content > .modal-body,
    .modal-body,
    .admin-modal-body,
    .post-composer-sheet .pcs-body {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        max-height: none !important;
    }
    .modal-header,
    .admin-modal-header,
    .post-composer-sheet .pcs-header {
        flex: 0 0 auto !important;
        /* Keep the close control reachable even if a modal's header sits inside a
           scroll container on the full-screen sheet. */
        position: sticky !important;
        top: 0 !important;
        z-index: 5 !important;
        background: var(--navy-light, #0f1a2e) !important;
    }
    /* Footers / action bars pin to the bottom with safe-area padding. */
    .modal-footer,
    .admin-modal-footer,
    .modal-actions {
        flex: 0 0 auto !important;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ============================================================================
   LOG SCREEN — full-screen push pages for the choose-first logging flow.
   Shell styles are global (harmless on desktop); the FAB that launches them is
   mobile-only. Motion: iOS push (translateX), decelerate curve.
   ============================================================================ */
.log-screen {
    position: fixed; inset: 0;
    z-index: 3000;
    background: #0a1628;
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.34s cubic-bezier(.32,.72,0,1);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.log-screen.active { transform: translateX(0); }
.log-nav {
    flex: 0 0 auto;
    display: grid; grid-template-columns: 48px 1fr 48px; align-items: center;
    height: 52px; padding: 0 6px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.log-nav-btn {
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: none; color: #fff; cursor: pointer; border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
}
.log-nav-btn:active { background: rgba(255,255,255,0.08); }
.log-nav-title { text-align: center; font-weight: 700; color: #fff; font-size: 1.05rem; }
.log-body {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    /* !important defeats the global `* { padding: 0 }` reset in styles.css */
    padding: 1.25rem 1.1rem !important;
}
.log-actionbar {
    flex: 0 0 auto;
    padding: 0.9rem 1.1rem calc(0.9rem + env(safe-area-inset-bottom, 0px)) !important;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.log-nav { padding: 0 6px !important; }
.log-action-btn {
    width: 100%; min-height: 52px;
    border: none; border-radius: 14px;
    background: var(--gold, #c8a03c); color: #0a1628;
    font-weight: 700; font-size: 1rem; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.log-action-btn:active { transform: scale(.99); }
.log-action-btn:disabled { opacity: .5; }

/* CHOOSE grid */
.log-choose-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.log-choose-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.65rem;
    aspect-ratio: 1 / 0.82;
    background: #142238; border: 1px solid rgba(255,255,255,0.08); border-radius: 18px;
    color: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: transform .1s ease, background .15s ease;
}
.log-choose-card:active { transform: scale(.97); background: #18283f; }
.log-choose-ico {
    width: 50px; height: 50px; border-radius: 15px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(200,160,60,0.15); color: var(--gold, #c8a03c);
}
.log-choose-label { font-weight: 600; font-size: 0.98rem; }

/* Simple log form fields */
.log-field-label { display: block; color: rgba(255,255,255,0.6); font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; margin: 0 0 .55rem; }
.log-input { width: 100%; padding: 0.95rem 1rem; background: #0d1424; border: 1px solid rgba(255,255,255,0.14); border-radius: 12px; color: #fff; font-size: 1.15rem; }
.log-input:focus { outline: none; border-color: var(--gold, #c8a03c); }
.log-stepper { display: grid; grid-template-columns: 64px 1fr 64px; gap: .6rem; align-items: center; }
.log-step-btn { height: 56px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.14); background: #0d1424; color: var(--gold, #c8a03c); font-weight: 700; font-size: 1rem; cursor: pointer; }
.log-step-btn:active { background: #18283f; }
.log-water-quick { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.log-water-chip { flex: 1; min-width: 68px; padding: .75rem; border-radius: 12px; border: 1px solid rgba(255,255,255,0.14); background: #0d1424; color: #fff; cursor: pointer; font-weight: 600; }
.log-water-chip:active { background: #18283f; }
.log-textarea { width: 100%; min-height: 210px; padding: 1rem; background: #0d1424; border: 1px solid rgba(255,255,255,0.14); border-radius: 12px; color: #fff; font-size: 1rem; line-height: 1.5; resize: vertical; font-family: inherit; }
.log-textarea:focus { outline: none; border-color: var(--gold, #c8a03c); }

/* ============================================================================
   COMMUNITY top-gap fix. The community page hides the app header on mobile, but
   older patch files still offset .dc-layout / .dc-main by top:60px to clear a
   header that's no longer there → ~120px dead gap. Zero it on mobile. Scoped to
   the community page + <=900px so the desktop sidebar layout is untouched.
   (Full retirement of the competing community CSS happens in P9.)
   ============================================================================ */
@media (max-width: 900px) {
    #page-content.page-community .dc-layout,
    #page-content.page-community .dc-main {
        top: 0 !important;
    }
}

/* ============================================================================
   DAY-DETAIL responsive split: mobile = full-screen page (default in styles.css),
   WEB = centered modal card. One breakpoint, same DOM.
   ============================================================================ */
@media (min-width: 769px) {
    .day-detail-overlay {
        background: rgba(0, 0, 0, 0.6) !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 2rem !important;
    }
    .day-detail-panel {
        width: min(640px, 92vw) !important;
        height: auto !important;
        max-height: 86vh !important;
        border-radius: 18px !important;
        overflow: hidden !important;
        background: var(--navy-light, #0d1424) !important;
        box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55) !important;
    }
    /* Ensure the inner content scrolls within the card rather than overflowing it. */
    .day-detail-panel .ddp-body,
    .day-detail-panel .dv-body,
    .day-detail-panel .day-detail-body {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ============================================================================
   FULL-SCREEN CAMERA (getUserMedia). Falls back to a file picker if unavailable.
   ============================================================================ */
.cam-screen { position: fixed; inset: 0; z-index: 4000; background: #000; }
.cam-video, .cam-preview { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; object-fit: cover !important; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; transition: opacity 0.06s ease; pointer-events: none; z-index: 3; }
.cam-preview-wrap { position: absolute; inset: 0; z-index: 1; }
.cam-bar { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem; z-index: 4; }
/* Top bar: close (left) + gallery (right). Bottom bar: timer (left) / shutter (centre) / flip (right). */
.cam-bar-top, .cam-bar-bottom { justify-content: space-between; }
.cam-bar-top { top: 0; padding-top: calc(1rem + env(safe-area-inset-top, 0px)); }
.cam-bar-bottom { bottom: 0; padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); }
.cam-x, .cam-gallery { width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,0.4); border: none; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cam-timer, .cam-flip { width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.18); color: #fff; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em; display: flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; }
/* Scoped to .cam-screen (the day-log camera) so it beats social-profile's generic
   .cam-shutter without affecting the other (community/profile) camera. Force the circle. */
.cam-screen .cam-shutter { width: 72px !important; height: 72px !important; border-radius: 50% !important; background: #fff !important; border: 4px solid rgba(255,255,255,0.6) !important; cursor: pointer; transition: transform 0.1s ease; flex: 0 0 auto; padding: 0 !important; }
.cam-screen .cam-shutter:active { transform: scale(0.88); }
.cam-countdown { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; font-size: 5rem; font-weight: 800; color: #fff; text-shadow: 0 2px 24px rgba(0,0,0,0.7); z-index: 5; pointer-events: none; }
/* Recording state: shutter turns red and pulses while a video is being recorded. */
.cam-screen .cam-shutter.cam-recording { background: #e0392b !important; border-color: rgba(224,57,43,0.55) !important; animation: camRecPulse 1s ease-in-out infinite; }
@keyframes camRecPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(0.86); } }
/* Grey play-icon fix: fade the live feed in only once frames flow. */
.cam-screen .cam-video { opacity: 0; transition: opacity 0.25s ease; }
.cam-screen .cam-video.cam-ready { opacity: 1; }
/* Recording indicator: red dot + running seconds (top-centre, only while recording). */
.cam-screen .cam-rec-indicator { display: none; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; background: rgba(0,0,0,0.5); color: #fff; font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cam-screen.cam-recording .cam-rec-indicator { display: flex; }
.cam-screen .cam-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e0392b; animation: camRecBlink 1s ease-in-out infinite; }
@keyframes camRecBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
/* Self-timer cog badge + popup menu (top-right). */
.cam-screen .cam-timer { position: relative; }
.cam-screen .cam-timer-badge { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px; background: var(--gold,#c8a03c); color: #0a1628; font-size: 0.6rem; font-weight: 800; line-height: 16px; text-align: center; }
.cam-screen .cam-timer-menu { position: absolute; top: calc(62px + env(safe-area-inset-top,0px)); right: 16px; display: flex; flex-direction: column; gap: 2px; background: rgba(0,0,0,0.72); border-radius: 12px; padding: 5px; z-index: 6; }
.cam-screen .cam-timer-opt { background: transparent; border: none; color: #fff; font-size: 0.85rem; font-weight: 600; padding: 8px 18px; border-radius: 8px; cursor: pointer; }
.cam-screen .cam-timer-opt.selected { background: rgba(200,160,60,0.25); color: var(--gold,#c8a03c); }
.cam-preview-video { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; object-fit: cover !important; z-index: 1; }
.cam-retake, .cam-use { padding: 0.7rem 1.3rem; border-radius: 24px; border: none; font-weight: 700; cursor: pointer; }
.cam-retake { background: rgba(0,0,0,0.5); color: #fff; }
.cam-use { background: var(--gold, #c8a03c); color: #0a1628; }

/* FAB — mobile-only entry point to the choose-first log flow */
.log-fab { display: none; }
@media (max-width: 768px) {
    .log-fab {
        display: flex; align-items: center; justify-content: center;
        position: fixed; right: 16px;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        width: 50px; height: 50px; border-radius: 50%;
        background: var(--gold, #c8a03c); color: #0a1628; border: none;
        box-shadow: 0 6px 20px rgba(0,0,0,0.45);
        z-index: 1100; cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .log-fab:active { transform: scale(.94); }
    body.modal-open .log-fab,
    body.drawer-open .log-fab { display: none; }
}

/* ============================================================================
   ADMIN TABLES — fix the mobile card transform (data-loss bug). The table→card
   transform (styles.css) makes each row a WHITE card, but value text inherits the
   dark-theme white colour → white-on-white, so names/emails/dates vanish. Force
   dark text on the white cards. Also let wide admin tables scroll on web instead
   of clipping the right-most action buttons ("Suspend" → "uspend").
   ============================================================================ */
@media (max-width: 768px) {
    .data-table tbody td { color: #1f2937 !important; }
    .data-table tbody td strong { color: #0a1628 !important; }
    .data-table tbody td a { color: #1d4ed8 !important; }
    .data-table tbody td:before { color: #6b7280 !important; }
    /* content-size the cards so they aren't giant empty blocks */
    .data-table tbody tr { padding: 0.85rem 1rem !important; }
}
/* Wide admin tables: scroll rather than clip the actions column (web + mobile). */
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table .actions-cell { white-space: nowrap; }

/* ============================================================================
   ADMIN MOBILE NAV — both admin portals reuse .super-admin-nav. On mobile the
   horizontal nav overflowed off-screen, stranding admins on one page. Drop it to
   its own full-width, horizontally-scrollable row so every destination is reachable.
   ============================================================================ */
@media (max-width: 768px) {
    .super-admin-header {
        flex-wrap: wrap !important;
        height: auto !important;
        row-gap: 0.5rem !important;
    }
    .super-admin-nav {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        order: 3 !important;
        gap: 0.4rem !important;
        padding: 0.4rem 0.25rem !important;
        scrollbar-width: none;
    }
    .super-admin-nav::-webkit-scrollbar { display: none; }
    .super-admin-nav-item {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        min-height: 40px;
    }
}

/* ============================================================================
   ADMIN HEADER user/sign-out strip — a patch gave .super-admin-user a near-white
   bg on mobile while its text stays white (for the dark header) → washed out.
   Blend it into the dark header with readable text + a gold-outlined Sign Out.
   Also darken admin table-card status/role badges (light-on-white → readable).
   ============================================================================ */
@media (max-width: 768px) {
    .super-admin-user { background: transparent !important; padding: 0.25rem 0 !important; }
    .admin-user-name { color: rgba(255,255,255,0.9) !important; }
    .admin-logout-btn {
        color: var(--gold, #c8a03c) !important;
        background: transparent !important;
        border: 1px solid rgba(200,160,60,0.45) !important;
    }
    /* Table-card badges: light theme badge colours are invisible on the white card. */
    .data-table tbody td .badge,
    .data-table tbody td .badge-role-user,
    .data-table tbody td .badge-role-member,
    .data-table tbody td [class*="badge-status"] { color: #374151 !important; background: #eef2f7 !important; }
}

/* ============================================================================
   MEMBER mobile polish:
   - DRAWER-ONLY NAV: the hamburger drawer holds every destination, so the bottom
     tab bar AND the top-right profile avatar are removed on mobile (redundant).
     The floating + (log) FAB stays. Reclaim the strip the nav bar used to occupy.
   - Horizontal tab strips (exercise-library filters, programme pathways) get a
     right-edge fade so it's obvious there's more to scroll.
   ============================================================================ */
@media (max-width: 768px) {
    /* Hamburger drawer is the single source of navigation now */
    .bottom-nav { display: none !important; }
    /* Keep the profile avatar out of the header (it lives in the drawer), but surface the
       notification BELL pinned just left of the hamburger so notifications work in portrait. */
    .app-header .app-header-right {
        display: flex !important;
        align-items: center !important;
        position: absolute !important;
        right: 3.3rem !important;
        top: env(safe-area-inset-top, 0px) !important;
        height: var(--ms-topbar-h, 54px) !important;
        z-index: 4 !important;
        background: transparent;
        /* NO transform here: a transform makes the notification panel's position:fixed resolve to
           this tiny box instead of the screen, throwing the dropdown off-screen. Centre via height
           + align-items instead. */
    }
    .app-header .app-header-right .profile-nav { display: none !important; }
    .app-header .app-header-right .notif-wrap { display: inline-flex !important; }
    /* Just the bell icon — no circular box/border/background. */
    .app-header .app-header-right .notif-bell-btn {
        color: #fff;
        background: transparent !important;
        border: none !important;
        margin-right: 0 !important;
    }
    .app-header .app-header-right .notif-bell-btn:hover {
        background: transparent !important;
        border: none !important;
        color: var(--gold, #c8a03c);
    }

    /* Nav bar is gone — reclaim the ~70px dead strip it reserved at page bottom */
    main, #page-content, .app-container,
    .page, .page-content, .main-content,
    .profile-page, .page-profile {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .ex-lib-filter-buttons,
    .pathway-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 0.5rem !important;
        scrollbar-width: none;
        -webkit-mask-image: linear-gradient(to right, #000 88%, transparent);
        mask-image: linear-gradient(to right, #000 88%, transparent);
    }
    .ex-lib-filter-buttons::-webkit-scrollbar,
    .pathway-tabs::-webkit-scrollbar { display: none; }
    .ex-lib-filter-btn,
    .pathway-tab { flex: 0 0 auto !important; white-space: nowrap !important; }
}

/* ============================================================================
   CALENDAR mobile alignment — .gc-cal day cells are a fixed 115px tall, which on
   a phone makes giant near-empty cells (dominates the screen, the selected-day
   highlight only fills part of the box, taps feel misaligned). Compact them to
   date + event-dots height so the grid is tight and the highlight fills the cell.
   ============================================================================ */
@media (max-width: 768px) {
    .gc-cal .cal-day {
        height: auto !important;
        min-height: 48px !important;
        max-height: 66px !important;
        padding: 0.3rem 0.25rem !important;
        gap: 0.15rem !important;
    }
    .gc-cal .cal-weekday { padding: 0.4rem 0.2rem !important; font-size: 0.6rem !important; }
    .gc-cal .cal-day .day-num { font-size: 0.8rem !important; }
    /* Selected day fills the (now compact) cell cleanly */
    .gc-cal .cal-day.cal-day-selected {
        background: rgba(200,160,60,0.14) !important;
        box-shadow: inset 0 0 0 2px rgba(200,160,60,0.55) !important;
    }
}

/* ============================================================
   COMMUNITY CHANNELS — GLOBAL vs PRIVATE grouping (web + mobile)
   ============================================================ */
.dc-channel-section-label {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    padding: 14px 12px 6px;
    margin-top: 2px;
    user-select: none;
}
#dc-channel-list .dc-channel-section-label:first-child { margin-top: 0; padding-top: 4px; }
/* Lock/globe SVG sits where the old "#" was */
.dc-channel-hash { display: inline-flex !important; align-items: center; justify-content: center; width: 15px; }
.dc-channel-hash svg { width: 13px; height: 13px; display: block; opacity: 0.8; }
.dc-channel-item.active .dc-channel-hash svg { opacity: 1; }

/* ============================================================================
   CELEBRATION overlay (PRs, streak milestones) — modern card + confetti
   ============================================================================ */
.celebration-overlay { position: fixed; inset: 0; z-index: 6000; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: rgba(10,22,40,0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0; transition: opacity .3s ease; overflow: hidden; }
.celebration-overlay.show { opacity: 1; }
.celebration-card { position: relative; z-index: 2; width: 100%; max-width: 380px; text-align: center; background: linear-gradient(180deg,#13203a,#0f1a2e); border: 1px solid rgba(200,160,60,0.35); border-radius: 20px; padding: 2rem 1.75rem 1.5rem; box-shadow: 0 24px 70px rgba(0,0,0,0.55); transform: scale(.85) translateY(12px); transition: transform .38s cubic-bezier(.2,.9,.3,1.25); }
.celebration-overlay.show .celebration-card { transform: scale(1) translateY(0); }
.celebration-badge { width: 72px; height: 72px; margin: 0 auto 1rem; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #e8c87c, #c8a03c); color: #0a1628; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 26px rgba(200,160,60,0.45); animation: cel-pop .5s cubic-bezier(.2,.9,.3,1.4) both, cel-glow 2.2s ease-in-out .5s infinite; }
@keyframes cel-pop { 0% { transform: scale(0) rotate(-25deg); } 60% { transform: scale(1.15) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes cel-glow { 0%, 100% { box-shadow: 0 8px 26px rgba(200,160,60,0.4); } 50% { box-shadow: 0 8px 38px rgba(200,160,60,0.85); } }
.celebration-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.celebration-share { background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(200,160,60,0.5); border-radius: 10px; padding: .7rem 1.25rem; font-weight: 700; font-size: .95rem; cursor: pointer; }
.celebration-share:active { transform: scale(.96); }
/* channel picker (share win) */
.cel-share-list { display: flex; flex-direction: column; gap: .4rem; margin: .5rem 0 1rem; max-height: 240px; overflow-y: auto; }
.cel-share-ch { display: flex; align-items: center; gap: .5rem; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: .65rem .85rem; color: #fff; font-weight: 600; cursor: pointer; text-align: left; }
.cel-share-ch:hover { border-color: #c8a03c; background: rgba(200,160,60,0.12); }
.cel-share-ch small { color: rgba(255,255,255,0.45); font-weight: 500; margin-left: auto; }
.celebration-kicker { font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; color: #c8a03c; font-weight: 700; margin-bottom: .35rem; }
.celebration-title { font-size: 1.6rem; color: #fff; margin: 0 0 .4rem; font-weight: 800; }
.celebration-detail { color: rgba(255,255,255,0.6); font-size: .92rem; margin: 0 0 1rem; }
.celebration-items { display: flex; flex-direction: column; gap: .4rem; margin: .25rem 0 1.25rem; }
.celebration-item { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: .6rem .8rem; font-size: .9rem; color: rgba(255,255,255,0.85); }
.celebration-item strong { color: #fff; }
.celebration-item .cel-prev { color: rgba(255,255,255,0.4); font-size: .78rem; margin-left: .4rem; }
.celebration-dismiss { background: #c8a03c; color: #0a1628; border: none; border-radius: 10px; padding: .7rem 2rem; font-weight: 700; font-size: .95rem; cursor: pointer; }
.celebration-dismiss:active { transform: scale(.96); }
.cel-confetti { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.cel-confetti-piece { position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; opacity: 0; animation-name: cel-fall; animation-timing-function: linear; animation-iteration-count: 1; }
@keyframes cel-fall { 0% { opacity: 0; transform: translateY(-20px) rotate(0); } 8% { opacity: 1; } 100% { opacity: .9; transform: translateY(102vh) rotate(620deg); } }

/* Calendar PR / achievement star marker */
.cal-pr-star { position: absolute; top: 3px; right: 4px; width: 15px; height: 15px; color: #c8a03c; z-index: 3; pointer-events: none; transform-origin: center; animation: pr-twinkle 2.6s ease-in-out infinite; }
@keyframes pr-twinkle {
    0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
    50% { transform: scale(1.22) rotate(10deg); filter: drop-shadow(0 0 5px rgba(200,160,60,0.85)); }
}
.gc-cal .cal-day.has-pr { box-shadow: inset 0 0 0 1px rgba(200,160,60,0.4); }

/* Muted channels — dimmed, italic, bell-off icon, no unread badge */
.dc-channel-item.channel-muted { opacity: 0.52; }
.dc-channel-item.channel-muted .dc-channel-name { font-style: italic; }
.dc-channel-item.channel-muted .dc-channel-badge { display: none !important; }
.dc-channel-muted-ic { display: inline-flex; align-items: center; margin-left: auto; color: rgba(255,255,255,0.4); flex-shrink: 0; }
