*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Light Theme (Default) ── */
:root {
    --bg: #f3f1ed;
    --bg-alt: #eae7e2;
    --card: #ffffff;
    --card-hover: #faf9f6;
    --card-alt: #f9f8f5;
    --text: #1e1d1c;
    --text-secondary: #6b6a66;
    --text-tertiary: #9c9a94;
    --text-muted: #bfbdb6;
    --border: #e4e1da;
    --border-light: #ece9e3;
    --accent: #7d9b76;
    --accent-soft: #eaf1e7;
    --accent-deep: #5d7a57;
    --accent-glow: rgba(125, 155, 118, 0.18);
    --online: #5c8a6e;
    --online-soft: #e6f0e9;
    --online-tag-bg: #dce8df;
    --local: #c48b5c;
    --local-soft: #f4ebe2;
    --local-tag-bg: #efe3d5;
    --selected-bg: #f0f5ee;
    --selected-border: #7d9b76;
    --unselected-bg: #fbfaf8;
    --danger: #c47b5c;
    --danger-soft: #f5e8e1;
    --danger-hover: #b06848;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.025);
    --shadow-sm: 0 1px 5px rgba(0, 0, 0, 0.05);
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 36px rgba(0, 0, 0, 0.08);
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Menlo', 'Consolas', monospace;
    --toast-bg: rgba(255, 255, 255, 0.94);
}

/* ── Dark Theme ── */
[data-theme="dark"] {
    --bg: #1a1b1d;
    --bg-alt: #212225;
    --card: #252628;
    --card-hover: #2a2b2e;
    --card-alt: #28292c;
    --text: #e2e1de;
    --text-secondary: #a09e98;
    --text-tertiary: #72716c;
    --text-muted: #545350;
    --border: #343536;
    --border-light: #2e2f31;
    --accent: #8aaa86;
    --accent-soft: #1e2920;
    --accent-deep: #6e8e6a;
    --accent-glow: rgba(138, 170, 134, 0.14);
    --online: #6ea07a;
    --online-soft: #1a261d;
    --online-tag-bg: #243328;
    --local: #d49a6e;
    --local-soft: #261f18;
    --local-tag-bg: #32281e;
    --selected-bg: #1e261f;
    --selected-border: #8aaa86;
    --unselected-bg: #232426;
    --danger: #d48a6e;
    --danger-soft: #261d18;
    --danger-hover: #c07858;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.12);
    --shadow-sm: 0 1px 5px rgba(0, 0, 0, 0.18);
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.24);
    --shadow-lg: 0 8px 36px rgba(0, 0, 0, 0.3);
    --toast-bg: rgba(37, 38, 40, 0.94);
}

/* ── Base ── */
html {
    font-size: 18px;
    -webkit-text-size-adjust: 100%;
}
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: 24px 20px;
    transition: background var(--transition-slow), color var(--transition-slow);
}

/* ── SVG Sprite (hidden) ── */
.svg-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ── Container ── */
.app-container {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 80px;
}

/* ── Header ── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 32px 8px 8px;
    animation: fadeUp 0.5s ease both;
    flex-wrap: wrap;
    gap: 16px;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}
.logo-icon-wrapper {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition);
}
.logo-icon-wrapper svg {
    width: 28px;
    height: 28px;
    color: var(--accent);
}
.header-text h1 {
    font-size: 26px;
    font-weight: 620;
    letter-spacing: -0.3px;
    line-height: 1.2;
}
.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.1px;
    margin-top: 2px;
}

/* ── Back Button ── */
.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 20;
    text-decoration: none;
    color: var(--text-secondary);
}
.back-button:hover {
    background: var(--card-hover);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg);
}
.back-button svg {
    width: 24px;
    height: 24px;
    color: currentColor;
}

/* ── Theme Toggle ── */
.theme-toggle-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    color: var(--text-secondary);
    position: relative;
}
.theme-toggle-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    transform: rotate(12deg);
}
.theme-toggle-btn svg {
    width: 22px;
    height: 22px;
    transition: transform var(--transition), opacity var(--transition);
    position: absolute;
}
.icon-sun { opacity: 1; transform: rotate(0deg); }
.icon-moon { opacity: 0; transform: rotate(-90deg); }
[data-theme="dark"] .icon-sun { opacity: 0; transform: rotate(90deg); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: rotate(0deg); }

/* ── Upload Zone ── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 28px 42px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--card);
    box-shadow: var(--shadow-xs);
    animation: fadeUp 0.5s ease both;
    animation-delay: 0.06s;
    outline: none;
    user-select: none;
}
.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.upload-zone.drag-over {
    border-style: solid;
    box-shadow: 0 0 0 10px var(--accent-glow);
}
.upload-graphic {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    color: var(--accent);
    transition: color var(--transition), transform var(--transition);
}
.upload-graphic svg {
    width: 60px;
    height: 60px;
}
.upload-zone:hover .upload-graphic {
    transform: translateY(-4px);
}
.upload-text {
    font-size: 17px;
    font-weight: 540;
    margin-bottom: 6px;
}
.upload-hint {
    font-size: 13px;
    color: var(--text-tertiary);
}
.upload-zone input[type="file"] { display: none; }
.upload-zone.has-file {
    border-style: solid;
    border-color: var(--accent);
    background: var(--accent-soft);
    padding: 22px 28px 20px;
}
.upload-zone.has-file .upload-graphic {
    width: 34px;
    height: 34px;
    margin-bottom: 8px;
    color: var(--accent-deep);
}
.upload-zone.has-file .upload-graphic svg {
    width: 34px;
    height: 34px;
}
.upload-zone.has-file .upload-text {
    font-size: 16px;
    color: var(--accent-deep);
}
.file-info {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
}
.re-upload-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 22px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 22px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    font-family: var(--font);
    letter-spacing: 0.1px;
}
.re-upload-btn:hover {
    background: var(--accent-deep);
    transform: scale(1.04);
    box-shadow: 0 4px 14px var(--accent-glow);
}

/* ── Stats Bar ── */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 14px 20px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 16px;
    z-index: 10;
    border: 1px solid var(--border-light);
    animation: fadeUp 0.45s ease both;
    animation-delay: 0.1s;
    min-height: 64px;
}
.stats-bar:hover { box-shadow: var(--shadow-sm); }
.stat-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 480;
    padding: 5px 12px;
    border-radius: 22px;
    background: var(--card-alt);
    min-width: 110px;
    justify-content: center;
    white-space: nowrap;
}
.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.stat-dot.online { background: var(--online); }
.stat-dot.local { background: var(--local); }
.stat-dot.selected-dot { background: var(--accent); }
.stat-value {
    font-weight: 600;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}
.divider {
    width: 1px;
    height: 24px;
    background: var(--border-light);
    flex-shrink: 0;
    border-radius: 1px;
}
.btn-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ── Buttons ── */
.btn {
    padding: 9px 18px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font);
    letter-spacing: 0.1px;
    user-select: none;
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.8;
}
.btn:hover {
    background: var(--card-hover);
    border-color: var(--text-muted);
    color: var(--text);
    transform: translateY(-1px);
    box-shadow: var(--shadow-xs);
}
.btn:active { transform: scale(0.97); transition: transform 0.08s ease; }
.btn.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}
.btn.primary:hover {
    background: var(--accent-deep);
    border-color: var(--accent-deep);
    box-shadow: 0 4px 16px var(--accent-glow);
    color: #fff;
}
.btn.outline-accent {
    border-color: var(--online);
    color: var(--online);
    background: transparent;
}
.btn.outline-accent:hover {
    background: var(--online-soft);
}
.btn.outline-warning {
    border-color: var(--local);
    color: var(--local);
    background: transparent;
}
.btn.outline-warning:hover {
    background: var(--local-soft);
}
.btn.ghost {
    background: transparent;
    border-color: transparent;
    padding: 8px 12px;
    color: var(--text-secondary);
}
.btn.ghost:hover {
    background: var(--card-alt);
    border-color: var(--border-light);
    box-shadow: none;
}
/* 反选按钮颜色跟随主题文字 */
#btnToggleAll {
    color: var(--text) !important;
    border-color: var(--border) !important;
}
#btnToggleAll:hover {
    background: var(--card-alt);
}
.btn.sm {
    padding: 7px 14px;
    font-size: 12px;
    border-radius: 6px;
}
.btn.sm svg { width: 14px; height: 14px; }

/* 切换按钮（在线 / 本地）默认样式 */
.toggle-btn {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}
.toggle-btn:hover {
    background: var(--card-hover);
    border-color: var(--text-muted);
    color: var(--text);
}

/* ── Base64 Toggle ── */
.base64-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
}
.base64-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
.toggle-text { font-weight: 500; }
.base64-info {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-left: 4px;
}

/* ── Sheet Section ── */
.sheet-section {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    border: 1px solid var(--border-light);
    animation: fadeUp 0.45s ease both;
    margin-bottom: 24px;
    transition: all var(--transition);
}
.sheet-section:last-child { margin-bottom: 0; }
.sheet-section:hover {
    box-shadow: var(--shadow);
    border-color: var(--border);
}
.sheet-header {
    padding: 18px 22px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border-light);
    background: var(--card-alt);
}
.sheet-cover-wrap {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid var(--border-light);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.sheet-cover-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.sheet-cover-wrap .placeholder-svg {
    width: 30px;
    height: 30px;
    color: var(--text-muted);
    position: absolute;
}
.sheet-info { flex: 1; min-width: 140px; }
.sheet-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.1px;
    line-height: 1.3;
}
.sheet-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    align-items: center;
}
.sheet-platform-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 520;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 1.2;
}
.online-tag { background: var(--online-tag-bg); color: var(--online); }
.local-tag { background: var(--local-tag-bg); color: var(--local); }
.sheet-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Song List ── */
.song-list {
    list-style: none;
    max-height: 480px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}
.song-list::-webkit-scrollbar { width: 5px; }
.song-list::-webkit-scrollbar-track { background: transparent; }
.song-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
.song-list::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.song-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--border-light);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 58px;
}
.song-item:last-child { border-bottom: none; }
.song-item:hover { background: var(--card-hover); }
.song-item.selected { background: var(--selected-bg); }
.song-item.unselected-highlight { background: var(--unselected-bg); }
.checkbox-wrapper {
    flex-shrink: 0;
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.checkbox-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
    margin: 0;
}
.custom-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    background: var(--card);
    pointer-events: none;
}
.custom-checkbox::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
    transition: all var(--transition);
}
.song-item.selected .custom-checkbox {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}
.song-item.selected .custom-checkbox::after {
    width: 8px;
    height: 8px;
    background: #fff;
}
.song-thumb-wrap {
    width: 40px;
    height: 40px;
    border-radius: 5px;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid var(--border-light);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.song-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.song-thumb-wrap .placeholder-svg-sm {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    position: absolute;
}
.song-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.song-title {
    font-size: 15px;
    font-weight: 510;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}
.song-artist {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.song-duration {
    font-size: 12px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}
.song-platform-mini {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 510;
    padding: 4px 9px;
    border-radius: 4px;
    letter-spacing: 0.2px;
    line-height: 1;
}
.online-mini { background: var(--online-tag-bg); color: var(--online); }
.local-mini { background: var(--local-tag-bg); color: var(--local); }

/* ── Empty State ── */
.empty-songs {
    padding: 32px 20px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.empty-songs svg {
    width: 32px;
    height: 32px;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--toast-bg);
    color: var(--text);
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 460;
    z-index: 100;
    transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.09);
    pointer-events: none;
    letter-spacing: 0.05px;
    border: 1px solid var(--border-light);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    white-space: nowrap;
    max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
[data-theme="dark"] .toast { box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3); }

/* ── Animations ── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 700px) {
    body { padding: 16px 12px; }
    .app-container { gap: 16px; }
    .app-header { padding-top: 20px; }
    .header-text h1 { font-size: 22px; }
    .logo-icon-wrapper { width: 44px; height: 44px; }
    .logo-icon-wrapper svg { width: 24px; height: 24px; }
    .upload-zone { padding: 36px 20px 32px; }
    .upload-graphic { width: 48px; height: 48px; }
    .upload-graphic svg { width: 48px; height: 48px; }
    .stats-bar { gap: 8px; padding: 12px 16px; border-radius: var(--radius-sm); }
    .stat-pill { font-size: 13px; padding: 4px 10px; min-width: 90px; }
    .stat-value { font-size: 15px; }
    .btn { padding: 7px 14px; font-size: 12px; }
    .btn.sm { padding: 6px 10px; font-size: 11px; }
    .song-list { max-height: 380px; }
    .song-item { padding: 10px 14px; gap: 10px; min-height: 52px; }
    .song-thumb-wrap { width: 36px; height: 36px; }
    .song-title { font-size: 14px; }
    .song-artist { font-size: 12px; }
    .sheet-header { padding: 14px 16px; gap: 10px; }
    .sheet-cover-wrap { width: 44px; height: 44px; }
    .sheet-title { font-size: 15px; }
    .base64-toggle { font-size: 12px; }
}
@media (max-width: 480px) {
    .stats-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .btn-row { width: 100%; justify-content: space-between; }
    .base64-toggle { margin-left: 0; width: 100%; justify-content: flex-start; }
}