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

:root {
    --bg: #0f1117;
    --bg-card: #1a1d29;
    --bg-hover: #222639;
    --text: #e4e6eb;
    --text-dim: #8b8fa3;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --hot: #ff4757;
    --pick: #ffa502;
    --new: #2ed573;
    --border: #2d3149;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ═══ Header ═══ */
.header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(15,17,23,0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.header-inner {
    max-width: 1400px; margin: 0 auto;
    padding: 0 24px; height: 64px;
    display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 1.4rem; font-weight: 800; }
.logo-icon { font-size: 1.6rem; }
.logo-accent { color: var(--accent-light); }
.header-nav { display: flex; gap: 24px; }
.nav-link { color: var(--text-dim); font-size: 0.95rem; font-weight: 500; transition: color 0.2s; }
.nav-link:hover, .nav-link.active { color: var(--text); }

/* ═══ Filter Bar ═══ */
.filter-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}
.filter-inner {
    max-width: 1400px; margin: 0 auto; padding: 0 24px;
    display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.filter-group { display: flex; gap: 6px; }
.filter-btn {
    padding: 6px 14px; border: 1px solid var(--border);
    background: transparent; color: var(--text-dim);
    border-radius: 20px; font-size: 0.85rem; cursor: pointer;
    transition: all 0.2s; font-family: inherit;
}
.filter-btn:hover { background: var(--bg-hover); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: white; }
.badge-hot.active { background: var(--hot); border-color: var(--hot); }
.badge-pick.active { background: var(--pick); border-color: var(--pick); }
.badge-new.active { background: var(--new); border-color: var(--new); }

.filter-select {
    padding: 6px 12px; background: var(--bg);
    border: 1px solid var(--border); color: var(--text);
    border-radius: 20px; font-size: 0.85rem; font-family: inherit;
    cursor: pointer;
}
.filter-check { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-dim); cursor: pointer; }
.filter-check input { accent-color: var(--accent); }

/* ═══ Main ═══ */
.main { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* ═══ Channel Grid ═══ */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
}

/* ═══ Channel Card ═══ */
.channel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
    cursor: pointer;
}
.channel-card:hover { transform: translateY(-2px); border-color: var(--accent); }

.card-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px;
}
.card-rank {
    font-size: 1.5rem; font-weight: 800;
    color: var(--text-dim); min-width: 32px;
}
.card-avatar {
    width: 48px; height: 48px;
    border-radius: 50%; object-fit: cover;
    border: 2px solid var(--border);
}
.card-info { flex: 1; min-width: 0; }
.card-title {
    font-size: 1rem; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-stats { display: flex; gap: 12px; font-size: 0.8rem; color: var(--text-dim); }

.card-badge {
    padding: 4px 10px; border-radius: 12px;
    font-size: 0.7rem; font-weight: 700;
}
.badge-HOT { background: rgba(255,71,87,0.15); color: var(--hot); }
.badge-PICK { background: rgba(255,165,2,0.15); color: var(--pick); }
.badge-NEW { background: rgba(46,213,115,0.15); color: var(--new); }

/* ═══ Viral Video ═══ */
.viral-section {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 12px;
}
.viral-label {
    font-size: 0.75rem; color: var(--text-dim);
    margin-bottom: 8px; display: flex; align-items: center; gap: 4px;
}
.viral-video {
    position: relative; border-radius: var(--radius-sm); overflow: hidden;
}
.viral-thumb { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.viral-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    padding: 20px 12px 10px;
}
.viral-title {
    font-size: 0.85rem; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.viral-views { font-size: 0.75rem; color: var(--accent-light); margin-top: 2px; }

/* ═══ Latest Videos ═══ */
.latest-section { padding: 0 16px 16px; }
.latest-list { display: flex; flex-direction: column; gap: 8px; }
.latest-item {
    display: flex; gap: 10px; align-items: center;
    padding: 6px; border-radius: var(--radius-sm);
    transition: background 0.2s;
}
.latest-item:hover { background: var(--bg-hover); }
.latest-thumb {
    width: 80px; height: 45px;
    border-radius: 6px; object-fit: cover; flex-shrink: 0;
}
.latest-info { flex: 1; min-width: 0; }
.latest-video-title {
    font-size: 0.8rem; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.latest-video-views { font-size: 0.7rem; color: var(--text-dim); }

/* ═══ Loading ═══ */
.loading { text-align: center; padding: 60px 0; color: var(--text-dim); }
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Empty State ═══ */
.empty-state { text-align: center; padding: 60px 0; color: var(--text-dim); font-size: 1.1rem; }

/* ═══ Channel Detail Page ═══ */
.channel-detail { max-width: 900px; margin: 0 auto; }
.detail-header {
    display: flex; gap: 24px; align-items: center;
    padding: 24px; background: var(--bg-card);
    border-radius: var(--radius); border: 1px solid var(--border);
    margin-bottom: 24px;
}
.detail-avatar {
    width: 100px; height: 100px;
    border-radius: 50%; border: 3px solid var(--accent);
}
.detail-info h1 { font-size: 1.6rem; margin-bottom: 8px; }
.detail-stats { display: flex; gap: 20px; color: var(--text-dim); font-size: 0.9rem; }
.detail-stat strong { color: var(--text); font-size: 1.1rem; display: block; }
.detail-section { margin-bottom: 32px; }
.detail-section h2 { font-size: 1.2rem; margin-bottom: 16px; }
.detail-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.detail-video-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden;
    transition: transform 0.2s;
}
.detail-video-card:hover { transform: translateY(-2px); }
.detail-video-thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.detail-video-info { padding: 10px 12px; }
.detail-video-info h3 { font-size: 0.9rem; font-weight: 500; margin-bottom: 4px; line-height: 1.4; }
.detail-video-meta { font-size: 0.75rem; color: var(--text-dim); }

/* ═══ Footer ═══ */
.footer {
    text-align: center; padding: 24px;
    color: var(--text-dim); font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* ═══ Region Dropdown ═══ */
.region-dropdown { position: relative; }
.region-btn {
    display: flex; align-items: center; gap: 6px;
    min-width: 140px; justify-content: space-between;
}
.region-arrow { font-size: 0.7rem; transition: transform 0.2s; }
.region-dropdown .region-btn:hover + .region-menu,
.region-menu.open { display: block; }
.region-menu {
    display: none; position: absolute; top: calc(100% + 4px); left: 0;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 200; min-width: 260px; max-height: 400px; overflow: hidden;
    flex-direction: column;
}
.region-menu.open { display: flex; }
.region-search {
    padding: 10px 14px; background: var(--bg-card);
    border: none; border-bottom: 1px solid var(--border);
    color: var(--text); font-size: 0.9rem; font-family: inherit;
    outline: none; width: 100%; box-sizing: border-box;
}
.region-search:focus { border-bottom-color: var(--accent); }
.region-list {
    overflow-y: auto; max-height: 320px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.region-list::-webkit-scrollbar { width: 6px; }
.region-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.region-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; cursor: pointer; transition: background 0.15s;
}
.region-item:hover { background: var(--bg-hover); }
.region-item-flag { font-size: 1.2rem; }
.region-item-name { flex: 1; font-size: 0.9rem; }
.region-item-code { font-size: 0.7rem; color: var(--text-dim); }
.region-empty { padding: 16px; text-align: center; color: var(--text-dim); font-size: 0.85rem; }

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
    .header-inner { padding: 0 16px; }
    .filter-inner { padding: 0 16px; gap: 12px; }
    .main { padding: 16px; }
    .channel-grid { grid-template-columns: 1fr; }
    .filter-bar { overflow-x: auto; }
    .filter-inner { flex-wrap: nowrap; white-space: nowrap; }
}
