@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    --bg: #050505;
    --surface: #0f0f12;
    --surface-bright: #1a1a1f;
    --primary: #66fcf1;
    --primary-dim: #45a29e;
    --primary-glow: rgba(102, 252, 241, 0.3);
    --accent: #ff3366;
    --text: #ffffff;
    --text-dim: #9494a0;
    --border: rgba(102, 252, 241, 0.1);
    --radius: 12px;
    --ease: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Global Aesthetics */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    /* Subtle Scanline Rizz */
    background-image: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), 
                      linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 4px, 3px 100%;
}

/* ========== SHARED NAVIGATION ========== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 56px;
    position: sticky;
    top: 0;
    backdrop-filter: blur(16px) saturate(180%);
    background-color: rgba(5, 5, 5, 0.9);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.brand {
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--primary-glow);
    text-decoration: none;
    flex-shrink: 0;
}

.brand span {
    color: var(--primary);
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 6px 16px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--primary);
    background: rgba(102, 252, 241, 0.08);
}

.nav-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Status Components */
.status-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1.5rem;
    flex-shrink: 0;
}

/* Mobile Bottom Nav */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(5, 5, 5, 0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
}

.mobile-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 12px;
    transition: color 0.2s;
}

.mobile-nav-link svg {
    width: 20px;
    height: 20px;
}

.mobile-nav-link.active {
    color: var(--primary);
}

.live-badge {
    background: rgba(255, 51, 102, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 6px 14px;
    border-radius: 4px;
    font-weight: 900;
    font-size: 0.75rem;
    letter-spacing: 2px;
    text-shadow: 0 0 8px var(--accent);
    animation: neon-pulse 2s infinite ease-in-out;
}

@keyframes neon-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 51, 102, 0.2); border-color: rgba(255, 51, 102, 0.4); }
    50% { box-shadow: 0 0 20px rgba(255, 51, 102, 0.5); border-color: rgba(255, 51, 102, 0.8); }
}

.viewer-count {
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
}

/* Main Layout & Player */
main {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.player-container {
    position: relative;
    width: 100%;
    max-width: 1600px;
    aspect-ratio: 16 / 9;
    margin: 0 auto;
}

#ambilight {
    position: absolute;
    inset: 0;
    z-index: 0;
    filter: blur(120px) opacity(0.5);
    transform: scale(1.1);
    pointer-events: none;
}

.player-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
    border: 1px solid var(--border);
    overflow: hidden;
}

/* Grids & Cards */
.clips-section {
    padding: 3rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.clips-section h2,
.queue-section h2 {
    color: var(--text);
    margin-bottom: 0;
    font-size: 1.4rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.clips-section h2::before,
.queue-section h2::before {
    content: '';
    width: 4px;
    height: 24px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

.queue-section h2::before {
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.section-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
}

.clips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 2rem;
}

.clip-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.4s var(--ease);
    text-decoration: none;
    display: block;
    position: relative;
    /* Add a subtle dark glow by default */
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}
.clip-date {
    color: var(--primary-dim); /* Muted teal instead of ugly grey */
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 1px;
    opacity: 0.7;
    text-transform: uppercase;
}
.clip-card:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: var(--primary);
    box-shadow: 0 0 30px rgba(102, 252, 241, 0.15);
}

.clip-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    transition: filter 0.3s;
}

.clip-card:hover .clip-thumb {
    filter: brightness(1.1);
}
.clip-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}
.clip-meta {
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(4px);
}

.clip-card:hover .clip-meta {
    background: rgba(102, 252, 241, 0.03); /* Subtle teal tint on hover */
}

/* Action Buttons */
.clip-it-btn {
    background: var(--primary);
    color: #0b0c10;
    border: 1px solid var(--primary);
    padding: 8px 24px;
    border-radius: 6px;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 0.8rem;
    transition: all 0.3s var(--ease);
    box-shadow: 0 0 15px rgba(102, 252, 241, 0.2);
}

.clip-it-btn:hover {
    background: transparent;
    color: var(--primary);
    box-shadow: 0 0 25px var(--primary-glow);
    transform: scale(1.05);
}

.clip-it-btn:active {
    transform: scale(0.95);
}
.title {
    color: white;
    font-weight: 800;
    font-size: 1rem;
    line-height: 1.2;
    /* Prevent title from squishing the button */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.share-mini-btn {
    background: rgba(102, 252, 241, 0.05);
    border: 1px solid var(--border);
    color: var(--primary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* CRITICAL: Prevents icon from getting squished by long titles */
    flex-shrink: 0; 
    transition: all 0.2s var(--ease);
}

.share-mini-btn:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

/* Ensure the SVG inside the button behaves */
.share-mini-btn svg {
    width: 14px;
    height: 14px;
    display: block;
}
/* VOD Sidebar & Specifics */
.sidebar {
    padding-right: 10px;
    scrollbar-gutter: stable;
}

.vod-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-left: 4px solid transparent;
    transition: all 0.2s var(--ease);
}

.vod-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(102, 252, 241, 0.1);
    border-left-color: var(--primary-dim);
}

.vod-card.active {
    background: rgba(102, 252, 241, 0.05);
    border-color: rgba(102, 252, 241, 0.2);
    border-left-color: var(--primary);
    box-shadow: inset 10px 0 20px rgba(102, 252, 241, 0.05);
}

/* Scrubber & Player UI */
.custom-controls {
    background: var(--surface);
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 20px;
    border-top: 1px solid var(--border);
}

.progress-container {
    flex-grow: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    border-radius: 10px;
    width: 0%;
}

.marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 20px;
    background: var(--accent);
    border-radius: 2px;
    box-shadow: 0 0 10px var(--accent);
    z-index: 10;
}

/* Modals */
.clip-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 2000;
}

.clip-modal.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- MODAL REWRITE --- */
.modal-content {
    width: 95%;
    max-width: 1400px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 30px 60px rgba(0,0,0,0.9);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#modal-video {
    width: 100%;
    max-height: 65vh; /* Prevents vertical overflow on smaller screens */
    background: #000;
    object-fit: contain;
    display: block;
    outline: none;
}

.modal-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 1.1rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

/* Left: inputs stacked above track toggles */
.modal-info-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.modal-inputs {
    display: flex;
    gap: 10px;
}

.modal-inputs .game-input {
    flex: 1;
    min-width: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
}

.track-toggles {
    display: flex;
    gap: 14px;
    align-items: center;
}

.track-toggles label {
    color: var(--text-dim);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.track-toggles input[type="checkbox"] {
    accent-color: var(--primary);
}

/* Right: action buttons + close */
.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.modal-status {
    font-size: 0.72rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--primary);
    min-width: 48px;
    text-align: right;
}

.modal-close-btn {
    background: transparent;
    color: var(--text-dim);
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0 2px;
    margin-left: 4px;
}

.modal-close-btn:hover { color: var(--accent); }

/* Explicit Button Styling */
.modal-btn {
    background: rgba(102, 252, 241, 0.05);
    border: 1px solid var(--border);
    color: var(--primary);
    padding: 10px 18px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.modal-btn:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: #fff;
}

.modal-btn.primary {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    font-weight: 800;
}

.modal-btn.primary:hover {
    background: #fff;
    box-shadow: 0 0 15px var(--primary);
}

.modal-btn.trash-btn {
    background: transparent;
    border-color: rgba(255, 51, 102, 0.3);
    color: var(--accent);
}

.modal-btn.trash-btn:hover {
    background: rgba(255, 51, 102, 0.1);
    border-color: var(--accent);
    color: #fff;
}

/* Forms & Inputs */
.game-input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.game-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}
.queue-section {
    padding: 1.5rem 3rem 0;
    margin-bottom: 2rem;
}
#queue-grid {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    /* Add vertical padding so the hover 'jump' has room to breathe without hitting the title */
    padding: 1.5rem 0.5rem; 
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}
/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { 
    background: var(--surface-bright); 
    border-radius: 10px; 
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Utilities */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(102, 252, 241, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

#status-msg {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--primary);
}
/* --- TOAST NOTIFICATIONS --- */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}

.hk-toast {
    background: #141418;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.hk-toast.visible { transform: translateX(0); }
.hk-toast.leaving { opacity: 0; transform: translateX(20px); }

.hk-toast.error { border-left: 4px solid #ff3366; }
.hk-toast.success { border-left: 4px solid #66fcf1; }
.hk-toast.info { border-left: 4px solid #9494a0; }

.hk-toast a {
    color: #66fcf1;
    text-decoration: none;
    font-weight: 800;
    margin-left: 8px;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}
.hk-toast a:hover { border-color: #66fcf1; }
/* =========================================
   MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 768px) {
    /* Navigation */
    .main-nav { display: none; }
    .mobile-nav { display: block; }
    body { padding-bottom: 64px; }

    /* Header */
    header {
        padding: 0 1rem;
        height: 48px;
    }
    .status-container { gap: 0.75rem; }

    /* Padding Reductions */
    main { padding: 1rem; }
    .clips-section, .queue-section { padding: 1rem; }

    /* The Main Grid Fix */
    .clips-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .clip-card {
        min-width: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    /* UI Scaling for small cards */
    .clip-meta { padding: 0.6rem; }
    .title {
        font-size: 0.8rem;
        -webkit-line-clamp: 2;
    }
    .clip-date { font-size: 0.6rem; }

    /* Action Queue */
    #queue-grid {
        display: flex !important;
        gap: 1rem;
        padding: 1rem 0;
    }
    #queue-grid .clip-card {
        min-width: 240px !important;
    }

    /* Modal Mobile Overhaul */
    .modal-content {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        border: none;
        justify-content: flex-start;
        overflow-y: auto;
    }
    #modal-video { max-height: 40vh; }
    .modal-controls {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px;
        gap: 10px;
    }
    .modal-info-left { width: 100%; }
    .modal-inputs { flex-direction: column; }
    .modal-actions {
        flex-wrap: wrap;
        justify-content: center;
    }
    .modal-btn {
        flex-grow: 1;
        text-align: center;
    }

    /* Library-specific */
    .library-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem !important;
    }
    .library-toolbar {
        flex-direction: column;
        width: 100%;
    }
    .library-search {
        width: 100% !important;
    }
}

/* =========================================
   SHARED VIEWER COMPONENTS
   ========================================= */

/* Game pill badge */
.viewer-game-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 8px;
    border-radius: 20px;
    background: rgba(102, 252, 241, 0.07);
    border: 1px solid rgba(102, 252, 241, 0.28);
    color: var(--primary);
    font-size: 0.65rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(102, 252, 241, 0.08);
}
.viewer-game-pill::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 5px var(--primary);
    flex-shrink: 0;
}

/* Nav arrow buttons (absolutely positioned over video) */
.viewer-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(5, 5, 5, 0.65);
    border: 1px solid rgba(102, 252, 241, 0.2);
    color: rgba(255, 255, 255, 0.8);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s, color 0.2s, transform 0.15s;
    z-index: 10;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.viewer-nav-btn:hover {
    background: rgba(102, 252, 241, 0.14);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-50%) scale(1.08);
}
.viewer-nav-btn:disabled {
    opacity: 0 !important;
    cursor: default;
    pointer-events: none;
}
.viewer-nav-btn svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}
.viewer-prev { left: 12px; }
.viewer-next { right: 12px; }

/* Show nav buttons when hovering the video container */
.viewer-video-wrap:hover .viewer-nav-btn:not(:disabled) {
    opacity: 1;
}

/* Thumbnail strip */
.viewer-strip-wrap {
    overflow-x: auto;
    padding: 10px 14px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    flex-shrink: 0;
}
.viewer-strip-wrap::-webkit-scrollbar { height: 3px; }
.viewer-strip-wrap::-webkit-scrollbar-track { background: transparent; }
.viewer-strip-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.viewer-strip {
    display: flex;
    gap: 7px;
    width: max-content;
}
.viewer-strip-item {
    width: 96px;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 5px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.15s;
    background: var(--surface-bright);
}
.viewer-strip-item:hover {
    border-color: rgba(102, 252, 241, 0.4);
    transform: translateY(-2px);
}
.viewer-strip-item.active {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(102, 252, 241, 0.2);
}
.viewer-strip-item img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

/* Always show nav on touch devices */
@media (hover: none) {
    .viewer-nav-btn:not(:disabled) { opacity: 1; }
}
@media (max-width: 600px) {
    .viewer-nav-btn { width: 34px; height: 34px; }
    .viewer-strip-item { width: 72px; }
}

/* Clip tags */
.clip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}
.clip-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 51, 102, 0.08);
    border: 1px solid rgba(255, 51, 102, 0.2);
    color: var(--accent);
    font-size: 0.6rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.5px;
}

/* Viewer tags row */
.viewer-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 16px 8px;
    background: var(--surface);
}
.viewer-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 51, 102, 0.08);
    border: 1px solid rgba(255, 51, 102, 0.2);
    color: var(--accent);
    font-size: 0.6rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.5px;
    cursor: default;
}
.viewer-tags-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    padding: 6px 16px 10px;
    background: var(--surface);
}
.viewer-tag-input {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.6rem;
    font-family: 'JetBrains Mono', monospace;
    outline: none;
    width: 80px;
}
.viewer-tag-input:focus {
    border-color: var(--accent);
}
.viewer-tag.removable {
    cursor: pointer;
    position: relative;
    padding-right: 16px;
}
.viewer-tag.removable::after {
    content: '\00d7';
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    opacity: 0.6;
}
.viewer-tag.removable:hover {
    background: rgba(255, 51, 102, 0.15);
    border-color: var(--accent);
}
.viewer-tag.removable:hover::after {
    opacity: 1;
}

/* --- OFFLINE MODE OVERRIDES --- */
main.offline-mode {
    flex-grow: 0 !important;
    padding-bottom: 0 !important;
}

.player-container.offline-mode {
    aspect-ratio: auto !important;
    height: 140px !important;
    max-height: 140px !important;
}

/* =========================================
   PWA / SAFE AREA INSETS
   ========================================= */
@supports (padding: env(safe-area-inset-bottom)) {
    /* Library viewer: bottom elements clear home indicator */
    .viewer-strip-wrap  { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .viewer-actions-bar { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    /* Index clip-modal viewer mode */
    #modal-clip-strip-wrap { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .modal-controls        { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
    /* Mobile nav bar */
    .mobile-nav { padding-bottom: env(safe-area-inset-bottom); }
}