:root {
    --bg: #0f111a;
    --surface: #171a25;
    --surface-2: #1f2331;
    --text: #f5f7fb;
    --text-muted: #b6bfce;
    --brand: #6e45e2;
    --brand-strong: #8d6eff;
    --brand-contrast: #ffffff;
    --border: rgba(255, 255, 255, 0.14);
    --focus: #79b8ff;
    --success: #22c55e;
    --danger: #ef4444;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.24);
}

[data-theme="light"] {
    --bg: #f6f8fc;
    --surface: #ffffff;
    --surface-2: #eef2f8;
    --text: #101828;
    --text-muted: #475467;
    --border: rgba(16, 24, 40, 0.14);
    --focus: #2563eb;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

nav.navbar.fixed-top {
    padding-top: max(0.35rem, env(safe-area-inset-top, 0px));
    padding-right: max(0.25rem, env(safe-area-inset-right, 0px));
    padding-left: max(0.25rem, env(safe-area-inset-left, 0px));
}

@media (max-width: 991.98px) {
    nav.navbar.fixed-top > .container {
        flex-wrap: wrap;
        align-items: center;
    }

    nav.navbar.fixed-top > .container > .navbar-collapse {
        flex-basis: 100%;
    }

    nav.navbar.fixed-top > .container > .search-form-mobile {
        flex-basis: 100%;
    }
}

/* Member navbar (partials/nav-member.html): avatar + notifications — shared so pages without member-dashboard.css still match */
.glass-nav .notification-toggle {
    position: relative;
}

.glass-nav .notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ff4d4f;
    color: #fff;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #0f111a;
    line-height: 1;
    pointer-events: none;
}

.glass-nav button.user-profile {
    border: none;
    background: transparent;
    cursor: pointer;
    max-width: min(240px, 46vw);
}

.glass-nav .user-profile {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 50px;
    transition: background 0.25s ease, box-shadow 0.25s ease;
    padding: 0.1rem 0.45rem 0.1rem 0.1rem;
}

.glass-nav .user-profile:hover {
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 12px rgba(110, 69, 226, 0.28);
}

.glass-nav .user-profile img {
    width: 36px !important;
    height: 36px !important;
    max-width: 36px !important;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}

.glass-nav .user-profile:hover img {
    transform: scale(1.06);
}

.glass-nav .user-profile .username {
    font-size: 0.9rem;
    font-weight: 500;
    color: #f8f9fa;
    margin-left: 0.45rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loader-wrapper {
    transition: opacity 0.42s ease, visibility 0.42s ease;
    will-change: opacity;
}

a {
    text-decoration: none;
    color: inherit;
}

.is-placeholder-link {
    opacity: 0.7;
    cursor: not-allowed;
}

.ui-empty-state {
    padding: 1rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-align: center;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
}

.notification-row.unread {
    border-left: 3px solid var(--brand-strong);
}

.demo-toast {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right, 0px));
    bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    left: auto;
    z-index: 1200;
    min-width: 220px;
    max-width: min(360px, calc(100vw - 2rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    padding: 0.75rem 0.95rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    color: var(--text);
    box-shadow: var(--shadow-soft);
    transform: translateY(12px);
    opacity: 0;
}

.demo-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.demo-toast-success {
    border-color: color-mix(in srgb, var(--success) 60%, var(--border));
}

.demo-toast-warning {
    border-color: color-mix(in srgb, #f59e0b 60%, var(--border));
}

.btn,
.form-control,
.form-select,
.form-check-input,
.dropdown-item,
.chat-item,
[role="button"],
button,
input,
textarea,
select,
a {
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

:focus-visible {
    outline: 2px solid var(--focus) !important;
    outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus-visible,
.dropdown-item:focus-visible,
.chat-item:focus-visible,
a:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 40%, transparent);
}

.text-muted,
small,
.creator-title,
.author-title {
    color: var(--text-muted) !important;
}

.glass-nav,
.glass-card,
.project-card,
.feature-card,
.testimonial-card,
.chat-container,
.chat-sidebar,
.chat-main {
    border-color: var(--border);
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    color: var(--text);
}

.hup-skip-link {
    position: absolute;
    left: 0.5rem;
    top: -40px;
    z-index: 2000;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.4rem 0.7rem;
    text-decoration: none;
}

.hup-skip-link:focus {
    top: 0.5rem;
}

.with-nav-offset {
    padding-top: 80px;
}

/* Global guardrail: when a fixed-top navbar exists, push page content below it. */
body:has(.navbar.fixed-top) {
    padding-top: 80px;
}

/* Home page is intentionally excluded from global fixed-header offset. */
body.home-no-header-offset:has(.navbar.fixed-top) {
    padding-top: 0;
}

/* Prevent double spacing on pages already using explicit offset utility. */
body:has(.navbar.fixed-top) .with-nav-offset {
    padding-top: 0;
}

/* Global guardrail: when member sidebar exists, keep main content clear of it. */
body:has(.sidebar#sidebar) .main-content {
    margin-left: 250px;
}

/* Collapsed member shell support. */
body.member-shell-collapsed .main-content,
body:has(.sidebar#sidebar.collapsed) .main-content {
    margin-left: 60px;
}

.workspace-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(12px);
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding: 1rem;
    overflow-y: auto;
}

.workspace-sidebar.open {
    transform: translateX(0);
}

.workspace-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1090;
    display: none;
}

.workspace-sidebar-backdrop.show {
    display: block;
}

.workspace-sidebar .sidebar-link {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    margin-bottom: 0.4rem;
    border: 1px solid transparent;
}

.workspace-sidebar .sidebar-link:hover,
.workspace-sidebar .sidebar-link.active {
    background: color-mix(in srgb, var(--brand) 25%, transparent);
    border-color: var(--border);
}

.main-content,
.container,
.container-fluid {
    max-width: 100%;
}

.glass-card,
.project-card,
.feature-card,
.testimonial-card {
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
}

.project-card:hover,
.feature-card:hover,
.testimonial-card:hover,
.glass-card:hover {
    transform: translateY(-2px);
}

.project-card.project-card-clickable {
    cursor: pointer;
}

.project-card .project-creator {
    cursor: pointer;
}

@media (max-width: 768px) {
    .with-nav-offset {
        padding-top: calc(72px + env(safe-area-inset-top, 0px));
    }

    .hero-section {
        min-height: 560px !important;
        height: auto !important;
        padding-top: 130px;
    }
}

@media (max-width: 991.98px) {
    body:has(.sidebar#sidebar) .main-content,
    body.member-shell-collapsed .main-content,
    body:has(.sidebar#sidebar.collapsed) .main-content {
        margin-left: 0;
    }
}

/* Home Masterpieces / Showcase skeleton & filters */
.home-skeleton-card,
.showcase-skeleton-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    border: 1px solid var(--border);
    padding: var(--space-3);
}

.home-skeleton,
.showcase-skel {
    display: block;
    border-radius: var(--radius-sm);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.04) 75%
    );
    background-size: 200% 100%;
    animation: hup-skel-shimmer 1.15s ease-in-out infinite;
}

@keyframes hup-skel-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.home-skeleton--thumb,
.showcase-skel-thumb {
    height: 160px;
    margin-bottom: var(--space-3);
}

.home-skeleton--line,
.showcase-skel-line {
    height: 12px;
    margin-bottom: var(--space-2);
}

.home-skeleton--line-lg,
.showcase-skel-line--lg {
    width: 70%;
    height: 18px;
}

.home-skeleton--line-sm {
    width: 45%;
}

.showcase-grid--busy {
    opacity: 0.42;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.showcase-toolbar {
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-5);
}

.showcase-chip {
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text);
    margin: var(--space-1);
    background: transparent;
    padding: 0.35rem 0.85rem;
}

.showcase-chip:hover {
    border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
    color: var(--text);
}

.showcase-chip.active {
    background: color-mix(in srgb, var(--brand) 32%, transparent);
    border-color: color-mix(in srgb, var(--brand-strong) 55%, var(--border));
    color: var(--text);
}

.showcase-cat-results {
    position: absolute;
    z-index: 40;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    max-height: 280px;
    overflow-y: auto;
    background: color-mix(in srgb, var(--surface) 96%, #000 4%);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 40px color-mix(in srgb, #000 35%, transparent);
}

.showcase-cat-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.85rem;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.showcase-cat-item:last-child {
    border-bottom: 0;
}

.showcase-cat-item:hover,
.showcase-cat-item[aria-selected="true"] {
    background: color-mix(in srgb, var(--brand) 22%, transparent);
}

@media (max-width: 576px) {
    .demo-toast {
        left: max(1rem, env(safe-area-inset-left, 0px));
        right: max(1rem, env(safe-area-inset-right, 0px));
        max-width: none;
        width: auto;
        min-width: 0;
    }

    .member-sidebar-open-btn,
    .workspace-sidebar-toggle,
    .navbar-toggler,
    .theme-toggle {
        min-height: 44px;
        min-width: 44px;
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
