@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* ──────────────── Theme Tokens ──────────────── */
:root {
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2f7;
    --text-primary: #1a1d26;
    --text-secondary: #5a5f72;
    --text-tertiary: #8b90a0;
    --accent: #3b99fc;
    --accent-soft: rgba(59, 153, 252, 0.1);
    --accent-hover: #2b85e8;
    --border: rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.5);
    --category-bg: #f0f2f7;
    --category-hover: #e5e8f0;
    --slider-track: #e0e3eb;
    --success: #10b981;
    --error: #ef4444;
}

[data-theme="dark"] {
    --bg-primary: #0e1117;
    --bg-secondary: #161b26;
    --bg-tertiary: #1e2433;
    --text-primary: #e8eaf0;
    --text-secondary: #9ca3b8;
    --text-tertiary: #6b7280;
    --accent: #5daafd;
    --accent-soft: rgba(93, 170, 253, 0.12);
    --accent-hover: #4a9bef;
    --border: rgba(255, 255, 255, 0.06);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --glass-bg: rgba(14, 17, 23, 0.78);
    --glass-border: rgba(255, 255, 255, 0.08);
    --category-bg: #1e2433;
    --category-hover: #252d3e;
    --slider-track: #2a3040;
}

/* ──────────────── Reset & Base ──────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.35s ease, color 0.35s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ──────────────── Sticky Header ──────────────── */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 150;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    transition: background 0.35s, border-color 0.35s;
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.25rem;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
}
.header-logo img {
    width: 30px;
    height: 30px;
}
.header-logo .logo-dark { display: none; }
[data-theme="dark"] .header-logo .logo-light { display: none; }
[data-theme="dark"] .header-logo .logo-dark { display: block; }
.header-logo-text {
    letter-spacing: -0.02em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-dl-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    background: var(--accent);
    color: #fff;
    border-radius: 100px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}
.header-dl-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}
.header-dl-android {
    background: #34a853;
}
.header-dl-android:hover {
    background: #2d9249;
}
.header-dl-android img {
    filter: brightness(0) invert(1);
}

.theme-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.95rem;
    transition: background 0.2s, transform 0.2s;
}
.theme-toggle:hover {
    background: var(--accent-soft);
    transform: scale(1.08);
}

.header-menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 8px;
    transition: background 0.15s;
}
.header-menu-btn:hover {
    background: var(--accent-soft);
}
.header-menu-btn svg {
    width: 22px;
    height: 22px;
}

.header-dropdown {
    display: none;
    flex-direction: column;
    padding: 0.5rem 1.25rem 0.75rem;
    gap: 0.25rem;
}
.header-dropdown.open {
    display: flex;
}
.header-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s;
}
.header-dropdown-item:hover {
    background: var(--accent-soft);
}
.header-dropdown-item img {
    filter: none;
}
[data-theme="dark"] .header-dropdown-item img {
    filter: brightness(0) invert(1);
}

/* ──────────────── Layout ──────────────── */
.profile-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 4.5rem 1.25rem 3rem;
}

/* ──────────────── Profile Card ──────────────── */
.profile-card {
    text-align: center;
    padding: 2rem 1.5rem 1.75rem;
    margin-bottom: 2rem;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-soft);
    margin-bottom: 1rem;
    box-shadow: 0 4px 20px rgba(59, 153, 252, 0.15);
}
.profile-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: 2.25rem;
    font-weight: 700;
}

.profile-display-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}
.profile-nickname {
    font-size: 0.9rem;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
}
.profile-bio {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto 0.75rem;
}
.profile-joined {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-bottom: 1.25rem;
}
.profile-joined svg { width: 14px; height: 14px; opacity: 0.6; }

/* ──────────────── Stats ──────────────── */
.profile-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}
.profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}
.profile-stat-btn {
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    transition: background 0.15s;
}
.profile-stat-btn:hover {
    background: var(--accent-soft);
}

.stat-number {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: lowercase;
}
.stat-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
}

/* ──────────────── Posts Section ──────────────── */
.posts-section { margin-bottom: 2rem; }

.no-posts {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-tertiary);
}
.no-posts-icon { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.4; }
.no-posts p { font-size: 0.95rem; }

/* ──────────────── Posts Grid ──────────────── */
.posts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.post-card {
    display: flex;
    color: inherit;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    box-shadow: var(--shadow-sm);
    cursor: default;
}
.post-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent-soft);
}

/* ──── Cover with play overlay ──── */
.post-card-cover {
    position: relative;
    width: 140px;
    min-height: 100px;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    overflow: hidden;
    cursor: pointer;
}
.post-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}
.post-card-cover:hover img {
    transform: scale(1.05);
}

.post-card-cover-empty {
    display: flex;
    align-items: center;
    justify-content: center;
}
.post-card-mic-icon {
    width: 28px;
    height: 28px;
    color: var(--text-tertiary);
    opacity: 0.35;
}

.post-card-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    font-variant-numeric: tabular-nums;
}

.post-card-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s;
}
.post-card-play-overlay svg {
    width: 32px;
    height: 32px;
    color: #fff;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
    transition: transform 0.15s;
}
.post-card-cover:hover .post-card-play-overlay {
    opacity: 1;
}
.post-card-cover:hover .post-card-play-overlay svg {
    transform: scale(1.1);
}
.post-card.playing .post-card-play-overlay {
    opacity: 1;
    background: rgba(59, 153, 252, 0.35);
}

/* ──── Card body (clickable to open post) ──── */
.post-card-body {
    flex: 1;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    cursor: pointer;
}
.post-card-body:hover .post-card-title {
    color: var(--accent);
}

.post-card-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s;
}

.post-card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 0.4rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card-cats { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.4rem; }
.post-card-cat {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    background: var(--category-bg);
    padding: 2px 7px;
    border-radius: 100px;
    white-space: nowrap;
}

.post-card-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: auto;
}
.post-card-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}
.post-card-stat svg { width: 13px; height: 13px; opacity: 0.65; }
.post-card-time {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin-left: auto;
}

/* ──────────────── Load More ──────────────── */
.load-more-sentinel { display: flex; justify-content: center; padding: 2rem 0; }
.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ──────────────── CTA ──────────────── */
.cta-section { text-align: center; padding: 2rem 1rem; margin-bottom: 1.5rem; }
.cta-text { font-size: 0.9rem; color: var(--text-tertiary); margin-bottom: 1rem; }
.cta-link {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.75rem 1.5rem; background: var(--accent); color: #fff;
    border-radius: 100px; font-family: 'Outfit',sans-serif; font-size: 0.95rem;
    font-weight: 600; text-decoration: none;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(59,153,252,0.3);
}
.cta-link:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(59,153,252,0.35); }
.cta-buttons { display: flex; align-items: center; justify-content: center; gap: 0.75rem; flex-wrap: wrap; }
.cta-link-android { background: #34a853; box-shadow: 0 4px 14px rgba(52,168,83,0.3); }
.cta-link-android:hover { background: #2d9249; box-shadow: 0 6px 20px rgba(52,168,83,0.35); }

/* ──────────────── Footer ──────────────── */
.profile-footer {
    text-align: center; padding: 1.5rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.8rem; color: var(--text-tertiary);
}
.profile-footer a { color: var(--accent); text-decoration: none; }

/* ──────────────── Inline Player ──────────────── */
.inline-player {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
    display: flex; align-items: center; padding: 0.6rem 1rem; gap: 0.75rem;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.inline-player.active { transform: translateY(0); }

.inline-player-info { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; }
.inline-player-cover { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--bg-tertiary); }
.inline-player-text { display: flex; flex-direction: column; min-width: 0; }
.inline-player-title { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inline-player-time { font-size: 0.7rem; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.inline-player-controls { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
.inline-player-btn {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; background: none; border: none; cursor: pointer;
    color: var(--text-primary); border-radius: 50%; transition: background 0.15s, transform 0.1s;
}
.inline-player-btn:hover { background: var(--accent-soft); }
.inline-player-btn:active { transform: scale(0.92); }
.inline-player-btn svg { width: 22px; height: 22px; }
.inline-player-close svg { width: 18px; height: 18px; color: var(--text-tertiary); }
.inline-player-progress { position: absolute; top: -2px; left: 0; right: 0; height: 3px; background: var(--border); }
.inline-player-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.25s linear; border-radius: 0 2px 2px 0; }
[data-theme="dark"] .inline-player { box-shadow: 0 -4px 24px rgba(0,0,0,0.35); }

/* ──────────────── Bottom Sheet (Followers/Following) ──────────────── */
.sheet-backdrop {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.sheet-backdrop.active { opacity: 1; visibility: visible; }

.sheet {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 301;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 70vh;
    display: flex; flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.2);
}
.sheet.active { transform: translateY(0); }

.sheet-handle {
    width: 36px; height: 4px;
    background: var(--text-tertiary); opacity: 0.3;
    border-radius: 100px;
    margin: 10px auto 0;
    flex-shrink: 0;
}

.sheet-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1.25rem 0.5rem;
    flex-shrink: 0;
}
.sheet-title {
    font-size: 1.1rem; font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
}
.sheet-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary); border: none; border-radius: 50%;
    cursor: pointer; color: var(--text-secondary);
    font-size: 1.3rem; line-height: 1;
    transition: background 0.15s;
}
.sheet-close:hover { background: var(--accent-soft); }

.sheet-body {
    flex: 1; overflow-y: auto; padding: 0 1.25rem 1.5rem;
    -webkit-overflow-scrolling: touch;
}
.sheet-body::-webkit-scrollbar { width: 4px; }
.sheet-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }

.sheet-spinner { display: flex; justify-content: center; padding: 2.5rem 0; }
.sheet-empty {
    text-align: center; padding: 2.5rem 0;
    font-size: 0.9rem; color: var(--text-tertiary);
}

.sheet-list { display: flex; flex-direction: column; gap: 0.25rem; }

.sheet-user {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.5rem;
    border-radius: var(--radius-sm);
    text-decoration: none; color: inherit;
    transition: background 0.15s;
}
.sheet-user:hover { background: var(--accent-soft); }

.sheet-user-avatar {
    width: 44px; height: 44px;
    border-radius: 50%; object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border);
}
.sheet-user-avatar-ph {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent); color: #fff;
    font-size: 1.1rem; font-weight: 700;
}
.sheet-user-info { display: flex; flex-direction: column; min-width: 0; }
.sheet-user-name {
    font-size: 0.9rem; font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sheet-user-nick {
    font-size: 0.78rem; color: var(--text-tertiary);
}

/* ──────────────── Responsive: Mobile (hide desktop nav, show hamburger) ──────────────── */
@media (max-width: 640px) {
    .header-nav { display: none; }
    .header-menu-btn { display: flex; }

    .profile-page { padding-top: 4rem; }

    .profile-card { padding: 1.5rem 1rem 1.25rem; }
    .profile-avatar { width: 80px; height: 80px; }
    .profile-display-name { font-size: 1.3rem; }
    .profile-stats { gap: 1rem; }
    .stat-number { font-size: 1.05rem; }

    .post-card-cover { width: 110px; }
    .post-card-body { padding: 0.65rem 0.75rem; }
    .post-card-title { font-size: 0.85rem; }
    .post-card-desc { font-size: 0.75rem; -webkit-line-clamp: 1; }

    .inline-player { padding: 0.5rem 0.75rem; }

    .sheet { max-height: 80vh; }
}

/* ──────────────── Responsive: Tablet ──────────────── */
@media (min-width: 641px) {
    .header-menu-btn { display: none; }
    .header-dropdown { display: none !important; }

    .profile-page { padding: 5rem 2rem 4rem; }
    .profile-avatar { width: 112px; height: 112px; }
    .profile-display-name { font-size: 1.75rem; }

    .posts-grid { grid-template-columns: repeat(2, 1fr); }
    .post-card { flex-direction: column; }
    .post-card-cover { width: 100%; height: 160px; min-height: unset; }
    .post-card-body { padding: 0.9rem 1rem; }

    .sheet { max-width: 480px; left: 50%; right: auto; transform: translate(-50%, 100%); }
    .sheet.active { transform: translate(-50%, 0); }
}

/* ──────────────── Responsive: Desktop ──────────────── */
@media (min-width: 960px) {
    .profile-page { max-width: 900px; }
    .posts-grid { grid-template-columns: repeat(3, 1fr); }
    .post-card-cover { height: 140px; }
    .profile-card { padding: 2.5rem 2rem 2rem; }

}

/* ──────────────── Small phones ──────────────── */
@media (max-width: 380px) {
    .profile-page { padding: 3.5rem 0.65rem 2rem; }
    .post-card-cover { width: 95px; }
    .post-card-play-overlay svg { width: 24px; height: 24px; }
}

/* ──────────────── Print ──────────────── */
@media print {
    .site-header, .inline-player, .cta-section, .sheet, .sheet-backdrop { display: none !important; }
    .profile-page { padding-top: 1rem; }
}
