.app-shell {
    --footer-floating-height: 38px;
    --floating-toolbar-footer-gap: 14px;
    min-height: 100vh;
    padding-bottom: calc(
        var(--footer-floating-height) + var(--floating-toolbar-footer-gap) + 4px
    );
    background: transparent;
    color: var(--text);
    --shell-content-width: 96%;
    display: flex;
    flex-direction: column;
}

.app-shell--frameless {
    padding-bottom: 0;
}

.site-header {
    width: 98%;
    margin: 0 auto;
    border-bottom-left-radius: 9px;
    border-bottom-right-radius: 9px;
    overflow: visible;
    position: sticky;
    top: 0;
    z-index: 1200;
}

.global-topbar {
    min-height: 78px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    padding: 14px 30px;
    background: var(--header-top-bg);
    border: 1px solid var(--nav-border);
    border-bottom: 0;
}

.brandline {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.45rem;
}
.topbar-icon {
    width: 34px;
    height: 34px;
}

.page-context {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 0;
}
.page-context h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}
.page-context p {
    margin: 0;
    color: var(--context-muted);
    font-size: 0.82rem;
    font-style: italic;
}

.global-navrow {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 10px 30px;
    border: 1px solid var(--nav-border);
    border-top: 1px solid var(--nav-border-top);
    border-bottom-left-radius: 22px;
    border-bottom-right-radius: 22px;
    background: var(--nav-bg);
    max-height: 120px;
    overflow: visible;
    transform-origin: top center;
    transition:
        max-height 0.2s ease,
        padding 0.2s ease,
        border-width 0.2s ease,
        opacity 0.2s ease,
        transform 0.2s ease;
}

.page-subnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    padding: 6px 30px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--nav-bg);
    backdrop-filter: blur(8px);
    transition:
        margin-top 0.2s ease,
        padding 0.2s ease,
        border-radius 0.2s ease,
        border-width 0.2s ease;
}

.app-shell--has-subnav .global-navrow {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.app-shell--has-subnav .page-subnav {
    margin-top: 0;
    border-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.app-shell--subnav-priority .global-navrow {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
}

.app-shell--subnav-priority .page-subnav {
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;
}

.page-subnav-list {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
    min-width: 0;
    overflow-x: auto;
}

.page-subnav-list a,
.page-subnav-list button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 7px 12px;
    text-decoration: none;
    color: var(--text-muted);
    background: transparent;
    white-space: nowrap;
    font-size: 0.9rem;
    font-weight: 600;
}

.page-subnav-list a:hover,
.page-subnav-list button:hover {
    border-color: var(--border);
    color: var(--text);
    background: var(--surface-soft);
}

.page-subnav-list a.active,
.page-subnav-list button.active {
    border-color: color-mix(in srgb, var(--accent-2) 35%, transparent);
    color: var(--text);
    background: color-mix(in srgb, var(--accent-2) 22%, transparent);
}

.nav-compact-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    line-height: 1;
    transition: background 0.15s;
}

.global-navrow .nav-compact-toggle {
    grid-column: 1;
    justify-self: start;
}

.nav-compact-toggle:hover {
    background: var(--surface-soft);
}

.global-navrow--compact .nav-compact-toggle {
    display: flex;
}

.global-navrow--compact .topnav {
    visibility: hidden;
    pointer-events: none;
}

.nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 1700;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow-y: auto;
    pointer-events: none;
    visibility: hidden;
    display: flex;
    flex-direction: column;
}

.nav-drawer--open {
    transform: translateX(0);
    pointer-events: auto;
    visibility: visible;
}

.nav-drawer-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-drawer-close {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    align-self: flex-end;
    padding: 2px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s;
    margin-bottom: 8px;
}

.nav-drawer-close:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.nav-drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-drawer-nav a {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.97rem;
    font-weight: 600;
    opacity: 0.88;
    transition: background 0.15s;
}

.nav-drawer-nav a:hover,
.nav-drawer-nav a.active {
    background: var(--surface-soft);
    opacity: 1;
}

.nav-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: var(--drawer-backdrop);
    z-index: 1690;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.26s ease;
}

.nav-drawer-backdrop:not([hidden]) {
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
}

.topnav {
    display: flex;
    grid-column: 2;
    gap: 18px;
    font-size: 0.97rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    overflow: hidden;
}
.topnav a {
    color: var(--text);
    text-decoration: none;
    opacity: 0.92;
    padding: 6px 2px;
    white-space: nowrap;
}
.topnav a:hover,
.topnav a.active {
    color: var(--text);
    opacity: 1;
    border-bottom: 2px solid var(--accent-2);
}
.topnav a[aria-disabled="true"] {
    opacity: 0.38;
    pointer-events: none;
}

.account-cluster {
    display: flex;
    grid-column: 3;
    align-items: center;
    gap: 18px;
    justify-self: end;
    margin-left: auto;
    white-space: nowrap;
}
.user-greeting {
    color: var(--user-greeting);
    font-style: italic;
    font-size: 1.4em;
    font-weight: 700;
}

.global-search-wrap {
    display: contents;
}

.profile-menu {
    position: relative;
}
.avatar-button {
    border-radius: 999px;
    width: 38px;
    height: 38px;
    padding: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.avatar-image {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    display: block;
    object-fit: cover;
}
.avatar-initials {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    user-select: none;
}
.dropdown {
    position: absolute;
    right: 0;
    top: 36px;
    z-index: 100;
    list-style: none;
    margin: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    min-width: 170px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(-6px);
    transition:
        opacity 0.16s ease,
        transform 0.16s ease;
    pointer-events: none;
    max-width: min(280px, calc(100vw - 32px));
    overflow: hidden;
}

.dropdown li {
    display: flex;
}

.dropdown li[hidden] {
    display: none;
}

.profile-menu.open .dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    text-align: left;
    padding: 8px;
    color: var(--text);
    text-decoration: none;
    border-radius: 6px;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.25;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    transition:
        background 0.15s ease,
        transform 0.15s ease;
}
.dropdown-item:hover {
    background: var(--surface-soft);
    transform: translateX(3px);
}
.hidden {
    display: none;
}

.workspace {
    padding: 24px;
    width: var(--shell-content-width);
    margin: 12px auto 0;
    background: rgba(6, 12, 28, 0.1);
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.08);
    backdrop-filter: blur(2px);
}

.global-footer {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    z-index: 880;
    width: var(--shell-content-width);
    margin: 0;
    min-height: var(--footer-floating-height);
    padding: 6px 14px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 12px;
    background: rgba(6, 12, 28, 0.08);
    backdrop-filter: blur(8px);
}

.global-footer-inner {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
}

.global-footer-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 8px;
}

.global-footer-link:hover,
.global-footer-link:focus-visible {
    color: var(--text);
    background: var(--surface-soft);
}

.content-grid {
    display: grid;
    gap: 14px;
}

.app-shell button,
.app-shell select,
.app-shell input,
.app-shell textarea {
    background: var(--control-bg);
    color: var(--control-text);
    border: 1px solid var(--control-border);
}

.app-shell .avatar-button,
.app-shell .dropdown-item {
    background: transparent;
    border: 0;
}

.app-shell .avatar-button {
    border: 1px solid var(--border);
}

.app-shell .theme-toggle {
    background: var(--theme-toggle-bg);
    border: 1px solid var(--border);
}

button.dropdown-item {
    -webkit-appearance: none;
    appearance: none;
}

.app-shell
    button:hover:not(.dropdown-item):not([class*="btn-"]):not(
        .theme-toggle
    ):not(.font-size-btn):not(:disabled),
.app-shell select:hover {
    background: var(--control-hover-bg);
}

.app-shell .avatar-button:hover {
    background: var(--surface-soft);
}

.app-shell .theme-toggle:hover {
    background: var(--theme-toggle-bg-hover);
}

.app-shell .badge {
    background: var(--badge-bg);
    color: var(--badge-text);
    border: 1px solid var(--control-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

@media (max-width: 900px) {
    .global-topbar {
        grid-template-columns: 1fr;
        gap: 10px;
        padding-left: 18px;
        padding-right: 18px;
    }
    .global-navrow {
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 10px;
        padding-left: 18px;
        padding-right: 18px;
    }
    .page-subnav {
        padding-left: 18px;
        padding-right: 18px;
    }
    .page-context {
        align-items: flex-start;
    }
    .page-context h1 {
        font-size: 1.35rem;
    }
    .page-context p {
        font-size: 0.92rem;
    }
    .account-cluster {
        justify-self: end;
    }
}

@media (max-width: 640px) {
    .app-shell {
        --footer-floating-height: 34px;
        --floating-toolbar-footer-gap: 10px;
    }
    .site-header {
        width: 100%;
        border-radius: 0;
    }
    .global-topbar {
        padding: 10px 14px;
        min-height: 60px;
    }
    .global-navrow {
        padding: 8px 14px;
        border-radius: 0;
    }
    .page-subnav {
        padding: 6px 14px;
        border-radius: 12px;
    }
    .workspace {
        width: 100%;
        margin: 0;
        padding: 14px;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }
    .global-footer {
        left: 0;
        bottom: 0;
        transform: none;
        width: 100%;
        margin: 0;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }
    .user-greeting {
        display: none;
    }
    .dropdown {
        width: min(240px, calc(100vw - 28px));
        max-width: calc(100vw - 28px);
        padding: 6px;
    }
    .dropdown-item {
        align-items: flex-start;
        padding: 10px 12px;
    }
}

.theme-toggle {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 48px;
    height: 48px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--theme-toggle-bg);
    color: var(--theme-toggle-color);
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 1000;
    font-size: 1.25rem;
}
.theme-toggle[data-mode="light"] {
    color: #f59e0b;
}
.theme-toggle[data-mode="dark"] {
    color: #94a3b8;
}

.app-shell,
.app-shell * {
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.app-shell ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.app-shell ::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
.app-shell ::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
}
.app-shell ::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.profile-mini-preview {
    position: fixed;
    z-index: 10000;
    max-width: calc(100vw - 24px);
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    padding: 12px;
    pointer-events: auto;
}

.profile-mini-preview[hidden] {
    display: none;
}

.profile-mini-preview__header {
    display: flex;
    gap: 10px;
    align-items: center;
}

.profile-mini-preview__avatar {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    overflow: hidden;
    flex: 0 0 auto;
}

.profile-mini-preview__avatar-img,
.profile-mini-preview__avatar-initials {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    background: var(--initials-bg, var(--accent));
    color: #fff;
    font-weight: 700;
}

.profile-mini-preview__identity {
    display: grid;
    min-width: 0;
}

.profile-mini-preview__identity span,
.profile-mini-preview__stats,
.profile-mini-preview__loading {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.profile-mini-preview__bio {
    margin: 10px 0 0;
    font-size: 0.9rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.profile-mini-preview__bio > :first-child {
    margin-top: 0;
}

.profile-mini-preview__bio > :last-child {
    margin-bottom: 0;
}

.profile-mini-preview__bio p {
    margin: 0;
}

.profile-mini-preview__bio p + p {
    margin-top: 0.35rem;
}

.profile-mini-preview__bio ul,
.profile-mini-preview__bio ol {
    margin: 0.3rem 0 0.3rem 1rem;
}

.profile-mini-preview__bio li + li {
    margin-top: 0.15rem;
}

.profile-mini-preview__bio a {
    color: var(--link);
}

.profile-mini-preview__stats {
    margin: 10px 0 0;
}
