/* ==========================================================================
   Design System Baseline Tokens
   ========================================================================== */
:root {
    --bg: #0a0a0c;
    --surface: #121216;
    --surface-elevated: #1c1c22;
    --border: #26262b;
    --text: #e4e4e7;
    --text-muted: #a1a1aa;
    --accent: #ff3e3e;
    --accent-hover: #e03535;
    --max-width: 1400px;
}

/* ==========================================================================
   Global Reset & Normalization Baseline
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Selection Highlight Accentuation */
::selection {
    background: var(--accent);
    color: #fff;
}

/* Modern Minimalist Scrollbar Engine Configuration */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==========================================================================
   Application Shell Layout Framework
   ========================================================================== */
.main-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 20px;
    backdrop-filter: blur(12px); /* High-fidelity dynamic blur fallback */
    -webkit-backdrop-filter: blur(12px);
}

.header-container {
    max-width: var(--max-width);
    margin: 0 auto;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo {
    font-size: 22px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -0.03em;
    color: #fff;
    text-decoration: none;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.logo:hover {
    color: var(--accent);
}

.search-wrap {
    flex: 1;
    max-width: 500px;
    transition: max-width 0.2s ease-in-out;
}

#search-input {
    width: 100%;
    height: 40px;
    padding: 10px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(255, 62, 62, 0.15);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

#limit-select {
    background: var(--bg);
    color: #fff;
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

#limit-select:focus {
    border-color: var(--accent);
}

.nav-btn {
    padding: 8px 16px;
    background: transparent;
    color: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.nav-btn:hover {
    background: var(--surface-elevated);
    border-color: var(--text-muted);
}

.nav-btn:active {
    transform: scale(0.98);
}

.status-badge {
    font-size: 13px;
    background: var(--surface-elevated);
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
}

.app-viewport {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px 20px;
    
    /* Hardware Accelerated Guard Matrix against WebView Paint Drop Offs */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

.view-panel {
    width: 100%;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.view-header h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
}

/* ==========================================================================
   Grid System & Presentation Matrix Component Card Layouts
   ========================================================================== */
.matrix-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.video-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
    will-change: transform;
}

.video-card:hover {
    transform: translateY(-4px);
    border-color: #3f3f46;
}

.thumb-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* Fixed 16:9 Aspect Ratio Boundary lock */
    background: #000;
}

.thumb-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-meta {
    padding: 16px;
}

.card-meta h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #fff;
    line-height: 1.3;
}

.card-meta p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ==========================================================================
   Focused Video Room Split Panel Layout Framework
   ========================================================================== */
.room-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 32px;
    align-items: start;
}

.media-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.back-link:hover {
    color: #fff;
}

.player-aspect-box {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* Native 16:9 Cinema Aspect Guard */
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.player-aspect-box #player-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.editorial-box h1 {
    font-size: 24px;
    color: #fff;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.editorial-box p {
    font-size: 15px;
    color: var(--text-muted);
    white-space: pre-line;
}

/* Dynamic Interactive Discussion Container Module */
.discussion-stack {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    height: calc(100vh - 170px);
    position: sticky;
    top: 110px;
    display: flex;
    flex-direction: column;
}

.discussion-stack h3 {
    font-size: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    color: #fff;
}

.chat-input-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.chat-input-row textarea {
    width: 100%;
    height: 60px;
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input-row textarea:focus {
    border-color: var(--accent);
}

.chat-input-row textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--surface-elevated);
}

.chat-input-row button {
    padding: 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.chat-input-row button:hover {
    background: var(--accent-hover);
}

.chat-input-row button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--border);
}

.stream-scroll {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 4px;
}

.comment-node {
    background: var(--surface-elevated);
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.comment-head {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 6px;
}

.comment-author {
    font-weight: 600;
    color: #fff;
}

.comment-time {
    color: var(--text-muted);
}

.comment-body {
    font-size: 13px;
    color: var(--text);
    word-break: break-word;
}

/* ==========================================================================
   Global Managed Overlay Surface Configurations
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 6, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-surface {
    background: var(--surface);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 420px;
    padding: 32px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.gate-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field-group {
    width: 100%;
}

.gate-form input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.gate-form input:focus {
    border-color: var(--accent);
}

.form-notice {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    text-align: center;
}

.action-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.action-btn:hover {
    background: var(--accent-hover);
}

/* ==========================================================================
   Real-Time Hardware Accelerated Notification Infrastructure
   ========================================================================== */
.toast-viewport {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
    pointer-events: none;
}

.toast-notification {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    color: var(--text);
    padding: 14px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    min-width: 280px;
    max-width: 420px;
    pointer-events: auto;
    animation: toastSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.toast-notification.toast-success {
    border-left-color: #10b981;
}

.toast-notification.toast-error {
    border-left-color: #ef4444;
}

.toast-notification.toast-warning {
    border-left-color: #f59e0b;
}

@keyframes toastSlideIn {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Infrastructure State Displays */
.empty-state, .loader, .error-state {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.error-state { 
    color: var(--accent); 
}

/* ==========================================================================
   Media Adaptive Breakpoints (Responsive Layout Logic)
   ========================================================================== */
@media (max-width: 1024px) {
    .room-layout {
        grid-template-columns: 1fr;
    }
    .discussion-stack {
        position: static;
        height: 500px;
    }
}

@media (max-width: 680px) {
    /* Critical Mobile WebView Render Patch Fix */
    .matrix-grid {
        grid-template-columns: 1fr !important; /* Forces solid paint bounds on mobile viewports */
        gap: 20px;
        margin-bottom: 40px;
    }

    /* Webview Clipping Mask Correction */
    .video-card {
        will-change: auto !important; /* De-promote GPU layers on mobile to stop webview blackouts */
        transform: translateZ(0); /* Force clean execution bounds */
    }

    .main-header {
        padding: 0 16px;
    }

    .header-container {
        height: auto;
        flex-wrap: wrap;
        padding: 14px 0;
        gap: 16px 0;
    }

    .logo {
        order: 1;
        flex: 0 0 auto;
    }

    .header-actions {
        order: 2;
        flex: 0 0 auto;
        gap: 12px;
    }

    .search-wrap {
        order: 3;
        flex: 0 0 100%;
        max-width: 100%;
        margin-top: 4px;
    }

    #search-input {
        height: 46px; /* Optimized hit-target for touch inputs */
        font-size: 15px;
    }

    .filter-controls {
        display: none; /* Hide configuration dropdown matrix flags under space-constrained screens */
    }

    .app-viewport {
        padding: 24px 16px;
    }
}