:root {
    --bg-base: #0f1015;
    --bg-surface: #181922;
    --bg-card: #202230;
    --bg-card-hover: #282a3c;
    --border-color: #2e3146;
    --text-main: #f1f1f5;
    --text-muted: #9a9db0;
    --accent-red: #ff334b;
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-green: #10b981;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Navbar */
.navbar {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 1.5rem;
    color: var(--accent-red);
}

.brand-name {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.badge-anti-binge {
    font-size: 0.7rem;
    background: linear-gradient(135deg, #ff334b, #9333ea);
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    color: var(--text-main);
    background-color: var(--bg-card);
}

.nav-item.active {
    color: #60a5fa;
}

/* Container */
.container {
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* Flash alerts */
.flash-container {
    margin-bottom: 1.5rem;
}
.flash {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}
.flash-success {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.flash-danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
}
.btn-primary {
    background-color: var(--accent-primary);
    color: #fff;
}
.btn-primary:hover {
    background-color: var(--accent-primary-hover);
}
.btn-accent {
    background-color: var(--accent-red);
    color: #fff;
}
.btn-accent:hover {
    background-color: #e0243d;
}
.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover {
    background-color: var(--bg-card);
}
.btn-outline-danger {
    background-color: transparent;
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}
.btn-outline-danger:hover {
    background-color: rgba(239, 68, 68, 0.15);
}
.btn-danger {
    background-color: #ef4444;
    color: white;
}
.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}
.btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
}
.btn-block {
    width: 100%;
}
.btn-icon {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}
.btn-icon:hover {
    color: var(--accent-red);
}

/* Feed Header */
.feed-header {
    margin-bottom: 2rem;
}
.feed-stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.stat-pill {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}
.stat-pill strong {
    color: #38bdf8;
}
.stat-pill.dominant-warning {
    border-color: rgba(234, 179, 8, 0.3);
    background-color: rgba(234, 179, 8, 0.08);
    color: #facc15;
}

/* Tag Carousel */
.tag-carousel {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
}
.tag-chip {
    white-space: nowrap;
    padding: 0.35rem 0.85rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: var(--transition);
}
.tag-chip:hover, .tag-chip.active {
    background-color: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.video-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}
.video-card:hover {
    border-color: #3f4460;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.thumbnail-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 ratio */
    background-color: #000;
}
.thumbnail-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.video-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.video-title {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-main);
}
.video-title:hover {
    color: #60a5fa;
}

.video-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}
.channel-name {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 65%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.score-badge {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.75rem;
}

.video-submeta {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: -0.25rem;
    margin-bottom: 0.55rem;
}

.video-date {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    opacity: 0.85;
}

.matched-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}
.tag-mini {
    font-size: 0.7rem;
    color: #93c5fd;
    background-color: rgba(30, 58, 138, 0.4);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    max-width: 600px;
    margin: 0 auto;
}
.empty-icon {
    font-size: 4rem;
    color: #4b5563;
    margin-bottom: 1.5rem;
}
.empty-state h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
}
.empty-state p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}
.empty-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Watch Page */
.watch-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 2rem;
}
.video-player-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    background-color: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.video-player-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
.watch-details {
    margin-top: 1.25rem;
}
.watch-title {
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
}
.watch-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.channel-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.channel-badge {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.watch-tags {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.tags-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.tag-chip-sm {
    font-size: 0.8rem;
    color: #60a5fa;
    background-color: var(--bg-card);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Watch Sidebar */
.watch-sidebar {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    height: fit-content;
}
.sidebar-heading {
    font-size: 1.05rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sidebar-hint {
    font-size: 0.75rem;
    color: #34d399;
    font-weight: 400;
}
.sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.sidebar-card {
    display: flex;
    gap: 0.75rem;
}
.sidebar-thumb {
    position: relative;
    width: 120px;
    height: 68px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background-color: #000;
}
.sidebar-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.duration-badge-sm {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 0.65rem;
    background: rgba(0,0,0,0.85);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}
.sidebar-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.25rem;
}
.sidebar-channel {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.sidebar-match {
    font-size: 0.7rem;
    color: #60a5fa;
}

/* History Page */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.interest-vector-card, .dominant-channels-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}
.interest-tag {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
}
.weight-label {
    font-size: 0.7rem;
    background-color: #2563eb;
    color: #fff;
    padding: 0.1rem 0.35rem;
    border-radius: 10px;
}
.dominant-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}
.badge-dominant {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

.search-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.history-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.history-table th, .history-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.history-table th {
    background-color: var(--bg-card);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.badge-source {
    font-size: 0.75rem;
    background-color: var(--bg-card);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: var(--text-muted);
}

/* Import Page */
.import-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.card-header {
    background-color: var(--bg-card);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-body {
    padding: 1.5rem;
}
.badge-format {
    font-size: 0.75rem;
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.05);
}
.drop-icon {
    font-size: 2.5rem;
    color: #60a5fa;
    margin-bottom: 0.75rem;
}
.drop-text {
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.drop-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.file-name-display {
    font-size: 0.85rem;
    color: #34d399;
    margin: 0.75rem 0;
    min-height: 1.2rem;
}
.quick-sample-box {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Forms */
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}
.form-control {
    width: 100%;
    padding: 0.65rem 1rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: #3b82f6;
}
.code-font {
    font-family: Consolas, monospace;
    font-size: 0.85rem;
}
.takeout-steps {
    padding-left: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-size: 0.95rem;
}
.channel-manage-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}
.channel-manage-item {
    background-color: var(--bg-card);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Footer */
.footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: auto;
}

/* Spinner */
.spin {
    animation: fa-spin 1s infinite linear;
}

/* Responsive */
@media (max-width: 1024px) {
    .watch-container {
        grid-template-columns: 1fr;
    }
    .import-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    .container {
        padding: 1rem;
    }
    .video-grid {
        grid-template-columns: 1fr;
    }
}


/* Language Switcher */
.lang-switch {
    display: inline-flex;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
}
.lang-link {
    color: var(--text-muted);
    padding: 0.1rem 0.3rem;
    border-radius: 10px;
    transition: var(--transition);
}
.lang-link:hover, .lang-link.active {
    color: #60a5fa;
}
.lang-sep {
    color: var(--border-color);
    margin: 0 0.2rem;
    font-size: 0.75rem;
}

/* Account Page */
.badge-status-connected {
    background-color: rgba(16, 185, 129, 0.2);
    color: #34d399;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.badge-status-disconnected {
    background-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.connected-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    background-color: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-md);
}
.connected-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.1rem;
}
.connected-user i {
    font-size: 2.2rem;
    color: #60a5fa;
}
.connected-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.code-box {
    background-color: #0b0c10;
    border: 1px solid var(--border-color);
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.85rem;
    color: #38bdf8;
    margin-bottom: 0.4rem;
}
.info-sub-box {
    background-color: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-sm);
}
.info-sub-box h4 {
    font-size: 0.95rem;
    color: #60a5fa;
}

/* Age Filter Chips */
.filter-controls-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.age-filter-chips {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.filter-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-right: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.age-chip {
    padding: 0.25rem 0.65rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
}
.age-chip:hover, .age-chip.active {
    background-color: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

/* Quick Topic Chips */
.quick-topics-selection {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}
.btn-topic-chip {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.45rem 0.85rem;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}
.btn-topic-chip:hover {
    border-color: #3b82f6;
    transform: translateY(-1px);
}
.btn-topic-chip.selected {
    background-color: #2563eb;
    color: #fff;
    border-color: #2563eb;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}
