.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    background: var(--bw-bg);
    color: var(--bw-text);
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 15px 17px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid var(--bw-border);
    background: var(--bw-surface-soft);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.sidebar-top {
    display: grid;
    gap: 35px;
}

.app-brand {
    width: fit-content;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--bw-text);
    text-decoration: none;
}

.app-brand:hover {
    color: var(--bw-text);
}

.app-brand strong {
    font-size: 1.05rem;
    font-weight: 780;
    letter-spacing: -0.04em;
}

.app-brand-mark {
    position: relative;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: linear-gradient(145deg, #244bf1, #6079f8);
    box-shadow: 0 8px 22px rgba(37, 75, 241, 0.26);
}

.app-brand-mark span {
    position: absolute;
    width: 12px;
    height: 12px;
    top: 9px;
    left: 9px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    transform: rotate(-28deg);
}

.app-nav {
    display: grid;
    gap: 5px;
}

.app-nav-link {
    min-height: 44px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--bw-text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 650;
    transition: color 150ms ease, background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.app-nav-link:hover {
    color: var(--bw-text);
    background: rgba(100, 120, 170, 0.055);
}

.app-nav-link.active {
    border-color: rgba(85, 109, 239, 0.15);
    background: rgba(79, 104, 237, 0.11);
    color: #8095ff;
}

.nav-icon {
    width: 19px;
    height: 19px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
}

.mobile-bottom-nav {
    display: none;
}

.sidebar-bottom {
    display: grid;
    gap: 13px;
}

.sidebar-account {
    padding: 12px 8px 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    border-top: 1px solid var(--bw-border);
}

.account-avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: linear-gradient(145deg, rgba(80, 105, 240, 0.18), rgba(94, 119, 251, 0.08));
    color: #879aff;
    font-size: 0.76rem;
    font-weight: 800;
}

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

.account-copy strong {
    overflow: hidden;
    color: var(--bw-text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-copy span {
    margin-top: 2px;
    color: var(--bw-text-subtle);
    font-size: 0.61rem;
}

.logout-button {
    width: 32px;
    height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--bw-text-subtle);
    cursor: pointer;
    transition: color 150ms ease, background 150ms ease;
}

.logout-button:hover {
    color: #ef746c;
    background: rgba(221, 73, 66, 0.09);
}

.logout-button svg {
    width: 17px;
    height: 17px;
}

.app-main {
    min-width: 0;
    background: radial-gradient(circle at 58% -150px, rgba(66, 90, 226, 0.08), transparent 480px), var(--bw-bg);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 69px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--bw-border);
    background: var(--bw-header-bg);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.mobile-brand {
    display: none;
}

.mobile-brand a {
    color: var(--bw-text);
    text-decoration: none;
    font-weight: 760;
}

.topbar-spacer {
    flex: 1;
}

.topbar-status {
    padding: 7px 10px;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--bw-border);
    border-radius: 999px;
    background: var(--bw-surface-soft);
    color: var(--bw-text-muted);
    font-size: 0.66rem;
    font-weight: 700;
}

.watch-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #38b878;
    box-shadow: 0 0 0 4px rgba(56, 184, 120, 0.1);
}

.app-content {
    width: min(1220px, calc(100% - 60px));
    margin: 0 auto;
    padding: 42px 0 80px;
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .app-sidebar {
        position: fixed;
        z-index: 100;
        left: 12px;
        right: 12px;
        bottom: calc(10px + env(safe-area-inset-bottom));
        top: auto;
        width: auto;
        height: 72px;
        padding: 6px;
        display: block;
        overflow: visible;
        border: 1px solid color-mix(in srgb, var(--bw-border) 88%, transparent);
        border-radius: 24px;
        background: color-mix(in srgb, var(--bw-bg) 84%, transparent);
        box-shadow: 0 18px 54px rgba(3, 7, 20, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.035);
        backdrop-filter: blur(34px) saturate(145%);
        -webkit-backdrop-filter: blur(34px) saturate(145%);
    }

    .sidebar-top {
        display: block;
    }

    .app-brand,
    .desktop-app-nav,
    .sidebar-bottom {
        display: none;
    }

    .mobile-bottom-nav {
        height: 60px;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
    }

    .mobile-bottom-link {
        min-width: 0;
        min-height: 60px;
        padding: 6px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        border: 1px solid transparent;
        border-radius: 18px;
        background: transparent;
        color: var(--bw-text-muted);
        text-decoration: none;
        font: inherit;
        font-size: 0.65rem;
        font-weight: 700;
        line-height: 1;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: color 150ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
    }

    .mobile-bottom-link.active,
    .mobile-more-menu.is-open > .mobile-menu-trigger,
    .mobile-more-menu.is-current > .mobile-menu-trigger {
        border-color: rgba(98, 119, 255, 0.28);
        background: linear-gradient(145deg, rgba(62, 86, 225, 0.28), rgba(75, 96, 221, 0.14));
        color: var(--bw-text);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 24px rgba(42, 62, 180, 0.16);
    }

    .mobile-bottom-link .nav-icon {
        width: 22px;
        height: 22px;
    }

    .mobile-bottom-link .nav-icon svg {
        width: 21px;
        height: 21px;
    }

    .mobile-more-menu {
        position: relative;
        min-width: 0;
    }

    .mobile-more-menu.is-open::before {
        content: "";
        position: fixed;
        z-index: 110;
        inset: 0 0 calc(94px + env(safe-area-inset-bottom)) 0;
        pointer-events: none;
        background: color-mix(in srgb, var(--bw-bg) 24%, transparent);
        backdrop-filter: blur(12px) saturate(86%);
        -webkit-backdrop-filter: blur(12px) saturate(86%);
    }

    .mobile-menu-trigger {
        position: relative;
        width: 100%;
        box-sizing: border-box;
        appearance: none;
        -webkit-appearance: none;
    }

    .mobile-menu-icon {
        width: 22px;
        height: 22px;
        display: grid;
        align-content: center;
        gap: 4px;
    }

    .mobile-menu-icon span {
        width: 20px;
        height: 2px;
        display: block;
        border-radius: 999px;
        background: currentColor;
    }

    .mobile-menu-sheet {
        position: fixed;
        z-index: 120;
        left: 14px;
        right: 14px;
        bottom: calc(96px + env(safe-area-inset-bottom));
        max-height: min(66vh, 520px);
        padding: 18px;
        overflow-y: auto;
        overscroll-behavior: contain;
        border: 1px solid color-mix(in srgb, var(--bw-border) 88%, transparent);
        border-radius: 28px;
        background:
            linear-gradient(180deg, rgba(104, 124, 210, 0.055), transparent 28%),
            color-mix(in srgb, var(--bw-bg) 92%, transparent);
        box-shadow: 0 30px 90px rgba(2, 6, 20, 0.54), inset 0 1px 0 rgba(255, 255, 255, 0.045);
        backdrop-filter: blur(42px) saturate(155%);
        -webkit-backdrop-filter: blur(42px) saturate(155%);
    }

    .mobile-menu-heading {
        padding: 3px 4px 16px;
        display: flex;
        align-items: end;
        justify-content: space-between;
        gap: 18px;
        border-bottom: 1px solid color-mix(in srgb, var(--bw-border) 82%, transparent);
    }

    .mobile-menu-heading > div {
        display: grid;
        gap: 4px;
    }

    .mobile-menu-heading strong {
        color: var(--bw-text);
        font-size: 1.18rem;
        letter-spacing: -0.035em;
    }

    .mobile-menu-hint {
        color: var(--bw-text-subtle);
        font-size: 0.68rem;
        text-align: right;
    }

    .mobile-menu-links {
        padding-top: 11px;
        display: grid;
        gap: 6px;
    }

    .mobile-menu-links .app-nav-link {
        min-height: 52px;
        padding: 0 13px;
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        border-radius: 16px;
        font-size: 0.82rem;
        background: color-mix(in srgb, var(--bw-surface-soft) 46%, transparent);
    }

    .mobile-menu-links .app-nav-link:hover {
        background: color-mix(in srgb, var(--bw-surface-soft) 72%, transparent);
    }

    .mobile-menu-links .app-nav-link.active {
        border-color: rgba(98, 119, 255, 0.24);
        background: linear-gradient(145deg, rgba(62, 86, 225, 0.24), rgba(75, 96, 221, 0.11));
        color: var(--bw-text);
    }

    .pwa-install-action {
        width: 100%;
        appearance: none;
        -webkit-appearance: none;
        font: inherit;
        text-align: left;
        cursor: pointer;
    }

.pwa-install-message {
        margin: 2px 8px 0;
        color: var(--bw-text-subtle);
        font-size: 0.72rem;
        line-height: 1.45;
    }

    .app-topbar {
        height: 64px;
        padding: 0 18px;
    }

    .mobile-brand {
        display: block;
    }

    .app-content {
        width: min(100% - 30px, 1220px);
        padding: 30px 0 calc(132px + env(safe-area-inset-bottom));
    }
}

.pwa-update-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 42px;
    padding: 8px 18px;
    border-bottom: 1px solid rgba(98, 119, 255, 0.2);
    background: color-mix(in srgb, var(--bw-surface-soft) 82%, transparent);
    color: var(--bw-text-secondary);
    font-size: 0.76rem;
}

.pwa-update-notice button {
    min-height: 28px;
    padding: 0 11px;
    border: 1px solid rgba(98, 119, 255, 0.32);
    border-radius: 999px;
    background: rgba(98, 119, 255, 0.12);
    color: var(--bw-text);
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

.pwa-update-notice button:disabled {
    cursor: wait;
    opacity: 0.65;
}

@media (max-width: 520px) {
    .topbar-status {
        display: none;
    }

    .app-sidebar {
        left: 10px;
        right: 10px;
    }

    .mobile-menu-sheet {
        left: 10px;
        right: 10px;
    }
}
