* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #1a1a2e; color: #e0e0e0; }
#app { display: flex; flex-direction: column; height: 100%; max-height: 100vh; max-width: 800px; margin: 0 auto; }

/* ── 顶部栏 ── */
#topbar { display: flex; align-items: center; padding: 8px 12px; background: #16213e; gap: 10px; flex-shrink: 0; }
#topbar h1 { flex: 1; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar button { background: none; border: none; color: #e0e0e0; font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
#topbar button:active { background: rgba(255,255,255,0.1); }

/* ── 搜索栏 ── */
#search-bar { display: flex; align-items: center; padding: 6px 12px; background: #16213e; border-top: 1px solid #0f3460; gap: 8px; flex-shrink: 0; }
#search-bar.hidden { display: none; }
#search-input { flex: 1; padding: 8px 12px; border: 1px solid #0f3460; border-radius: 6px; background: #1a1a2e; color: #e0e0e0; font-size: 14px; outline: none; }
#search-input:focus { border-color: #e94560; }
#search-count { font-size: 12px; color: #888; white-space: nowrap; }

/* ── 视频区域 ── */
#video-container { position: relative; background: #000; flex-shrink: 0; width: 100%; aspect-ratio: 16/9; max-height: 45vh; }
#video { width: 100%; height: 100%; display: none; }
#video.show { display: block; }
#video-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #555; }
#video-placeholder.hidden { display: none; }
#placeholder-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
#placeholder-text { font-size: 14px; opacity: 0.6; }

/* ── 当前播放信息 ── */
#now-playing { padding: 8px 12px; background: #16213e; border-top: 1px solid #0f3460; flex-shrink: 0; }
#np-name { font-size: 14px; font-weight: 600; color: #e94560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#np-url { font-size: 11px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* ── 播放列表 ── */
#playlist-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#playlist-header { display: flex; align-items: center; padding: 8px 12px; background: #16213e; font-size: 13px; font-weight: 600; gap: 6px; flex-shrink: 0; }
#playlist-count { color: #888; font-weight: 400; }
.btn-sm { padding: 4px 10px; border: 1px solid #0f3460; border-radius: 4px; background: #1a1a2e; color: #e0e0e0; font-size: 12px; cursor: pointer; }
.btn-sm:active { background: #0f3460; }
.btn-danger { border-color: #e94560; color: #e94560; }
.btn-danger:active { background: #e94560; color: #fff; }
#playlist { flex: 1; overflow-y: auto; list-style: none; }
#playlist-empty { padding: 24px; text-align: center; color: #555; font-size: 13px; }
#playlist-empty.hidden { display: none; }
.playlist-item { display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid #0f3460; cursor: pointer; gap: 8px; font-size: 13px; transition: background 0.15s; }
.playlist-item:active { background: #0f3460; }
.playlist-item.active { background: #0f3460; border-left: 3px solid #e94560; }
.playlist-item.hidden-by-search { display: none; }
.item-index { color: #888; font-size: 11px; min-width: 24px; text-align: right; }
.item-info { flex: 1; min-width: 0; }
.item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #e0e0e0; }
.item-url { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; color: #666; margin-top: 2px; }
.item-type { font-size: 10px; color: #e94560; background: rgba(233,69,96,0.15); padding: 1px 6px; border-radius: 3px; white-space: nowrap; }

/* ── 侧边菜单 ── */
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; }
#overlay.hidden { display: none; }
#sidebar { position: fixed; top: 0; left: 0; width: 260px; height: 100%; background: #16213e; z-index: 200; overflow-y: auto; transition: transform 0.25s; }
#sidebar.hidden { transform: translateX(-100%); }
#sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #0f3460; font-size: 16px; font-weight: 600; }
#sidebar-header button { background: none; border: none; color: #e0e0e0; font-size: 18px; cursor: pointer; padding: 4px 8px; }
.menu-item { padding: 14px 16px; cursor: pointer; font-size: 14px; border-bottom: 1px solid rgba(15,52,96,0.5); }
.menu-item:active { background: #0f3460; }
.menu-divider { height: 1px; background: #0f3460; padding: 0; margin: 8px 0; cursor: default; }

/* ── 弹窗 ── */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; }
#modal.hidden { display: none; }
#modal-content { background: #1a1a2e; border-radius: 12px; width: 100%; max-width: 500px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
#modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #0f3460; }
#modal-title { font-size: 15px; font-weight: 600; }
#modal-close { background: none; border: none; color: #e0e0e0; font-size: 18px; cursor: pointer; padding: 4px 8px; }
#modal-body { flex: 1; overflow-y: auto; padding: 12px 16px; font-size: 13px; }
.modal-list-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #0f3460; gap: 8px; }
.modal-list-item .info { flex: 1; min-width: 0; }
.modal-list-item .name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-list-item .meta { font-size: 11px; color: #888; margin-top: 2px; }
.modal-list-item button { padding: 4px 10px; border: 1px solid #0f3460; border-radius: 4px; background: none; color: #e0e0e0; font-size: 11px; cursor: pointer; }
.modal-list-item button:active { background: #0f3460; }
.modal-empty { text-align: center; color: #555; padding: 30px 0; }

/* ── Toast ── */
#toast { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); background: #e94560; color: #fff; padding: 10px 24px; border-radius: 20px; font-size: 13px; z-index: 400; white-space: nowrap; transition: opacity 0.3s; }
#toast.hidden { opacity: 0; pointer-events: none; }

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 2px; }

/* ── 响应式 ── */
@media (min-width: 600px) {
    #topbar h1 { font-size: 18px; }
    #video-container { max-height: 50vh; }
    .playlist-item { padding: 10px 14px; }
}
