
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: var(--navbar-height);
    min-height: var(--navbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 6px var(--accent-wash);
    gap: 16px;
    z-index: 100;
    flex-wrap: nowrap;
}

.nav-brand {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    flex-shrink: 0;
    text-shadow: none;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    text-decoration: none;
}

a.nav-brand {
    cursor: pointer;
}

a.nav-brand:hover {
    color: var(--accent-hover);
}

a.nav-brand:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--radius-xs);
}

.nav-logo {
    font-size: 1.1rem;
    line-height: 1;
    color: var(--accent);
    transition: transform var(--transition-smooth);
}

.nav-brand:hover .nav-logo {
    transform: scale(1.1);
    text-shadow: none;
}

.nav-brand-text {
    position: relative;
}

a.nav-brand .nav-brand-text {
    cursor: pointer;
}

.nav-workspace {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding: 2px 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    text-decoration: none;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.nav-workspace:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.nav-workspace:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.nav-workspace-name {
    font-weight: 700;
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-tabs {
    display: flex;
    gap: 2px;
    align-items: stretch;
    height: 100%;
    flex: 1 1 0;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-tab {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0 16px;
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast), background var(--transition-fast);
    white-space: nowrap;
    letter-spacing: 0.02em;
    text-transform: none;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: var(--accent-wash);
}

.nav-tab.active {
    color: var(--accent);
    font-weight: 700;
}

.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
    box-shadow: 0 0 8px var(--accent-glow);
    animation: tab-slide-in 0.25s ease-out;
}

@keyframes tab-slide-in {
    from { transform: scaleX(0); opacity: 0; }
    to { transform: scaleX(1); opacity: 1; }
}

.nav-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-action-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.78rem;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all var(--transition-base);
    letter-spacing: 0.02em;
}

.nav-action-link:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-subtle);
}

.btn-theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
    min-width: 24px;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.theme-selector {
    position: relative;
    display: inline-block;
}

.theme-selector-toggle {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
    letter-spacing: 0.02em;
    text-transform: none;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.theme-selector-toggle:hover,
.theme-selector.open .theme-selector-toggle {
    color: var(--accent);
    background: var(--accent-wash);
}

.theme-selector-toggle::after {
    content: " \25BE";
    font-size: 0.7em;
    color: var(--text-dim);
}

.theme-selector.open .theme-selector-toggle::after {
    color: var(--accent);
}

.theme-selector-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 240px;
    max-height: min(70vh, 460px);
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    padding: 4px 0;
    list-style: none;
}

.theme-selector.open .theme-selector-menu {
    display: block;
}

.theme-selector-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 14px;
    gap: 12px;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-fast), color var(--transition-fast);
    letter-spacing: 0.01em;
}

.theme-selector-item:hover,
.theme-selector-item.active-option {
    background: var(--accent-subtle);
    color: var(--accent);
}

.theme-selector-item[aria-checked="true"] {
    color: var(--accent);
    font-weight: 700;
}

.theme-selector-item-label {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.theme-selector-swatches {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.theme-selector-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--border);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
    display: inline-block;
}

@media (max-width: 640px) {
    .theme-selector-toggle {
        padding: 5px 8px;
        font-size: 0.74rem;
    }

    .theme-selector-menu {
        min-width: 200px;
    }
}

.nav-tab.nav-tab-icon {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 8px;
    font-size: 0.88rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.nav-tab.nav-tab-icon:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.nav-tab.nav-tab-icon.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.nav-tab.nav-tab-icon.active::after {
    content: none;
}

@media (max-width: 640px) {
    .navbar {
        padding: 0 10px;
        gap: 8px;
    }

    .nav-brand {
        font-size: 0.95rem;
    }

    .nav-brand-text {
        display: none;
    }

    .nav-tab {
        padding: 0 10px;
        font-size: 0.78rem;
    }

    .nav-actions {
        gap: 6px;
        min-width: 0;
    }

    .nav-action-link {
        padding: 5px 8px;
    }

    .theme-selector-toggle-label,
    .user-menu-label {
        display: inline-block;
        max-width: 6ch;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: bottom;
    }
}


@media (prefers-reduced-motion: reduce) {
    .nav-logo,
    .nav-tab,
    .nav-tab.active::after,
    .nav-action-link,
    .btn-theme-toggle,
    .theme-selector-toggle,
    .theme-selector-item,
    .nav-tab.nav-tab-icon {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
}
