@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
    --green: #006a4e;
    --green-soft: #0d7a5f;
    --green-muted: rgba(0,106,78,0.08);
    --green-glow: rgba(0,106,78,0.25);
    --red: #f42a41;
    --red-soft: rgba(244,42,65,0.1);
    --bg: #090c0b;
    --bg-elevated: #0f1312;
    --bg-card: #131917;
    --bg-card-hover: #1a2220;
    --bg-input: #111715;
    --text: #e4ede8;
    --text-secondary: #94a89e;
    --text-dim: #5e756a;
    --border: #1c2a24;
    --border-subtle: #162019;
    --radius: 10px;
    --radius-lg: 14px;
}

html { font-size: 16px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

::selection { background: var(--green); color: white; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ===== TOPBAR ===== */
.topbar {
    height: 52px;
    background: var(--bg);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 200;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.topbar-flag {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--green) 60%, var(--red));
    display: grid;
    place-items: center;
    position: relative;
}

.topbar-flag::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
}

.topbar-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.topbar-title span {
    color: var(--text-dim);
    font-weight: 400;
    font-size: 12px;
    margin-left: 6px;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-btn {
    height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.topbar-btn:hover { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.topbar-btn.on { background: var(--green); border-color: var(--green); color: white; }

.topbar-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.hamburger {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--text);
    cursor: pointer;
    border-radius: 8px;
    place-items: center;
}

.hamburger:hover { background: var(--bg-card); }
.hamburger svg { width: 20px; height: 20px; }

/* ===== LAYOUT ===== */
.shell {
    display: flex;
    height: calc(100vh - 52px);
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 320px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-search {
    padding: 10px 12px;
}

.search-wrap {
    position: relative;
}

.search-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--text-dim);
    pointer-events: none;
}

.search-wrap input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 32px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.search-wrap input:focus { border-color: var(--green-soft); }
.search-wrap input::placeholder { color: var(--text-dim); }

.sidebar-tags {
    padding: 6px 12px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag {
    height: 26px;
    padding: 0 9px;
    border-radius: 6px;
    border: none;
    background: var(--bg-card);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 3px;
}

.tag:hover { color: var(--text-secondary); background: var(--bg-card-hover); }
.tag.on { background: var(--green); color: #fff; }
.tag .n { opacity: 0.6; font-size: 10px; font-family: 'JetBrains Mono', monospace; }

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 6px;
}

.ch-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
    border: 1px solid transparent;
}

.ch-item:hover { background: var(--bg-card-hover); }
.ch-item.picked { background: var(--green-muted); border-color: rgba(0,106,78,0.18); }

.ch-item-thumb {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--bg-card);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ch-item-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }

.ch-item-thumb .ic {
    color: var(--green);
    width: 18px;
    height: 18px;
    display: none;
}

.ch-item-body { flex: 1; min-width: 0; }

.ch-item-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.ch-item-sub {
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.dot-live {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--red);
    animation: blink 2.5s ease-in-out infinite;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.ch-item-fav {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.ch-item-fav:hover { color: var(--red); background: var(--red-soft); }
.ch-item-fav.liked { color: var(--red); }
.ch-item-fav svg { width: 14px; height: 14px; }

.sidebar-foot {
    padding: 8px 12px;
    border-top: 1px solid var(--border-subtle);
    font-size: 10px;
    color: var(--text-dim);
    text-align: center;
    letter-spacing: 0.2px;
}

.empty-msg {
    text-align: center;
    padding: 28px 16px;
}

.empty-msg svg { width: 32px; height: 32px; color: var(--text-dim); margin-bottom: 8px; }
.empty-msg p { font-size: 12px; color: var(--text-dim); }
.empty-msg small { font-size: 11px; color: var(--text-dim); opacity: 0.7; }

/* ===== STAGE (main) ===== */
.stage {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.stage-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== PLAYER ===== */
.player {
    position: relative;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 16/9;
    max-height: 65vh;
    box-shadow: 0 2px 40px rgba(0,0,0,0.5);
}

.player video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.player-ov {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-ov.clickable { cursor: pointer; }

.p-load {
    text-align: center;
}

.p-spinner {
    width: 40px;
    height: 40px;
    border: 2.5px solid rgba(255,255,255,0.08);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 14px;
}

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

.p-load p { color: rgba(255,255,255,0.85); font-size: 13px; font-weight: 500; }
.p-load small { color: rgba(255,255,255,0.35); font-size: 11px; display: block; margin-top: 4px; }

.p-err { text-align: center; padding: 20px; }

.p-err-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--red-soft);
    display: grid;
    place-items: center;
    margin: 0 auto 10px;
}

.p-err-icon svg { width: 22px; height: 22px; color: var(--red); }
.p-err p { color: rgba(255,255,255,0.85); font-size: 13px; font-weight: 500; }
.p-err small { color: rgba(255,255,255,0.4); font-size: 11px; display: block; margin: 4px 0 14px; }

.p-err-btn {
    height: 32px;
    padding: 0 16px;
    border-radius: 7px;
    border: none;
    background: var(--green);
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.p-err-btn:hover { background: var(--green-soft); }

.p-play-big {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(0,106,78,0.85);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    box-shadow: 0 0 30px rgba(0,106,78,0.3);
}

.p-play-big:hover { background: var(--green); transform: scale(1.06); }
.p-play-big svg { width: 26px; height: 26px; fill: #fff; margin-left: 3px; }

.player-bar-top {
    position: absolute;
    top: 0; left: 0; right: 0;
    padding: 10px 14px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent);
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}

.player:hover .player-bar-top,
.player:hover .player-bar-bot { opacity: 1; }

.player-bar-top .np {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
}

.mutetag {
    font-size: 9px;
    font-weight: 600;
    background: rgba(255,193,7,0.12);
    color: #ffc107;
    padding: 2px 5px;
    border-radius: 3px;
}

.player-bar-bot {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 10px 14px;
    background: linear-gradient(to top, rgba(0,0,0,0.65), transparent);
    opacity: 0;
    transition: opacity 0.25s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.p-ctrl {
    width: 34px;
    height: 34px;
    border: none;
    background: none;
    color: #fff;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
}

.p-ctrl:hover { background: rgba(255,255,255,0.12); }
.p-ctrl svg { width: 18px; height: 18px; }
.p-ctrl.muted svg { color: #ffc107; }

.ctrl-row { display: flex; align-items: center; gap: 2px; }

/* ===== INFO SECTION ===== */
.ch-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-top: 18px;
}

.ch-head-logo {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: var(--bg-card);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-subtle);
}

.ch-head-logo img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }

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

.ch-head-info h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.25;
}

.ch-head-info .badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.bdg {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 5px;
    font-family: 'JetBrains Mono', monospace;
}

.bdg-live { background: var(--green-muted); color: var(--green-soft); }
.bdg-grp { background: var(--bg-card); color: var(--text-dim); }
.bdg-res { background: var(--bg-card); color: var(--text-dim); }

.ch-head-fav {
    flex-shrink: 0;
    margin-top: 4px;
}

.hr { border: none; border-top: 1px solid var(--border-subtle); margin: 18px 0; }

.sec-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sec-title svg { width: 14px; height: 14px; color: var(--green-soft); }

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
}

.rel-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.12s;
    border: 1px solid transparent;
}

.rel-card:hover { border-color: var(--border); background: var(--bg-card-hover); }

.rel-card-thumb {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--bg);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rel-card-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }

.rel-card-name { font-size: 12px; font-weight: 500; line-height: 1.2; }
.rel-card-sub { font-size: 10px; color: var(--text-dim); }

.pill-row { display: flex; flex-wrap: wrap; gap: 5px; }

.pill {
    height: 28px;
    padding: 0 12px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s;
}

.pill:hover { border-color: var(--green-soft); color: var(--green-soft); background: var(--green-muted); }

/* ===== WELCOME ===== */
.welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 52px);
    padding: 24px;
}

.welcome-box {
    max-width: 400px;
    text-align: center;
}

.welcome-flag {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--green) 55%, var(--red));
    display: grid;
    place-items: center;
    margin: 0 auto 20px;
    box-shadow: 0 4px 32px var(--green-glow);
    position: relative;
}

.welcome-flag::after {
    content: '';
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--red);
}

.welcome-box h2 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.welcome-box .tagline {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 22px;
}

.welcome-stats {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.w-stat {
    font-size: 11px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 6px;
}

.w-stat.g { background: var(--green-muted); color: var(--green-soft); }
.w-stat.b { background: rgba(59,130,246,0.08); color: #60a5fa; }
.w-stat.o { background: rgba(251,146,60,0.08); color: #fb923c; }

.welcome-cta {
    height: 40px;
    padding: 0 24px;
    border-radius: 9px;
    border: none;
    background: var(--green);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
}

.welcome-cta:hover { background: var(--green-soft); }
.welcome-cta svg { width: 16px; height: 16px; }

.welcome-note {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 14px;
    line-height: 1.6;
}

/* ===== CREATOR SECTION ===== */
.creator-section {
    margin-top: 28px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.creator-inner {
    display: flex;
    align-items: center;
    gap: 16px;
}

.creator-photo {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--border);
}

.creator-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.creator-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--green-soft);
    margin-bottom: 3px;
}

.creator-name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    margin-bottom: 4px;
}

.creator-bio {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.55;
    margin-bottom: 8px;
}

.creator-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.creator-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.12s;
}

.creator-link:hover { border-color: var(--green-soft); color: var(--green-soft); }
.creator-link svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ===== CAST MODAL ===== */
.cast-modal-bg {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.cast-modal-bg.show { display: flex; }

.cast-modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 380px;
    width: 90%;
    text-align: center;
}

.cast-modal h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}

.cast-modal .cast-sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 18px;
    line-height: 1.5;
}

.cast-qr-wrap {
    background: #fff;
    border-radius: 10px;
    padding: 12px;
    display: inline-block;
    margin-bottom: 14px;
}

.cast-qr-wrap canvas {
    display: block;
}

.cast-url {
    font-size: 11px;
    color: var(--text-dim);
    word-break: break-all;
    margin-bottom: 14px;
    font-family: 'JetBrains Mono', monospace;
}

.cast-close {
    height: 34px;
    padding: 0 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.cast-close:hover { background: var(--bg-card); color: var(--text); }

.cast-methods {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cast-method-btn {
    height: 38px;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s;
    width: 100%;
}

.cast-method-btn:hover { border-color: var(--green-soft); color: var(--green-soft); background: var(--green-muted); }
.cast-method-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ===== FOOTER ===== */
.site-footer {
    margin-top: 28px;
    padding: 14px 0 18px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 10px;
    color: var(--text-dim);
}

.site-footer a {
    color: var(--green-soft);
    text-decoration: none;
}

.site-footer a:hover { text-decoration: underline; }

/* ===== MOBILE OVERLAY ===== */
.sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 90;
}

.sb-overlay.show { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .hamburger { display: grid; }

    .sidebar {
        position: fixed;
        top: 52px;
        left: 0;
        bottom: 0;
        z-index: 100;
        width: 300px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open { transform: translateX(0); }

    .topbar-btn .btn-label { display: none; }
    .topbar-btn { padding: 0 8px; }
}

@media (max-width: 600px) {
    .stage-inner { padding: 14px; }

    .ch-head {
        flex-wrap: wrap;
    }

    .ch-head-info h2 { font-size: 17px; }

    .related-grid {
        grid-template-columns: 1fr 1fr;
    }

    .creator-inner {
        flex-direction: column;
        text-align: center;
    }

    .creator-links { justify-content: center; }

    .welcome-box h2 { font-size: 22px; }

    .player {
        border-radius: 10px;
    }

    .site-footer {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 380px) {
    .related-grid { grid-template-columns: 1fr; }
    .sidebar { width: 280px; }
}

/* Fullscreen */
.player:fullscreen,
.player:-webkit-full-screen {
    border-radius: 0;
    max-height: none;
}