:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-elevated: #1c1c28;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #2a2a3a;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Login Screen */
.screen { min-height: 100vh; }

#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
    background-image: 
        radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(168, 85, 247, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
}

.login-card {
    background: var(--bg-card);
    padding: 3rem 2.5rem;
    border-radius: 24px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.05), inset 0 1px 0 rgba(255,255,255,0.05);
    width: 100%;
    max-width: 420px;
    backdrop-filter: blur(20px);
    position: relative;
}

.login-card::before {
    content: '';
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.login-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(10px);
    max-height: 90vh;
    overflow-y: auto;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 3.2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
    text-shadow: 0 0 40px rgba(99, 102, 241, 0.4);
}

.login-tagline {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    letter-spacing: 0.02em;
}

.accent {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.title-word {
    display: inline-flex;
    align-items: baseline;
    white-space: nowrap;
}

.title-plain {
    display: inline;
}

.title-word .accent {
    display: inline;
    margin: 0;
    padding: 0;
}

.version-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    margin-left: 0.4rem;
    align-self: center;
    padding: 0.15rem 0.5rem;
    letter-spacing: 0.04em;
    opacity: 1;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 8px;
    white-space: nowrap;
}

.acn {
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* Forms */
form { display: flex; flex-direction: column; gap: 0.5rem; }
label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; margin-top: 0.5rem; }

input[type="email"], input[type="password"], input[type="text"] {
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
input::placeholder { color: var(--text-muted); }

button {
    padding: 0.85rem 1.5rem;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    letter-spacing: 0.01em;
    margin-top: 0.5rem;
}
button:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 15px var(--accent-glow); }
button:active { transform: translateY(0); }

.error { color: var(--error); font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.25rem; }

.forgot-link {
    display: block;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-top: 0.5rem;
    transition: color 0.15s ease;
}
.forgot-link:hover { color: var(--accent-hover); }

.form-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

/* App screen layout */
#app-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Content + sidebar wrapper */
.app-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.app-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-content > main {
    flex: 1;
}

#app-screen > main {
    flex: 1;
}


header {
    width: 100%;
    padding: 0 2rem;
    height: 64px;
    background: rgba(18, 18, 26, 0.8);
    backdrop-filter: blur(20px);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    justify-self: start;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.home-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.15s ease;
}
.home-link:hover { opacity: 0.85; }

.logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.5));
}

nav { display: flex; gap: 0.4rem; align-items: center; justify-self: center; }

#logout-btn { justify-self: end; }

.nav-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s ease;
    margin-top: 0;
}
.nav-btn:hover { color: var(--text-primary); background: var(--bg-elevated); transform: none; box-shadow: none; opacity: 1; }
.nav-btn.active { color: var(--text-primary); background: var(--accent); background-image: var(--gradient); }
.nav-btn.secondary { color: var(--text-muted); }
.nav-btn.secondary:hover { color: var(--error); background: rgba(239, 68, 68, 0.1); }

/* Main Content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

main h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Video Grid */
.grid-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.grid-scale {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.grid-scale input[type="range"] {
    width: 100px;
    accent-color: var(--accent);
    cursor: pointer;
}
#grid-cols-label {
    min-width: 1.2rem;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
}
.grid-pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
#page-info {
    color: var(--text-muted);
    min-width: 3rem;
    text-align: center;
}
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Video Cards */
.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}
.video-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--accent-glow);
}
.card-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--bg-elevated);
    flex-shrink: 0;
}
.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.card-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.card-thumb-placeholder svg {
    width: 48px;
    height: 48px;
}
.card-body {
    padding: 1.25rem 1.5rem 1.5rem;
}
.video-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}
.video-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}
.video-card .reason {
    font-style: italic;
    color: var(--accent);
    font-size: 0.85rem;
}

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.tag {
    background: var(--bg-elevated);
    color: var(--accent-hover);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.status-badge.completed { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.status-badge.pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-badge.failed { background: rgba(239, 68, 68, 0.15); color: var(--error); }

/* Player View */
#player-view { max-width: 1000px; }
#back-btn {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
}
#back-btn:hover { color: var(--text-primary); background: var(--bg-card); transform: none; box-shadow: none; opacity: 1; }

#video-player {
    width: 100%;
    border-radius: 16px;
    background: #000;
    margin-bottom: 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

#video-meta {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
}
#video-summary {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1rem;
}
#video-topics { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Admin View */
#admin-view { max-width: 100%; }
#upload-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

input[type="file"] {
    padding: 0.85rem 1rem;
    border: 2px dashed var(--border);
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
}
input[type="file"]:hover { border-color: var(--accent); }
input[type="file"]::file-selector-button {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 1rem;
    font-weight: 500;
}

#upload-status {
    color: var(--accent);
    font-size: 0.9rem;
    margin-top: 1rem;
    min-height: 1.25rem;
}

.admin-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    gap: 1rem;
}
.admin-item-info { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.admin-item-title { color: var(--text-primary); font-weight: 500; }
.admin-item-summary { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; margin: 0; }
.admin-item button {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    margin-top: 0;
}
.admin-item button:hover { background: rgba(239, 68, 68, 0.1); transform: none; box-shadow: none; opacity: 1; }

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
    font-size: 1rem;
}

/* Your Video Valet Sidebar */
#chat-sidebar {
    width: 340px;
    min-width: 340px;
    border-left: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    z-index: 40;
    transition: margin-right 0.25s ease, opacity 0.25s ease;
}
#chat-sidebar.collapsed {
    display: none;
}

#chat-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    flex-shrink: 0;
}
#chat-collapse, #chat-new {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
#chat-collapse:hover, #chat-new:hover { color: var(--text-primary); background: var(--bg-card); transform: none; box-shadow: none; opacity: 1; }

.chat-turn-limit {
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border-radius: 12px;
    margin: 0.25rem 0;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}
.chat-msg.user {
    align-self: flex-end;
    background: var(--gradient);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-msg.bot {
    align-self: flex-start;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.chat-msg.typing { opacity: 0.7; font-style: italic; }
.chat-video-link {
    display: block;
    color: var(--accent-hover);
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    margin: 0.35rem 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: background 0.15s, border-color 0.15s;
}
.chat-video-link:hover {
    background: var(--bg-elevated);
    border-color: var(--accent);
}
.chat-video-link::before {
    content: '▶ ';
    font-size: 0.75rem;
    opacity: 0.6;
}

/* Chat Suggestion Chips */
#chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    flex-shrink: 0;
}
#chat-suggestions:empty {
    display: none;
}
.chat-chip {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.chat-chip:hover {
    background: var(--bg-elevated);
    border-color: var(--accent);
    color: var(--accent-hover);
}

#chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    flex-shrink: 0;
}
#chat-form input {
    flex: 1;
    border-radius: 20px;
    padding: 0.75rem 1rem;
}
#chat-form button {
    padding: 0.75rem 1.25rem;
    border-radius: 20px;
    margin: 0;
}

/* Expand button (visible when sidebar is collapsed) */
#chat-expand {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 30px;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 8px 30px var(--accent-glow);
    margin: 0;
    font-family: inherit;
    transition: transform 0.15s ease;
}
#chat-expand:hover { transform: translateY(-2px); box-shadow: 0 12px 35px var(--accent-glow); opacity: 1; }

/* Shared progress bar (used in upload toast) */
.progress-bar {
    width: 100%;
    height: 5px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--gradient);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.progress-bar.indeterminate .progress-fill {
    width: 40%;
    animation: indeterminate 1.5s ease-in-out infinite;
}
@keyframes indeterminate {
    from { transform: translateX(-100%); }
    to   { transform: translateX(350%); }
}

/* Upload Toast */
#upload-toast {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 300;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    min-width: 260px;
    max-width: 320px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: toast-in 0.25s ease;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
#upload-toast.toast-success { border-color: rgba(34, 197, 94, 0.4); }
#upload-toast.toast-error   { border-color: rgba(239, 68, 68, 0.4); }
#toast-top {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}
#toast-icon { font-size: 1.1rem; flex-shrink: 0; }
#toast-title { flex: 1; font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
#toast-close {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    margin: 0;
    line-height: 1;
    flex-shrink: 0;
}
#toast-close:hover { color: var(--text-primary); background: var(--bg-card); transform: none; box-shadow: none; opacity: 1; }
#toast-percent {
    font-size: 0.78rem;
    color: var(--accent-hover);
    font-weight: 600;
    min-height: 1rem;
    margin-top: 0.25rem;
}

/* Edit Metadata Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
}
.edit-modal-content {
    max-width: 500px;
    text-align: left;
}
.edit-modal-content h3 { margin-bottom: 1.25rem; font-size: 1.15rem; }
.edit-modal-content textarea {
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
    width: 100%;
    transition: all 0.2s ease;
}
.edit-modal-content textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.field-hint { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.edit-modal-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }
.edit-modal-actions button { flex: 1; margin-top: 0; }
.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    background-image: none;
}
.btn-secondary:hover { background: var(--bg-card); color: var(--text-primary); box-shadow: none; }
.admin-item button.edit-btn {
    background: transparent;
    color: var(--accent-hover);
    border: 1px solid var(--accent);
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    margin-top: 0;
}
.admin-item button.edit-btn:hover { background: rgba(99, 102, 241, 0.1); transform: none; box-shadow: none; opacity: 1; }
.admin-item button.reprocess-btn {
    background: transparent;
    color: #f59e0b;
    border: 1px solid #f59e0b;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    margin-top: 0;
}
.admin-item button.reprocess-btn:hover { background: rgba(245, 158, 11, 0.1); transform: none; box-shadow: none; opacity: 1; }
.admin-item button.reprocess-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-item-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.admin-card-actions { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
.admin-card-actions button {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    margin-top: 0;
}
.admin-card-actions .delete-btn { background: transparent; color: var(--error); }
.admin-card-actions .delete-btn:hover { background: rgba(239, 68, 68, 0.1); transform: none; box-shadow: none; }
.admin-card-actions .edit-btn { background: transparent; color: var(--accent-hover); }
.admin-card-actions .edit-btn:hover { background: rgba(99, 102, 241, 0.1); transform: none; box-shadow: none; }
.admin-card-actions .reprocess-btn { background: transparent; color: #f59e0b; }
.admin-card-actions .reprocess-btn:hover { background: rgba(245, 158, 11, 0.1); transform: none; box-shadow: none; }
.admin-card-actions .reprocess-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Users Table */
#users-view { max-width: 1200px; }
#users-table-wrap { overflow-x: auto; }
#users-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}
#users-table th {
    text-align: left;
    padding: 0.85rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
#users-table td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.users-row:hover td { background: rgba(99, 102, 241, 0.05); }
.users-detail-btn {
    background: transparent;
    color: var(--accent-hover);
    border: 1px solid var(--accent);
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    border-radius: 6px;
    margin: 0;
}
.users-detail-btn:hover { background: rgba(99, 102, 241, 0.1); transform: none; box-shadow: none; opacity: 1; }
.users-detail-wrap { padding: 0.5rem 1rem 1rem 2rem; }
.users-detail-table {
    width: auto;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.users-detail-table th {
    text-align: left;
    padding: 0.4rem 1.5rem 0.4rem 0;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.users-detail-table td {
    padding: 0.3rem 1.5rem 0.3rem 0;
    color: var(--text-secondary);
    border: none;
}
.users-detail-row td { background: var(--bg-elevated); }
.sortable { cursor: pointer; user-select: none; position: relative; }
.sortable:hover { color: var(--accent-hover); }
.sort-arrow { font-size: 0.7rem; margin-left: 0.25rem; opacity: 0.4; }
.sort-arrow.asc::after { content: "▲"; }
.sort-arrow.desc::after { content: "▼"; }
.sort-arrow.asc, .sort-arrow.desc { opacity: 1; }
.users-reset-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}
.users-reset-btn:hover { color: #ef4444; border-color: #ef4444; background: rgba(239, 68, 68, 0.08); transform: none; box-shadow: none; opacity: 1; }
.users-reset-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.users-reset-btn:disabled:hover { color: var(--text-secondary); border-color: var(--border); background: transparent; }
.users-toggle-btn { cursor: pointer; border: none; padding: 0.25rem 0.6rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.users-toggle-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.users-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.users-reset-btn, .users-detail-btn { white-space: nowrap; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
    header { padding: 0 1rem; grid-template-columns: auto 1fr auto; }
    header h1 { font-size: 1.1rem; }
    .logo-icon { width: 26px; height: 26px; }
    nav { gap: 0.25rem; }
    .nav-btn { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
    main { padding: 1rem; }
    .video-grid { grid-template-columns: 1fr; }
    .login-card { margin: 1rem; padding: 1.5rem; }
    #chat-sidebar {
        position: fixed;
        top: 64px;
        right: 0;
        width: 100%;
        min-width: 0;
        height: calc(100vh - 64px);
        z-index: 100;
    }
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 1.5rem 2rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.footer-name {
    color: var(--accent-hover);
    text-decoration: none;
    transition: color 0.15s ease;
    cursor: pointer;
}
.footer-name:hover { color: var(--accent); }
.footer-powered { font-size: 0.75rem; opacity: 0.6; }

/* Fireworks */
#fireworks-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    display: none;
}

/* Viewed Badge */
.viewed-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(245, 158, 11, 0.9);
    color: #000;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    z-index: 2;
    letter-spacing: 0.02em;
    pointer-events: none;
}
.video-card { position: relative; }

/* View Later button on card */
.vl-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    background: rgba(0,0,0,0.7);
    border: 2px solid rgba(245, 158, 11, 0.6);
    color: #f59e0b;
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    transition: all 0.15s ease;
}
.vl-btn.active {
    background: rgba(245, 158, 11, 0.85);
    color: #000;
    border-color: rgba(245, 158, 11, 1);
}
.vl-btn:hover { transform: none; box-shadow: 0 0 10px rgba(245,158,11,0.4); opacity: 1; background: rgba(245, 158, 11, 0.7); color: #000; }

/* View Later Sidebar */
#vl-sidebar {
    width: 220px;
    min-width: 220px;
    border-right: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
    z-index: 40;
}
#vl-header {
    padding: 1rem 1rem 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
#vl-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}
.vl-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 2px;
}
.vl-item:hover { background: var(--bg-elevated); }
.vl-title {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.vl-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    margin: 0;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.12s;
}
.vl-item:hover .vl-remove { opacity: 1; }
.vl-remove:hover { color: var(--error); background: rgba(239,68,68,0.1); transform: none; box-shadow: none; }
.vl-empty {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 1rem;
    text-align: center;
    line-height: 1.5;
}
.viewed-badge-sm {
    color: var(--warning);
    font-size: 0.7rem;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    #vl-sidebar { display: none; }
}

/* Player top bar */
.player-top-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.player-vl-btn {
    background: var(--bg-elevated);
    color: #f59e0b;
    border: 2px solid rgba(245, 158, 11, 0.5);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    margin: 0;
}
.player-vl-btn:hover { background: rgba(245, 158, 11, 0.15); transform: none; box-shadow: 0 0 12px rgba(245,158,11,0.3); opacity: 1; }
.player-vl-btn.active {
    background: rgba(245, 158, 11, 0.85);
    color: #000;
    border-color: #f59e0b;
}
.player-vl-btn.active:hover { background: rgba(245, 158, 11, 0.7); }
