/* ─── Top Nav ──────────────────────────────────────────── */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.top-nav-inner {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo-link {
    color: var(--text);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo-link svg {
    display: block;
    width: 104px;
    height: 28px;
}

/* ─── Search icon (all screens) ─────────────────────────── */
.mobile-search-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--premium-accent) 40%, transparent);
    background: color-mix(in srgb, var(--premium-accent) 6%, var(--surface-muted));
    color: var(--premium-accent);
    cursor: pointer;
    transition: all 0.15s ease;
}
.mobile-search-trigger:hover {
    border-color: var(--premium-accent);
    color: var(--premium-accent);
    background: color-mix(in srgb, var(--premium-accent) 12%, var(--surface-muted));
}
.mobile-search-trigger svg {
    width: 16px;
    height: 16px;
}

.nav-search {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
    padding: 7px 16px;
    min-width: 260px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.nav-search:focus-within {
    border-color: var(--border-hover);
    background: var(--surface);
}

.nav-search input {
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 500;
    min-width: 180px;
}

.nav-search input::placeholder {
    color: var(--muted);
}

.nav-search button {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.nav-search button:hover {
    color: var(--text);
}

.nav-search svg {
    width: 14px;
    height: 14px;
    display: block;
}

/* ─── Nav right ─────────────────────────────────────────── */
.nav-right {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.profile-menu-container {
    position: relative;
    display: flex;
    align-items: center;
}

.login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid var(--text);
    padding: 8px 20px;
    background: var(--text);
    color: var(--bg);
    font-size: 0.85rem;
    transition: opacity 0.2s ease;
    text-decoration: none !important;
    font-family: inherit;
}

.login-btn:hover {
    opacity: 0.85;
}

/* ─── Profile menu (desktop) ────────────────────────────── */
.profile-menu {
    position: relative;
    z-index: 60;
}

.profile-menu summary {
    list-style: none;
    cursor: pointer;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    transition: border-color 0.2s ease;
}

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

.profile-menu summary:hover,
.profile-menu[open] summary {
    border-color: var(--border-hover);
}

.profile-avatar {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: var(--text);
    color: var(--bg);
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    overflow: hidden;
}

.profile-avatar.profile-avatar-lg {
    width: 38px;
    height: 38px;
    font-size: 0.92rem;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    min-width: 0;
}

.profile-name {
    font-size: 0.85rem;
    font-weight: 700;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-context {
    margin-top: 2px;
    font-size: 0.7rem;
    color: var(--muted);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-chevron {
    width: 16px;
    height: 16px;
    display: block;
    color: var(--muted);
    flex: 0 0 auto;
    transition: transform 0.2s ease;
}

.profile-menu[open] .profile-chevron {
    transform: rotate(180deg);
}

.profile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.12);
    cursor: default;
    z-index: 58;
    border: 0;
}

.profile-menu[open] .profile-backdrop {
    display: block;
}

.profile-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 260px;
    padding: 6px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    max-height: calc(100vh - 100px);
    z-index: 59;
}

.profile-dropdown-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 6px 6px 10px;
}

.profile-dropdown-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.profile-close {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: none;
    background: var(--surface-muted);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.profile-close:hover {
    background: var(--border);
}

.profile-close svg {
    width: 16px;
    height: 16px;
    display: block;
}

.profile-dropdown a:not(.profile-primary),
.profile-dropdown button {
    width: 100%;
    box-sizing: border-box;
    border: 0;
    border-radius: 10px;
    background: transparent;
    text-align: left;
    padding: 9px 10px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.88rem;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    transition: background 0.15s ease;
}

.profile-dropdown a.profile-primary {
    margin: 2px 0;
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 10px 12px;
    gap: 10px;
}

.profile-primary-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.1;
    flex: 1;
}

.profile-primary-name {
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-primary-context {
    margin-top: 2px;
    font-size: 0.7rem;
    color: var(--muted);
}

.profile-primary-hint {
    color: var(--muted);
    font-weight: 700;
    flex: 0 0 auto;
    font-size: 0.78rem;
}

.profile-dropdown a:hover,
.profile-dropdown button:hover {
    background: var(--surface-muted);
}

.profile-dropdown a.profile-primary:hover {
    background: var(--surface-muted);
}

.profile-dropdown .sep {
    height: 1px;
    background: var(--border);
    margin: 4px 6px;
}

.profile-switch-ctx {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 10px 12px !important;
  background: var(--surface-muted) !important;
  margin: 0 6px;
  border-radius: 8px;
}
.profile-switch-ctx:hover {
  border-color: var(--text) !important;
}
.profile-switch-hint {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  color: var(--premium-accent);
}

.profile-dropdown svg {
    width: 16px;
    height: 16px;
    display: block;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* ─── Bottom Nav (mobile only) ──────────────────────────── */
.bottom-nav {
    display: none;
}

/* ─── Mobile Search Overlay (hidden by default) ─────────── */
.mobile-search-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    flex-direction: column;
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top));
    animation: searchFadeIn 0.2s ease;
}

@keyframes searchFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.mobile-search-overlay.open {
    display: flex;
}

.mobile-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 0 16px;
    box-shadow: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mobile-search-bar:focus-within {
    border-color: var(--premium-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--premium-accent) 15%, transparent);
}

.mobile-search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 16px 0;
    font-size: 17px;
    color: var(--text);
    outline: none;
    font-weight: 500;
    font-family: inherit;
    letter-spacing: -0.02em;
}

.mobile-search-bar input::placeholder {
    color: var(--muted);
    font-weight: 500;
}

.mobile-search-cancel {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    padding: 16px 0 16px 4px;
    white-space: nowrap;
    font-family: inherit;
    transition: color 0.15s;
    letter-spacing: -0.01em;
}

.mobile-search-cancel:hover {
    color: var(--text);
}

.mobile-search-hints {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-search-hint {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mobile-search-hint:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.mobile-search-hint svg {
    width: 16px;
    height: 16px;
    color: var(--muted);
    flex-shrink: 0;
}

/* ─── Mobile overrides ──────────────────────────────────── */
@media (max-width: 640px) {

    .nav-search {
        display: none !important;
    }

    .profile-text {
        display: none !important;
    }

    .profile-chevron {
        display: none !important;
    }

    .profile-menu summary {
        border: none;
        background: transparent !important;
        padding: 0;
        min-height: unset;
        gap: 0;
    }

    .profile-menu summary:hover {
        background: transparent !important;
    }

    .profile-avatar {
        width: 32px;
        height: 32px;
        border: none;
    }

    .nav-right .profile-menu>summary {
        display: none;
    }

    .nav-right .login-btn {
        display: none;
    }

    .top-nav-inner {
        min-height: 50px;
    }

    .profile-backdrop {
        background: rgba(0, 0, 0, 0.3);
    }

    .profile-dropdown {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(64px + env(safe-area-inset-bottom));
        top: auto;
        width: auto;
        border-radius: 20px;
        box-shadow: var(--shadow-xl);
    }

    .main-content {
        padding-bottom: 90px !important;
    }

    /* ── Bottom Nav ── */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 99;
        background: color-mix(in srgb, var(--bg) 92%, transparent);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border);
        padding: 4px 0;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        justify-content: space-around;
        align-items: center;
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        flex: 1;
        color: var(--muted);
        font-size: 0.6rem;
        font-weight: 600;
        text-decoration: none !important;
        background: none;
        border: none;
        cursor: pointer;
        padding: 4px 0;
        font-family: inherit;
        transition: color 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .bottom-nav-item svg {
        width: 22px;
        height: 22px;
        display: block;
    }

    .bottom-nav-item.active {
        color: var(--text);
    }

    .bottom-nav-item.active svg {
        stroke-width: 2.5;
    }

    .bottom-nav-avatar {
        width: 24px;
        height: 24px;
        border-radius: 999px;
        background: var(--text);
        color: var(--bg);
        font-size: 0.65rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        border: 2px solid transparent;
        transition: border-color 0.15s ease;
    }

    .bottom-nav-item.active .bottom-nav-avatar {
        border-color: var(--text);
    }

    .bottom-nav-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

/* Ensure footer isn't hidden behind bottom nav on mobile */
@media (max-width: 640px) {
    .app-main > main, .app-content, .page-main,
    .wrap, .app-main > .wrap {
        padding-bottom: 120px !important;
    }
}

/* ─── Top Bar (new layout) ────────────────────────────── */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 28px;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
}

.breadcrumb-item {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none !important;
    padding: 4px 6px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.breadcrumb-item:hover {
    color: var(--text);
    background: var(--surface-muted);
}

.breadcrumb-item.active {
    color: var(--text);
    font-weight: 700;
}

.breadcrumb-sep {
    color: var(--muted);
    opacity: 0.3;
    font-size: 13px;
    font-weight: 400;
    user-select: none;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.top-bell:hover {
    color: var(--text);
    border-color: var(--text);
}

.top-bell svg {
    width: 14px;
    height: 14px;
}

.top-bell-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c9a84c;
}

.top-bar-profile {
    display: none;
    align-items: center;
    gap: 8px;
}

@media (max-width: 1199px) {
    .top-bar {
        padding: 0 16px;
        min-height: 48px;
    }
    .top-bar-profile { display: flex; }
}
