/* ===== Design Tokens ===== */
:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --primary-light: #A29BFE;
    --surface: #1A1A2E;
    --surface-elevated: #222240;
    --surface-card: #2A2A4A;
    --surface-card-hover: #333360;
    --text-primary: #EAEAFF;
    --text-secondary: #9B9BC0;
    --text-muted: #6B6B8D;
    --accent: #FD79A8;
    --accent-alt: #FDCB6E;
    --gradient-start: #6C5CE7;
    --gradient-end: #A29BFE;
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 8px 32px rgba(108, 92, 231, 0.25);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Utility Tokens */
    --white: #ffffff;
    --black: #000000;
    --glass-white-10: rgba(255, 255, 255, 0.1);
    --glass-white-15: rgba(255, 255, 255, 0.15);
    --glass-white-30: rgba(255, 255, 255, 0.3);
    --border-light: rgba(255, 255, 255, 0.05);
}

/* ===== Light Theme ===== */
[data-theme="light"] {
    --surface: #F5F5FA;
    --surface-elevated: #EEEEF5;
    --surface-card: #FFFFFF;
    --surface-card-hover: #F0F0F8;
    --text-primary: #1A1A2E;
    --text-secondary: #5A5A7A;
    --text-muted: #9B9BB0;
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-card-hover: 0 4px 20px rgba(108, 92, 231, 0.15);
}

[data-theme="light"] #app-bar {
    box-shadow: 0 2px 12px rgba(108, 92, 231, 0.2);
}

[data-theme="light"] .search-header {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] #global-search-overlay {
    background: var(--surface);
}

[data-theme="light"] .share-btn {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
}

[data-theme="light"] #page-player {
    background: var(--surface);
}

[data-theme="light"] #toast {
    background: #1A1A2E;
    color: #EAEAFF;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--surface);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* ===== Top App Bar ===== */
#app-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 56px;
    box-shadow: 0 2px 12px rgba(108, 92, 231, 0.3);
}

#app-bar h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--white);
}

.icon-btn {
    background: var(--glass-white-15);
    border: none;
    color: var(--white);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    flex-shrink: 0;
}

.icon-btn:active {
    background: var(--glass-white-30);
    transform: scale(0.92);
}

.hidden {
    display: none !important;
}

/* ===== Content Area ===== */
#content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Loading ===== */
.loading-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    background: var(--surface);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface-card);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner.small {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

.loading-more {
    display: flex;
    justify-content: center;
    padding: 24px;
}

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

/* ===== Search ===== */
.search-container {
    display: flex;
    align-items: center;
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    padding: 0 16px;
    margin-bottom: 16px;
    height: 48px;
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: box-shadow var(--transition), border-color var(--transition);
}

.search-container:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.2);
}

.search-icon {
    color: var(--text-muted);
    font-size: 20px;
    margin-right: 8px;
}

.search-container input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    width: 100%;
}

.search-container input::placeholder {
    color: var(--text-muted);
}

.search-container .icon-btn {
    width: 28px;
    height: 28px;
    margin-left: 8px;
    background: rgba(255, 255, 255, 0.1);
}

.search-container .icon-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.search-container .icon-btn .material-icons-round {
    font-size: 16px;
}

/* ===== Global Search Overlay ===== */
#global-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    z-index: 200;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.search-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface-card);
    gap: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.search-header .icon-btn {
    background: rgba(108, 92, 231, 0.12);
    color: var(--text-primary);
}

.search-header .icon-btn:active {
    background: rgba(108, 92, 231, 0.25);
}

.search-header input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    outline: none;
}

.search-header input::placeholder {
    color: var(--text-muted);
}

.search-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ===== List (Channels / Videos) ===== */
.list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --- Channel Card --- */
.channel-card {
    background: var(--surface-card);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border-light);
}

.channel-card:active {
    transform: scale(0.98);
    background: var(--surface-card-hover);
}

.channel-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
}

.channel-info {
    flex: 1;
    min-width: 0;
}

.channel-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-handle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.channel-arrow {
    color: var(--text-muted);
    font-size: 20px;
    flex-shrink: 0;
}

.fav-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 24px;
    padding: 8px;
    margin: -8px;
    transition: transform var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fav-toggle-btn.active {
    color: var(--accent);
}

.fav-toggle-btn:active {
    transform: scale(0.8);
}

/* --- Video Card --- */
.video-card {
    background: var(--surface-card);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-card);
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-light);
}

.video-card:active {
    transform: scale(0.98);
    background: var(--surface-card-hover);
}

.video-thumb {
    width: 140px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    background: var(--surface-elevated);
}

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

.video-thumb img.error {
    display: none;
}

.video-duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.85); /* Specific dark glass effect for labels */
    color: var(--white);
    font-size: 11px;
    font-weight: 500;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}

.video-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    gap: 6px;
    position: relative;
}

.video-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.video-date {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Video Filter ===== */
.video-filter-container {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    padding: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.filter-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 0;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: #fff;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

/* ===== Player ===== */
#page-player {
    padding: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

#player-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    flex-shrink: 0;
}

#youtube-player {
    width: 100%;
    height: 100%;
}

#youtube-player iframe {
    width: 100%;
    height: 100%;
    border: none;
}

#player-details {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#player-video-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 8px;
}

#player-channel-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.player-ch-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    color: var(--primary-light);
    overflow: hidden;
    flex-shrink: 0;
}

.player-ch-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#player-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 0;
}

#player-channel-name {
    font-weight: 500;
    color: var(--primary-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#player-actions-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.player-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 8px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.player-action-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.15);
}

.player-action-btn.active {
    color: var(--accent);
    background: rgba(253, 121, 168, 0.15);
}

.player-action-btn .material-icons-round {
    font-size: 20px;
}

[data-theme="light"] #player-actions-row {
    border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .player-action-btn {
    background: rgba(0, 0, 0, 0.05);
}

#related-videos-section {
    padding: 16px;
    flex: 1;
}

.related-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

/* ===== Home Page ===== */
.home-section {
    margin-bottom: 28px;
}

.home-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.home-section-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.see-all-btn {
    background: transparent;
    border: none;
    color: var(--primary-light);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.see-all-btn:active {
    background: rgba(162, 155, 254, 0.15);
}

.home-scroll-row {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

.home-scroll-row::-webkit-scrollbar {
    display: none;
}

.home-video-card {
    flex-shrink: 0;
    width: 200px;
    scroll-snap-align: start;
    cursor: pointer;
}

.home-video-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    background: var(--surface-elevated);
    margin-bottom: 8px;
}

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

.home-video-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.home-video-channel {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== Channel Avatar Image ===== */
.channel-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* ===== Share Button ===== */
.share-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.share-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.9);
}

.share-btn .material-icons-round {
    font-size: 20px;
}

#player-details-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    flex-shrink: 0;
}

.share-btn-sm {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition);
}

.share-btn-sm:active {
    color: var(--text-primary);
}

.share-btn-sm .material-icons-round {
    font-size: 18px;
}

.playlist-add-btn-sm {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition);
}

.playlist-add-btn-sm:active {
    color: var(--primary-light);
}

.playlist-add-btn-sm .material-icons-round {
    font-size: 18px;
}

/* ===== Toast ===== */
#toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface-card);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: var(--radius-xl);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 300;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state .material-icons-round {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

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

/* ===== Tabs (Favorites) ===== */
.tabs-container {
    display: flex;
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    padding: 4px;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 0;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
}

.tab-btn.active {
    background: var(--surface-elevated);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ===== Scrollbar ===== */
.page::-webkit-scrollbar {
    width: 4px;
}

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

.page::-webkit-scrollbar-thumb {
    background: var(--surface-card);
    border-radius: 2px;
}

/* ===== Bottom Navigation ===== */
#bottom-nav {
    display: flex;
    background: var(--surface-card);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 6px 0;
    flex-shrink: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#bottom-nav.hidden-nav {
    transform: translateY(100%);
}

.nav-item {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
    transition: color var(--transition);
}

.nav-item.active {
    color: var(--primary-light);
}

.nav-item .material-icons-round {
    font-size: 20px;
}

.nav-label {
    font-size: 9px;
    font-weight: 600;
}

/* ===== Skeleton Loading ===== */
@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

.shimmer {
    background: linear-gradient(90deg, var(--surface-elevated) 25%, var(--surface-card-hover) 50%, var(--surface-elevated) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.2s ease-in-out infinite;
}

.skeleton-home-card {
    flex-shrink: 0;
    width: 200px;
}

.skeleton-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
    margin-bottom: 6px;
    width: 100%;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-channel {
    height: 72px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
}

.skeleton-video {
    height: 96px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
}

/* ===== Pull to Refresh ===== */
.ptr-indicator {
    display: flex;
    justify-content: center;
    padding: 12px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: var(--surface);
}

/* ===== Category Chips (Home) ===== */
.home-category-chip {
    flex-shrink: 0;
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    padding: 10px 20px;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 8px;
    scroll-snap-align: start;
    white-space: nowrap;
}

.home-category-chip:active {
    transform: scale(0.95);
    background: var(--surface-card-hover);
}

.home-category-chip .chip-icon {
    font-size: 20px;
}

.home-category-chip .chip-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.skeleton-category-chip {
    flex-shrink: 0;
    width: 110px;
    height: 42px;
    border-radius: var(--radius-xl);
}

/* ===== Sort Button ===== */
.sort-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.sort-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--surface-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition);
}

.sort-btn:active {
    background: var(--surface-card-hover);
}

.sort-btn .material-icons-round {
    font-size: 16px;
}

/* ===== Shorts Viewer ===== */
.shorts-page {
    padding: 0 !important;
    background: #000 !important;
}

#shorts-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

#shorts-player-wrap {
    width: 100%;
    height: 100%;
    background: #000;
}

#shorts-player {
    width: 100%;
    height: 100%;
}

#shorts-player iframe {
    width: 100%;
    height: 100%;
    border: none;
}

#shorts-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    display: flex;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
    z-index: 10;
}

#shorts-info {
    flex: 1;
    min-width: 0;
}

#shorts-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

#shorts-channel {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
}

#shorts-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    pointer-events: auto;
}

.shorts-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.shorts-action-btn:active {
    background: rgba(255,255,255,0.3);
}

#shorts-nav-hint {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    color: rgba(255,255,255,0.4);
    font-size: 11px;
    gap: 4px;
    pointer-events: none;
    animation: hintFade 3s ease forwards;
}

@keyframes hintFade {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}

/* ===== Channel Detail ===== */
#channel-detail-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding: 8px 0;
}

.channel-avatar.large {
    width: 64px;
    height: 64px;
    font-size: 26px;
}

#channel-detail-info {
    flex: 1;
    min-width: 0;
}

#channel-detail-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#channel-detail-handle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== New Badge ===== */
.new-badge {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
    flex-shrink: 0;
    line-height: 1.4;
}

/* ===== Channel Stats ===== */
.channel-stats {
    display: flex;
    gap: 0;
    background: var(--surface-card);
    border-radius: var(--radius-md);
    padding: 12px 0;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
}

.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item:last-child {
    border-right: none;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-light);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== Playlist ===== */
.create-playlist-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--surface-card);
    border: 2px dashed rgba(108, 92, 231, 0.3);
    border-radius: var(--radius-md);
    color: var(--primary-light);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 16px;
}

.create-playlist-btn:active {
    background: var(--surface-card-hover);
    border-color: var(--primary);
}

.playlist-card {
    background: var(--surface-card);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border-light);
}

.playlist-card:active {
    transform: scale(0.98);
    background: var(--surface-card-hover);
}

.playlist-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.playlist-info {
    flex: 1;
    min-width: 0;
}

.playlist-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-count {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.playlist-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition);
}

.playlist-delete-btn:active {
    color: var(--accent);
}

/* ===== Dialog ===== */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeInOverlay 0.2s ease;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dialog-content {
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.dialog-content h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.dialog-content input {
    width: 100%;
    background: var(--surface-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    margin-bottom: 16px;
}

.dialog-content input:focus {
    border-color: var(--primary-light);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.dialog-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.dialog-btn.primary {
    background: var(--primary);
    color: #fff;
}

.dialog-btn:active {
    opacity: 0.7;
}

.playlist-options {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.playlist-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.playlist-option:active {
    background: var(--surface-elevated);
}

.playlist-option .material-icons-round {
    color: var(--primary-light);
    font-size: 22px;
}

.playlist-option span:last-child {
    font-size: 14px;
    color: var(--text-primary);
}

/* ===== Switch Toggle ===== */
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
}

.settings-item-info {
    flex: 1;
    margin-right: 16px;
}

.settings-item-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.settings-item-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--surface-card-hover);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* ===== Safe Area (notch support) ===== */
@supports (padding-top: env(safe-area-inset-top)) {
    #app-bar, .search-header {
        padding-top: calc(12px + env(safe-area-inset-top));
    }

    #bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .page {
        padding-bottom: 16px;
    }
}

/* ===== Language Selector ===== */
.lang-dialog {
    max-width: 280px;
}

.lang-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--surface-card-hover);
    border-radius: var(--radius-md);
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
}

.lang-btn:hover {
    border-color: var(--primary-light);
    background: var(--surface-card-hover);
}

.lang-btn.active {
    border-color: var(--primary);
    background: var(--surface-elevated);
    font-weight: 600;
}

.lang-flag {
    font-size: 20px;
}

/* ===== Offline Banner ===== */
#offline-banner {
    position: fixed;
    top: -48px;
    left: 0;
    right: 0;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #e74c3c;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    z-index: 10000;
    transition: top 0.3s ease;
}

#offline-banner .material-icons-round {
    font-size: 18px;
}

#offline-banner.show {
    top: 0;
}

#offline-banner.online {
    background: #27ae60;
}

/* ===== Settings Bottom Sheet ===== */
.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: background 0.3s ease;
}

.bottom-sheet-overlay.show {
    background: rgba(0, 0, 0, 0.5);
}

.bottom-sheet {
    width: 100%;
    max-width: 480px;
    background: var(--surface-elevated);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 12px 24px 32px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 85vh;
    overflow-y: auto;
}

.bottom-sheet-overlay.show .bottom-sheet {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--text-muted);
    border-radius: 2px;
    margin: 0 auto 16px;
    opacity: 0.5;
}

.bottom-sheet h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.context-menu-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.context-menu-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    padding: 14px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
}

.context-menu-item:active {
    background: rgba(255, 255, 255, 0.08);
}

.context-menu-item .material-icons-round {
    font-size: 22px;
    color: var(--text-secondary);
}

[data-theme="light"] .context-menu-item:active {
    background: rgba(0, 0, 0, 0.05);
}

.settings-section {
    margin-bottom: 20px;
}

.settings-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-toggle-group {
    display: flex;
    gap: 8px;
}

.theme-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 2px solid var(--surface-card-hover);
    border-radius: var(--radius-md);
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.theme-option:hover {
    border-color: var(--primary-light);
}

.theme-option.active {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.15);
    color: var(--primary-light);
}

.theme-option .material-icons-round {
    font-size: 20px;
}

.settings-lang-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== History Clear Button ===== */
.history-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.clear-all-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.clear-all-btn:active {
    background: rgba(231, 76, 60, 0.3);
    transform: scale(0.96);
}

.clear-all-btn .material-icons-round {
    font-size: 16px;
}

.delete-btn-sm {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.delete-btn-sm:active {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
}

/* ===== Onboarding ===== */
#onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}

#onboarding-overlay.show {
    opacity: 1;
}

.onboarding-content {
    text-align: center;
    padding: 32px 24px;
    max-width: 400px;
    width: 100%;
    max-height: 100vh;
    overflow-y: auto;
}

.onboarding-logo {
    font-size: 64px;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.onboarding-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.onboarding-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.5;
}

.onboarding-section {
    margin-bottom: 32px;
}

.onboarding-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.onboarding-lang-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.onboarding-lang-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 2px solid var(--surface-card-hover);
    border-radius: var(--radius-md);
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.onboarding-lang-btn:hover {
    border-color: var(--primary-light);
}

.onboarding-lang-btn.active {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.15);
    font-weight: 600;
}

.onboarding-start-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
}

.onboarding-start-btn:active {
    transform: scale(0.97);
}

/* ===== Glossary ===== */
.glossary-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.glossary-card {
    display: flex;
    gap: 14px;
    padding: 16px;
    background: var(--surface-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
}

.glossary-emoji {
    font-size: 28px;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

.glossary-content {
    flex: 1;
    min-width: 0;
}

.glossary-term {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.glossary-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== AI Tags & Badges ===== */
.video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.tag {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tag-mood {
    background: rgba(253, 121, 168, 0.15);
    color: var(--accent);
    border: 1px solid rgba(253, 121, 168, 0.2);
}

.tag-genre {
    background: rgba(162, 155, 254, 0.15);
    color: var(--primary-light);
    border: 1px solid rgba(162, 155, 254, 0.2);
}

.tag-type {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.shorts-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: #FF0000;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.shorts-badge .material-icons-round {
    font-size: 12px;
}

.no-shorts-banner {
    background: rgba(108, 92, 231, 0.1);
    color: var(--primary-light);
    font-size: 12px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(108, 92, 231, 0.2);
}

/* ===== Recent Searches ===== */
.recent-search-section {
    padding: 8px 0;
}

.recent-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px;
    margin-bottom: 4px;
}

.recent-search-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.recent-search-clear {
    background: none;
    border: none;
    color: var(--primary-light);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.recent-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 8px;
    background: none;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition);
}

.recent-search-item:active {
    background: var(--surface-card);
}

.recent-search-item .material-icons-round {
    font-size: 20px;
    color: var(--text-muted);
}

/* ===== Trending Rank Badge ===== */
.trending-card .home-video-thumb {
    position: relative;
}

.trending-rank {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 1;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.trending-rank:nth-child(1) { background: #FFB800; }

/* ===== Fan Count on Channel Card ===== */
.channel-handle-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    flex-wrap: wrap;
}

.fan-count {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 2px;
}

.fan-count:not(:empty)::before {
    content: '♥';
    font-size: 10px;
}

/* ===== Comeback Calendar Page ===== */
#page-comeback {
    padding: 16px;
}

.comeback-week-group {
    margin-bottom: 24px;
}

.comeback-week-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-light);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.comeback-week-label .material-icons-round {
    font-size: 18px;
}

.comeback-count {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}

.comeback-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
    border-radius: var(--radius-sm);
}

.comeback-item:active {
    background: var(--surface-card-hover);
}

.comeback-thumb {
    width: 96px;
    height: 54px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    background: var(--surface-elevated);
}

.comeback-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.comeback-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.comeback-channel {
    font-size: 12px;
    color: var(--text-secondary);
}

.comeback-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.comeback-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: auto;
}

/* ===== Playlist Share Button ===== */
.playlist-share-icon-btn {
    background: transparent;
    border: none;
    color: var(--primary-light);
    cursor: pointer;
    padding: 8px;
    margin: -8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--transition);
    min-width: 44px;
    min-height: 44px;
}

.playlist-share-icon-btn:active {
    background: rgba(162, 155, 254, 0.15);
}

.playlist-share-icon-btn .material-icons-round {
    font-size: 20px;
}

/* 공유받은 플레이리스트 저장 버튼 */
#playlist-save-btn .material-icons-round {
    color: var(--primary-light);
}
