:root {
    --neath-app-topbar-height: 48px;
    --neath-app-topbar-ink: #111111;
    --neath-app-topbar-muted: #626262;
    --neath-app-topbar-line: #e8e8e8;
}

.neath-app-topbar {
    position: relative;
    z-index: 40;
    width: 100%;
    height: var(--neath-app-topbar-height);
    flex: 0 0 var(--neath-app-topbar-height);
    overflow: visible;
    border-bottom: 1px solid var(--neath-app-topbar-line);
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025);
    scrollbar-width: none;
}

.neath-app-topbar::-webkit-scrollbar,
.neath-app-topbar__nav::-webkit-scrollbar,
.neath-app-topbar__actions::-webkit-scrollbar {
    display: none;
}

.neath-app-topbar__inner {
    display: flex;
    width: 100%;
    min-width: 0;
    height: 100%;
    align-items: center;
    gap: 24px;
    padding: 0 16px;
}

.neath-app-topbar__brand {
    flex: 0 0 auto;
    color: var(--neath-app-topbar-ink);
    font-size: 19px;
    font-weight: 700;
    line-height: 1;
}

.neath-app-topbar__nav {
    position: relative;
    isolation: isolate;
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
    gap: 4px;
    padding: 5px 3px;
    overflow-x: auto;
    scrollbar-width: none;
}

.neath-app-topbar__link {
    position: relative;
    display: inline-flex;
    height: 34px;
    padding: 0 12px;
    border-radius: 9px;
    isolation: isolate;
    white-space: nowrap;
    flex: 0 0 auto;
    align-items: center;
    color: var(--neath-app-topbar-muted);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    transition: color 220ms ease;
}

.neath-app-topbar__link::before {
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: #f1f1f1;
    content: "";
    opacity: 0;
    transition: opacity 220ms ease;
}

.neath-app-topbar__link.is-active {
    color: #ffffff;
}

.neath-app-topbar__link.is-active::before {
    background: var(--neath-app-topbar-ink);
    opacity: 1;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
}

@media (hover: hover) {
    .neath-app-topbar__link:hover {
        color: var(--neath-app-topbar-ink);
    }

    .neath-app-topbar__link:hover::before {
        opacity: 1;
        }

    .neath-app-topbar__link.is-active:hover {
        color: #ffffff;
    }
}

/* One shared backdrop moves between stationary links. The pseudo-elements
   above remain a usable fallback if the enhancement cannot load. */
.neath-app-topbar__indicator {
    position: absolute;
    left: 0;
    top: 0;
    z-index: -1;
    height: 34px;
    border-radius: 9px;
    background: var(--neath-app-topbar-ink);
    pointer-events: none;
}

.neath-app-topbar__nav.has-indicator .neath-app-topbar__indicator {
    transition: transform 380ms cubic-bezier(0.65, 0, 0.35, 1),
                width 380ms cubic-bezier(0.65, 0, 0.35, 1);
}

.neath-app-topbar__nav.has-indicator .neath-app-topbar__link::before {
    opacity: 0;
}

.neath-app-topbar__nav.has-indicator .neath-app-topbar__link {
    color: var(--neath-app-topbar-muted);
}

.neath-app-topbar__nav.has-indicator .neath-app-topbar__link.is-indicated {
    color: #ffffff;
}

/* A quiet divider separates workspace pages from the existing service links. */
.neath-app-topbar__link:nth-child(5) {
    margin-left: 13px;
}

.neath-app-topbar__link:nth-child(5)::after {
    position: absolute;
    left: -9px;
    top: 10px;
    width: 1px;
    height: 14px;
    background: var(--neath-app-topbar-line);
    content: "";
}

.neath-app-topbar__actions {
    display: flex;
    min-width: 0;
    flex: 0 0 auto;
    align-items: center;
    gap: 16px;
}

.neath-app-topbar__search {
    position: relative;
    margin-right: 0;
}

.neath-app-topbar__button,
.neath-app-topbar__outlined-button,
.neath-app-topbar__quota {
    display: inline-flex;
    min-height: 32px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    color: var(--neath-app-topbar-muted);
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    transition-property: color, background-color, border-color, scale;
    transition-duration: 160ms;
    transition-timing-function: ease-out;
}

/* Keep the quota's JS-controlled hidden state above the shared display rule. */
.neath-app-topbar__quota.hidden {
    display: none;
}

.neath-app-topbar__button {
    border: 0;
    background: transparent;
}

.neath-app-topbar__outlined-button,
.neath-app-topbar__quota {
    border: 1px solid var(--neath-app-topbar-line);
    border-radius: 999px;
    background: #ffffff;
    padding: 0 12px;
    text-decoration: none;
}

.neath-app-topbar__button:hover,
.neath-app-topbar__outlined-button:hover,
.neath-app-topbar__quota:hover {
    color: var(--neath-app-topbar-ink);
}

.neath-app-topbar__outlined-button:hover,
.neath-app-topbar__quota:hover {
    border-color: #d4d4d4;
    background: #f5f5f5;
}

.neath-app-topbar__button:active,
.neath-app-topbar__outlined-button:active,
.neath-app-topbar__quota:active {
    scale: 0.96;
}

.neath-app-topbar__account-id {
    max-width: 220px;
    overflow: hidden;
    color: var(--neath-app-topbar-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.neath-app-topbar__collecting-action {
    position: static;
    min-height: 32px;
    padding-top: 0;
    padding-bottom: 0;
}

.neath-app-topbar :where(a, button, input):focus-visible {
    outline: 2px solid var(--neath-app-topbar-ink);
    outline-offset: 2px;
}

/* Keep search popovers outside the independently scrolling navigation. */
.neath-app-topbar__search > div:first-child {
    background: #f5f5f5;
    border-color: #e8e8e8;
    border-radius: 10px;
}

.neath-app-topbar__search > div:first-child:focus-within {
    background: #ffffff;
    border-color: #b5b5b5;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

.neath-app-topbar__search button,
.neath-app-topbar__search input {
    color: var(--neath-app-topbar-ink);
}

.neath-app-topbar__search input::placeholder {
    color: #737373;
}

.neath-app-topbar__search #mode-toggle {
    border-color: var(--neath-app-topbar-line);
    border-radius: 10px 0 0 10px;
}

.neath-app-topbar__button {
    padding: 0 8px;
    border-radius: 8px;
}

.neath-app-topbar__button:hover {
    background: #f1f1f1;
}

@media (max-width: 1100px) {
    .neath-app-topbar__inner { gap: 14px; }
    .neath-app-topbar__actions { gap: 8px; }
    .neath-app-topbar__link { padding: 0 10px; }
}

@media (max-width: 760px) {
    :root { --neath-app-topbar-height: 96px; }

    .neath-app-topbar__inner {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: 48px 47px;
        gap: 0 12px;
        padding: 0 12px;
    }

    .neath-app-topbar__brand { font-size: 18px; }

    .neath-app-topbar__nav {
        grid-column: 1 / -1;
        grid-row: 2;
        align-self: stretch;
        gap: 4px;
        border-top: 1px solid #f1f1f1;
    }

    .neath-app-topbar__actions {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        gap: 4px;
    }

    .neath-app-topbar__quota,
    .neath-app-topbar__account-id {
        display: none !important;
    }

    .neath-app-topbar__search input,
    .neath-app-topbar__search input:focus {
        width: 88px;
    }
}

@media (max-width: 400px) {
    .neath-app-topbar__search input,
    .neath-app-topbar__search input:focus {
        width: 64px;
    }

    .neath-app-topbar__search #mode-toggle {
        padding-left: 8px;
        padding-right: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .neath-app-topbar *,
    .neath-app-topbar *::before,
    .neath-app-topbar *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* GSAP owns the real-sized backdrop; do not also interpolate it in CSS.
   Avoid magnifying a 1px layer and its rounded corners at fractional DPI. */
.neath-app-topbar__nav.has-magnetic-indicator .neath-app-topbar__indicator {
    transition: none;
}
