/* --- CUSTOM FONT DEFINITION --- */
@font-face {
    font-family: 'Kick Font';
    src: url('/font/kick-font.woff2') format('woff2'),
         url('/font/kick-font.otf') format('opentype');
    font-display: swap;
}

/* --- SELF-HOSTED FREDOKA / NUNITO / SHARE TECH MONO ---
   Self-hosted instead of Google Fonts so weights load instantly from our own
   cached, same-origin files - no CDN round trip and no font-swap layout shift. */
@font-face {
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 500;
    font-display: optional;
    src: url('/font/fredoka/fredoka-latin-500-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 600;
    font-display: optional;
    src: url('/font/fredoka/fredoka-latin-600-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 700;
    font-display: optional;
    src: url('/font/fredoka/fredoka-latin-700-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Nunito';
    font-style: normal;
    font-weight: 400;
    font-display: optional;
    src: url('/font/nunito/nunito-latin-400-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Nunito';
    font-style: normal;
    font-weight: 500;
    font-display: optional;
    src: url('/font/nunito/nunito-latin-500-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Nunito';
    font-style: normal;
    font-weight: 600;
    font-display: optional;
    src: url('/font/nunito/nunito-latin-600-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Nunito';
    font-style: normal;
    font-weight: 700;
    font-display: optional;
    src: url('/font/nunito/nunito-latin-700-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Share Tech Mono';
    font-style: normal;
    font-weight: 400;
    font-display: optional;
    src: url('/font/sharetechmono/share-tech-mono-latin-400-normal.woff2') format('woff2');
}

/* --- THEME & FONT DEFINITIONS --- */
:root {
    /* Colors - Kick black, kick green accents only */
    --kick-green: #53fc18;
    --kick-green-glow: rgba(83, 252, 24, 0.18);
    --kick-green-dim: rgba(83, 252, 24, 0.1);
    --kick-green-flash: #6fff3d;

    --bg-deep: #0a0a0b;
    --bg-panel: #17171a;

    /* Panel Gradients (flattened - solid panel colors, no glow gradient) */
    --bg-glass-panel: #121214;
    --bg-terminal: #1c1c1f;

    /* Borders & Highlights - subtle, low-contrast hairlines */
    --glass-border: rgba(255, 255, 255, 0.08);
    --neon-border: rgba(83, 252, 24, 0.35);
    --ink: rgba(255, 255, 255, 0.08);

    /* Text */
    --text-primary: #f5f5f5;
    --text-secondary: #8f8f96;

    /* Fonts - one clean, neutral sans family throughout */
    --font-primary: 'Nunito', sans-serif; /* Headers / Data */
    --font-secondary: 'Nunito', sans-serif; /* Body */

    /* Geometry - standard, restrained corner radii */
    --clip-tech: none;
    --radius-btn: 8px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Effects - flat & subtle, no glows */
    --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-sticker: none;
    --shadow-sticker-sm: none;
    --shadow-neon: none;

    --transition-smooth: all 0.15s ease;
}

/* HARDWARE ACCELERATION RESET */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    outline: none; 
    -webkit-tap-highlight-color: transparent; 
}

/* --- CUSTOM SCROLLBAR (site-wide) ---
   Two mechanisms so this covers every engine:
   - scrollbar-width/scrollbar-color: the standard property. Firefox has
     supported it for years; Chrome/Edge picked it up too, so on those
     browsers this alone is now enough.
   - ::-webkit-scrollbar*: the older Chrome/Safari/Edge (and Opera)
     pseudo-elements, still needed for older Chromium/WebKit builds and
     for full track/thumb styling control.
   Applied to `*` and `html` so it reaches every scrollable panel (chat,
   modals, grids) without having to opt in per-element. Anything that
   deliberately hides its scrollbar (e.g. #chat-tabs) uses a more
   specific ID selector, so it still wins over these `*` rules.
   Mobile note: iOS Safari renders its own translucent overlay
   scrollbars and ignores these rules entirely (no CSS override exists
   for that yet) - it just falls back to its native look, same as
   before. Android Chrome/Firefox and every desktop browser pick this
   styling up normally. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--kick-green) rgba(255, 255, 255, 0.06);
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
}

*::-webkit-scrollbar-thumb {
    background-color: var(--kick-green);
    border-radius: 10px;
    border: 2px solid var(--bg-panel, #17171a);
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--kick-green-flash, #6fff3d);
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-secondary);
    
    /* Flex layout that locks screen height */
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; 
    overflow: hidden; 
    width: 100%;
}

/* --- HEADER --- */
header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin: 0; 
    padding: 0 1.5rem; 
    height: 64px;
    
    background: var(--bg-glass-panel);
    border-bottom: 1px solid var(--glass-border);
    
    position: relative; 
    z-index: 100; 
    gap: 1.5rem; 
    flex-shrink: 0; 
}

header .logo h1 {
    font-family: 'Kick Font', sans-serif;
    font-size: 1.8rem;
    color: #fff;
    text-transform: uppercase;
    position: relative;
    letter-spacing: -1px;
}

/* Input Area - Command Terminal */
.add-stream-form-wrap {
    position: relative;
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 180px;
    max-width: 650px;
}

#add-stream-form { 
    display: flex; 
    gap: 0; 
    width: 100%;
    background: var(--bg-terminal);
    padding: 3px;
    border-radius: var(--radius-btn);
    border: 1px solid var(--glass-border);
    transition: var(--transition-smooth);
    position: relative;
}
#add-stream-form:focus-within {
    background: var(--bg-terminal);
    border-color: rgba(83, 252, 24, 0.5);
}

#add-stream-form::before {
    content: ''; position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    width: 6px; height: 6px; background: #3a3a3d; border-radius: 50%; z-index: 2;
    transition: 0.3s;
}
#add-stream-form:focus-within::before { background: var(--kick-green); }

#username-input { 
    background-color: transparent; 
    border: none;
    color: var(--text-primary); 
    padding: 0 1.5rem 0 2rem;
    font-family: var(--font-secondary); 
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.85rem;
    font-weight: 500;
    height: 44px;
    caret-color: var(--kick-green);
}
#username-input::placeholder { color: var(--text-secondary); font-family: var(--font-secondary); font-weight: 500; }

#add-stream-form button[type=submit] { flex-shrink: 0; }

/* Username autocomplete dropdown - reuses the same cached "browse" streams
   list as the Browse modal, filtered as-you-type. */
.stream-suggest {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-float);
    z-index: 500;
    display: none;
    max-height: 320px;
    overflow-y: auto;
}

.stream-suggest.visible {
    display: block;
}

.stream-suggest-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--glass-border);
}

.stream-suggest-item:last-child {
    border-bottom: none;
}

.stream-suggest-item:hover,
.stream-suggest-item.active {
    background: var(--kick-green-dim);
}

.stream-suggest-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--ink);
}

.stream-suggest-name {
    flex: 1;
    min-width: 0;
    font-family: var(--font-secondary);
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1.3;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stream-suggest-name strong {
    color: var(--kick-green);
}

.stream-suggest-viewers {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    white-space: nowrap;
}

.stream-suggest-viewers .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--kick-green);
    flex-shrink: 0;
}

.stream-suggest-empty {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-secondary);
}

/* Swap-stream search box, shown inside the quality-menu-overlay style panel */
.swap-input-wrapper {
    position: relative;
    width: 100%;
    max-width: 400px;
    flex-shrink: 0;
}

.swap-search-input {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-terminal);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 12px 14px;
    font-family: var(--font-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.swap-search-input::placeholder { color: var(--text-secondary); }

.swap-search-input:focus {
    outline: none;
    border-color: #7ea6ff;
}

.swap-input-wrapper .stream-suggest {
    max-height: 220px;
    text-align: left;
}

.header-actions, #add-stream-form button[type=submit] { display: flex; align-items: center; gap: 0.8rem; }

/* Buttons - flat, professional */
.header-actions button, #add-stream-form button[type=submit] { 
    font-family: var(--font-primary); 
    padding: 0 1.4rem; 
    height: 42px;
    font-weight: 600; 
    cursor: pointer; 
    transition: var(--transition-smooth); 
    white-space: nowrap; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    gap: 8px; 
    font-size: 0.85rem;
    flex-shrink: 0; 
    position: relative;
    border-radius: var(--radius-btn);
    border: 1px solid var(--glass-border); 
}

/* 1. HEADER ACTIONS (subtle outlined chips) */
.header-actions button {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.header-actions button:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
}
.header-actions button svg { fill: currentColor; width: 14px; height: 14px; }

/* 2. PRIMARY 'ADD STREAM' BUTTON (Solid Kick Green) */
#add-stream-form button[type=submit] {
    background: var(--kick-green);
    color: #06210a;
    margin-right: 0;
    font-weight: 700;
    border: none;
}
#add-stream-form button[type=submit]:hover { 
    background: var(--kick-green-flash); 
}
#add-stream-form button[type=submit] svg { fill: #06210a; width: 14px; height: 14px; }

/* Edit Layout Active State */
#edit-layout-btn.active { 
    background: var(--kick-green);
    color: #06210a; 
    border-color: var(--kick-green);
}

/* Toast Notification */
#share-toast { 
    position: fixed; 
    top: 90px; 
    left: 50%; 
    transform: translate(-50%, -8px); 
    background: var(--bg-panel);
    color: var(--text-primary); 
    padding: 0.8rem 1.6rem; 
    font-family: var(--font-primary); 
    font-weight: 600; 
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-float); 
    z-index: 2000; 
    opacity: 0; 
    visibility: hidden; 
    transition: var(--transition-smooth); 
    border-radius: var(--radius-sm);
}
#share-toast::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--kick-green);
    margin-right: 10px;
}
#share-toast.visible { opacity: 1; visibility: visible; transform: translate(-50%, 0) scale(1); }

#theater-mode-btn { display: none; }
.mobile-header-buttons { display: none; }

/* --- MAIN LAYOUT & VIDEO GRID --- */
#main-content { 
    display: flex; 
    flex-grow: 1; 
    overflow: hidden; 
    position: relative; 
    padding: 0; 
    gap: 0; 
}

#video-grid-container { 
    flex-grow: 1; 
    overflow: hidden !important; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    background: #000; 
    width: 100%;
    height: 100%;
    padding: 0 !important;
    margin: 0 !important;
    position: relative;
}

/* Empty grid shows instructions; JS never needs to toggle this */
#video-grid:empty {
    display: none;
}

#video-grid-empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.9rem;
    max-width: 400px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    color: var(--text-secondary);
}

#video-grid:empty + #video-grid-empty-state {
    display: flex;
}

#video-grid-empty-state .empty-state-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(83, 252, 24, 0.3);
    background: rgba(83, 252, 24, 0.06);
    color: var(--kick-green);
    margin-bottom: 0.4rem;
}

#video-grid-empty-state h2 {
    font-family: var(--font-primary, inherit);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color, #f5fbf0);
    margin: 0;
    letter-spacing: 0.2px;
}

#video-grid-empty-state .empty-state-subtitle {
    margin: 0 0 0.4rem;
    font-size: 0.85rem;
    opacity: 0.7;
}

#video-grid-empty-state .empty-state-steps {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: 100%;
    text-align: left;
}

#video-grid-empty-state .empty-state-step {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.9rem;
    line-height: 1.4;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 0.55rem 0.8rem;
}

#video-grid-empty-state .step-number {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    color: var(--kick-green);
    overflow: visible;
}

#video-grid-empty-state .step-number text {
    font-family: var(--font-primary, inherit);
    font-size: 10px;
    font-weight: 700;
    fill: var(--text-color, #f5fbf0);
}

#video-grid-empty-state .empty-state-step strong {
    color: var(--kick-green);
}


#video-grid { 
    display: grid;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    gap: 4px;
    box-sizing: border-box;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    grid-auto-rows: minmax(0, auto);
    align-content: center;
    justify-content: center;
    align-items: center;
    justify-items: center;
    transform-origin: center center; 
    transition: transform 0.25s ease;
    font-size: 0; 
    line-height: 0; 
    z-index: 1;
}

/* VIDEO BOX */
.video-box { 
    position: relative; 
    width: 100%;
    aspect-ratio: 16 / 9;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden; 
    background: #000; 
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: border-color 0.25s ease;
    margin: 0;
    padding: 0;
}

.video-box:hover {
    border-color: rgba(83, 252, 24, 0.3);
    z-index: 1;
    transform: none !important;
}

.video-box .plyr { 
    width: 100% !important; 
    height: 100% !important;
    position: absolute;
    inset: 0;
}

.video-box video,
.video-box .plyr__video-wrapper {
    object-fit: fill;
    width: 100% !important;
    height: 100% !important;
}

/* Removed Corner Squares/Brackets */
.video-box::before, .video-box::after { display: none; }

/* Edit Mode */
.layout-editing-mode .video-box { 
    cursor: grab; 
    border: 1px dashed var(--kick-green);
    background: repeating-linear-gradient(45deg, rgba(83,252,24,0.05), rgba(83,252,24,0.05) 10px, transparent 10px, transparent 20px);
    transform: scale(0.98);
}
.layout-editing-mode .video-box::after {
    content: '>> DRAG <<';
    display: block; 
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: var(--kick-green); font-family: var(--font-primary); font-size: 1.2rem; font-weight: 700;
    pointer-events: none;
}

/* ==========================================================================
   STREAM CONTROLS
   ========================================================================== */
video::-webkit-media-controls-panel { display: none !important; -webkit-appearance: none; opacity: 0; visibility: hidden; }

/* Visibility States */
.remove-stream-btn, .refresh-stream-btn, .swap-stream-btn, .video-overlay, .ios-btn {
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 2147483647 !important;
}

@media (hover: hover) and (pointer: fine) {
    .video-box:hover .remove-stream-btn,
    .video-box:hover .refresh-stream-btn,
    .video-box:hover .swap-stream-btn,
    .video-box:hover .video-overlay {
        opacity: 1 !important;
        pointer-events: auto;
    }
}
.video-box.user-is-active .remove-stream-btn,
.video-box.user-is-active .refresh-stream-btn,
.video-box.user-is-active .swap-stream-btn,
.video-box.user-is-active .video-overlay,
.video-box.user-is-active .ios-btn {
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}
.video-box.is-offline .remove-stream-btn,
.video-box.is-offline .refresh-stream-btn,
.video-box.is-offline .swap-stream-btn {
    opacity: 1; pointer-events: auto;
}

/* Control Buttons - simple round icon buttons */
.remove-stream-btn, .refresh-stream-btn, .swap-stream-btn { 
    position: absolute; 
    top: 10px; 
    width: 36px; 
    height: 36px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7); 
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.12); 
    z-index: 20;
    transition: var(--transition-smooth);
}

.remove-stream-btn { right: 10px; color: #ff5252; }

.refresh-stream-btn { 
    right: 55px; 
    color: var(--kick-green); 
}

.swap-stream-btn {
    right: 100px;
    color: #7ea6ff;
}

.remove-stream-btn:hover { background: #ff5252; color: #000; border-color: #ff5252; }

.refresh-stream-btn:hover { 
    background: var(--kick-green); 
    color: #06210a; 
    border-color: var(--kick-green);
}

.swap-stream-btn:hover {
    background: #7ea6ff;
    color: #06122b;
    border-color: #7ea6ff;
}

.remove-stream-btn svg, .refresh-stream-btn svg, .swap-stream-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* Username Tag */
.video-overlay { 
    position: absolute; 
    top: 10px; 
    left: 10px; 
    background: rgba(0, 0, 0, 0.75); 
    backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--kick-green);
    display: inline-flex;    
    align-items: center;     
    justify-content: center; 
    padding: 6px 14px;
}

.video-overlay .username-link { 
    color: #fff; 
    font-family: var(--font-primary); 
    text-decoration: none; 
    font-size: 0.8rem; 
    font-weight: 700; 
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1;
}

.video-overlay .username-link::before {
    content: ''; display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--kick-green);
}

.ios-btn {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(83, 252, 24, 0.5);
    border-radius: 25%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--kick-green);
    position: absolute;
    cursor: pointer;
}
.ios-btn:active { transform: scale(0.92); background: var(--kick-green); color: #06210a; }
.ios-btn svg { width: 25px; height: 25px; fill: currentColor; }

/* --- CHAT SIDEBAR --- */
#chat-sidebar {
    width: 375px;
    min-width: 360px;
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: var(--transition-smooth);
    margin: 0; 
    z-index: 90;
    position: relative;
    border-left: 1px solid var(--glass-border);
}

/* --- UPDATED CHAT HEADER STYLES --- */

/* 1. Tabs Container - Now takes full width */
.chat-controls {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.6);
    min-height: 60px;
    gap: 8px; /* Space between arrows and tabs */
}

#chat-tabs {
    display: flex;
    flex-wrap: nowrap; /* Forces items into a single row */
    gap: 6px;
    justify-content: flex-start;
    align-content: center;
    align-items: center;
    flex-grow: 1;
    
    /* CRITICAL FIX for resize issue: allows container to shrink below content width */
    min-width: 0; 
    
    overflow-x: auto; /* Enables scrolling */
    overflow-y: hidden;
    
    /* Hide Scrollbar - Firefox */
    scrollbar-width: none;
    /* Smooth scrolling behavior */
    scroll-behavior: smooth;
    
    /* Ensure it takes up available width */
    max-width: 100%;

    /* Remove any shadows/masks from previous versions */
    mask-image: none !important;
    -webkit-mask-image: none !important;
    box-shadow: none !important;
}

/* Hide Scrollbar - Chrome/Safari/Edge */
#chat-tabs::-webkit-scrollbar {
    display: none;
}

/* Chat Tabs - Shards */
.chat-tab-item {
    background: rgba(255,255,255,0.02);
    border: 1px solid transparent;
    padding: 0;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px; 
    height: 52px;
    border-radius: 0px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0; /* Prevents tabs from squishing */
}
.chat-tab-item:hover { 
    background: rgba(255,255,255,0.08); 
}
.chat-tab-item.active { 
    background: var(--kick-green) !important;
    box-shadow: none;
    z-index: 100;
}
.chat-tab-item.active .chat-tab-avatar {
    width: 85% !important;
    height: 85% !important;
    border: 2px solid #000000;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chat-tab-avatar { width: 100%; height: 100%; object-fit: cover; border-radius: 0px; }

/* Scroll Arrows */
.scroll-arrow {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--kick-green);
    width: 24px;
    height: 52px; /* Match tab height */
    display: none; /* Hidden by default, JS toggles flex */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.2s ease;
    flex-shrink: 0; /* Ensures arrows don't shrink when flex container is tight */
    z-index: 10;
}

.scroll-arrow:hover {
    background: var(--kick-green);
    color: #06210a;
}

/* Hide arrows on mobile completely */
@media (max-width: 1000px) {
    .scroll-arrow { display: none !important; }
}

/* 2. New Toolbar Section */
.chat-toolbar {
    display: flex;
    width: 100%;
    height: 40px;
    background: #050505;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 0;
    margin: 0;
    z-index: 5;
    flex-shrink: 0;
}

.chat-toolbar button {
    flex: 1; /* 50% width */
    border: none;
    background: transparent;
    color: #888;
    font-family: var(--font-primary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 0;
    margin: 0;
    clip-path: none;
    box-shadow: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-split-btn {
    border-right: 1px solid rgba(255,255,255,0.1);
}

#chat-split-btn:hover { background: rgba(255,255,255,0.05); color: #fff; }
#chat-split-btn.active { background: rgba(0, 229, 255, 0.15); color: var(--kick-secondary); }

#chat-toggle-btn:hover { background: rgba(255, 77, 77, 0.1); color: #ff4d4d; }

#chat-container { flex-grow: 1; position: relative; background: var(--bg-panel); }
#chat-container iframe { width: 100%; height: 100%; border: none; background: var(--bg-panel); }

/* No Chat - simple placeholder */
#no-chat-selected {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
    font-family: var(--font-primary);
    flex-direction: column;
    gap: 1.5rem;
    background: var(--bg-panel);
}

#no-chat-selected::before {
    content: 'K';
    font-family: 'Kick Font', sans-serif;
    font-size: 6rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.12);
}

/* Floating Chat Open Button */
#show-chat-btn {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 150;
    
    width: 40px;
    height: 80px;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    background: var(--bg-panel);
    
    border: 1px solid var(--glass-border);
    border-right: none;
    color: var(--kick-green);
    
    display: none; 
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

#show-chat-btn:hover {
    width: 50px;
    background: var(--kick-green);
    color: #06210a;
}
#show-chat-btn svg { width: 24px; height: 24px; fill: currentColor; transform: rotate(180deg); }

#main-content.chat-hidden #chat-sidebar { width: 0; min-width: 0; border: none; opacity: 0; margin: 0; }
#main-content.chat-hidden #show-chat-btn { display: flex; }

/* --- MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-smooth);
}
.modal-overlay.visible { opacity: 1; visibility: visible; }

/* --- UNIFIED MODAL TYPOGRAPHY --- */
.extension-modal, .contact-modal, .legal-modal {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-float);
    width: 100%;
    padding: 3rem;
    transform: scale(0.95);
    transition: var(--transition-smooth);
    max-height: 85vh;
    overflow-y: auto;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    position: relative;
    text-align: left; 
}

.modal-overlay.visible .contact-modal, 
.modal-overlay.visible .legal-modal { transform: scale(1); }

/* Headers */
.extension-modal h2, .contact-modal h2, .legal-modal h2 {
    font-family: var(--font-primary);
    color: var(--kick-green);
    margin-bottom: 1.5rem;
    text-align: center; 
    font-size: 1.8rem;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
    font-weight: 700;
}

/* Sub-headers (h3) */
.extension-modal h3, .contact-modal h3, .legal-modal h3 {
    font-family: var(--font-primary);
    color: #fff;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    font-size: 1.1rem;
    text-align: left; 
    border-left: 2px solid var(--kick-green);
    padding-left: 15px;
}

/* Body Text */
.extension-modal p, .contact-modal p, .legal-modal p,
.extension-modal li, .contact-modal li, .legal-modal li {
    font-family: var(--font-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-align: left; 
}

/* Unified Lists */
.extension-modal ul, .contact-modal ul, .legal-modal ul {
    list-style-type: none;
    padding-left: 1.5rem; 
    margin-bottom: 1.5rem;
}

/* List Items */
.extension-modal li, .contact-modal li, .legal-modal li {
    position: relative;
    padding-left: 1.5rem;
}

/* Bullets */
.extension-modal li::before, .contact-modal li::before, .legal-modal li::before {
    content: '-';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--kick-green); 
    font-family: monospace; 
    font-weight: 700;
}

.modal-content-scroll {
    overflow-y: auto;
    padding-right: 15px;
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
}
.close-modal-btn:hover { color: var(--kick-green); }

/* --- FOOTER --- */
.site-footer {
    background: var(--bg-glass-panel);
    border-top: 1px solid rgba(83, 252, 24, 0.25);
    margin: 0; 
    padding: 0 2rem;
    height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-primary);
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    flex-shrink: 0;
    letter-spacing: 1px;
}
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 20px; }
.site-footer nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}
.site-footer nav a:hover { color: var(--kick-green); }

/* --- THEATER MODE RULES --- */
body.theater-mode-active header {
    position: relative; 
    width: 100%;
    height: 24px; 
    background: #000 !important; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
    margin: 0; 
    z-index: 5000;
    flex-shrink: 0;
    background-image: none !important;
    backdrop-filter: none !important;
    border: none !important;
    justify-content: center;
    align-items: center;
    padding: 0;
    box-shadow: none !important;
    pointer-events: auto; 
}

/* Hide other header elements */
body.theater-mode-active header .logo, 
body.theater-mode-active header .add-stream-form-wrap, 
body.theater-mode-active .mobile-header-buttons { display: none !important; }

/* Reset container for the button */
body.theater-mode-active .header-actions {
    display: flex !important;
    background: transparent;
    border: none;
    position: static;
    padding: 0;
    gap: 0;
    width: auto;
    height: 100%;
    pointer-events: auto;
    box-shadow: none;
}

body.theater-mode-active .header-actions > *:not(#theater-mode-btn) { display: none !important; }

/* THEATER BUTTON STYLING */
body.theater-mode-active #theater-mode-btn {
    display: flex !important;
    background-color: transparent; 
    border: none;
    box-shadow: none;
    margin: 0;
    color: #666; /* Dimmed by default */
    width: auto; 
    padding: 0 2rem;
    height: 100%; /* Fill the height of the black bar */
    clip-path: none;
    border-radius: 0;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: color 0.2s ease;
}

/* 1. HIDE original text */
body.theater-mode-active #theater-mode-btn span { 
    display: none !important; 
}

/* 2. INJECT 'EXIT THEATER' text */
body.theater-mode-active #theater-mode-btn::after {
    content: 'EXIT THEATER';
    font-family: var(--font-primary);
    font-size: 0.75rem; 
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-left: 8px;
}

/* 3. Smaller Icon */
body.theater-mode-active #theater-mode-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    margin-bottom: 2px;
}

/* Hover Effect - Text turns Green */
body.theater-mode-active #theater-mode-btn:hover { 
    background-color: rgba(83, 252, 24, 0.05); 
    color: var(--kick-green); 
    box-shadow: none;
}

/* Hide other UI elements */
body.theater-mode-active .site-footer, 
body.theater-mode-active #chat-sidebar,
body.theater-mode-active #show-chat-btn { display: none !important; }

/* Layout adjustments */
body.theater-mode-active #main-content { 
    height: auto !important; 
    flex-grow: 1;
    padding: 0 !important; 
    margin: 0 !important; 
    gap: 0; 
    overflow: hidden;
}

body.theater-mode-active #video-grid-container { 
    padding: 0 !important; 
    margin: 0 !important; 
    background: #000; 
    border-radius: 0;
}

body.theater-mode-active .video-box { border-radius: 0; border: none; box-shadow: none; }

/* --- RESPONSIVE STYLES & MOBILE OPTIMIZATIONS --- */
@media (max-width: 1250px) and (min-width: 1001px) {
    #theater-mode-btn, #edit-layout-btn, #share-btn { padding: 0; width: 44px; height: 44px; justify-content: center; }
    #theater-mode-btn span, #edit-layout-btn span, #share-btn span { display: none; }
}

@media (max-width: 1000px) { 
    
    /* 1. PERFORMANCE & LAYOUT FIXES - APP FEEL */
    html, body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        position: relative;
        width: 100%;
        height: auto;
        min-height: 100dvh;
        max-width: 100vw;
        
        /* PERFORMANCE: Solid color base */
        background-color: #050505 !important;
        background-image: none !important; 
        background-attachment: scroll !important;
        
        /* SMOOTHNESS: Native momentum scrolling & No rubber-banding */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: none; /* Prevents browser bounce */
        scroll-behavior: smooth;
    }

    /* REMOVE HEAVY OVERLAYS */
    
    /* DISABLE ANIMATIONS FOR FPS */
    .offline-avatar, header .logo h1::after, #no-chat-selected::before, .video-overlay .username-link::before {
        animation: none !important;
    }

    /* 2. STICKY HEADER (Optimized) */
    header { 
        position: sticky;
        top: 0;
        left: 0;
        height: auto;
        padding: 0.8rem 1rem; 
        margin: 0; 
        border: none; 
        border-bottom: 1px solid rgba(255,255,255,0.1);
        flex-wrap: wrap; 
        gap: 0.8rem;
        flex-shrink: 0;
        z-index: 100; 
        background: #0a0a0f !important; /* Opaque for scrolling performance */
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    header .logo h1 { font-size: 1.4rem; }
    
    .add-stream-form-wrap {
        order: 3; 
        width: 100%; 
        max-width: none; 
        margin-top: 0; 
    }
    #add-stream-form { 
        background: rgba(255,255,255,0.03); 
    }
    
    /* USABILITY: 16px font prevents iOS zoom on focus */
    #username-input { 
        height: 44px; 
        font-size: 16px !important; 
    }
    
    .header-actions { 
        display: none; 
        position: absolute;
        top: 100%; left: 0; right: 0;
        background: #0a0a0f; 
        border-bottom: 2px solid var(--kick-green);
        z-index: 100;
        flex-direction: column;
        align-items: stretch;
        padding: 2rem;
        gap: 1.5rem;
        box-shadow: 0 10px 30px rgba(0,0,0,0.9);
        backdrop-filter: none !important;
    }
    .header-actions.menu-open { display: flex; animation: slideDown 0.3s ease; }
    @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

    .header-actions button { justify-content: center; height: 50px; border-radius: 0; font-size: 1rem; }
    
    .mobile-header-buttons { display: flex; align-items: center; gap: 0.8rem; }
    #mobile-chat-open-btn, #mobile-menu-toggle {
        background: rgba(255,255,255,0.05);
        border: 1px solid var(--glass-border);
        color: #fff;
        cursor: pointer;
        padding: 0.6rem;
        border-radius: 4px;
        /* Better touch target */
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    #mobile-chat-open-btn svg, #mobile-menu-toggle svg { fill: currentColor; width: 24px; height: 24px; }
    
    /* 3. MAIN CONTENT */
    #main-content { 
        display: flex; 
        flex-direction: column;
        padding: 0; 
        gap: 0; 
        flex-grow: 1; 
        overflow: visible !important; 
        height: auto !important;
        position: static;
        z-index: auto;
    }
    
    #video-grid-container {
        display: block; 
        overflow: visible !important;          
        padding: 0;
        background: #000;
        border-radius: 0;
        min-height: auto;
        height: auto !important;  
        padding-bottom: 40px; /* Space at bottom for scrolling */             
    }
    
    #video-grid {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: auto !important;
        padding: 0;
        padding-bottom: 0;
        gap: 4px; /* Adds space between "Cards" */
    }

    .video-box { 
        width: 100%;
        min-height: auto; 
        height: auto !important;
        aspect-ratio: 16 / 9;
        flex-shrink: 0;
        border-radius: 0; 
        border: none; 
        
        /* CARD LOOK: Subtle separators instead of thick borders */
        box-shadow: 0 4px 10px rgba(0,0,0,0.5) !important;
        border-top: 1px solid rgba(255,255,255,0.05);
        border-bottom: 1px solid rgba(0,0,0,0.8);
        
        touch-action: pan-y; /* Ensures vertical scrolling works perfectly over videos */
    }
    /* Disable hover effects on mobile */
    .video-box:hover { border-color: transparent; transform: none; }
    .video-box::before, .video-box::after { display: none; } 
    
    .video-box .plyr,
    .video-box video,
    .video-box .plyr__video-wrapper {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* 4. SIDEBAR (Optimized Transition) */
    #chat-sidebar {
        position: fixed;
        top: 0; right: 0;
        width: 100%; max-width: 350px;
        height: 100dvh;
        z-index: 2000 !important; 
        
        transform: translate3d(100%, 0, 0); 
        will-change: transform;
        visibility: hidden;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s; /* Smoother curve */
        
        border-left: 2px solid var(--kick-green);
        background: #050505; 
        border-radius: 0;
        margin: 0;
        padding-top: env(safe-area-inset-top);
        
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    #chat-sidebar.is-open { 
        transform: translate3d(0, 0, 0);
        visibility: visible;
    }
    
    /* Mobile Chat Controls & Toolbar */
    .chat-controls, .chat-toolbar { 
        position: relative;
        z-index: 20;
        background: #050505;
    }
    .chat-controls { padding-top: 1rem; }

    #chat-toggle-btn {
        position: relative;
        z-index: 2001; 
        width: auto;   
        height: auto;
        min-width: 0; 
        clip-path: none !important; 
        touch-action: manipulation;
        background: transparent; 
        border: none;
    }
    
    #show-chat-btn { display: none !important; }
    .site-footer { flex-direction: column; gap: 1rem; text-align: center; height: auto; padding: 1.5rem; flex-shrink: 0; backdrop-filter: none !important; background: #0a0a0f; }

    /* 5. VIDEO CONTROLS */
    .remove-stream-btn, 
    .refresh-stream-btn, 
    .swap-stream-btn,
    .video-overlay, 
    .ios-btn {
        z-index: 10 !important;
        backdrop-filter: none !important;
        background: rgba(0,0,0,0.8);
        /* Larger touch targets */
        min-width: 44px;
        min-height: 44px;
    }
    
    /* FLATTEN MODALS ON MOBILE */
    .extension-modal, .contact-modal, .legal-modal {
        transform: none !important;
        perspective: none !important;
        rotate: none !important;
        box-shadow: none !important;
        border: 1px solid #333;
    }
}

@media (min-width: 1001px) { .mobile-header-buttons { display: none !important; } }

@media (max-width: 500px) {
    #add-stream-form button[type=submit] { padding: 0 1rem; }
    #add-stream-form button[type=submit] span { display: none; }
}

/* Offline Card */
.offline-card { 
    display: flex; flex-direction: column; align-items: center; gap: 1rem; 
    text-align: center; pointer-events: none; opacity: 1; 
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 100%;
}
.offline-avatar { 
    width: 80px; height: 80px; 
    border-radius: 50%;
    border: 2px solid var(--kick-green); 
    object-fit: cover; 
    background: #000;
    padding: 2px;
}

.offline-username { 
    font-family: var(--font-primary); 
    font-size: 1.2rem; 
    color: #fff; 
    font-weight: 700; 
    letter-spacing: 0.3px;
}

/* PLYR OVERRIDES */
.plyr--video .plyr__controls { background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent); padding: 15px 25px 25px; }
.plyr__control--overlaid { background: var(--kick-green); color: #06210a; border-radius: var(--radius-sm); }
.plyr--video .plyr__control.plyr__tab-focus, .plyr--video .plyr__control:hover, .plyr--video .plyr__control[aria-expanded=true] { background: var(--kick-green); color: #06210a; border-radius: var(--radius-sm); }
.plyr__control--overlaid:hover, .plyr__control--overlaid:focus { background: #fff; color: var(--kick-green); }
.plyr__range::-webkit-slider-runnable-track { height: 4px; border-radius: 0; background: rgba(255,255,255,0.2); }
.plyr__range input[type=range]:active::-webkit-slider-thumb { background: var(--kick-green); }
.plyr--full-ui input[type=range] { color: var(--kick-green); }

/* --- UPDATED AUTH SECTION LAYOUT --- */
#chat-auth-section {
    position: relative;
    z-index: 50;
    padding: 10px; /* Comfortable padding */
    display: flex;
    flex-direction: column;
    gap: 10px; /* Space between the Row and the Input */
    background: var(--dark-bg);
    border-top: 1px solid rgba(83, 252, 24, 0.2);
}

/* 1. THE ROW: Holds [Login/User] + [Gear] */
.auth-row {
    display: flex;
    flex-direction: row;
    align-items: stretch; /* Ensures both items are same height */
    gap: 8px;
    width: 100%;
    height: 44px; /* Fixed height for consistency */
}

/* 2. LOGIN BUTTON (Logged Out State) */
#login-btn {
    flex-grow: 1;
    height: 100%;
    font-family: var(--font-primary);
    background: var(--kick-green);
    color: #000;
    border: none;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.3s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#login-btn:hover {
    background: var(--kick-green-flash);
}

/* 3. USER INFO CONTAINER (Logged In State) */
#user-info-container {
    display: none; /* Hidden by default */
    flex-grow: 1;  /* Takes up the space of the login button */
    height: 100%;
    
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    box-sizing: border-box;
    border-radius: 2px;
}

/* Toggle Visibility based on body class */
body.logged-in #user-info-container { display: flex; }
body.logged-in #login-btn { display: none; }

/* User Display Area (Avatar + Name) */
#user-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-primary);
    font-weight: 700;
    color: #fff;
    font-size: 0.85rem;
    overflow: hidden;
    white-space: nowrap;
}

#user-display img {
    width: 28px;
    height: 28px;
    border: 1px solid var(--glass-border);
    border-radius: 4px;
}

/* Compact Logout Button */
#logout-btn {
    font-family: var(--font-primary);
    background: rgba(0, 0, 0, 0.3);
    color: #ff4d4d;
    border: 1px solid rgba(255, 77, 77, 0.3);
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    height: 28px;
    display: flex;
    align-items: center;
}

#logout-btn:hover {
    background: #ff4d4d;
    color: #000;
    border-color: #ff4d4d;
}

/* 4. SETTINGS GEAR (Fixed width) */
.sidebar-dock {
    width: 44px; /* Square */
    flex-shrink: 0;
}

#chat-options-trigger {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4); 
    color: var(--kick-green);
    border: 2px solid var(--kick-green);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 2px;
}

#chat-options-trigger:hover,
#chat-options-trigger.active {
    background: var(--kick-green);
    color: #000;
}

/* 5. INPUT AREA (Sits below the row) - REVISED */
#chat-input-area {
    display: none;
    width: 100%;
}
body.logged-in #chat-input-area { 
    display: flex; /* Use flex to layout the label and form */
    flex-direction: column;
}

/* Style the "SENDING TO" label */
#chat-input-area > div:first-child,
.sending-to-label { /* Add a fallback class */
    font-family: var(--font-primary);
    font-size: 0.7rem;
    color: #fff;
    text-transform: uppercase;
    margin-bottom: 6px;
    padding-left: 2px;
}
.sending-to-label span { /* Target the username part */
    color: var(--kick-green);
    font-weight: 700;
}


/* This form is now the main bordered container */
#chat-send-form {
    display: flex;
    align-items: stretch; /* Make input and button the same height */
    height: 44px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(83, 252, 24, 0.2);
    /* Use the same clip-path as the user info box for consistency */
    border-radius: 2px;
    transition: all 0.2s;
    gap: 0; /* No gap between input and button */
}

#chat-send-form:focus-within {
    border-color: var(--kick-green);
    background: rgba(0, 0, 0, 0.5);
}

/* Strip the input field of its own styling */
#chat-message-input {
    flex-grow: 1;
    min-width: 0;
    background: transparent;
    border: none;
    clip-path: none;
    color: #fff;
    padding: 0 15px; /* Add some internal padding */
    font-family: var(--font-secondary);
    font-size: 0.9rem;
}

/* Remove the default focus outline since the parent form handles the highlight */
#chat-message-input:focus {
    outline: none;
}

/* Style the send button to be an integrated part of the form */
#chat-send-btn {
    width: 44px; /* Make it a square */
    flex-shrink: 0;
    background: transparent;
    border: none; /* Remove main border */
    border-left: 1px solid rgba(83, 252, 24, 0.2); /* Add vertical separator */
    clip-path: none;
    padding: 0;
    color: var(--kick-green);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

/* Hide the "SEND" text on ALL screen sizes now */
#chat-send-btn span {
    display: none;
}

#chat-send-btn:hover:not(:disabled) {
    background: var(--kick-green);
    color: #000;
}

#chat-send-btn svg {
    width: 20px;
    height: 20px;
}

/* --- SYSTEM NOTIFICATION CARD (Tech Panel) --- */
#sys-notify {
    display: none; 
    width: 100%;
    max-width: 360px; 
    height: auto;
    min-height: 80px;
    display: flex; 
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-left: 3px solid var(--kick-green);
    box-shadow: var(--shadow-float);
    padding: 16px;
    margin: 15px auto;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    border-radius: var(--radius-md);
}

#sys-notify .notify-icon svg {
    width: 28px;
    height: 28px;
    fill: var(--kick-green);
    display: block;
}

#sys-notify .notify-content { flex-grow: 1; text-align: left; z-index: 2; }

#sys-notify h3 {
    font-family: var(--font-primary);
    color: #fff;
    font-size: 0.9rem;
    margin: 0 0 4px 0;
    font-weight: 700;
    letter-spacing: 0.5px;
}

#sys-notify p {
    font-family: var(--font-secondary); 
    color: #bbb;
    font-size: 0.75rem;
    line-height: 1.4;
    margin: 0;
}

#sys-notify .mini-reload {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    z-index: 2;
}

#sys-notify .mini-reload:hover {
    background: var(--kick-green);
    color: #000;
    border-color: var(--kick-green);
    transform: rotate(180deg);
}
#sys-notify .mini-reload svg { width: 16px; height: 16px; fill: currentColor; }

/* --- MOBILE MODAL FIXES (GEOMETRIC PERFECT CENTER) --- */
@media (max-width: 768px) {
    /* 1. Modal Spacing & Safe Zones */
    .extension-modal, .contact-modal, .legal-modal {
        padding: 1.5rem !important;
        padding-top: 4rem !important; 
        padding-bottom: 100px !important; 
        max-height: 85dvh !important; 
        margin-bottom: env(safe-area-inset-bottom);
        border: 1px solid #333 !important;
        box-shadow: none !important;
    }

    /* 2. Title Centering */
    .extension-modal h2, .contact-modal h2, .legal-modal h2 {
        font-size: 1.5rem !important;
        text-align: center !important; /* KEEP TITLE CENTERED */
        margin-top: 0;
        padding: 0;
        width: 100%;
        border-bottom: 1px solid rgba(83, 252, 24, 0.2);
    }

    /* 3. EXTENSION MODAL SPECIFIC - FORCE LEFT ALIGNMENT */
    /* This forces the container of the buttons/icons to align left */
    .extension-modal,
    .extension-modal div,
    .extension-modal p {
        text-align: left !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
    }

    /* Target the icons (img/svg) and the Get Extension buttons (a) */
    .extension-modal img, 
    .extension-modal svg, 
    .extension-modal a {
        display: inline-block;
        margin-left: 0 !important;
        margin-right: 15px !important; /* Spacing between side-by-side items */
        margin-bottom: 10px !important; /* Vertical spacing */
    }

    /* 4. CLOSE BUTTON CONTAINER */
    .close-modal-btn {
        position: absolute;
        top: 15px;
        right: 15px;
        background: transparent;
        border: none;
        /* The native "&times;" glyph is drawn below via ::before/::after
           instead - hide it here so it doesn't double up with those bars
           (this is also why :active only recolors the bars, not text). */
        color: transparent;
        font-size: 1.5rem;
        cursor: pointer;
        z-index: 10;
    }

    /* 5. DRAW THE PERFECT X WITH CSS LINES */
    .close-modal-btn::before, 
    .close-modal-btn::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 18px; 
        height: 2px;
        background-color: var(--kick-green); 
        border-radius: 1px;
        /* Missing before: without a rotate, both bars sat in the exact
           same unrotated spot, so instead of crossing into an X they
           rendered as one stray horizontal line next to the button. */
    }
    .close-modal-btn::before {
        transform: translate(-50%, -50%) rotate(45deg);
    }
    .close-modal-btn::after {
        transform: translate(-50%, -50%) rotate(-45deg);
    }

    .close-modal-btn:active {
        background: var(--kick-green);
        border-color: var(--kick-green);
    }
    .close-modal-btn:active::before,
    .close-modal-btn:active::after {
        background-color: #000; 
    }
}
