/* Facebook Profile Biolink */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.fb-light {
    --fb-bg: #f0f2f5;
    --fb-surface: #ffffff;
    --fb-text: #050505;
    --fb-text-secondary: #65676b;
    --fb-border: #ced0d4;
    --fb-btn-secondary-bg: #e4e6eb;
    --fb-btn-secondary-text: #050505;
    --fb-tab-active: #1877f2;
    --fb-tab-inactive: #65676b;
    --fb-modal-bg: #ffffff;
    --fb-cover-fallback: linear-gradient(135deg, #1877f2 0%, #42b72a 100%);
}

.fb-dark {
    --fb-bg: #18191a;
    --fb-surface: #242526;
    --fb-text: #e4e6eb;
    --fb-text-secondary: #b0b3b8;
    --fb-border: #3e4042;
    --fb-btn-secondary-bg: #3a3b3c;
    --fb-btn-secondary-text: #e4e6eb;
    --fb-tab-active: #2d88ff;
    --fb-tab-inactive: #b0b3b8;
    --fb-modal-bg: #242526;
    --fb-cover-fallback: linear-gradient(135deg, #1877f2 0%, #3a3b3c 100%);
}

html, body {
    margin: 0;
    background: var(--fb-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.fb-app {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--fb-bg);
    color: var(--fb-text);
    position: relative;
}

/* Top bar */
.fb-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 8px;
    background: var(--fb-surface);
    border-bottom: 1px solid var(--fb-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.fb-topbar-title {
    font-size: 17px;
    font-weight: 700;
}

.fb-topbar-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--fb-text);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
}

.fb-topbar-btn:active { background: var(--fb-btn-secondary-bg); }

/* Cover + avatar */
.fb-cover-section {
    position: relative;
    background: var(--fb-surface);
    padding-bottom: 16px;
}

.fb-cover {
    height: 160px;
    background: var(--fb-cover-fallback);
    background-size: cover;
    background-position: center;
}

.fb-avatar-block {
    position: relative;
    margin-top: -48px;
    padding: 0 16px;
}

.fb-story-ring {
    background: linear-gradient(135deg, #1877f2, #42b72a, #1877f2);
    border: none;
    border-radius: 50%;
    padding: 4px;
    cursor: pointer;
    display: block;
    line-height: 0;
}

.fb-story-ring-inner {
    display: block;
    background: var(--fb-surface);
    border-radius: 50%;
    padding: 4px;
}

.fb-story-ring img,
.fb-avatar-plain img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 4px solid var(--fb-surface);
}

.fb-avatar-ph {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1877f2, #42b72a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 36px;
    font-weight: 700;
    border: 4px solid var(--fb-surface);
}

/* Profile info */
.fb-main {
    background: var(--fb-surface);
    border-top: 1px solid var(--fb-border);
    margin-top: 8px;
}

.fb-profile {
    padding: 0 16px 12px;
    background: var(--fb-surface);
}

.fb-name {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 2px;
}

.fb-handle {
    font-size: 14px;
    color: var(--fb-text-secondary);
    margin-bottom: 10px;
}

.fb-stats {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--fb-text-secondary);
}

.fb-stats strong {
    color: var(--fb-text);
    font-weight: 600;
}

.fb-bio {
    font-size: 15px;
    line-height: 1.4;
    margin-bottom: 8px;
    white-space: pre-wrap;
}

.fb-website {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--fb-tab-active);
    text-decoration: none;
    margin-bottom: 12px;
}

.fb-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.fb-btn {
    flex: 1;
    min-width: 0;
    height: 36px;
    border: none;
    border-radius: var(--fb-btn-radius, 6px);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-family: inherit;
    padding: 0 12px;
}

.fb-btn-primary {
    background: var(--fb-btn-primary, #1877f2);
    color: var(--fb-btn-text, #fff);
}

.fb-btn-secondary {
    background: var(--fb-btn-secondary-bg);
    color: var(--fb-btn-secondary-text);
}

.fb-btn-icon {
    flex: 0 0 36px;
    padding: 0;
}

.fb-btn.friends,
.fb-btn.following {
    background: var(--fb-btn-secondary-bg);
    color: var(--fb-text-secondary);
}

.fb-btn:active { opacity: 0.85; }

/* Albums / categories */
.fb-albums {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

.fb-albums::-webkit-scrollbar { display: none; }

.fb-album {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 72px;
    padding: 0;
    color: var(--fb-text);
    font-family: inherit;
}

.fb-album-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    background: var(--fb-btn-secondary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid transparent;
}

.fb-album.active .fb-album-thumb {
    border-color: var(--fb-tab-active);
}

.fb-album-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fb-album-icon {
    font-size: 20px;
    color: var(--fb-text-secondary);
}

.fb-album-label {
    font-size: 12px;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tabs */
.fb-tabs {
    display: flex;
    border-top: 1px solid var(--fb-border);
    border-bottom: 1px solid var(--fb-border);
    background: var(--fb-surface);
}

.fb-tab {
    flex: 1;
    height: 44px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--fb-tab-inactive);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    font-family: inherit;
}

.fb-tab.active {
    color: var(--fb-tab-active);
    border-bottom-color: var(--fb-tab-active);
}

/* Grid */
.fb-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 3px;
    background: var(--fb-bg);
}

.fb-posts-grid[hidden],
.fb-reels-grid[hidden] { display: none !important; }

.fb-post-item {
    position: relative;
    aspect-ratio: 1;
    border: none;
    padding: 0;
    cursor: pointer;
    background: var(--fb-btn-secondary-bg);
    overflow: hidden;
}

.fb-post-item img,
.fb-post-item .profile-grid-video,
.ig-post-item img,
.ig-post-item .profile-grid-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.fb-post-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--fb-text-secondary);
}

.fb-post-item.hidden { display: none; }

.fb-reel-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}

.fb-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 16px;
    color: var(--fb-text-secondary);
    font-size: 14px;
    background: var(--fb-surface);
}

.fb-brand {
    text-align: center;
    padding: 16px;
    font-size: 11px;
    background: var(--fb-surface);
}

.fb-brand a { color: var(--fb-text-secondary); text-decoration: none; }

/* Story viewer */
.fb-story-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.fb-story-viewer[hidden] { display: none !important; }

.fb-story-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 12px;
    max-width: 430px;
    margin: 0 auto;
}

.fb-story-progress {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.fb-story-progress-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    overflow: hidden;
}

.fb-story-progress-fill {
    height: 100%;
    background: #1877f2;
    width: 0%;
}

.fb-story-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.fb-story-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.fb-story-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.fb-story-content {
    flex: 1;
    width: 100%;
    max-width: 430px;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 52px 12px 40px;
    box-sizing: border-box;
}

.fb-story-content img,
.fb-story-content video {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.fb-story-caption {
    position: absolute;
    bottom: 80px;
    left: 16px;
    right: 16px;
    color: #fff;
    text-align: center;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.fb-story-link-btn {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: #1877f2;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
}

.fb-story-nav {
    position: absolute;
    top: 60px;
    bottom: 0;
    width: 35%;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 5;
}

.fb-story-prev { left: 0; }
.fb-story-next { right: 0; }

/* Modal */
.fb-modal {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.fb-modal[hidden] { display: none !important; }

.fb-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.fb-modal-sheet {
    position: relative;
    background: var(--fb-modal-bg);
    border-radius: 12px 12px 0 0;
    width: 100%;
    max-width: 430px;
    max-height: 90vh;
    overflow-y: auto;
    animation: fbSlideUp 0.25s ease;
}

@keyframes fbSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.fb-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--fb-text);
    cursor: pointer;
    z-index: 2;
}

.fb-modal-image-wrap {
    width: 100%;
    aspect-ratio: 1;
    background: var(--fb-btn-secondary-bg);
    position: relative;
}

.fb-modal-image-wrap img,
.fb-modal-image-wrap .fb-modal-video {
    width: 100%;
    height: 100%;
    display: block;
}

.fb-modal-image-wrap img {
    object-fit: cover;
}

.fb-modal-image-wrap img[hidden],
.fb-modal-video[hidden] {
    display: none !important;
}

.fb-modal-image-wrap.fb-modal-media-video {
    aspect-ratio: 9 / 16;
    max-height: min(70vh, 560px);
    background: #000;
}

.fb-modal-video {
    object-fit: contain;
    background: #000;
}

.fb-modal-body {
    padding: 20px 16px 32px;
}

.fb-modal-body h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.fb-modal-body p {
    font-size: 15px;
    color: var(--fb-text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.fb-modal-cta {
    display: block;
    width: 100%;
    height: 44px;
    line-height: 44px;
    text-align: center;
    padding: 0;
}

@media (min-width: 768px) {
    .fb-cover { height: 200px; }
    .fb-story-ring img, .fb-avatar-plain img { width: 120px; height: 120px; }
    .fb-avatar-ph { width: 120px; height: 120px; font-size: 44px; }
}
