/**
 * Member Category Page Styles with Sliding Chat
 * 
 * Styles for the custom member category page with sliding chat functionality
 * 
 * @package SndCore\Assets
 * @since 2.0.0
 */

.snd-member-category-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

.snd-member-content {
    display: block;
    width: 100%;
}

/* Admin upload hint */
.snd-admin-upload-hint {
    margin-bottom: 20px;
    padding: 10px 15px;
    background: rgba(187, 134, 252, 0.1);
    border: 1px solid rgba(187, 134, 252, 0.3);
    border-radius: 6px;
    text-align: center;
}

.snd-admin-upload-hint small {
    color: #bb86fc;
    font-size: 12px;
}

/* Floating Animation Mode Button */
.snd-animation-float-button {
    position: fixed;
    top: 20px;
    left: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50px;
    padding: 15px 25px;
    cursor: pointer;
    z-index: 10003;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    transform: translateY(0);
}

.snd-animation-float-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.snd-animation-float-button:active {
    transform: translateY(0);
}

.snd-animation-button-emoji {
    font-size: 2rem;
    line-height: 1;
    animation: sndEmojiPulse 2s ease-in-out infinite;
}

.snd-animation-button-text {
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Emoji pulse animation */
@keyframes sndEmojiPulse {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.1) rotate(-5deg);
    }
    75% {
        transform: scale(1.1) rotate(5deg);
    }
}

/* Posts Container */
.snd-posts-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.snd-category-title {
    font-size: 2rem;
    margin-bottom: 30px;
    color: #d00;
    padding-bottom: 10px;
}

.snd-posts-grid {
    column-count: 2;
    column-gap: 20px;
    margin-bottom: 20px;
}

.snd-post-card {
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    break-inside: avoid;
    margin-bottom: 20px;
}

.snd-post-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border-color: #555;
}

.snd-post-thumbnail {
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.snd-post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.snd-post-content {
    padding: 20px;
}

/* Post Header Styles */
.snd-post-header {
    padding: 20px 20px 5px 20px;
    margin-bottom: 0;
}

.snd-post-title {
    font-size: 1.3rem;
    margin: 0;
    line-height: 1.3;
}

.snd-post-title a {
    color: #e0e0e0;
    text-decoration: none;
    transition: color 0.2s ease;
}

.snd-post-title a:hover {
    color: #bb86fc;
}

/* Post Meta at bottom */
.snd-post-meta {
    color: #999;
    font-size: 0.8rem;
    margin-top: 15px;
    padding-top: 10px;
    text-align: right;
}

/* Post Media Styles */
.snd-post-media {
    margin: 15px 20px 20px 20px;
    padding-top: 15px;
}

.snd-media-item {
    margin-bottom: 20px;
}

.snd-media-item:last-child {
    margin-bottom: 0;
}

/* Image Media */
.snd-media-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.snd-media-caption {
    margin: 8px 0 0 0;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* Audio Media */
.snd-media-audio {
    padding: 0;
    border-radius: 6px;
}

.snd-media-title {
    margin: 0 0 10px 0;
    font-size: 1rem;
    color: #e0e0e0;
    font-weight: 600;
}

.snd-member-audio {
    width: 100%;
    margin: 10px 0;
}

/* Video Media */
.snd-media-video {
    padding: 0;
    border-radius: 6px;
}

.snd-member-video {
    width: 100%;
    margin: 10px 0;
    border-radius: 4px;
    overflow: hidden;
}

/* File Downloads */
.snd-media-file {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
}

.snd-media-download {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #333;
    transition: color 0.2s ease;
}

.snd-media-download:hover {
    color: #8e44ad;
}

.snd-file-icon {
    background: #8e44ad;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}

.snd-file-name {
    font-weight: 500;
}

.snd-media-description {
    margin: 10px 0 0 0;
    font-size: 0.9rem;
    color: #b0b0b0;
    line-height: 1.5;
}

.snd-post-excerpt {
    color: #b0b0b0;
    line-height: 1.6;
    margin-bottom: 15px;
}

.snd-post-read-more {
    padding-top: 5px;
}

.snd-read-more {
    color: #bb86fc;
    text-decoration: none;
    font-weight: 600;
}

.snd-read-more:hover {
    text-decoration: underline;
}

.snd-no-posts {
    text-align: center;
    padding: 40px 20px;
    background: #f9f9f9;
    border-radius: 8px;
    color: #666;
}

/* Sliding Chat Container */
.snd-chat-container {
    position: fixed;
    top: 50%;
    right: -320px; /* Hidden by default, only tab visible */
    transform: translateY(-50%);
    width: 350px;
    height: 500px;
    background: #fff;
    border: 1px solid #ddd;
    border-right: none;
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 0 15px rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

.snd-chat-container.snd-chat-expanded {
    right: 0; /* Slide in */
}

/* Large Screen Mode for Chat */
.snd-chat-container.snd-chat-large {
    width: 80vw;
    height: 80vh;
    max-width: 1000px;
    max-height: 700px;
    top: 50%;
    right: 50%;
    transform: translate(50%, -50%);
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
}

.snd-chat-container.snd-chat-large .snd-chat-tab {
    display: none; /* Hide tab in large mode */
}

/* Chat Tab - Always visible */
.snd-chat-tab {
    position: absolute;
    left: -40px;
    top: 20px;
    width: 40px;
    height: 100px;
    background: #8e44ad;
    border: 1px solid #8e44ad;
    border-right: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    user-select: none;
}

.snd-chat-tab:hover {
    background: #732d91;
}

.snd-chat-tab-icon {
    position: absolute;
    top: 9px;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.snd-chat-container.snd-chat-expanded .snd-chat-tab-icon {
    transform: rotate(180deg);
}

.snd-chat-header {
    background: #8e44ad;
    color: white;
    padding: 15px 20px;
    border-radius: 8px 0 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer; /* Make header clickable */
    transition: background-color 0.2s ease;
}

.snd-chat-header:hover {
    background: #732d91;
}

.snd-chat-container.snd-chat-large .snd-chat-header {
    border-radius: 8px 8px 0 0;
}

.snd-chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.snd-chat-header h3::after {
    content: " ↗";
    font-size: 0.8rem;
    opacity: 0.7;
    margin-left: 8px;
}

.snd-chat-container.snd-chat-large .snd-chat-header h3::after {
    content: " ↙";
}

.snd-chat-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-size: 1.2rem;
    line-height: 1;
}

.snd-chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.snd-chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.snd-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.snd-chat-message {
    margin-bottom: 15px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.snd-chat-message:last-child {
    margin-bottom: 0;
}

.snd-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.snd-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.snd-message-author {
    font-weight: bold;
    color: #333;
    font-size: 0.85rem;
}

.snd-message-date {
    color: #999;
    font-size: 0.75rem;
    margin-left: auto;
}

.snd-message-content {
    color: #444;
    line-height: 1.4;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.snd-message-actions {
    display: flex;
    gap: 8px;
}

.snd-message-action {
    background: none;
    border: none;
    color: #8e44ad;
    cursor: pointer;
    font-size: 0.75rem;
    text-decoration: underline;
    padding: 0;
}

.snd-message-action:hover {
    color: #732d91;
}

.snd-message-replies {
    margin-top: 8px;
    padding-left: 15px;
    border-left: 2px solid #f0f0f0;
}

.snd-message-reply {
    margin-bottom: 8px;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 4px;
    font-size: 0.85rem;
}

.snd-reply-form {
    margin-top: 8px;
    padding-left: 15px;
    display: none;
}

.snd-reply-form.active {
    display: block;
}

.snd-reply-input {
    width: 100%;
    min-height: 50px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.snd-reply-actions {
    display: flex;
    gap: 8px;
}

.snd-reply-submit,
.snd-reply-cancel {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.snd-reply-submit {
    background: #8e44ad;
    color: white;
}

.snd-reply-submit:hover {
    background: #732d91;
}

.snd-reply-cancel {
    background: #ccc;
    color: #333;
}

.snd-reply-cancel:hover {
    background: #bbb;
}

/* Chat Form */
.snd-chat-form {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    border-radius: 8px 0 0 8px;
}

.snd-chat-input-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#snd-chat-message {
    flex: 1;
    min-height: 60px;
    max-height: 100px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
}

.snd-chat-submit {
    background: #8e44ad;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.85rem;
    transition: background-color 0.2s ease;
    min-width: 50px;
}

.snd-chat-submit:hover {
    background: #732d91;
}

.snd-chat-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Loading States */
.snd-chat-loading {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 0.9rem;
}

.snd-chat-error {
    background: #fee;
    color: #d00;
    padding: 8px 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    border: 1px solid #fcc;
    font-size: 0.85rem;
}

/* Animation Mode Styles */
.snd-member-category-page.snd-animation-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0a0a0a;
    z-index: 9999;
    overflow: hidden;
    margin: 0;
    max-width: none;
    padding: 0;
}

.snd-member-category-page.snd-animation-mode .snd-chat-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    transform: none;
    border-radius: 0;
    z-index: 10000; /* Place chat container below the animation canvas */
}

.snd-member-category-page.snd-animation-mode .snd-chat-content {
    height: calc(100vh - 60px);
    overflow-y: auto;
}

.snd-member-category-page.snd-animation-mode .snd-chat-messages {
    opacity: 0.7;
    background: rgba(255, 255, 255, 0.8);
}

.snd-member-category-page.snd-animation-mode .snd-chat-form {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 400px;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 10002; /* Chat form above canvas */
}

.snd-animation-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* Allow clicks/scroll to pass through; animations are visual only */
    pointer-events: none;
    z-index: 10001; /* Visual layer above chat messages, but non-interactive */
    background: transparent; /* transparent so underlying chat/messages remain visible */
}

/* Ensure float button always above canvas */
.snd-animation-float-button { z-index: 10004; }

/* Avatar ball that follows the cursor */
.snd-animation-avatar-ball {
    position: fixed;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    border: 2px solid rgba(255,255,255,0.9);
    z-index: 10004; /* Above canvas and fun root */
    pointer-events: none; /* don't block clicks */
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    opacity: 1;
}

/* Fun root chat layering: show faint messages under canvas, bottom input captures clicks */
.snd-fun-root .snd-chat-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    transform: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    z-index: 10002; /* above canvas */
    background: rgba(10,10,10,0.85); /* soft dark backdrop so site header doesn’t bleed through */
}

.snd-fun-root .snd-chat-messages {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 64px; /* leave space for input */
    opacity: 0.55; /* feint */
    background: transparent;
    pointer-events: auto; /* allow scroll */
    border: none;
}

/* Disable interactive elements inside messages so clicks don't intercept animations */
.snd-fun-root .snd-chat-messages .snd-message-actions,
.snd-fun-root .snd-chat-messages .snd-message-action,
.snd-fun-root .snd-chat-messages a,
.snd-fun-root .snd-chat-messages button,
.snd-fun-root .snd-chat-messages input,
.snd-fun-root .snd-chat-messages textarea { pointer-events: none; }

.snd-fun-root .snd-chat-form {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10003; /* above canvas to capture input */
    background: rgba(255,255,255,0.98);
    pointer-events: auto; /* allow typing/clicks */
    width: 100vw; /* full-width input bar */
    border-top: 1px solid rgba(0,0,0,0.08);
}

/* Disable pointer events on header and tab so they don't block animations */
.snd-fun-root .snd-chat-header,
.snd-fun-root .snd-chat-tab {
    display: none !important; /* hide chrome in fun mode */
}

/* Ensure float button remains on top */
.snd-fun-root .snd-animation-float-button {
    z-index: 10005;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 12px; /* bigger hit area while staying emoji-only */
    min-width: 56px;
    min-height: 56px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}
.snd-fun-root .snd-animation-button-text { display: none !important; }

/* When lifted to body in fun mode */
.snd-animation-float-button.snd-animation-float-button--fun {
    position: fixed !important;
    top: 12px !important;
    left: 12px !important;
    transform: none !important;
    z-index: 10006 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    pointer-events: auto !important;
    padding: 14px !important;
    min-width: 60px !important;
    min-height: 60px !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    touch-action: manipulation;
}
.snd-animation-float-button.snd-animation-float-button--fun .snd-animation-button-text { display: none !important; }
.snd-animation-float-button.snd-animation-float-button--fun .snd-animation-button-emoji { font-size: 2.2rem; line-height: 1; }

.snd-animation-mode .snd-posts-sidebar,
.snd-animation-mode .snd-member-content {
    display: none;
}

/* In-place fun container */
.snd-fun-page {
    position: fixed;
    inset: 0;
    z-index: 10000; /* below float button (10003) and chat form (10002), above messages */
    display: none;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.snd-fun-page .snd-fun-inner { text-align: center; color: #ddd; }
.snd-fun-page .snd-fun-title { margin: 0 0 8px; }
.snd-fun-page .snd-fun-sub { margin: 0; opacity: 0.9; }

.snd-animation-mode .snd-fun-page { display: flex; }

.snd-animation-mode .snd-animation-float-button {
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 1);
    color: #333;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.3);
    z-index: 10003; /* Float button above everything in animation mode */
}

.snd-animation-mode .snd-animation-float-button:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-3px);
    box-shadow: 0 8px 35px rgba(0, 0, 0, 0.4);
}

.snd-animation-mode .snd-animation-button-text {
    color: #333;
    text-shadow: none;
}

.snd-animation-mode .snd-animation-button-text::after {
    content: " (Exit)";
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Animation User Tags */
.snd-member-user-tag {
    position: fixed;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10002;
    transform: translate(-50%, 0);
    animation: sndMemberUserTag 2s ease-out forwards;
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* Avatar tag replaces text tag for remote users */
.snd-member-user-avatar-tag {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    border: 2px solid rgba(255,255,255,0.95);
}

/* User Tag Animation */
@keyframes sndMemberUserTag {
    0% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -10px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -20px) scale(0.8);
    }
}

/* Trail Particle Animations */
@keyframes sndMemberTrailParticle {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
    }
}

@keyframes sndMemberTrailEnd {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 1;
    }
    50% {
        transform: translate(var(--endX), var(--endY)) scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: translate(var(--endX), var(--endY)) scale(0);
        opacity: 0;
    }
}

@keyframes sndMemberClickBurst {
    0% {
        transform: translate(-50%, -50%) scale(0.2) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translate(calc(-50% + var(--burstX)), calc(-50% + var(--burstY))) scale(1) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: translate(calc(-50% + var(--burstX)), calc(-50% + var(--burstY))) scale(0.5) rotate(360deg);
        opacity: 0;
    }
}

/* Access Denied Page */
.snd-member-access-denied {
    max-width: 600px;
    margin: 40px auto;
    padding: 40px 20px;
    text-align: center;
}

.snd-member-access-denied .snd-title {
    font-size: 2.5rem;
    color: #8e44ad;
    margin-bottom: 20px;
}

.snd-member-access-denied .snd-text {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #666;
    margin-bottom: 30px;
}

.snd-member-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.snd-member-actions .button {
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.2s ease;
}

.snd-member-actions .button:not(.secondary) {
    background: #8e44ad;
    color: white;
}

.snd-member-actions .button:not(.secondary):hover {
    background: #732d91;
}

.snd-member-actions .button.secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.snd-member-actions .button.secondary:hover {
    background: #eee;
}

/* Responsive Design */
@media (max-width: 768px) {
    .snd-chat-container {
        right: -100%;
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height for modern browsers */
        top: 0;
        transform: none;
        border-radius: 0;
        /* Ensure content stays within safe areas on iOS */
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }
    
    .snd-chat-container.snd-chat-expanded {
        right: 0;
    }
    
    .snd-chat-tab {
        left: -30px;
        width: 30px;
        height: 80px;
        font-size: 0.8rem;
        /* Ensure tab is positioned relative to safe area */
        top: calc(20px + env(safe-area-inset-top, 0));
    }
    
    /* Chat content adjustments for mobile */
    .snd-chat-content {
        /* Reserve space for mobile browser UI */
        margin-bottom: max(60px, env(safe-area-inset-bottom, 0));
        height: calc(100% - 60px); /* Account for header */
        min-height: 0;
    }
    
    /* Ensure chat form stays above mobile browser UI */
    .snd-chat-form {
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 1px solid #eee;
        /* Additional padding for iOS home indicator */
        padding-bottom: calc(15px + env(safe-area-inset-bottom, 0));
        z-index: 10;
    }
    
    /* Adjust messages container to account for sticky form */
    .snd-chat-messages {
        padding-bottom: 20px;
        /* Prevent content from being hidden behind form */
        margin-bottom: 0;
    }
    
    .snd-posts-grid {
        column-count: 1;
    }
    
    .snd-member-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .snd-member-actions .button {
        width: 200px;
    }

    /* Large mode takes full screen on mobile with proper constraints */
    .snd-chat-container.snd-chat-large {
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height */
        top: 0;
        right: 0;
        transform: none;
        border-radius: 0;
        /* Maintain safe area padding in large mode */
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }
    
    /* Animation Mode Mobile Styles */
    .snd-animation-mode .snd-animation-float-button {
        top: env(safe-area-inset-top, 10px);
        left: 10px;
        padding: 12px 20px;
    }

    /* Fun mode float button (emoji-only) mobile sizing */
    .snd-fun-root .snd-animation-float-button {
        top: calc(env(safe-area-inset-top, 8px) + 8px);
        left: 10px;
        padding: 14px;
        min-width: 60px;
        min-height: 60px;
    }
    .snd-fun-root .snd-animation-button-emoji {
        font-size: 2.2rem;
    }

    /* Fun-mode dedicated chat (vanilla) */
    .snd-fun-root {
        position: fixed;
        inset: 0;
        z-index: 9999; /* below canvas and float button that we set higher */
        pointer-events: none; /* don't trap taps; specific children re-enable */
    }
    .snd-fun-chat {
        position: fixed;
        inset: 0;
        display: flex;
        flex-direction: column;
        pointer-events: none; /* allow animations to pass through by default */
    }
    .snd-fun-chat-messages {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
        opacity: 0.6;
    }
    .snd-fun-chat-form {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        background: rgba(255,255,255,0.95);
        border-top: 1px solid rgba(0,0,0,0.1);
        display: flex;
        gap: 8px;
        padding: 10px;
        pointer-events: auto; /* input must be clickable */
        z-index: 10002;
    }
    .snd-fun-chat-input {
        flex: 1;
        padding: 10px 12px;
        border-radius: 6px;
        border: 1px solid #ddd;
    }
    .snd-fun-chat-submit {
        padding: 10px 14px;
        background: #8e44ad;
        border: none;
        border-radius: 6px;
        color: #fff;
        cursor: pointer;
    }
    .snd-fun-chat-message {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 8px;
        padding: 10px 12px;
        margin-bottom: 12px;
    }
    .snd-fun-chat-header { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: #555; }
    .snd-fun-chat-avatar { width: 20px; height: 20px; border-radius: 50%; }
    .snd-fun-chat-author { font-weight: 600; margin-right: 8px; }
    .snd-fun-chat-date { opacity: 0.7; font-size: 0.8rem; }
    .snd-fun-chat-text { margin-top: 6px; color: #333; }
    
    .snd-animation-mode .snd-animation-button-emoji {
        font-size: 1.5rem;
    }
    
    .snd-animation-mode .snd-animation-button-text {
        font-size: 0.8rem;
    }
    
    .snd-member-category-page.snd-animation-mode .snd-chat-container {
        width: 100vw;
        background: rgba(255, 255, 255, 0.9);
    }
    
    .snd-member-category-page.snd-animation-mode .snd-chat-form {
        width: 100vw;
        padding-bottom: calc(15px + env(safe-area-inset-bottom, 0));
    }
}

@media (max-width: 480px) {
    .snd-member-category-page {
        padding: 10px;
    }
    
    .snd-category-title {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
    
    .snd-chat-header {
        padding: 12px 15px;
    }
    
    .snd-chat-messages,
    .snd-chat-form {
        padding: 12px;
    }
    
    .snd-member-access-denied {
        padding: 20px 10px;
    }
    
    .snd-member-access-denied .snd-title {
        font-size: 2rem;
    }
}

/* iPhone Pro devices (iPhone 14 Pro, 15 Pro, 16 Pro) specific adjustments */
@media only screen 
  and (device-width: 430px) 
  and (device-height: 932px) 
  and (-webkit-device-pixel-ratio: 3) {
    
    .snd-chat-container {
        /* Use screen-specific height accounting for Dynamic Island and home indicator */
        height: calc(100vh - 44px); /* Account for status bar and Dynamic Island */
        height: calc(100dvh - 44px);
    }
    
    .snd-chat-form {
        /* Extra padding for iPhone Pro home indicator */
        padding-bottom: calc(15px + 34px); /* 34px is typical iOS home indicator height */
    }
    
    .snd-posts-sidebar {
        /* Apply same constraints to posts sidebar */
        height: calc(100vh - 44px);
        height: calc(100dvh - 44px);
    }
}

/* Additional fallback for all iOS devices with notch/Dynamic Island */
@supports (padding-top: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        /* Do not lock the entire page on mobile when animation mode is toggled */
        .snd-member-category-page.snd-animation-mode {
            position: relative;
            top: auto;
            left: auto;
            width: 100%;
            height: auto;
            min-height: 100dvh;
            overflow: auto;
            background: inherit;
            z-index: auto;
            margin: 0;
            max-width: none;
            padding: 0;
        }

        .snd-chat-container,
        .snd-posts-sidebar {
            /* Use safe area for height calculation */
            height: calc(100vh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
            height: calc(100dvh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
        }
        
        .snd-chat-form {
            /* Ensure form stays above any iOS UI elements */
            padding-bottom: calc(15px + env(safe-area-inset-bottom, 20px));
        }
    }
}

/* ========================================
   SLIDING POSTS SIDEBAR (LEFT)
   ======================================== */

/* Posts Sidebar - Slides in from left */


.snd-posts-sidebar {
    position: fixed;
    top: 50%;
    left: -320px; /* Hidden by default, shows 40px tab */
    transform: translateY(-50%);
    width: 350px;
    height: 500px;
    background: #fff;
    border: 1px solid #ddd;
    border-left: none;
    border-radius: 0 8px 8px 0 !important;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: visible !important;
}

.snd-posts-sidebar.snd-posts-expanded {
    left: 0; /* Slide in */
}

/* Large Screen Mode for Posts */
.snd-posts-sidebar.snd-posts-large {
    width: 80vw;
    height: 80vh;
    max-width: 1000px;
    max-height: 700px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
}

.snd-posts-sidebar.snd-posts-large .snd-posts-tab {
    display: none; /* Hide tab in large mode */
}

/* Posts Sidebar Tab - Always visible - EXACT COPY OF CHAT TAB BUT MIRRORED */

.snd-posts-tab {
    position: absolute;
    right: -40px;
    top: 20px;
    width: 40px;
    height: 100px;
    background: #8e44ad !important;
    border: 1px solid #8e44ad;
    border-left: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    user-select: none;
}

.snd-posts-tab:hover {
    background: #732d91 !important;
}

.snd-posts-tab-text {
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
}

.snd-posts-tab-icon {
    position: absolute;
    top: 6px;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
    color: white;
}

.snd-posts-sidebar.snd-posts-expanded .snd-posts-tab-icon {
    transform: rotate(180deg);
}

/* Posts Sidebar Header */
.snd-posts-header {
    background: #8e44ad;
    color: white;
    padding: 15px 20px;
    flex-shrink: 0;
    border-radius: 0 8px 0 0;
    cursor: pointer; /* Make header clickable */
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.snd-posts-header:hover {
    background: #732d91;
}

.snd-posts-sidebar.snd-posts-large .snd-posts-header {
    border-radius: 8px 8px 0 0;
}

.snd-posts-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-size: 1.2rem;
    line-height: 1;
}

.snd-posts-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.snd-posts-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.snd-posts-header h3::after {
    content: " ↗";
    font-size: 0.8rem;
    opacity: 0.7;
    margin-left: 8px;
}

.snd-posts-sidebar.snd-posts-large .snd-posts-header h3::after {
    content: " ↙";
}

/* Posts Sidebar Content */
.snd-posts-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
     border-radius: 0 8px 8px 0;
}

/* Posts List */
.snd-posts-list {
    margin-bottom: 30px;
}

.snd-posts-list h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: #333;
    border-bottom: 2px solid #8e44ad;
    padding-bottom: 5px;
}

.snd-post-item {
    display: block;
    padding: 12px 15px;
    margin-bottom: 8px;
    background: white;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.snd-post-item:hover {
    background: #f0f0f0;
    transform: translateX(5px);
    border-left-color: #8e44ad;
    color: #8e44ad;
    text-decoration: none;
}

.snd-post-item.current {
    background: #8e44ad;
    color: white;
    border-left-color: #732d91;
}

.snd-post-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    line-height: 1.3;
}

.snd-post-item-meta {
    font-size: 0.75rem;
    opacity: 0.7;
    display: flex;
    gap: 10px;
}

/* Categories Section */
.snd-categories-list h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: #333;
    border-bottom: 2px solid #8e44ad;
    padding-bottom: 5px;
}

.snd-category-item {
    display: block;
    padding: 8px 15px;
    margin-bottom: 5px;
    background: white;
    border-radius: 4px;
    text-decoration: none;
    color: #666;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.snd-category-item:hover {
    background: #8e44ad;
    color: white;
    text-decoration: none;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .snd-posts-sidebar {
        left: -100%;
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height for modern browsers */
        top: 0;
        transform: none;
        border-radius: 0;
        /* Ensure content stays within safe areas on iOS */
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }
    
    .snd-posts-sidebar.snd-posts-expanded {
        left: 0;
    }
    
    .snd-posts-tab {
        right: -30px;
        width: 30px;
        height: 80px;
        font-size: 0.8rem;
        /* Ensure tab is positioned relative to safe area */
        top: calc(20px + env(safe-area-inset-top, 0));
    }

    /* Large mode takes full screen on mobile with proper constraints */
    .snd-posts-sidebar.snd-posts-large {
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height */
        top: 0;
        left: 0;
        transform: none;
        border-radius: 0;
        /* Maintain safe area padding in large mode */
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }
}
