/* ── Framework Default Theme ──────────────────────────── */
:root {
    --bg-deep: #09090b;
    --bg-base: #0f0f12;
    --bg-card: #18181b;
    --bg-surface: #1e1e24;
    --bg-hover: #27272a;
    --bg-input: #1a1a20;
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-soft: rgba(139,92,246,0.12);
    --green: #22c55e;
    --green-bg: rgba(34,197,94,0.08);
    --red: #ef4444;
    --red-bg: rgba(239,68,68,0.08);
    --yellow: #eab308;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body.light-mode {
    --bg-deep: #f5f5f5;
    --bg-base: #ffffff;
    --bg-card: #ffffff;
    --bg-surface: #f4f4f5;
    --bg-hover: #e4e4e7;
    --bg-input: #f4f4f5;
    --border: rgba(0,0,0,0.08);
    --border-hover: rgba(0,0,0,0.15);
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-main); background: var(--bg-deep); color: var(--text-primary); line-height: 1.5; min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Loading ──────────────────────────────────────────── */
.loading-page { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 16px; color: var(--text-muted); }
.loading-icon { animation: pulse 2s ease-in-out infinite; color: var(--accent); }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
.welcome-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; text-align: center; }
.welcome-icon { font-size: 64px; margin-bottom: 16px; }
.btn-link { display: inline-block; margin-top: 16px; color: var(--accent); font-size: 14px; }

/* ── Header ───────────────────────────────────────────── */
.header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: var(--bg-base); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; backdrop-filter: blur(12px); }
.logo { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; }
.logo-icon { width: 40px; height: 40px; background: var(--accent-soft); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── Buttons ──────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 100px; cursor: pointer; font-size: 13px; font-weight: 500; padding: 8px 16px; transition: all var(--transition); font-family: inherit; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: 4px; }
.btn-loading { opacity: 0.6; pointer-events: none; }

/* ── Container ────────────────────────────────────────── */
.container { max-width: 800px; margin: 0 auto; padding: 24px 16px; min-height: calc(100vh - 120px); }

/* ── Page Tabs (Spotify-style) ────────────────────────── */
.page-tabs { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-tabs-nav { display: flex; gap: 4px; background: var(--bg-card); padding: 4px; border-radius: 100px; }
.page-tab { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--text-muted); padding: 8px 20px; border-radius: 100px; cursor: pointer; font-size: 13px; font-weight: 500; transition: all var(--transition); font-family: inherit; }
.page-tab:hover { color: var(--text-primary); }
.page-tab.active { background: var(--accent); color: #fff; }
.page-tabs-action { display: flex; gap: 8px; }
.page-fade-out { opacity: 0; transition: opacity 0.15s; }

/* ── Toolbar ──────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.search-box { flex: 1; min-width: 200px; position: relative; }
.search-box input { width: 100%; padding: 10px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 100px; color: var(--text-primary); font-size: 14px; outline: none; transition: border-color var(--transition); font-family: inherit; }
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-muted); }
.filter-select-wrapper { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-select { padding: 8px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; outline: none; font-family: inherit; }
.view-toggle-group { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle-group .btn { border-radius: 0; border: none; }

/* ── SVG Icons ────────────────────────────────────────── */
.svg-icon { width: 20px; height: 20px; flex-shrink: 0; vertical-align: middle; }
.svg-icon-sm { width: 16px; height: 16px; }

/* ── Song Grid / Cards ────────────────────────────────── */
.song-grid { display: flex; flex-direction: column; gap: 8px; }
.song-card { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); transition: all var(--transition); }
.song-card:hover { border-color: var(--border-hover); background: var(--bg-surface); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.song-rank { min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; color: var(--text-muted); border-radius: var(--radius-sm); }
.song-rank.top { color: var(--accent); background: var(--accent-soft); }
.song-cover { width: 52px; height: 52px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; }
.song-cover-ph { width: 52px; height: 52px; border-radius: var(--radius-sm); background: var(--bg-surface); display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex-shrink: 0; }
.song-info { flex: 1; min-width: 0; }
.song-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-artist { font-size: 13px; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-message { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Vote Button ──────────────────────────────────────── */
.vote-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 14px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); flex-shrink: 0; color: var(--text-secondary); font-family: inherit; }
.vote-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.vote-btn.voted { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.vote-count { font-weight: 700; font-size: 18px; line-height: 1; }
.vote-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; gap: 3px; }
@keyframes votePop { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }
.vote-pop .vote-count { animation: votePop 0.3s ease; }

/* ── Skeleton Loading ─────────────────────────────────── */
.skeleton { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.skeleton-pulse { background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-hover) 50%, var(--bg-surface) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
.skeleton-rank { width: 32px; height: 32px; border-radius: var(--radius-sm); }
.skeleton-cover { width: 52px; height: 52px; flex-shrink: 0; }
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line { height: 14px; border-radius: 4px; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-vote { width: 50px; height: 48px; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ── Empty State ──────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }
.offline-page { text-align: center; padding: 60px 24px; }
.offline-icon { margin-bottom: 16px; }

/* ── Catalog Tile Grid ────────────────────────────────── */
.catalog-tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.catalog-tile { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: all var(--transition); cursor: default; }
.catalog-tile:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.catalog-tile-art { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--bg-surface); }
.catalog-tile-art img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.catalog-tile:hover .catalog-tile-art img { transform: scale(1.05); }
.catalog-tile-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.catalog-tile-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; }
.catalog-tile:hover .catalog-tile-overlay { opacity: 1; }
.catalog-tile-action { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; box-shadow: var(--shadow-md); }
.catalog-tile-action:hover { transform: scale(1.1); }
.catalog-tile-body { padding: 12px; }
.catalog-tile-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.catalog-tile-artist { font-size: 12px; color: var(--text-secondary); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catalog-tile-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Catalog List View ────────────────────────────────── */
.catalog-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; transition: all var(--transition); }
.catalog-row:hover { border-color: var(--border-hover); background: var(--bg-surface); }
.cr-cover { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; }
.cr-cover-ph { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--bg-surface); display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex-shrink: 0; }
.cr-info { flex: 1; min-width: 0; }
.cr-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.cr-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Playlist Browser ─────────────────────────────────── */
.playlist-browser-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.playlist-browser-head h2 { margin-top: 4px; }
.playlist-browser-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); font-weight: 600; }
.playlist-browser-head p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; max-width: 400px; }
.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.playlist-tile { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-card); border: 1px solid var(--border); cursor: pointer; transition: all var(--transition); text-align: left; width: 100%; font-family: inherit; color: inherit; }
.playlist-tile:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.playlist-tile-art { aspect-ratio: 1; overflow: hidden; background: var(--bg-surface); }
.playlist-cover-single { width: 100%; height: 100%; object-fit: cover; }
.playlist-collage { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; }
.playlist-collage-cell { width: 100%; height: 100%; object-fit: cover; }
.playlist-collage-cell.is-placeholder { display: flex; align-items: center; justify-content: center; background: var(--bg-hover); color: var(--text-muted); }
.playlist-tile-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%); }
.playlist-tile-body { position: absolute; bottom: 0; left: 0; right: 0; padding: 16px; }
.playlist-tile-title { font-weight: 700; font-size: 15px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }
.playlist-tile-desc { font-size: 12px; color: rgba(255,255,255,0.7); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist-tile-meta { font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 4px; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fadeIn 0.15s; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); animation: slideUp 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; outline: none; transition: border-color var(--transition); font-family: inherit; resize: vertical; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.form-help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Autocomplete ─────────────────────────────────────── */
.ac-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); z-index: 10; max-height: 200px; overflow-y: auto; }
.ac-item { padding: 10px 14px; cursor: pointer; font-size: 13px; transition: background 0.1s; }
.ac-item:hover { background: var(--bg-hover); }

/* ── Toast ─────────────────────────────────────────────── */
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: #fff; animation: toastIn 0.3s ease; box-shadow: var(--shadow-md); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ── Pagination ───────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 24px; padding: 12px 0; }
.pg-btn { min-width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; font-size: 13px; font-weight: 500; transition: all var(--transition); font-family: inherit; }
.pg-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.pg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pg-dots { color: var(--text-muted); padding: 0 4px; }

/* ── FAB (Mobile) ─────────────────────────────────────── */
.mobile-fab { display: none; position: fixed; bottom: 24px; right: 24px; padding: 14px 22px; background: var(--accent); color: #fff; border: none; border-radius: 100px; cursor: pointer; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 50; gap: 8px; align-items: center; transition: transform 0.2s; font-family: inherit; }
.mobile-fab:hover { transform: scale(1.05); }
.fab-label { font-size: 13px; }

/* ── Footer ───────────────────────────────────────────── */
.site-footer { text-align: center; padding: 32px 16px; border-top: 1px solid var(--border); margin-top: 40px; }
.footer-links { display: flex; justify-content: center; gap: 8px; }
.footer-links a { color: var(--text-muted); font-size: 13px; }
.footer-links a:hover { color: var(--text-primary); }
.footer-sep { color: var(--text-muted); font-size: 12px; }

/* ── Muted / Utility ──────────────────────────────────── */
.muted { color: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 640px) {
    .header { padding: 12px 16px; }
    .logo { font-size: 16px; }
    .container { padding: 16px 12px; }
    .page-tabs { flex-direction: column; align-items: stretch; }
    .page-tabs-action { justify-content: center; }
    .catalog-tile-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .playlist-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .mobile-fab { display: flex; }
    .modal { padding: 20px; margin: 12px; }
    .song-card { padding: 10px 14px; gap: 10px; }
    .song-cover { width: 44px; height: 44px; }
    .toolbar { flex-direction: column; }
    .filter-select-wrapper { width: 100%; justify-content: flex-start; }
    .catalog-toolbar-actions { width: 100%; }
}
