:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --on-primary: #fff;
    --surface: #fff;
    --surface-variant: #f1f3f4;
    --on-surface: #202124;
    --on-surface-secondary: #5f6368;
    --outline: #dadce0;
    --error: #d93025;
    --error-bg: #fce8e6;
    --shadow-1: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
    --shadow-2: 0 1px 3px 0 rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
    --radius: 8px;
    --radius-lg: 12px;
    --font: 'Google Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--surface-variant);
    color: var(--on-surface);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--surface-variant);
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    padding: 48px 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-card h1 {
    font-size: 22px;
    font-weight: 500;
    color: var(--on-surface);
    margin-bottom: 8px;
    line-height: 1.5;
}

.login-card p {
    font-size: 14px;
    color: var(--on-surface-secondary);
    margin-bottom: 32px;
}

.input-field {
    position: relative;
    margin-bottom: 24px;
}

.input-field input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--outline);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: var(--font);
    outline: none;
    transition: border-color .2s;
    background: var(--surface);
}

.input-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, .2);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: background .2s, box-shadow .2s;
    min-width: 120px;
    height: 40px;
    letter-spacing: .25px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-1);
}

.btn-primary:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.btn-outlined {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--outline);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: background .2s;
    height: 40px;
}

.btn-outlined:hover {
    background: rgba(26, 115, 232, .04);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius);
    transition: background .2s;
}

.btn-text:hover {
    background: rgba(26, 115, 232, .04);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    background: var(--error);
    color: var(--on-primary);
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    height: 40px;
}

.btn-danger:hover {
    opacity: .9;
}

.login-error {
    background: var(--error-bg);
    color: var(--error);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

/* Top Bar */
.topbar {
    background: var(--surface);
    box-shadow: var(--shadow-1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 16px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--on-surface);
    white-space: nowrap;
}

.topbar-spacer {
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tabs */
.tabs {
    background: var(--surface);
    border-bottom: 1px solid var(--outline);
}

.tabs-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-item {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color .2s, border-color .2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font);
}

.tab-item:hover {
    color: var(--primary);
}

.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Filter Chips */
.filter-bar {
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--outline);
    background: var(--surface);
    color: var(--on-surface-secondary);
    cursor: pointer;
    transition: all .2s;
    font-family: var(--font);
}

.chip:hover {
    background: rgba(26, 115, 232, .04);
}

.chip.active {
    background: #e8f0fe;
    color: var(--primary);
    border-color: var(--primary);
}

/* Video Grid */
.video-feed {
    max-width: 1000px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.video-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    cursor: pointer;
    transition: box-shadow .2s, transform .15s;
}

.video-card:hover {
    box-shadow: var(--shadow-2);
    transform: translateY(-2px);
}

.video-card-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    background: #e8eaed;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.video-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-card-thumb .placeholder-icon {
    font-size: 48px;
    color: var(--on-surface-secondary);
    opacity: .3;
}

.video-card-body {
    padding: 16px;
}

.video-card-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--on-surface);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-card-meta {
    font-size: 13px;
    color: var(--on-surface-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.video-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.video-card-tags .tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--surface-variant);
    color: var(--on-surface-secondary);
}

/* Player Page */
.player-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 0;
}

.player-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: var(--on-surface-secondary);
    cursor: pointer;
    font-size: 14px;
    background: none;
    border: none;
    font-family: var(--font);
}

.player-back:hover {
    color: var(--primary);
}

.player-wrapper {
    width: 100%;
    background: #000;
    position: relative;
}

.player-wrapper video {
    width: 100%;
    display: block;
    max-height: 70vh;
}

.player-info {
    padding: 20px 16px;
    background: var(--surface);
}

.player-info h1 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 8px;
}

.player-info .meta {
    font-size: 14px;
    color: var(--on-surface-secondary);
    margin-bottom: 16px;
}

.player-info .desc {
    font-size: 16px;
    color: var(--on-surface);
    line-height: 1.8;
    white-space: pre-wrap;
}

/* Admin Panel */
.admin-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-header h2 {
    font-size: 22px;
    font-weight: 500;
}

.admin-table-wrap {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th {
    text-align: left;
    padding: 14px 16px;
    font-weight: 500;
    color: var(--on-surface-secondary);
    border-bottom: 1px solid var(--outline);
    white-space: nowrap;
}

.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--outline);
    vertical-align: top;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: rgba(0, 0, 0, .02);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 500;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--on-surface-secondary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background: var(--surface-variant);
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--on-surface-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--outline);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color .2s;
    background: var(--surface);
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, .2);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group .help {
    font-size: 12px;
    color: var(--on-surface-secondary);
    margin-top: 4px;
}

.modal-actions {
    padding: 0 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Cover preview in admin */
.cover-preview {
    width: 120px;
    height: 68px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--surface-variant);
}

.cover-upload-area {
    border: 2px dashed var(--outline);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s;
}

.cover-upload-area:hover {
    border-color: var(--primary);
}

.cover-upload-area img {
    max-width: 200px;
    max-height: 120px;
    border-radius: 6px;
    margin-bottom: 8px;
}

/* Snackbar */
.snackbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #323232;
    color: #fff;
    padding: 14px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    z-index: 300;
    transition: transform .3s;
    box-shadow: var(--shadow-2);
}

.snackbar.show {
    transform: translateX(-50%) translateY(0);
}

/* Loading spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--outline);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 40px auto;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--on-surface-secondary);
}

.empty-state .icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: .3;
}

.empty-state p {
    font-size: 16px;
}

/* Responsive */
@media (max-width: 600px) {
    .login-card {
        padding: 32px 24px;
    }

    .video-feed {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 12px;
    }

    .topbar-title {
        font-size: 16px;
    }

    .admin-container {
        padding: 12px;
    }

    .modal {
        margin: 8px;
    }

    .modal-body {
        padding: 16px;
    }

    .player-info {
        padding: 16px 12px;
    }

    .video-card-title {
        font-size: 18px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--on-surface-secondary);
}