/* ===== REPLY FORM (inline) ===== */

.ce-v6-reply-form {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: stretch;
    gap: var(--ce-space-sm);
    padding: var(--ce-space-sm);
    margin-top: var(--ce-space-md);

    background: var(--ce-glass-bg);
    backdrop-filter: var(--ce-backdrop-blur);
    -webkit-backdrop-filter: var(--ce-backdrop-blur);
    border: 1px solid var(--ce-glass-border);
    border-radius: var(--ce-radius-lg);
    box-shadow: var(--ce-glass-shadow);

    position: relative;
    z-index: 25;
    width: 100%;
}

.ce-v6-reply-avatar {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.ce-v6-reply-avatar .ce-v6-avatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    background: url('https://pics.bessergrowen.com/meme-spongebud.webp?optimizer=image&format=webp&quality=80&w=80') center/cover no-repeat;
}

.ce-v6-reply-avatar .ce-v6-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ce-v6-reply-avatar .ce-v6-avatar .ce-v6-avatar-emoji-fallback {
    font-size: 1.6rem;
    line-height: 1;
}

.ce-v6-reply-body {
    display: flex;
    flex-direction: column;
    gap: var(--ce-space-sm);
    min-width: 0;
}

.ce-v6-reply-textarea-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--ce-space-sm);
    flex: 1 1 auto;
    min-width: 0;
}

.ce-v6-reply-text {
    width: 100%;
    min-height: 48px; /* Start smaller, encourage shorter replies */
    max-height: 400px; /* Prevent page takeover */
    padding: var(--ce-space-md);
    border-radius: var(--ce-radius-md);
    border: 1px solid transparent; /* No border by default */
    background: transparent; /* Fully transparent by default */
    color: var(--ce-text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.ce-v6-reply-text:focus {
    outline: none;
    border-color: var(--ce-primary);
    background: rgba(255, 255, 255, 0.8); /* Lighten up on focus */
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.ce-v6-reply-text::placeholder {
    color: var(--ce-text-muted);
}

.ce-v6-reply-preview {
    display: flex;
    gap: var(--ce-space-sm);
    flex-wrap: wrap;
    align-items: center;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--ce-glass-border);
    border-radius: var(--ce-radius-md);
    padding: calc(var(--ce-space-xs) + 2px) var(--ce-space-sm);
    transition: opacity 0.2s ease;
}

.ce-v6-reply-preview:empty {
    display: none;
    padding: 0;
    border: 0;
}

.ce-v6-reply-preview-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ce-radius-sm);
    border: 1px solid rgba(15, 23, 42, 0.12);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: var(--ce-glass-shadow);
}

.ce-v6-reply-preview-image img {
    display: block;
    max-width: 200px;
    max-height: 160px;
    object-fit: cover;
}

.ce-v6-reply-preview-audio {
    padding: var(--ce-space-xs) var(--ce-space-sm);
}

.ce-v6-reply-preview-audio audio {
    width: 220px;
}

.ce-v6-reply-preview-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.7);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.ce-v6-reply-preview-remove:hover,
.ce-v6-reply-preview-remove:focus-visible {
    background: rgba(15, 23, 42, 0.9);
    transform: translateY(-1px);
    outline: none;
}

.ce-v6-reply-footer,
.ce-v6-reply-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ce-space-md);
    width: 100%;
}

.ce-v6-reply-media-buttons {
    display: inline-flex;
    align-items: center;
    gap: var(--ce-space-sm);
}

.ce-v6-reply-submit-buttons {
    display: flex;
    gap: var(--ce-space-sm);
}

.ce-v6-reply-footer .ce-v6-btn,
.ce-v6-reply-footer .ce-v6-btn-secondary,
.ce-v6-reply-actions .ce-v6-btn,
.ce-v6-reply-actions .ce-v6-btn-secondary {
    padding: var(--ce-space-sm) var(--ce-space-md);
    font-size: 0.9rem;
    min-width: 100px; /* Give buttons some space */
}

/* If the reply form is injected into the actions row, make it span the full row */
.ce-v6-comment-actions .ce-v6-reply-form {
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    order: 10; /* ensure it appears below action buttons when wrapping */
}

/* Responsive adjustments */
@media (max-width: 540px) {
    .ce-v6-reply-form {
        grid-template-columns: 1fr;
        padding: var(--ce-space-sm);
    }

    .ce-v6-reply-avatar {
        display: none;
    }

    .ce-v6-reply-text {
        min-height: 90px; /* A bit more space on mobile */
        background: var(--ce-mobile-bg-elevated); /* Give it a background on mobile */
        border: 1px solid transparent;
    }

    .ce-v6-reply-text:focus {
        box-shadow: none; /* Remove outer shadow on mobile */
        border-color: var(--ce-primary);
    }

    .ce-v6-reply-footer,
    .ce-v6-reply-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .ce-v6-reply-submit-buttons {
        justify-content: flex-end;
    }
}

/* Lightbox Styles */
body.ce-v6-no-scroll {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}

.ce-v6-lightbox {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(12px, 4vw, 32px);
    background: rgba(3, 7, 18, 0.85);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.ce-v6-lightbox.ce-v6-lightbox-open {
    opacity: 1;
}

.ce-v6-lightbox-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: min(1100px, 100%);
    max-width: 100%;
}

.ce-v6-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.ce-v6-lightbox-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.ce-v6-lightbox-back:hover,
.ce-v6-lightbox-back:focus-visible {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
    outline: none;
}

.ce-v6-back-icon {
    font-size: 1rem;
    line-height: 1;
}

.ce-v6-lightbox-body {
    display: flex;
    gap: 1.25rem;
    align-items: stretch;
    min-height: 0;
    width: 100%;
    overflow-x: hidden;
}

.ce-v6-lightbox-media {
    flex: 1 1 60%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.35);
    border-radius: 18px;
    padding: clamp(10px, 2vw, 18px);
    min-height: 260px;
    min-width: 0;
    max-width: 100%;
}

.ce-v6-lightbox-media img,
.ce-v6-lightbox-media audio {
    max-width: 100%;
    max-height: calc(100vh - 220px);
    object-fit: contain;
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.45);
}

.ce-v6-lightbox-placeholder {
    width: 100%;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e2e8f0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.ce-v6-thread-panel {
    flex: 1 1 40%;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.22);
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
}

.ce-v6-thread-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1 1 auto;
}

.ce-v6-thread-body > .ce-v6-comment-card {
    margin: 0;
}

@media (max-width: 1080px) {
    .ce-v6-lightbox-body {
        gap: 1rem;
    }
}

@media (max-width: 900px) {
    .ce-v6-lightbox {
        align-items: stretch;
    }
    .ce-v6-lightbox-content {
        gap: 0.75rem;
    }
    .ce-v6-lightbox-body {
        flex-direction: column;
        gap: 0.75rem;
    }
    .ce-v6-lightbox-media {
        flex: none;
        background: rgba(15, 23, 42, 0.25);
        padding: 12px;
        border-radius: 16px;
        min-height: auto;
    }
    .ce-v6-lightbox-media img,
    .ce-v6-lightbox-media audio {
        max-height: 60vh;
    }
    .ce-v6-thread-panel {
        flex: none;
        max-height: none;
        padding: 12px 0 0;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }
    .ce-v6-thread-body {
        gap: 0.85rem;
    }
}

@media (max-width: 600px) {
    .ce-v6-lightbox {
        padding: clamp(10px, 3vw, 20px);
    }
    .ce-v6-lightbox-back {
        padding: 6px 12px;
        gap: 6px;
        font-size: 0.8rem;
    }
    .ce-v6-lightbox-media {
        background: none;
        padding: 0;
    }
    .ce-v6-lightbox-media img,
    .ce-v6-lightbox-media audio {
        border-radius: 18px;
        box-shadow: 0 18px 36px rgba(15, 23, 42, 0.35);
        width: 100%;
    }
    .ce-v6-thread-panel {
        background: rgba(255, 255, 255, 0.98);
        border-radius: 20px;
        padding: 18px 16px 24px;
    .ce-v6-lightbox-content {
        gap: 0.65rem;
    }
    .ce-v6-lightbox-body {
        gap: 0.65rem;
    }
    .ce-v6-thread-panel {
        padding: 0;
    }
    .ce-v6-thread-body {
        gap: 0.75rem;
    }
        box-shadow: 0 26px 48px rgba(15, 23, 42, 0.25);
    }
}

