/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #0a0a0f;
    color: #e6e6e6;
    overflow: hidden;
}

/* ===== 布局 ===== */
.app {
    display: grid;
    grid-template-rows: 56px 1fr;
    height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: linear-gradient(180deg, #1a1a25 0%, #11111a 100%);
    border-bottom: 1px solid #2a2a35;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; font-weight: 600; }
.logo { font-size: 22px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
#search {
    width: 220px;
    padding: 7px 12px;
    background: #1f1f2a;
    border: 1px solid #2a2a35;
    color: #e6e6e6;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}
#search:focus { border-color: #4a8eff; }
.btn {
    padding: 7px 14px;
    background: #4a8eff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
}
.btn:hover { background: #3a7eef; }
.btn-icon {
    width: 32px; height: 32px;
    background: #1f1f2a;
    border: 1px solid #2a2a35;
    color: #e6e6e6;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.15s;
}
.btn-icon:hover { background: #2a2a35; }

/* ===== 主体 ===== */
.main {
    display: grid;
    grid-template-columns: 320px 1fr;
    overflow: hidden;
}

.sidebar {
    background: #0f0f17;
    border-right: 1px solid #1a1a25;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.source-status {
    padding: 10px 14px;
    font-size: 12px;
    color: #888;
    border-bottom: 1px solid #1a1a25;
    background: #11111a;
    flex-shrink: 0;
}
.source-status.loading { color: #ffa500; }
.source-status.success { color: #4caf50; }
.source-status.error { color: #f44336; }

.categories {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.empty-hint {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 13px;
}
.empty-hint p { margin: 4px 0; }
.empty-hint .muted { font-size: 12px; }

/* ===== 分类 & 频道 ===== */
.category { margin-bottom: 4px; }
.category.collapsed .channel-list { display: none; }
.category.collapsed .cat-toggle { transform: rotate(-90deg); }

.category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    font-weight: 500;
    color: #ccc;
    transition: background 0.12s;
}
.category-header:hover { background: #1a1a25; }
.cat-name { flex: 1; }
.cat-count {
    font-size: 11px;
    color: #888;
    background: #1f1f2a;
    padding: 2px 7px;
    border-radius: 10px;
}
.cat-toggle { font-size: 10px; color: #888; transition: transform 0.2s; }

.channel-list { padding: 2px 0 6px 0; }
.channel {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 24px;
    cursor: pointer;
    font-size: 13px;
    color: #aaa;
    border-left: 3px solid transparent;
    transition: background 0.12s, color 0.12s;
}
.channel:hover { background: #1a1a25; color: #e6e6e6; }
.channel.playing {
    background: #1a2440;
    color: #4a8eff;
    border-left-color: #4a8eff;
    font-weight: 500;
}
.ch-logo {
    width: 22px; height: 22px;
    object-fit: contain;
    border-radius: 3px;
    background: #1f1f2a;
    flex-shrink: 0;
}
.ch-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== 播放器 ===== */
.player-wrap {
    display: grid;
    grid-template-rows: 1fr auto;
    background: #000;
    overflow: hidden;
}
.player-container {
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a25 100%);
    pointer-events: none;
}
.overlay-content { text-align: center; color: #555; }
.big-icon { font-size: 80px; margin-bottom: 16px; }
.overlay-content h2 {
    font-size: 20px;
    font-weight: 500;
    color: #888;
    margin-bottom: 6px;
}

.now-playing {
    padding: 12px 18px;
    background: #11111a;
    border-top: 1px solid #1a1a25;
    flex-shrink: 0;
}
.np-title {
    font-size: 15px;
    font-weight: 500;
    color: #e6e6e6;
    margin-bottom: 3px;
}
.np-meta {
    font-size: 12px;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.np-meta.error { color: #f44336; }

.muted { color: #888; }
.small { font-size: 11px; }

/* ===== 弹窗 ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-content {
    background: #15151f;
    border: 1px solid #2a2a35;
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-content h2 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #e6e6e6;
}
.modal-content h3 {
    font-size: 13px;
    font-weight: 500;
    color: #888;
    margin: 16px 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.modal-close {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}
.modal-close:hover { background: #1f1f2a; color: #fff; }

.source-list { display: grid; gap: 8px; }
.source-item {
    padding: 12px 14px;
    background: #1f1f2a;
    border: 1px solid #2a2a35;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.source-item:hover {
    background: #2a2a35;
    border-color: #4a8eff;
}
.si-name { font-size: 14px; font-weight: 500; margin-bottom: 3px; }
.si-desc { font-size: 12px; color: #888; }

.custom-input {
    display: flex;
    gap: 8px;
}
.custom-input input {
    flex: 1;
    padding: 8px 12px;
    background: #1f1f2a;
    border: 1px solid #2a2a35;
    color: #e6e6e6;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.custom-input input:focus { border-color: #4a8eff; }
.btn-primary {
    padding: 8px 18px;
    background: #4a8eff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.btn-primary:hover { background: #3a7eef; }

.chip {
    padding: 4px 10px;
    background: #1f1f2a;
    border: 1px solid #2a2a35;
    color: #aaa;
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.chip:hover {
    background: #2a3a5a;
    border-color: #4a8eff;
    color: #e6e6e6;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #0a0a0f; }
::-webkit-scrollbar-thumb { background: #2a2a35; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a45; }

/* ===== 响应式 ===== */
@media (max-width: 720px) {
    .main { grid-template-columns: 1fr; grid-template-rows: 220px 1fr; }
    .sidebar { border-right: none; border-bottom: 1px solid #1a1a25; }
    #search { width: 130px; }
    .brand h1 { font-size: 15px; }
}
