/* Loaded @ media (min-width:769px). Canonical mobile boundary: 768px. */

/* === App shell ======================================================= */
.app-shell {
    display: flex;
    width: 100%;
    min-height: 100vh;
    max-width: none;
    margin: 0;
    background: var(--color-bg-app);
    position: relative;
}

/* === Sidebar (left primary nav) ====================================== */
.app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-bg-panel);
    border-right: 1px solid var(--color-border-subtle);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
}

.app-sidebar-brand {
    padding: var(--space-3) var(--space-3);
    border-bottom: 1px solid var(--color-border-subtle);
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    text-align: center;
}

.app-sidebar-brand a {
    color: inherit;
    text-decoration: none;
}

.app-sidebar-brand a:hover {
    color: var(--color-accent);
    text-decoration: none;
}

.app-sidebar-nav {
    flex: 1;
    padding: var(--space-1) 0 var(--space-2);
}

.app-sidebar-category {
    padding: var(--space-2) var(--space-3) var(--space-0-5);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.app-sidebar-nav > .app-sidebar-category:first-of-type {
    padding-top: var(--space-1);
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.app-sidebar-link:hover {
    background: var(--color-bg-panel-raised);
    color: var(--color-text-primary);
    text-decoration: none;
}

.app-sidebar-link:focus-visible {
    outline: none;
    background: var(--color-bg-panel-raised);
    box-shadow: inset var(--focus-ring);
}

.app-sidebar-link.active {
    background: rgba(var(--color-accent-rgb), 0.12);
    color: var(--color-accent);
    border-left-color: var(--color-accent);
    font-weight: 600;
}

.app-sidebar-logout {
    padding: var(--space-1) 0;
    border-top: 1px solid var(--color-border-subtle);
}

.app-sidebar-logout button {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

/* Player sidebar refresh: scoped so the admin sidebar keeps the shared shell
   treatment above. */
.app-sidebar-player {
    background:
        linear-gradient(180deg, rgba(var(--color-accent-rgb), 0.08), transparent 210px),
        var(--color-bg-panel);
}

.app-sidebar-player .app-sidebar-brand {
    justify-content: center;
    padding: 0.875rem 1.375rem 0.9375rem;
    min-height: 68px;
    text-align: center;
    flex-wrap: wrap;
    row-gap: 0;
}

.app-sidebar-brand-lockup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.875rem;
    min-width: 0;
    width: 100%;
}

.app-sidebar-player .app-sidebar-brand a.app-sidebar-brand-lockup:hover {
    color: var(--color-text-primary);
}

.app-sidebar-brand-mark {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    color: #38c7f4;
    fill: rgba(56, 199, 244, 0.08);
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 10px rgba(56, 199, 244, 0.35));
}

.app-sidebar-wordmark {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
    color: var(--color-text-primary);
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 0.95;
    text-transform: uppercase;
}

.app-sidebar-title {
    overflow: hidden;
    color: var(--color-text-primary);
    font-size: 1.125rem;
    letter-spacing: 0.18em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-sidebar-subtitle {
    color: #7bdcff;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.42em;
    line-height: 1;
}

.app-sidebar-load-time {
    flex-basis: 100%;
    margin-top: 3px;
    text-align: center;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: none;
    opacity: 0.86;
}

/* The load-time line overflows the brand block at intermediate window sizes;
   only show it when the app is effectively full-screen. */
@media (max-width: 1599px), (max-height: 899px) {
    .app-sidebar-load-time {
        display: none;
    }
}

.app-sidebar-player .app-sidebar-nav {
    padding: var(--space-0-5) var(--space-1) var(--space-1);
}

.app-sidebar-player .app-sidebar-category {
    margin: 0.375rem var(--space-1) 0;
    padding: 0.5rem var(--space-1) 0.125rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.app-sidebar-player .app-sidebar-nav > .app-sidebar-category:first-of-type {
    margin-top: 0;
    padding-top: 0.125rem;
    border-top: 0;
}

.app-sidebar-player .app-sidebar-link {
    gap: 0.625rem;
    min-height: 34px;
    margin: 1px 0;
    padding: 0 var(--space-2);
    border: 1px solid transparent;
    border-left: 3px solid transparent;
    border-radius: 6px;
    color: var(--color-text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
}

.app-sidebar-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    color: var(--color-text-muted);
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.app-sidebar-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-sidebar-player .app-sidebar-link:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.06);
    border-left-color: rgba(var(--color-accent-rgb), 0.45);
    color: var(--color-text-primary);
}

.app-sidebar-player .app-sidebar-link:hover .app-sidebar-icon {
    color: var(--color-accent-soft);
}

.app-sidebar-player .app-sidebar-link:focus-visible {
    border-color: rgba(var(--color-accent-rgb), 0.75);
    box-shadow: inset 0 0 0 1px rgba(var(--color-accent-rgb), 0.45);
}

.app-sidebar-player .app-sidebar-link.active {
    background:
        linear-gradient(90deg, rgba(var(--color-accent-rgb), 0.24), rgba(var(--color-accent-rgb), 0.1));
    border-color: rgba(var(--color-accent-rgb), 0.36);
    border-left-color: var(--color-accent);
    color: var(--color-text-primary);
    box-shadow: inset 0 0 0 1px rgba(var(--color-accent-rgb), 0.18);
}

.app-sidebar-player .app-sidebar-link.active .app-sidebar-icon {
    color: var(--color-accent);
}

.app-sidebar-player .app-sidebar-logout {
    margin: 0 var(--space-1);
    padding: var(--space-0-5) 0;
}

.app-sidebar-player .app-sidebar-logout .app-sidebar-link {
    width: 100%;
}

/* === Main content area =============================================== */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Desktop: app-shell is a fixed-height console; content scrolls inside. */
html:has(.app-shell),
body:has(.app-shell) {
    height: 100%;
    overflow: hidden;
}
.app-shell {
    margin: 0;
    min-height: 100vh;
}
.app-shell .app-main {
    min-height: 0;
    height: 100vh;
    overflow: hidden;
}

.app-shell .app-content {
    min-height: 0;
    overflow-y: auto;
    scroll-padding-top: var(--space-2);
    scroll-padding-bottom: var(--space-2);
}

.app-shell .app-main :is(a, button, input, select, textarea, [tabindex]) {
    scroll-margin-top: var(--space-2);
    scroll-margin-bottom: var(--space-2);
}

html.wiki-page-root:not(:has(.app-shell)),
html.wiki-page-root:not(:has(.app-shell)) body.wiki-page {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
}

/* Resource bar desktop grid (shared .resource-bar-inner props stay in base.css;
   shell.mobile.css overrides display to horizontal-scroll flex at <=768px). */
.status-bar-inner {
    display: grid;
    grid-template-columns: minmax(180px, 20%) minmax(50px, 10%) minmax(80px, 15%) repeat(2, minmax(90px, 10%)) minmax(70px, 20%) minmax(40px, 5%) minmax(40px, 10%);
}

@media (min-width: 1601px) and (min-height: 1201px) {
    body:has(.app-shell) {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .app-shell {
        width: var(--shell-max);
        min-height: 0;
        height: var(--shell-container-height);
        max-height: var(--shell-container-height);
        overflow: hidden;
        border: 3px solid var(--race-primary);
        border-radius: 15px;
    }

    .app-sidebar {
        position: absolute;
    }

    .app-shell .app-main {
        height: 100%;
    }
}
