/* =============================================================================
   Mobile app shell — bottom tab bar + explore sheet (≤900px)
   ========================================================================== */

@media (min-width: 901px) {
    .mobile-bottom-bar,
    .mobile-sheet { display: none !important; }
}

@media (max-width: 900px) {
    /* Auth pages use auth-mobile-bar instead of site-header */
    .auth-mobile-bar ~ .auth-shell .auth-mobile-logo {
        display: none;
    }

    /* Compact sticky header */
    .site-header__inner {
        min-height: var(--mobile-header-height);
        gap: var(--space-4);
    }
    .site-logo__img { height: 32px; }
    .nav-toggle { margin-left: auto; }

    /* Hide legacy hamburger dropdown — sheet replaces it */
    .site-nav,
    .site-nav.is-open {
        display: none !important;
    }

    /* App-style compact footer — hide redundant link columns (in explore sheet) */
    body.has-mobile-shell .site-footer {
        margin-top: var(--space-6);
        padding: var(--space-5) 0;
        padding-bottom: calc(var(--space-4) + var(--mobile-shell-gap));
    }

    body.has-mobile-shell .site-footer__columns {
        display: none;
    }

    body.has-mobile-shell .site-footer__bottom {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: var(--space-3);
        font-size: var(--fs-caption);
        color: rgba(255, 255, 255, 0.5);
    }

    body.has-mobile-shell .site-footer__bottom nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-1) var(--space-3);
        max-width: 320px;
        line-height: 1.6;
    }

    body.has-mobile-shell .site-footer__bottom nav a {
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        padding: 0 var(--space-1);
    }

    /* Sheets sit above bottom tab bar */
    body.has-mobile-shell .mobile-sheet__panel {
        bottom: calc(var(--mobile-bottom-bar-height) + var(--mobile-shell-gap));
        padding-bottom: 0;
        max-height: min(calc(92vh - var(--mobile-bottom-bar-height) - var(--mobile-shell-gap)), 680px);
    }

    body.has-mobile-shell .mobile-sheet__backdrop {
        bottom: calc(var(--mobile-bottom-bar-height) + var(--mobile-shell-gap));
    }
}

/* ---- Bottom tab bar ----------------------------------------------------- */
.mobile-bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-bottom-bar);
    height: calc(var(--mobile-bottom-bar-height) + var(--mobile-shell-gap));
    padding-bottom: var(--mobile-shell-gap);
    background: var(--surface-bright);
    border-top: 1px solid var(--outline-variant);
    box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.08);
}

.mobile-bottom-bar__inner {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: var(--mobile-bottom-bar-height);
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-1);
}

.mobile-bottom-bar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: var(--space-1) var(--space-1);
    border: none;
    background: transparent;
    color: var(--on-surface-muted);
    font: var(--fw-medium) 10px/1.2 var(--font-sans);
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--dur-fast) var(--ease);
}

.mobile-bottom-bar__item:hover,
.mobile-bottom-bar__item:focus-visible {
    color: var(--on-surface);
    outline: none;
    text-decoration: none;
}

.mobile-bottom-bar__item.is-active {
    color: var(--color-accent);
}

.mobile-bottom-bar__item.is-active .mobile-bottom-bar__icon-wrap {
    background: rgba(33, 150, 243, 0.12);
}

.mobile-bottom-bar__icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    border-radius: var(--radius-full);
    transition: background var(--dur-fast) var(--ease);
}

.mobile-bottom-bar__icon {
    font-size: 1.25rem;
    line-height: 1;
}

.mobile-bottom-bar__label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-bottom-bar__badge {
    position: absolute;
    top: 0;
    right: -2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-full);
    background: var(--color-danger);
    color: #fff;
    font-size: 9px;
    font-weight: var(--fw-bold);
    line-height: 16px;
    text-align: center;
}

/* Profile avatar tab (logged-in account) */
.mobile-bottom-bar__item--profile .mobile-bottom-bar__profile-ring {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-bright);
    border: 2px solid var(--color-accent);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mobile-bottom-bar__item--profile.is-sheet-open .mobile-bottom-bar__profile-ring,
.mobile-bottom-bar__item--profile.is-active .mobile-bottom-bar__profile-ring {
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.3);
}

.mobile-bottom-bar__item--profile:active .mobile-bottom-bar__profile-ring {
    transform: scale(0.96);
}

.mobile-bottom-bar__profile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.mobile-bottom-bar__profile-img--initials {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #fff;
    font-size: 11px;
    font-weight: var(--fw-bold);
}

.mobile-bottom-bar__item--profile.is-active .mobile-bottom-bar__label,
.mobile-bottom-bar__item--profile.is-sheet-open .mobile-bottom-bar__label {
    color: var(--color-accent);
    font-weight: var(--fw-semibold);
}

/* Compare bar stacks above bottom nav */
@media (max-width: 900px) {
    .fr-compare-bar.is-visible {
        bottom: calc(var(--mobile-bottom-bar-height) + var(--mobile-shell-gap));
        z-index: var(--z-bottom-overlay);
    }
}

/* ---- Explore sheet ------------------------------------------------------ */
.mobile-sheet {
    position: fixed;
    inset: 0;
    z-index: var(--z-mobile-sheet);
    pointer-events: none;
    visibility: hidden;
}

.mobile-sheet.is-open {
    pointer-events: auto;
    visibility: visible;
}

.mobile-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease);
}

.mobile-sheet.is-open .mobile-sheet__backdrop {
    opacity: 1;
}

.mobile-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: min(92vh, 720px);
    display: flex;
    flex-direction: column;
    background: var(--surface-bright);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-3);
    transform: translateY(100%);
    transition: transform var(--dur-slow) var(--ease);
    padding-bottom: var(--mobile-shell-gap);
}

.mobile-sheet.is-open .mobile-sheet__panel {
    transform: translateY(0);
}

.mobile-sheet__handle {
    flex-shrink: 0;
    width: 40px;
    height: 4px;
    margin: var(--space-3) auto var(--space-2);
    border-radius: var(--radius-full);
    background: var(--outline);
}

.mobile-sheet__header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-4) var(--space-3);
    border-bottom: 1px solid var(--outline-variant);
    flex-shrink: 0;
}

.mobile-sheet__back,
.mobile-sheet__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-md);
    background: var(--surface-bright);
    color: var(--on-surface);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur-fast) var(--ease);
}

.mobile-sheet__back:hover,
.mobile-sheet__close:hover {
    background: var(--surface-alt);
}

.mobile-sheet__back[hidden] {
    display: none;
}

.mobile-sheet__title {
    flex: 1;
    margin: 0;
    font-size: var(--fs-body-md);
    font-weight: var(--fw-bold);
    color: var(--color-primary);
    text-align: center;
}

.mobile-sheet__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-4);
}

.mobile-sheet__view {
    display: none;
}

.mobile-sheet__view.is-active {
    display: block;
}

/* Root category grid */
.mobile-sheet__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.mobile-sheet__cat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-4);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-lg);
    background: var(--surface-alt);
    color: var(--on-surface);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}

.mobile-sheet__cat:hover,
.mobile-sheet__cat:focus-visible {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-1);
    outline: none;
}

.mobile-sheet__cat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--surface-bright);
    color: var(--color-accent);
    font-size: 1.25rem;
}

.mobile-sheet__cat-label {
    font-size: var(--fs-body-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-primary);
}

.mobile-sheet__cat-desc {
    font-size: var(--fs-caption);
    color: var(--on-surface-muted);
    line-height: 1.4;
}

/* Link lists in sub-views */
.mobile-sheet__section {
    margin-bottom: var(--space-5);
}

.mobile-sheet__section-title {
    margin: 0 0 var(--space-3);
    font-size: var(--fs-caption);
    font-weight: var(--fw-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--on-surface-muted);
}

.mobile-sheet__links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mobile-sheet__links a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    color: var(--on-surface);
    font-size: var(--fs-body-sm);
    font-weight: var(--fw-medium);
    text-decoration: none;
    transition: background var(--dur-fast);
}

.mobile-sheet__links a:hover,
.mobile-sheet__links a:focus-visible {
    background: var(--surface-alt);
    color: var(--color-accent);
    outline: none;
}

.mobile-sheet__links a .bi {
    color: var(--on-surface-muted);
    font-size: 0.85rem;
}

.mobile-sheet__cta-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--outline-variant);
}

.mobile-sheet__cta-row .btn {
    width: 100%;
}

body.mobile-sheet-open {
    overflow: hidden;
}

body.mobile-account-open {
    overflow: hidden;
}

/* Logged-in strip at top of website menu */
.mobile-sheet__account-strip {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    background: var(--surface-alt);
    border: 1px solid var(--outline-variant);
}

.mobile-sheet__account-strip-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.mobile-sheet__account-strip-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--outline-variant);
}

.mobile-sheet__account-strip-avatar--initials {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #fff;
    font-size: 14px;
    font-weight: var(--fw-bold);
}

.mobile-sheet__account-strip-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mobile-sheet__account-strip-name {
    font-weight: var(--fw-bold);
    font-size: var(--fs-body-sm);
    color: var(--on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-sheet__account-strip-hint {
    font-size: var(--fs-caption);
    color: var(--on-surface-muted);
}

.mobile-sheet__account-strip-cta {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Site account sheet (public) */
.site-account-sheet__header {
    border-bottom: none;
    padding-bottom: 0;
}

.site-account-sheet__body {
    padding-top: 0;
}

.site-account-sheet__profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-2) var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--outline-variant);
}

.site-account-sheet__avatar-link {
    text-decoration: none;
    margin-bottom: var(--space-3);
}

.site-account-sheet__avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--outline-variant);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
}

.site-account-sheet__avatar--initials {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #fff;
    font-size: 1.5rem;
    font-weight: var(--fw-bold);
}

.site-account-sheet__name {
    margin: 0 0 4px;
    font-size: var(--fs-body-lg);
    font-weight: var(--fw-bold);
    color: var(--on-surface);
}

.site-account-sheet__role {
    margin: 0 0 var(--space-3);
    font-size: var(--fs-body-sm);
    color: var(--on-surface-muted);
}

.site-account-sheet__workspace {
    margin-bottom: var(--space-5);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    background: var(--surface-alt);
    border: 1px solid var(--outline-variant);
}

.site-account-sheet__section-label {
    margin: 0 0 var(--space-3);
    font-size: 11px;
    font-weight: var(--fw-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--on-surface-muted);
}

.site-account-sheet__switch-row {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.site-account-sheet__switch-row .form-control {
    flex: 1;
    min-width: 0;
    min-height: 44px;
}

.site-account-sheet__switch-row .btn {
    flex-shrink: 0;
    min-height: 44px;
}

.site-account-sheet__section {
    margin-bottom: var(--space-5);
}

.site-account-sheet__links a {
    display: flex;
    align-items: center;
    gap: 10px;
}

.site-account-sheet__links a .bi:first-child {
    color: var(--color-accent);
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
}

.site-account-sheet__links a .bi-chevron-right {
    margin-left: auto;
    opacity: 0.45;
    font-size: 0.75rem;
}

.site-account-sheet__panel-btn,
.site-account-sheet__explore-btn {
    margin-top: var(--space-3);
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.site-account-sheet__signout {
    margin-top: var(--space-2);
    padding-top: var(--space-4);
    border-top: 1px solid var(--outline-variant);
}

.site-account-sheet__signout .btn {
    min-height: 48px;
}
