:root {
    --bg-main: #0d1117;
    --bg-surface: #161b22;
    --bg-surface-hover: #1f242c;
    --bg-surface-active: #232933;
    --border-color: #30363d;
    --border-subtle: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-apple: #fa2d48;
    --success: #3fb950;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* 4级标准整数统一字号阶梯 (Unified 4-Tier Typography Scale) */
    --fs-t1: 16px; /* T1 头部大标题 */
    --fs-t2: 11px; /* T2 主标题与核心文本 */
    --fs-t3: 11px; /* T3 次级信息与副标题 */
    --fs-t4: 11px; /* T4 辅助微型字与角标 */
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    font-size: var(--fs-t2);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 顶部 Header */
.app-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    height: 46px;
    gap: 8px;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-hamburger {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-right: 2px;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.btn-hamburger:hover, .btn-hamburger.active {
    background-color: var(--bg-surface-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.brand {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo-badge {
    font-size: var(--fs-t1);
    line-height: 1;
}

.brand-text h1 {
    font-size: var(--fs-t2);
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-bar-compact {
    display: flex;
    align-items: center;
    gap: 4px;
}

.search-bar-compact input {
    width: 200px;
    max-width: 40vw;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    color: var(--text-primary);
    font-size: var(--fs-t3);
    outline: none;
    transition: all 0.15s ease;
}

.search-bar-compact input:focus {
    border-color: var(--accent);
}

.btn-search-icon {
    padding: 4px 8px !important;
    font-size: var(--fs-t3) !important;
}

.btn-header-source {
    width: 26px;
    height: 26px;
    padding: 0 !important;
    font-size: var(--fs-t2) !important;
    font-weight: 600;
    color: var(--accent) !important;
    border-color: rgba(63, 185, 80, 0.4) !important;
    background: rgba(63, 185, 80, 0.08) !important;
    border-radius: 6px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.btn-header-source:hover {
    background: rgba(63, 185, 80, 0.18) !important;
    border-color: var(--accent) !important;
}

/* 状态条 (静默隐藏) */
.status-bar {
    display: none !important;
}

/* 主内容布局：左右分栏各 50% */
.main-layout {
    display: flex;
    flex-direction: row;
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 通用按钮 */
.btn {
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.15s ease;
    user-select: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: #238636;
    color: #fff;
}
.btn-primary:hover { background-color: #2ea043; }

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover { background-color: var(--bg-surface-hover); border-color: var(--accent); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text-primary); }

.btn-sm {
    padding: 3px 8px;
    font-size: 11px;
}

/* 底部播控区域：播放器栏 + 通栏进度条 + 智能双态歌词栏 */
.bottom-dock-container {
    flex-shrink: 0;
    width: 100%;
    position: relative;
    z-index: 100;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5);
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
}

.player-bar {
    padding: 4px 10px 2px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.player-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
}

.player-track-info {
    flex: 1 1 0%;
    min-width: 85px;
    max-width: 220px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.player-title {
    font-size: var(--fs-t2);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.player-artist {
    font-size: var(--fs-t3);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.player-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.player-btn:hover { background-color: var(--bg-surface-hover); }

.player-btn-main {
    background-color: var(--accent-apple) !important;
    color: #fff !important;
    border-radius: 50% !important;
    width: 28px !important;
    height: 28px !important;
}

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

.volume-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.volume-btn {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
    border-radius: 4px;
    outline: none;
    touch-action: manipulation;
}
.volume-btn:active {
    background-color: var(--bg-surface-hover);
}
.volume-icon {
    font-size: var(--fs-t2);
    user-select: none;
    -webkit-user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: color 0.15s ease, transform 0.1s ease;
    pointer-events: none;
}
.volume-btn:hover .volume-icon {
    color: var(--text-primary);
}
.volume-btn:active .volume-icon {
    transform: scale(1.15);
}
.volume-popup {
    display: none;
    position: absolute;
    bottom: 34px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.volume-popup.open {
    display: flex;
}
.volume-vertical-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    -webkit-appearance: slider-vertical;
    width: 6px;
    height: 80px;
    accent-color: var(--accent-apple);
    cursor: pointer;
}

.btn-compact-icon {
    padding: 2px 6px !important;
    font-size: 11px !important;
    background-color: var(--bg-surface-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
}

/* 全宽播放进度条 */
.player-progress-full {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 1px 2px;
}

.player-time {
    font-size: var(--fs-t4);
    color: var(--text-muted);
    font-family: var(--font-mono);
    min-width: 24px;
}

.progress-bar-bg {
    flex: 1;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--accent-apple);
    border-radius: 2px;
    transition: width 0.1s linear;
}

/* 双态歌词栏 */
.lyric-dock {
    background-color: #0b0e12;
    border-top: 1px solid var(--border-subtle);
    padding: 2px 8px;
    height: 36px;
    min-height: 36px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: hidden;
    transition: height 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    flex-shrink: 0;
}

.lyric-dock-header {
    width: 100%;
    display: none;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
    flex-shrink: 0;
}
.lyric-dock-indicator { font-size: var(--fs-t4); color: #7ee787; font-weight: 600; }
.lyric-close-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 2px 6px; }

.lyric-lines-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.lyric-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 95%;
}

.lyric-line-current {
    font-size: var(--fs-t3);
    font-weight: 600;
    color: #7ee787;
    line-height: 1.35;
}

.lyric-line-next {
    font-size: var(--fs-t4);
    color: var(--text-muted);
    margin-top: 1px;
    opacity: 0.8;
}

.lyric-dock.expanded {
    height: 160px;
    max-height: 38vh;
    background-color: #080a0d;
}
.lyric-dock.expanded .lyric-dock-header { display: flex; }
.lyric-dock.expanded .lyric-lines-wrapper { flex: 1; overflow-y: auto; justify-content: flex-start; gap: 4px; padding: 2px 0; }
.lyric-dock.expanded .lyric-line-current { font-size: var(--fs-t3); background: rgba(126, 231, 135, 0.08); padding: 2px 6px; border-radius: 4px; }

/* 底部向上拉起抽屉 (队列与音源) */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.queue-drawer, .source-drawer {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 75vh;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.2s ease;
}
.queue-drawer.open, .source-drawer.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.queue-drawer-header, .source-drawer-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-main);
}
.queue-drawer-title, .source-drawer-title { font-size: var(--fs-t2); font-weight: 600; color: #fff; }
.source-drawer-subtitle { font-size: var(--fs-t4); color: var(--text-muted); }
.queue-drawer-close, .source-drawer-close { background: transparent; border: none; color: var(--text-muted); font-size: var(--fs-t2); cursor: pointer; padding: 2px 6px; }

.queue-drawer-body, .source-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    max-height: 60vh;
}

.queue-item {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-t3);
    cursor: pointer;
}
.queue-item:hover { background: var(--bg-surface-hover); }
.queue-item.active { color: #ff7588; font-weight: 600; }

.source-card {
    padding: 6px 10px;
    background: var(--bg-main);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-t4);
}
.source-status-badge { font-size: var(--fs-t4); font-family: var(--font-mono); font-weight: 500; }
.source-status-ok { color: var(--success, #2ea043); }
.source-status-untested { color: #58a6ff; }
.source-status-failed { color: #8b949e; }

/* 模态弹窗 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.65);
    z-index: 1100;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 90%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: var(--fs-t2); font-weight: 600; }
.modal-close-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 2px 6px; }
.modal-body { padding: 10px 12px; font-size: var(--fs-t3); }

.playlist-choice-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.playlist-choice-item {
    padding: 6px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--fs-t3);
    color: var(--text-primary);
    transition: all 0.15s ease;
}
.playlist-choice-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-color);
}
.playlist-choice-item .meta-tag {
    font-size: var(--fs-t4);
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* 左侧歌单抽屉半透明遮罩 */
.left-drawer-backdrop {
    display: none;
    position: fixed;
    top: 46px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 840;
}
.left-drawer-backdrop.open {
    display: block;
}

/* 移动端专用调优 */
@media (max-width: 768px) {
    .player-right { gap: 6px; }
    .search-bar-compact input { width: 120px; font-size: 11px; }
    .btn-header-source { width: 24px; height: 24px; font-size: 12px !important; }
}

/* ========================================================
   全局轻量上下文菜单 (Context Menu)
   ======================================================== */
.context-menu-popup {
    position: fixed;
    z-index: 10000;
    background-color: #161b22;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
    padding: 4px;
    min-width: 130px;
    display: none;
    flex-direction: column;
    gap: 2px;
}

.context-menu-popup.open {
    display: flex;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-primary);
    font-size: var(--fs-t3);
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.context-menu-item:hover {
    background-color: var(--bg-surface-hover);
    color: #ffffff;
}

.context-menu-item.danger {
    color: #ff7588;
}

.context-menu-item.danger:hover {
    background-color: rgba(255, 117, 136, 0.15);
    color: #ff8598;
}

.context-menu-icon {
    font-size: var(--fs-t2);
    width: 14px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.context-menu-separator {
    height: 1px;
    background-color: var(--border-subtle);
    margin: 3px 0;
}
