/* The watch page owns its viewport, independently of the WordPress theme. */
html:has(.livestream-page),
body:has(.livestream-page) {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #041511 !important;
}

body:has(.livestream-page) #wpadminbar { display: none !important; }

.livestream-page {
    --page-bg: #041511;
    --surface: #17382d;
    --border: rgba(183, 224, 208, 0.13);
    --text: #eef6f1;
    --muted: #9bb6aa;
    --brand: #91cdb0;
    --chat-panel-width: clamp(280px, 15vw, 384px);
    position: fixed !important;
    inset: 0 !important;
    z-index: 100000;
    isolation: isolate;
    width: 100% !important;
    max-width: none !important;
    height: 100dvh;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    background: var(--page-bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    text-align: left;
    color-scheme: dark;
}

.livestream-page *,
.livestream-page *::before,
.livestream-page *::after {
    box-sizing: border-box;
    letter-spacing: 0;
}

.livestream-page::before,
.livestream-page::after { content: none; }

.livestream-page :where(button, input, select, textarea) {
    font: inherit;
    color: inherit;
    margin: 0;
}

.livestream-page button {
    appearance: none;
    cursor: pointer;
    text-shadow: none;
    box-shadow: none;
}

.livestream-page :where(button, a, input, textarea, select, summary):focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

.livestream-page button:disabled {
    cursor: wait;
    opacity: 0.5;
}

.livestream-page .livestream-layout,
.livestream-page .bible-service-container {
    width: 100%;
    height: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.livestream-page .bible-service-container { display: none; }

.livestream-page #service-container[hidden] { display: none !important; }

.livestream-page .service-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--chat-panel-width);
    width: 100%;
    height: 100%;
    gap: 0;
    margin: 0;
    padding: 0;
}

.livestream-page .service-main {
    min-width: 0;
    min-height: 0;
    position: relative;
    margin: 0;
    padding: 0;
    background: transparent;
}

.livestream-page .stream-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-width: 0;
    padding: 32px;
    background: transparent;
}

.livestream-page .youtube-container {
    position: relative;
    flex: 0 0 auto;
    width: var(--stream-frame-width, min(1024px, 40vw));
    height: var(--stream-frame-height, auto);
    aspect-ratio: var(--stream-aspect-ratio, 16 / 9);
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 5px;
    overflow: hidden;
    background: transparent;
    line-height: 0;
}

.livestream-page .stream-surface {
    display: none;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
}

.livestream-page .stream-surface.is-visible { display: block; }

.livestream-page .stream-frame-ratio,
.livestream-page .youtube-frame,
.livestream-page .stream-fallback-image {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.livestream-page .stream-fallback-image {
    object-fit: contain;
    object-position: center;
}

.livestream-page .page-back-link {
    position: absolute;
    top: 20px;
    left: 24px;
    z-index: 30;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 0 5px;
    border: 0;
    background: transparent;
    color: var(--muted);
    text-decoration: none;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
}

.livestream-page .page-back-link:hover { color: var(--text); }

.livestream-page .chat-sidebar {
    display: none;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border-left: 1px solid var(--border);
    background: transparent;
}

.livestream-page .sidebar-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    flex: 0 0 42px;
    height: 42px;
    border-bottom: 1px solid var(--border);
}

.livestream-page .sidebar-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    height: 42px;
    padding: 0 6px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

.livestream-page .sidebar-tab.active {
    border-bottom-color: var(--text);
    color: var(--text);
}

.livestream-page .sidebar-tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.025);
}

.livestream-page .chat-viewers {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 400;
}

.livestream-page .sidebar-tab-panel {
    display: none;
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.livestream-page .sidebar-tab-panel.active {
    display: flex;
    flex-direction: column;
}

.livestream-page .chat-panel,
.livestream-page .chat-shell {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    padding: 0;
    margin: 0;
    background: transparent;
}

.livestream-page .chat-messages {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    gap: 16px;
    min-height: 0;
    padding: 14px 14px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--surface) transparent;
}

.livestream-page .chat-empty {
    padding: 0;
    color: var(--muted);
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
}

.livestream-page .chat-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    min-width: 0;
}

.livestream-page .chat-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    color: var(--muted);
    font-size: 11px;
    overflow-wrap: anywhere;
}

.livestream-page .chat-author {
    color: var(--text);
    font-weight: 700;
}

.livestream-page .chat-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #b3f0cf;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.livestream-page .chat-body {
    max-width: 100%;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.livestream-page .chat-form {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 12px calc(42px + env(safe-area-inset-bottom));
    margin: 0;
    border-top: 1px solid var(--border);
    background: transparent;
}

.livestream-page .chat-input-wrap {
    flex: 1 1 0;
    min-width: 0;
}

.livestream-page .chat-input {
    display: block;
    width: 100%;
    min-height: 36px;
    height: 36px;
    padding: 9px 11px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    line-height: 16px;
    resize: none;
    box-shadow: none;
}

.livestream-page .chat-input::placeholder {
    color: var(--muted);
    opacity: 1;
}

.livestream-page .chat-send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: var(--surface);
    color: var(--muted);
    font-size: 15px;
}

.livestream-page .chat-send-btn:hover {
    color: var(--text);
    background: #234c3d;
}

.livestream-page .sidebar-bible,
.livestream-page .bible-frame {
    display: block;
    flex: 1 1 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.livestream-page .give-panel {
    flex: 1 1 0;
    min-height: 0;
    padding: 20px 16px;
    overflow-y: auto;
}

.livestream-page .give-title {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 16px;
    line-height: 1.4;
    font-weight: 700;
}

.livestream-page .give-note {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.livestream-page .give-item { border-top: 1px solid var(--border); }
.livestream-page .give-item:last-child { border-bottom: 1px solid var(--border); }

.livestream-page .give-item summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
}

.livestream-page .give-item summary::-webkit-details-marker { display: none; }
.livestream-page .give-item summary::after { content: '+'; color: var(--muted); }
.livestream-page .give-item[open] summary::after { content: '-'; }
.livestream-page .give-body { padding: 0 0 18px; }
.livestream-page .give-detail { margin-bottom: 10px; }

.livestream-page .give-label {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

.livestream-page .give-value {
    font-size: 13px;
    overflow-wrap: anywhere;
}

.livestream-page .give-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
}

/* Account dialogs remain above the stream and scroll within the viewport. */
.livestream-page .modal,
.livestream-page .viewer-count-modal {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    background: var(--page-bg);
}

.livestream-page .modal-content,
.livestream-page .viewer-count-content {
    flex: 0 1 420px;
    width: 100%;
    max-width: 420px;
    max-height: 100%;
    overflow-y: auto;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #0c261d;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.18);
}

.livestream-page .eyebrow {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 12px;
}

.livestream-page .modal-content h2,
.livestream-page .viewer-count-content h2 {
    margin: 0 0 10px;
    color: var(--text);
    font-size: 24px;
    line-height: 1.25;
    font-weight: 700;
}

.livestream-page .modal-content p,
.livestream-page .viewer-count-content p {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 13px;
}

.livestream-page .input-group { margin: 0 0 14px; }

.livestream-page .input-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 12px;
}

.livestream-page .input-group input,
.livestream-page .input-group select,
.livestream-page .manual-count-input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--page-bg);
    color: var(--text);
    font-size: 14px;
    box-shadow: none;
}

.livestream-page .input-group input::placeholder { color: var(--muted); }
.livestream-page .input-group input.invalid { border-color: #f19c9c; }

.livestream-page .error-message,
.livestream-page .success-message {
    display: none;
    margin: 6px 0;
    color: #ffb9b9;
    font-size: 12px;
}

.livestream-page .success-message { color: #acd8c5; }

.livestream-page .modal .btn,
.livestream-page .confirmation-btn {
    width: 100%;
    min-height: 42px;
    padding: 10px 16px;
    border: 0;
    border-radius: 3px;
    background: #acd8c5;
    color: #041511;
    font-size: 13px;
    font-weight: 700;
}

.livestream-page .register-link {
    margin-top: 18px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.livestream-page .register-link a {
    color: var(--text);
    text-decoration: underline;
}

.livestream-page .registration-success,
.livestream-page .viewer-count-content { text-align: center; }

.livestream-page .registration-success > i {
    margin-bottom: 18px;
    color: #acd8c5;
    font-size: 38px;
}

.livestream-page .viewer-count-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 24px 0;
}

.livestream-page .viewer-count-btn {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    font-size: 20px;
}

.livestream-page .manual-count-input {
    width: 100px;
    text-align: center;
}

.livestream-page .loading-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: middle;
    animation: livestream-spin 0.8s linear infinite;
}

@keyframes livestream-spin { to { transform: rotate(360deg); } }

.livestream-page .notification {
    display: none;
    position: absolute;
    z-index: 40;
    top: 16px;
    right: 16px;
    max-width: min(340px, calc(100% - 32px));
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    font-size: 13px;
}

.livestream-page .notification.show { display: block; }

.livestream-page .visually-hidden,
.livestream-page .reset-timer {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.livestream-page #registration-modal,
.livestream-page #registration-success-modal,
.livestream-page #viewer-count-modal { display: none; }

.livestream-page .livestream-hidden { display: none !important; }
.livestream-page .livestream-show-block { display: block !important; }
.livestream-page .livestream-show-flex { display: flex !important; }
.livestream-page .livestream-show-inline-flex { display: inline-flex !important; }
.livestream-page .livestream-show-inline-block { display: inline-block !important; }

@media (max-width: 1024px) {
    .livestream-page .service-shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(240px, 1fr);
        overflow-y: auto;
    }

    .livestream-page .stream-stage {
        height: auto;
        padding: 14px;
    }

    .livestream-page .youtube-container { width: var(--stream-frame-width, 100%); }

    .livestream-page .chat-sidebar {
        border-left: 0;
        border-top: 1px solid var(--border);
    }

    .livestream-page .sidebar-tabs,
    .livestream-page .sidebar-tab { height: 44px; }

    .livestream-page .sidebar-tabs { flex-basis: 44px; }
    .livestream-page .sidebar-tab { font-size: 11px; }

    .livestream-page .chat-form {
        padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
    }

    .livestream-page .chat-input {
        height: 44px;
        min-height: 44px;
        padding-top: 12px;
        font-size: 16px;
        line-height: 18px;
    }

    .livestream-page .chat-send-btn {
        flex-basis: 44px;
        width: 44px;
        height: 44px;
    }

    .livestream-page .page-back-link {
        top: 16px;
        left: 18px;
        min-height: 28px;
        padding: 2px 7px;
        border-radius: 3px;
        background: rgba(4, 21, 17, 0.78);
        color: var(--text);
    }

    .livestream-page:not(.modal-open) .page-back-link {
        display: none;
    }
}

@media (max-width: 480px) {
    .livestream-page .modal,
    .livestream-page .viewer-count-modal { padding: 16px; }

    .livestream-page .modal-content,
    .livestream-page .viewer-count-content { padding: 22px; }

    .livestream-page .input-group input,
    .livestream-page .input-group select { font-size: 16px; }
}

