/* Product shell layer: the persistent global header and the session/account
   chrome that now lives in it. The shell owns viewport height; pages are
   `flex: 1` inside the content region (see page layers). */

.app-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app-header {
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.app-header-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: clamp(0.6rem, 2vw, 1.25rem);
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.6rem clamp(1rem, 3vw, 2.5rem);
}

.app-wordmark {
    font-family: var(--font-heading, var(--font-ui));
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--color-emphasis);
    text-decoration: none;
}

.app-wordmark:hover {
    text-decoration: none;
    color: var(--color-primary);
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.app-nav-link {
    padding: 0.4rem 0.55rem;
    border: 1px solid transparent;
    border-radius: var(--radius-panel);
    color: var(--color-subtle);
    font-weight: 600;
}

.app-nav-link:hover {
    text-decoration: none;
    border-color: var(--color-primary);
    color: var(--color-tertiary);
}

.app-nav-link.is-active {
    border-color: var(--color-primary);
    color: var(--color-tertiary);
    background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

/* Global directed-search field (navigates client-side to /search). */
.app-search {
    display: flex;
    align-items: stretch;
    flex: 1 1 14rem;
    min-width: 8rem;
}

.app-search-input {
    flex: 1;
    min-width: 0;
    min-height: 2.1rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--color-border);
    border-right: 0;
    border-radius: var(--radius-panel) 0 0 var(--radius-panel);
    background: var(--color-base);
    color: var(--color-text);
    font-family: var(--font-ui);
    font-size: 0.9rem;
}

.app-search-input:focus {
    outline: 2px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
    outline-offset: 1px;
    border-color: var(--color-primary);
}

.app-search-button {
    min-height: 2.1rem;
    border-radius: 0 var(--radius-panel) var(--radius-panel) 0;
}

.app-publish-cta {
    white-space: nowrap;
}

.app-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Anonymous sign-in control (header + page-level reuse). */
.session-control {
    display: inline-flex;
    align-items: stretch;
    gap: 0;
    flex-wrap: nowrap;
}

.session-control input {
    width: min(9.5rem, 42vw);
    min-height: 2rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--color-border);
    border-right: 0;
    border-radius: var(--radius-panel) 0 0 var(--radius-panel);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-ui);
    font-size: 0.9rem;
}

.session-control input:focus {
    outline: 2px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
    outline-offset: 1px;
    border-color: var(--color-primary);
}

.session-control .button {
    min-height: 2rem;
    border-radius: 0 var(--radius-panel) var(--radius-panel) 0;
}

/* Signed-in account chrome: avatar trigger + click-to-open dropdown menu. */

.account-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.account-menu > summary {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    list-style: none;
}

.account-menu > summary::-webkit-details-marker {
    display: none;
}

.account-menu > summary:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--color-primary) 35%, transparent);
    outline-offset: 2px;
}

.session-avatar {
    display: block;
    width: 2.12rem;
    height: 2.12rem;
    object-fit: cover;
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}

.session-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-overlay);
    color: var(--color-primary);
    font-weight: 700;
    font-size: 0.9rem;
}

.account-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    z-index: 30;
    min-width: 13rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.4rem;
}

.account-menu-identity {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    padding: 0.35rem 0.5rem 0.5rem;
    margin-bottom: 0.2rem;
    border-bottom: 1px dashed var(--color-border);
}

.account-menu-identity strong {
    color: var(--color-text);
}

.account-menu-handle {
    color: var(--color-muted);
    font-size: 0.8rem;
    word-break: break-word;
}

.account-menu-form {
    margin: 0;
}

.account-menu-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.4rem 0.5rem;
    text-align: left;
    background: transparent;
    border: 0;
    color: var(--color-text);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    cursor: pointer;
}

.account-menu-item:hover {
    background-color: var(--color-overlay);
    text-decoration: none;
}

.account-menu-signout {
    color: var(--color-error);
}

/* Toast shelf (fixed feedback stack). */
.toast-shelf {
    position: fixed;
    right: clamp(0.75rem, 3vw, 1.5rem);
    bottom: clamp(0.75rem, 3vw, 1.5rem);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(22rem, 90vw);
}

.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
}

.toast-dismiss {
    border: 0;
    background: transparent;
    color: var(--color-muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.25rem;
}

/* On narrow viewports the directed-search field drops to its own row so the
   wordmark, Browse, Publish, and session control all stay visible. */
@media (max-width: 640px) {
    .app-search {
        order: 5;
        flex-basis: 100%;
    }
}
