:root {
    --bg-page: #f5f5f5;
    --bg-app: #ffffff;
    --bg-header: #ffffff;
    --bg-card: #fafafa;
    --bg-divider: #f5f5f5;
    --text-main: #111111;
    --text-muted: #999999;
    --text-dim: #aaaaaa;
    --border-color: #f0f0f0;
    --primary-color: #E53935;
    --header-border: #f0f0f0;
}

body.dark-theme {
    --bg-page: #121212;
    --bg-app: #1e1e1e;
    --bg-header: #1e1e1e;
    --bg-card: #252525;
    --bg-divider: #1a1a1a;
    --text-main: #e0e0e0;
    --text-muted: #888888;
    --text-dim: #666666;
    --border-color: #2a2a2a;
    --header-border: #2a2a2a;
}

/* Theme-based Logo Toggle */
.logo-link .logo-light { display: block; }
.logo-link .logo-dark { display: none; }
.dark-theme .logo-link .logo-light { display: none; }
.dark-theme .logo-link .logo-dark { display: block; }

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

body {
    font-family: -apple-system, 'Noto Sans KR', sans-serif;
    background: var(--bg-page);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    padding: 0; /* Reduced padding for full-width on mobile */
    min-height: 100vh;
}

.phone {
    width: 100%;
    max-width: 420px; /* Base mobile width */
    background: var(--bg-app);
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
    position: relative;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
}

/* Interaction Restrictions */
.item {
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent;
}

.item img {
    pointer-events: none; /* Prevents long-press image download */
}

/* Hover Video Preview */
.ytVideoBox {
    transition: opacity 0.5s ease-in-out;
    opacity: 0;
    pointer-events: none;
    border-radius: 8px;
    overflow: hidden;
}
.ytVideoBox.hoverTrans {
    opacity: 1;
}

/* Home3 Category Sections */
.cate-section {
    padding: 16px 0 8px;
    border-top: 1px solid var(--border-color);
}
.cate-list {
    display: flex;
    overflow-x: auto;
    padding: 0 16px;
    gap: 12px;
    scrollbar-width: none;
}
.cate-list::-webkit-scrollbar {
    display: none;
}
.cate-item {
    width: 140px;
    flex-shrink: 0;
}
.cate-thumb {
    width: 140px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 6px;
    background: #eee;
    position: relative;
}
.cate-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cate-title {
    font-size: 11px;
    font-weight: 500;
    color: #333;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cate-ch-name {
    font-size: 10px;
    color: #999;
    margin-top: 2px;
}

/* Header */
.header.v3-header {
    background: var(--bg-header);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--header-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    flex-shrink: 0;
}

.logo-link img {
    height: 20px;
    width: auto;
    display: block;
}

/* Title Section */
.section-title-box {
    padding: 24px 16px 10px;
}

.v3-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

.v3-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

@media (min-width: 768px) {
    .section-title-box {
        padding: 40px 32px 20px;
    }
    
    .v3-title {
        font-size: 28px;
    }
}

/* Common UI Components */
.v3-search-box {
    position: relative;
    width: 100%;
}

.v3-search-box input {
    width: 100%;
    padding: 12px 48px 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.v3-search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.1);
}

.v3-search-box .search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.v3-search-box .search-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 2.5;
}

.no-data {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
}

.divider {
    height: 8px;
    background: var(--bg-divider);
    border: none;
    margin: 16px 0;
}

.header-center {
    flex: 1;
    min-width: 0;
}

.v3-header-search {
    background: var(--bg-divider);
    border-radius: 20px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.v3-header-search svg {
    width: 14px;
    height: 14px;
    stroke: var(--text-dim);
    fill: none;
    stroke-width: 2.5;
}

.v3-header-search span {
    font-size: 13px;
    color: var(--text-dim);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--bg-divider);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-main);
    fill: none;
    stroke-width: 2;
}

.user-avatar-small {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--border-color);
}

/* User Popover */
.user-popover {
    position: absolute;
    top: 50px;
    right: 16px;
    width: 220px;
    background: var(--bg-app);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 2000;
}

.user-popover.active {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.popover-content {
    padding: 12px 0;
}

.popover-user-info {
    padding: 8px 20px 12px;
}

.popover-user-info strong {
    display: block;
    font-size: 14px;
    color: var(--text-main);
}

.popover-user-info span {
    font-size: 11px;
    color: var(--text-dim);
}

.popover-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
}

.popover-item:hover {
    background: var(--bg-divider);
}

.popover-item svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 2;
}

#popoverThemeToggle {
    justify-content: space-between;
}

.theme-label {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-switch {
    width: 32px;
    height: 18px;
    background: var(--bg-divider);
    border-radius: 10px;
    position: relative;
    transition: background 0.3s;
}

body.dark-theme .theme-switch {
    background: var(--primary-color);
}

.theme-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}

body.dark-theme .theme-switch::after {
    transform: translateX(14px);
}

/* Hero */
.hero {
    background: linear-gradient(135deg, #fff5f5 0%, #fff 60%);
    padding: 20px 16px 16px;
    border-bottom: 1px solid #f5f5f5;
}

.hero-label {
    font-size: 11px;
    font-weight: 600;
    color: #E53935;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.hero-title {
    font-size: 20px;
    font-weight: 700;
    color: #111;
    line-height: 1.3;
    margin-bottom: 12px;
}

.hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #E53935;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 20px;
    cursor: pointer;
}

.hero-btn svg {
    width: 14px;
    height: 14px;
    fill: #fff;
}

/* Section */
.section {
    padding: 16px 0 4px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 10px;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.section-more {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
}

.section-more:hover {
    color: var(--primary-color);
}

/* Best Cards - horizontal list */
.best-list {
    padding: 0 16px;
    display: flex;
    overflow-x: auto;
    gap: 12px;
    scrollbar-width: none;
}
.best-list::-webkit-scrollbar {
    display: none;
}

.best-card {
    flex-shrink: 0;
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.best-card:nth-child(n+4) {
    display: none;
}

.best-card:hover {
    background: var(--bg-divider);
}

.best-thumb {
    width: 100%;
    height: 100px;
    border-radius: 8px;
    background: var(--border-color);
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

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

.best-thumb-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ddd, #c8c8c8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-icon {
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-icon::after {
    content: '';
    border-left: 7px solid #fff;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    margin-left: 2px;
}

.duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
}

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

.best-info h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.35;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.best-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.channel-name {
    font-size: 11px;
    color: var(--primary-color);
    font-weight: 500;
}

.meta-dot {
    width: 2px;
    height: 2px;
    background: var(--text-dim);
    border-radius: 50%;
}

.view-count {
    font-size: 11px;
    color: var(--text-dim);
}

/* Shorts horizontal scroll */
.shorts-scroll {
    padding: 0 16px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.shorts-scroll::-webkit-scrollbar {
    display: none;
}

.short-card {
    flex-shrink: 0;
    width: 100px;
    cursor: pointer;
}

.short-thumb {
    width: 100px;
    height: 160px;
    border-radius: 10px;
    background: #e0e0e0;
    position: relative;
    overflow: hidden;
    margin-bottom: 6px;
}

.short-thumb-bg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    padding: 8px;
}

.short-thumb-bg.c1 {
    background: linear-gradient(180deg, #c8a882 0%, #8b5e3c 100%);
}

.short-thumb-bg.c2 {
    background: linear-gradient(180deg, #7ba7bc 0%, #3d6b80 100%);
}

.short-thumb-bg.c3 {
    background: linear-gradient(180deg, #a8c5a0 0%, #5a8a52 100%);
}

.short-thumb-bg.c4 {
    background: linear-gradient(180deg, #d4a5a5 0%, #a05555 100%);
}

.short-label {
    font-size: 10px;
    color: #fff;
    font-weight: 600;
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.shorts-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--primary-color);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
}

.short-title {
    font-size: 11px;
    color: var(--text-main);
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Category chips */
.cat-scroll {
    padding: 0 16px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 2px;
}

.cat-scroll::-webkit-scrollbar {
    display: none;
}

.cat-chip {
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    background: var(--bg-app);
    white-space: nowrap;
}

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

.cat-chip:hover:not(.active) {
    background: var(--bg-divider);
}

/* Channel auto cards - horizontal list */
.auto-list {
    padding: 0 16px;
    display: flex;
    overflow-x: auto;
    gap: 12px;
    scrollbar-width: none;
}
.auto-list::-webkit-scrollbar {
    display: none;
}

.auto-card {
    flex-shrink: 0;
    width: 180px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
}

.auto-card:nth-child(n+4) {
    display: none;
}

.auto-card:hover {
    background: var(--bg-card);
}

.auto-thumb {
    width: 100%;
    height: 90px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.thumb-c1 {
    background: linear-gradient(135deg, #b3cde8, #5b8fb9);
}

.thumb-c2 {
    background: linear-gradient(135deg, #f5c6c6, #d45555);
}

.thumb-c3 {
    background: linear-gradient(135deg, #c8e6c9, #558b2f);
}

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

.auto-info h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.35;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.auto-badge {
    display: inline-block;
    background: #fff3e0;
    color: #e65100;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-bottom: 3px;
}

.auto-badge.new {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Activity banner */
.activity-banner {
    margin: 16px;
    background: #fff5f5;
    border: 1px solid #ffcdd2;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.activity-text h3 {
    font-size: 13px;
    font-weight: 700;
    color: #c62828;
    margin-bottom: 2px;
}

.activity-text p {
    font-size: 11px;
    color: #e57373;
}

.activity-btn {
    background: #E53935;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 16px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Divider */
.divider {
    height: 6px;
    background: var(--bg-divider);
    margin: 8px 0;
}

/* Bottom nav */
.bottom-nav {
    background: #1e1e1e; /* Inverted for Light Theme */
    border-top: 1px solid #333;
    padding: 8px 8px 12px;
    display: flex;
    justify-content: space-around;
    width: 100%;
    position: sticky;
    bottom: 0;
    z-index: 1000;
}

body.dark-theme .bottom-nav {
    background: #ffffff; /* Inverted for Dark Theme */
    border-top: 1px solid #f0f0f0;
}

.nav-plus-btn {
    width: 44px;
    height: 44px;
    background: var(--primary-color);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -24px;
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.3);
    z-index: 1001;
    position: relative;
}

.nav-plus-btn svg {
    width: 24px !important;
    height: 24px !important;
    stroke: #fff !important;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    padding: 4px 0;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    stroke: #777; /* Neutral inactive */
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
}

body.dark-theme .nav-item svg {
    stroke: #999;
}

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

.nav-label {
    font-size: 10px;
    color: #777;
    font-weight: 500;
}

body.dark-theme .nav-label {
    color: #999;
}

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

/* --- Responsive Desktop Layout (768px+) --- */
@media (min-width: 768px) {
    body {
        padding: 0 20px; /* Removed top/bottom padding */
    }

    .phone {
        max-width: 90vw; /* Expand to 90% of screen */
        border-radius: 0; /* Remove rounding to stick to top/bottom */
        height: auto;
        min-height: 100vh;
        border-left: 1px solid var(--border-color);
        border-right: 1px solid var(--border-color);
        border-top: none;
        border-bottom: none;
    }

    .header {
        padding: 20px 32px;
    }

    .header-logo {
        font-size: 24px;
    }

    /* Reset grid for horizontal lists in desktop */
    .best-list, .auto-list {
        display: flex;
        grid-template-columns: none;
        gap: 16px;
        padding: 0 32px;
    }

    .best-card {
        width: 280px;
    }
    .best-thumb {
        height: 160px;
    }

    .auto-card {
        width: 240px;
    }
    .auto-thumb {
        height: 140px;
    }

    .best-card:nth-child(n+4), .auto-card:nth-child(n+4) {
        display: flex; /* Reveal all on desktop */
    }

    .best-card, .auto-card {
        flex-direction: column;
        align-items: stretch;
    }

    .best-thumb {
        width: 100%;
        height: 180px;
    }

    .auto-thumb {
        width: 100%;
        height: 160px;
    }

    .section-header {
        padding: 0 32px 16px;
    }

    .short-card {
        width: 180px;
    }
    .short-thumb {
        width: 180px;
        height: 290px;
    }

    .shorts-scroll, .cat-scroll {
        padding: 0 32px;
        gap: 20px;
    }

    .hero {
        padding: 105px 32px;
    }
    .hero-title {
        font-size: 42px;
    }

    .cate-item, .cate-thumb {
        width: 240px;
    }
    .cate-thumb {
        height: 140px;
    }
    .cate-title {
        font-size: 14px;
    }

    .bottom-nav {
        max-width: 500px;
        margin: 0 auto;
        border-radius: 20px 20px 0 0;
        position: sticky;
        bottom: 0;
        left: auto;
        border: 1px solid #333;
        border-bottom: none;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    }

    body.dark-theme .bottom-nav {
        border-color: #f0f0f0;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    }
}
