.app-shell {
    display: grid;
    width: 100%;
    min-height: 100vh;
    padding: 0.9375rem var(--workspace-gutter);
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: var(--workspace-gap);
}

.app-main {
    position: relative;
    min-width: 0;
    min-height: calc(100vh - 1.875rem);
}

.app-sidebar {
    position: sticky;
    top: 0.9375rem;
    z-index: var(--z-sidebar);
    display: flex;
    width: var(--sidebar-width);
    height: calc(100vh - 1.875rem);
    min-height: 0;
    flex-direction: column;
    background: transparent;
}

.app-sidebar__inner {
    display: flex;
    min-height: 100%;
    flex: 1;
    align-items: center;
    flex-direction: column;
    padding: var(--space-2) 0;
    /* The rail's tooltips are pseudo-elements on the nav items, so any scroll
       container here clips them: CSS forces overflow-x to auto whenever
       overflow-y scrolls, and the label is cut off at the rail's edge. The nav
       only needs ~594px, so it scrolls solely on short viewports - see the
       max-height query below. Revisit that breakpoint if nav items are added. */
    overflow: visible;
    overscroll-behavior: contain;
    scrollbar-width: none;
}

@media (max-height: 45rem) {
    .app-sidebar__inner {
        overflow-y: auto;
    }
}

.app-sidebar__inner::-webkit-scrollbar {
    display: none;
}

.app-sidebar__utility {
    display: grid;
    gap: var(--space-6);
    justify-items: center;
}

.app-sidebar__utility .ui-icon-button,
.app-sidebar__footer .ui-icon-button {
    width: 2.5rem;
    min-height: 2.5rem;
}

.app-sidebar__brand {
    display: inline-grid;
    width: 2.5rem;
    height: 2.5rem;
    place-items: center;
    border-radius: var(--radius-md);
}

.app-sidebar__brand .app-brand__mark {
    width: 2.25rem;
    height: 2.25rem;
}

.app-sidebar__brand:focus-visible {
    outline: 0;
    box-shadow: var(--focus-ring);
}

.app-sidebar__brand,
.app-brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: var(--space-3);
}

.app-brand__mark {
    position: relative;
    display: grid;
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    place-items: center;
    overflow: hidden;
    background: transparent;
}

.app-brand__mark-image {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    max-width: none;
    transform: translate(-50%, -50%);
    object-fit: contain;
}

.app-brand__copy {
    min-width: 0;
}

.app-brand__name {
    display: block;
    font-size: 1.5000rem;
    font-weight: var(--font-weight-semibold);
    letter-spacing: var(--letter-spacing-tight);
    line-height: var(--line-height-tight);
}

.app-brand__tagline {
    display: block;
    margin-top: var(--space-1);
    color: var(--color-text-muted);
    font-size: var(--font-size-2xs);
    white-space: nowrap;
}

.app-sidebar__nav {
    display: grid;
    width: 100%;
    flex: 0 0 auto;
    gap: 0.625rem;
    margin-block: auto;
    padding-block: var(--space-5);
    justify-items: center;
}

.app-sidebar__footer {
    display: grid;
    gap: var(--space-2);
    margin-top: 0;
    padding-top: var(--space-5);
    place-items: center;
}

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-sidebar) - 1);
    display: none;
    width: 100%;
    height: 100%;
    padding: 0;
    background: var(--color-backdrop);
}

.app-header {
    position: relative;
    z-index: var(--z-sticky);
    height: var(--header-height);
}

.app-header__inner {
    display: grid;
    width: 100%;
    height: 100%;
    align-items: start;
    grid-template-columns: minmax(15rem, 1fr) auto minmax(11rem, 1fr);
    gap: var(--space-6);
}

.app-header__command {
    min-width: 0;
    justify-self: center;
}

/* The account cluster is its own island, sitting on the same line as the
   navigation one without being part of it. */
.app-header__actions {
    display: flex;
    min-width: 0;
    height: var(--header-height);
    padding: var(--space-2);
    align-items: center;
    justify-content: flex-end;
    gap: 0.375rem;
    justify-self: end;
    border: 1px solid var(--color-inverse-border);
    border-radius: var(--radius-pill);
    background: var(--color-command);
    box-shadow: var(--shadow-command);
    color: var(--color-command-text);
}

.app-header__actions .ui-icon-button--command {
    width: 2.625rem;
}

/* Match the avatar to the icon buttons: a 3rem avatar overflows the island's
   2.625rem inner height and reads as clipped at the pill's edge. */
.app-header__actions .app-header__profile {
    width: 2.625rem;
    height: 2.625rem;
    font-size: var(--font-size-xs);
}

/* On the island's dark ground the avatar takes a light rim instead of the
   accent halo it wears against the page. */
.app-header__profile {
    box-shadow: 0 0 0 2px var(--color-inverse-border), var(--shadow-xs);
}

.app-user-menu__trigger:hover .app-header__profile {
    box-shadow: 0 0 0 2px var(--color-inverse-hover), var(--shadow-xs);
}

.app-context-notch {
    position: absolute;
    z-index: calc(var(--z-sticky) + 1);
    top: 0;
    left: 50%;
    max-width: calc(100% - 30rem);
    transform: translateX(-50%);
}

.app-mobile-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    display: none;
    height: var(--mobile-header-height);
    border-bottom: 1px solid var(--color-glass-border);
    background: var(--color-chrome);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.app-mobile-header__inner {
    display: grid;
    height: 100%;
    padding: 0 var(--space-4);
    align-items: center;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: var(--space-3);
}

.app-mobile-header__title {
    overflow: hidden;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-mobile-header__context {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: var(--space-2);
}

.app-mobile-header__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-1);
}

.app-mobile-header__brand-mark {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: var(--radius-xs);
}

.app-mobile-header__brand-trigger {
    display: grid;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: inherit;
}

.app-mobile-header__brand-trigger:hover {
    background: var(--color-control-hover);
}

.app-mobile-header__brand-trigger:focus-visible {
    outline: 0;
    box-shadow: var(--focus-ring);
}

.app-content {
    /* One premium content horizon below either the global or contextual island. */
    --app-content-start-gap: clamp(var(--space-5), 4.5vh, var(--space-10));
    width: min(100%, var(--content-max-width));
    min-width: 0;
    margin: 0 auto;
    padding: var(--app-content-start-gap) 0 var(--space-6);
}

.app-flash {
    width: min(100%, var(--content-max-width));
    margin: var(--space-3) auto 0;
}

.app-footer {
    width: min(100%, var(--content-max-width));
    margin: 0 auto;
    padding: var(--space-3) 0 var(--space-4);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

.app-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-3);
}

.app-page--record .app-footer {
    display: none;
}

.app-modal-root:empty {
    display: none;
}

@media (min-width: 64rem) {
    .has-js body.app-page--workspace {
        overflow: hidden;
    }

    .has-js .app-page--workspace .app-shell {
        height: 100vh;
        height: 100dvh;
        min-height: 0;
    }

    .has-js .app-page--workspace .app-main {
        display: flex;
        height: calc(100vh - 1.875rem);
        height: calc(100dvh - 1.875rem);
        min-height: 0;
        flex-direction: column;
    }

    .has-js .app-page--workspace .app-header,
    .has-js .app-page--workspace .app-flash {
        flex: 0 0 auto;
    }

    .has-js .app-page--workspace .app-content {
        min-height: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    /* Content-led workspaces use the page as the scroll container. */
    .has-js .app-page--contacts .app-content,
    .has-js .app-page--dashboard .app-content,
    .has-js .app-page--analytics .app-content,
    .has-js .app-page--calendar .app-content,
    .has-js .app-page--integrations .app-content,
    .has-js .app-page--billing .app-content,
    .has-js .app-page--settings .app-content,
    .has-js .app-page--credit-usage .app-content,
    .has-js .app-page--email-channel .app-content,
    .has-js .app-page--profile .app-content {
        overflow-y: auto;
    }

    .has-js .app-page--workspace .app-footer {
        display: none;
    }
}

.app-auth {
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    place-items: center;
    padding: 5rem var(--space-5) var(--space-8);
}

.app-auth__panel {
    width: min(100%, 27.5rem);
}

.app-auth__brand {
    display: flex;
    width: max-content;
    margin: 0 auto var(--space-5);
    flex-direction: column;
    gap: var(--space-2);
    text-align: center;
}

.app-auth__brand .app-brand__mark {
    width: 3.25rem;
    height: 3.25rem;
}

.app-auth__brand .app-brand__copy {
    text-align: center;
}

.app-auth-appearance {
    position: fixed;
    z-index: var(--z-dropdown);
    top: var(--space-5);
    right: var(--space-5);
}

.app-auth-appearance .appearance-menu__panel {
    right: 0;
    left: auto;
}

/* Toasts sit below the appearance control so they never cover it. */
.app-auth .app-toast-stack {
    top: calc(var(--space-5) + 3.5rem);
}

