/* ═══════════════════════════════════════════════════════════
   style.css — mixra.io design system
   ═══════════════════════════════════════════════════════════ */

/* ── Reset & tokens ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green: #1db954;
    --green-dim: #158a3e;
    --bg: #0d0d0d;
    --surface: #161616;
    --surface2: #1e1e1e;
    --border: #2a2a2a;
    --text: #f0f0f0;
    --muted: #888;
    --sidebar-w: 220px;
    --drawer-w: 520px;
}

/* ── Base ────────────────────────────────────────────────── */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

body.auth {
    align-items: center;
    justify-content: center;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.25rem;
    position: fixed;
    top: 0; left: 0; bottom: 0;
}

.sidebar-logo { font-size: 1.6rem; font-weight: 800; color: var(--green); letter-spacing: -0.5px; margin-bottom: 2.5rem; }
.nav-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.5rem; }

.nav a {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.55rem 0.75rem; border-radius: 6px;
    color: var(--muted); text-decoration: none; font-size: 0.9rem;
    margin-bottom: 0.15rem; transition: background 0.15s, color 0.15s;
}
.nav a.active, .nav a:hover { background: var(--surface2); color: var(--text); }
.nav a.active { color: var(--green); }

.sidebar-support {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.55rem 0.75rem; border-radius: 6px;
    color: var(--muted); text-decoration: none; font-size: 0.9rem;
    margin-top: auto; margin-bottom: 0.75rem;
    transition: background 0.15s, color 0.15s;
}
.sidebar-support:hover { background: var(--surface2); color: var(--text); }

.sidebar-footer { padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--muted); }
.sidebar-footer strong { display: block; color: var(--text); margin-bottom: 0.2rem; font-size: 0.875rem; }
.sidebar-plan-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.sidebar-plan { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.sidebar-plan--premium { color: var(--green); }
.sidebar-upgrade-link { font-size: 0.72rem; font-weight: 700; color: var(--green); text-decoration: none; letter-spacing: 0.02em; white-space: nowrap; }
.sidebar-upgrade-link:hover { text-decoration: underline; }
.nav-upgrade { color: var(--green) !important; }
.nav-upgrade:hover, .nav-upgrade.active { background: rgba(29,185,84,0.1) !important; color: var(--green) !important; }

.btn-logout {
    background: none; border: 1px solid var(--border); border-radius: 6px;
    color: var(--muted); font-size: 0.8rem; padding: 0.4rem 0.75rem;
    cursor: pointer; width: 100%; margin-top: 0.5rem;
    transition: border-color 0.15s, color 0.15s;
}
.btn-logout:hover { border-color: #f08080; color: #f08080; }

/* ── Main content area ───────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; padding: 2rem 2.5rem; transition: margin-right 0.3s; }
.main.drawer-open { margin-right: var(--drawer-w); }

/* ── Free-tier upgrade banner ────────────────────────────── */
.free-banner {
    position: fixed;
    top: 0; left: var(--sidebar-w); right: 0;
    z-index: 90;
    background: #1a2e1a;
    border-bottom: 1px solid #2a5a2a;
    color: var(--text);
    font-size: 0.82rem;
    padding: 0.55rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.free-banner span { flex: 1; }
.free-banner strong { color: var(--green); }
.free-banner-link {
    background: var(--green);
    color: #000;
    font-weight: 700;
    font-size: 0.78rem;
    padding: 0.25rem 0.75rem;
    border-radius: 5px;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.free-banner-link:hover { background: #1ed760; }
.free-banner-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
    flex-shrink: 0;
}
.free-banner-close:hover { color: var(--text); }

body.has-free-banner .main { padding-top: calc(2rem + 2.1rem); }

@media (max-width: 767px) {
    .free-banner { left: 0; top: 48px; }
    body.has-free-banner .main { padding-top: calc(1.25rem + 2.1rem + 48px); }
}

/* ── Page header ─────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; }
.page-header span { font-size: 0.875rem; color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1rem; border-radius: 6px; font-size: 0.85rem; font-weight: 600; cursor: pointer; border: none; transition: background 0.15s; }
.btn-primary { background: var(--green); color: #000; }
.btn-primary:hover { background: #1ed760; }
.btn-ghost { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.7rem; font-weight: 600; }
.badge-public  { background: #1a3a1a; color: #6fcf97; }
.badge-private { background: #2a2a1a; color: #f2c94c; }
.badge-collab  { background: #1a2a3a; color: #56ccf2; }
.badge-active  { background: #0f2a1a; color: var(--green); }
.badge-paused  { background: #2a2a1a; color: #f2c94c; }
.badge-daily   { background: #1a2a3a; color: #56ccf2; }
.badge-weekly  { background: #22183a; color: #bb6bd9; }
.badge-manual  { background: var(--surface2); color: var(--muted); }

/* ── Auth pages (login / register) ──────────────────────── */
body.auth .card {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 480px;
}
body.auth h1 { font-size: 2rem; font-weight: 700; color: #1db954; margin-bottom: 0.25rem; letter-spacing: -0.5px; }
body.auth .subtitle { font-size: 0.875rem; color: #888; margin-bottom: 2rem; }
body.auth .alert { background: #3a1a1a; border: 1px solid #6b2c2c; color: #f08080; border-radius: 6px; padding: 0.75rem 1rem; font-size: 0.875rem; margin-bottom: 1.25rem; display: none; }
body.auth .alert-success { background: #1a3a1a; border-color: #2c6b2c; color: #80f080; }
body.auth label { display: block; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #aaa; margin-bottom: 0.4rem; }
body.auth input { width: 100%; padding: 0.65rem 0.85rem; background: #111; border: 1px solid #333; border-radius: 6px; color: #f0f0f0; font-size: 0.95rem; margin-bottom: 1.1rem; transition: border-color 0.15s; }
body.auth input:focus { outline: none; border-color: #1db954; }
body.auth button { width: 100%; padding: 0.75rem; background: #1db954; color: #000; font-weight: 700; font-size: 0.95rem; border: none; border-radius: 6px; cursor: pointer; transition: background 0.15s; }
body.auth button:hover { background: #1ed760; }
body.auth button:disabled { opacity: 0.6; cursor: not-allowed; }
body.auth .register-link,
body.auth .login-link { text-align: center; margin-top: 1.25rem; font-size: 0.875rem; color: #888; }
body.auth .register-link a,
body.auth .login-link a { color: #1db954; text-decoration: none; }
.login-spotify-warning {
    display: flex; align-items: center; gap: 0.5rem;
    background: #2a1f0a; border: 1px solid #6b4c10;
    border-radius: 6px; padding: 0.65rem 0.9rem;
    font-size: 0.82rem; color: #c9a84c;
    margin-top: 1.25rem; line-height: 1.4;
}
.login-spotify-warning svg { flex-shrink: 0; }
.login-spotify-warning strong { color: #e0c070; }
body.auth .register-link a:hover,
body.auth .login-link a:hover { text-decoration: underline; }

/* ── Rules page: plan limit banner ──────────────────────── */
.rule-limit-banner {
    display: none;
    align-items: flex-start;
    gap: 0.65rem;
    background: #1e1a10;
    border: 1px solid #5a4010;
    border-radius: 8px;
    padding: 0.85rem 1.1rem;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: #c9a84c;
}
.rule-limit-banner svg { flex-shrink: 0; margin-top: 1px; }
.rule-limit-banner span { line-height: 1.5; }
.rule-limit-link { color: var(--green); font-weight: 600; text-decoration: none; }
.rule-limit-link:hover { text-decoration: underline; }

/* ── Dashboard: Spotify connection ───────────────────────── */
.spotify-banner {
    display: none; align-items: center; justify-content: space-between; gap: 1rem;
    background: #0f2a1a; border: 1px solid #1a5c32;
    border-radius: 10px; padding: 1rem 1.5rem; margin-bottom: 1.5rem;
}
.spotify-banner-text strong { display: block; color: var(--text); margin-bottom: 0.2rem; font-size: 0.95rem; }
.spotify-banner-text span { font-size: 0.8rem; color: var(--muted); }

.btn-connect {
    display: flex; align-items: center; gap: 0.5rem;
    background: var(--green); color: #000; font-weight: 700; font-size: 0.85rem;
    padding: 0.55rem 1.1rem; border-radius: 99px; text-decoration: none;
    white-space: nowrap; transition: background 0.15s; flex-shrink: 0;
}
.btn-connect:hover { background: #1ed760; }
.btn-connect-large { justify-content: center; width: 100%; font-size: 1rem; padding: 0.75rem 1.5rem; margin-top: 1.5rem; }

.spotify-connected-pill {
    display: none; align-items: center; gap: 0.4rem;
    font-size: 0.75rem; color: var(--green);
    background: #0f2a1a; border: 1px solid #1a5c32;
    border-radius: 99px; padding: 0.25rem 0.75rem;
}
.spotify-connected-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* ── Dashboard: Stats ────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem 1.5rem; }
.stat-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 0.5rem; }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; margin-bottom: 0.25rem; }
.stat-value.green { color: var(--green); }
.stat-sub { font-size: 0.78rem; color: var(--muted); }
.stat-sub .up { color: #6fcf97; }
.stat-sub .down { color: #f08080; }

/* ── Dashboard: Charts ───────────────────────────────────── */
.charts-row { display: grid; gap: 1rem; margin-bottom: 1rem; }
.charts-row.two-one { grid-template-columns: 2fr 1fr; }
.charts-row.one-one { grid-template-columns: 1fr 1fr; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.5rem; min-width: 0; overflow: hidden; }
.chart-title { font-size: 0.875rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--text); }
.chart-title span { font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-left: 0.5rem; }
.chart-wrap { position: relative; }

/* ── Dashboard: Playlist table ───────────────────────────── */
.playlist-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.playlist-table th { text-align: left; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 0 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
.playlist-table td { padding: 0.75rem 0.5rem; border-bottom: 1px solid var(--border); color: var(--text); }
.playlist-table tr:last-child td { border-bottom: none; }
.playlist-table td.muted { color: var(--muted); }
.progress-bar-wrap { background: var(--border); border-radius: 99px; height: 4px; width: 80px; }
.progress-bar { height: 4px; border-radius: 99px; background: var(--green); }

/* ── Playlists: Toolbar ──────────────────────────────────── */
.toolbar { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.25rem; }
.search-wrap { position: relative; flex: 1; max-width: 360px; }
.search-wrap svg { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
input[type="search"] { width: 100%; padding: 0.55rem 0.85rem 0.55rem 2.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 0.875rem; }
input[type="search"]:focus { outline: none; border-color: var(--green); }
.filter-btns { display: flex; gap: 0.4rem; }
.filter-btn { padding: 0.45rem 0.85rem; border-radius: 6px; font-size: 0.8rem; font-weight: 600; border: 1px solid var(--border); cursor: pointer; background: var(--surface); color: var(--muted); transition: background 0.12s, color 0.12s, border-color 0.12s; }
.filter-btn.active { background: var(--green); color: #000; border-color: var(--green); }
.filter-btn:not(.active):hover { color: var(--text); border-color: #444; }

/* ── Playlists: Grid ─────────────────────────────────────── */
.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.playlist-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.playlist-card:hover { background: var(--surface2); border-color: #3a3a3a; }
.playlist-card.selected { border-color: var(--green); background: rgba(29,185,84,0.06); }
.playlist-card.selected:hover { background: rgba(29,185,84,0.1); }
.card-checkbox { position: absolute; top: 0.55rem; right: 0.55rem; width: 15px; height: 15px; accent-color: var(--green); cursor: pointer; z-index: 1; opacity: 0; transition: opacity 0.15s; }
.playlist-card:hover .card-checkbox,
.playlist-card.selected .card-checkbox { opacity: 1; }

/* ── Playlists: View toggle ──────────────────────────────── */
.view-toggle { display: flex; gap: 0.25rem; margin-left: auto; }
.view-btn { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; transition: all 0.12s; }
.view-btn.active { background: var(--surface2); color: var(--text); border-color: #444; }
.view-btn:not(.active):hover { color: var(--text); }

/* ── Playlists: List view ────────────────────────────────── */
.playlist-list { display: flex; flex-direction: column; gap: 0.35rem; }
.playlist-row { display: flex; align-items: center; gap: 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.55rem 0.85rem; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.playlist-row:hover { background: var(--surface2); border-color: #3a3a3a; }
.playlist-row.selected { border-color: var(--green); background: rgba(29,185,84,0.06); }
.playlist-row.selected:hover { background: rgba(29,185,84,0.1); }
.row-checkbox { width: 15px; height: 15px; accent-color: var(--green); cursor: pointer; flex-shrink: 0; }
.row-art { width: 42px; height: 42px; border-radius: 4px; object-fit: cover; flex-shrink: 0; background: var(--surface2); display: block; }
.row-art-placeholder { width: 42px; height: 42px; border-radius: 4px; background: var(--surface2); display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; }
.row-name { flex: 1; font-size: 0.875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.row-meta { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }

/* ── Playlists: Create Rule banner ───────────────────────── */
.create-rule-banner { position: fixed; bottom: 2rem; right: 2rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--surface2); border: 1px solid #3a3a3a; border-radius: 12px; padding: 0.75rem 1rem 0.75rem 1.25rem; box-shadow: 0 8px 32px rgba(0,0,0,0.5); z-index: 50; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.create-rule-banner.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.banner-left { display: flex; flex-direction: column; gap: 0.2rem; }
.banner-actions { display: flex; align-items: center; gap: 0.75rem; white-space: nowrap; }
.banner-count { font-size: 0.875rem; color: var(--muted); }
.banner-limit-msg { font-size: 0.78rem; color: #f08080; }
.banner-clear { font-size: 0.8rem; color: var(--muted); background: none; border: none; cursor: pointer; padding: 0; text-decoration: underline; line-height: 1; }
.banner-clear:hover { color: var(--text); }
.source-limit-warning { margin: 0.4rem 0 0; font-size: 0.78rem; color: #f08080; }
.playlist-art { width: 100%; aspect-ratio: 1; border-radius: 6px; object-fit: cover; background: var(--surface2); display: block; margin-bottom: 0.85rem; }
.playlist-art-placeholder { width: 100%; aspect-ratio: 1; border-radius: 6px; background: var(--surface2); display: flex; align-items: center; justify-content: center; color: var(--muted); margin-bottom: 0.85rem; }
.card-name { font-size: 0.875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.3rem; }
.card-meta { font-size: 0.75rem; color: var(--muted); display: flex; align-items: center; gap: 0.4rem; }
.state-msg { grid-column: 1 / -1; padding: 3rem; text-align: center; color: var(--muted); font-size: 0.9rem; }
.state-msg.error { color: #f08080; }
.state-msg a { color: var(--green); }

/* ── Rules: Empty state ──────────────────────────────────── */
.empty-state { padding: 5rem 2rem; text-align: center; color: var(--muted); }
.empty-state svg { margin-bottom: 1rem; opacity: 0.3; }
.empty-state p { margin-bottom: 1.25rem; font-size: 0.95rem; }

/* ── Rules: Rule cards ───────────────────────────────────── */
.rules-list { display: flex; flex-direction: column; gap: 0.75rem; }
.rule-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem 1.5rem; display: flex; gap: 1rem; align-items: flex-start; transition: border-color 0.15s; }
.rule-card:hover { border-color: #3a3a3a; }
.rule-card.disabled { opacity: 0.55; }
.rule-card-body { flex: 1; min-width: 0; }
.rule-name { font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem; }
.rule-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.6rem; }
.rule-meta span { display: flex; align-items: center; gap: 0.3rem; }
.conditions-preview { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.condition-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.75rem; font-weight: 500; background: var(--surface2); border: 1px solid var(--border); }
.logic-chip { padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; background: #1a2a3a; color: #56ccf2; }
.target-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.65rem; border-radius: 99px; font-size: 0.75rem; font-weight: 500; background: #0f2a1a; border: 1px solid #1a5c32; color: var(--green); margin-top: 0.5rem; }
.rule-card-actions { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-end; flex-shrink: 0; }

/* ── Rules: Toggle switch ────────────────────────────────── */
.toggle { position: relative; width: 36px; height: 20px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track { position: absolute; inset: 0; border-radius: 99px; background: var(--border); transition: background 0.2s; }
.toggle input:checked + .toggle-track { background: var(--green); }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle input:checked ~ .toggle-thumb { transform: translateX(16px); }
.card-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0.25rem; border-radius: 4px; font-size: 0.8rem; transition: color 0.12s, background 0.12s; }
.card-btn:hover { background: var(--surface2); color: var(--text); }
.card-btn.danger:hover { color: #f08080; }

/* ── Rules: Drawer ───────────────────────────────────────── */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: var(--drawer-w); background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.3s; z-index: 50; overflow: hidden; }
.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-header h3 { font-size: 1rem; font-weight: 700; }
.drawer-close { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0.25rem; border-radius: 4px; }
.drawer-close:hover { color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.5rem; }
.drawer-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.75rem; justify-content: flex-end; flex-shrink: 0; }

/* ── Rules: Form elements ────────────────────────────────── */
.form-section { margin-bottom: 1.75rem; }
.form-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 0.6rem; display: block; }
input[type="text"], input[type="number"], input[type="date"], input[type="password"], select { width: 100%; padding: 0.6rem 0.85rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 0.875rem; }
input[type="text"]:focus, input[type="number"]:focus, input[type="date"]:focus, input[type="password"]:focus, select:focus { outline: none; border-color: var(--green); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ── Rules: Source pills ─────────────────────────────────── */
.source-picks { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; min-height: 0; }
.source-pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.65rem; border-radius: 99px; background: var(--surface2); border: 1px solid var(--border); font-size: 0.78rem; }
.source-pill button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; line-height: 1; font-size: 0.9rem; }
.source-pill button:hover { color: #f08080; }

/* ── Rules: Logic / schedule toggle ─────────────────────── */
.logic-toggle { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.logic-btn { flex: 1; padding: 0.45rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-size: 0.8rem; font-weight: 700; cursor: pointer; text-align: center; transition: all 0.12s; }
.logic-btn.active { background: #1a2a3a; border-color: #56ccf2; color: #56ccf2; }
.logic-btn.tier-locked { opacity: 0.4; cursor: not-allowed; }

/* ── Rules: Condition rows ───────────────────────────────── */
.condition-rows { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.condition-row { display: flex; gap: 0.4rem; align-items: flex-start; }
.condition-row select { flex: 1; min-width: 0; }
.condition-row input[type="text"] { flex: 1.2; }
.condition-row .remove-btn { flex-shrink: 0; background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); cursor: pointer; padding: 0.6rem 0.6rem; line-height: 1; font-size: 0.85rem; transition: all 0.12s; }
.condition-row .remove-btn:hover { border-color: #f08080; color: #f08080; }
.add-condition-btn { background: none; border: 1px dashed var(--border); border-radius: 6px; color: var(--muted); cursor: pointer; padding: 0.5rem 1rem; font-size: 0.8rem; width: 100%; text-align: center; transition: all 0.12s; }
.add-condition-btn:hover { border-color: var(--green); color: var(--green); }

/* ── Rules: Sync toast ───────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.card-btn.syncing svg { animation: spin 0.9s linear infinite; }
.sync-toast { position: fixed; bottom: 2rem; right: 2rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 0.9rem 1.1rem; font-size: 0.82rem; max-width: 340px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 40; }
.sync-toast.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.sync-toast-title { font-weight: 700; margin-bottom: 0.4rem; color: var(--green); }
.sync-toast-row { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); margin-top: 0.2rem; }
.sync-toast-row .added { color: var(--text); font-weight: 600; }
.sync-toast-error { color: #f08080; font-size: 0.78rem; margin-top: 0.2rem; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 2rem; }
.tab-btn { padding: 0.65rem 1.25rem; background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); font-size: 0.875rem; font-weight: 600; cursor: pointer; margin-bottom: -1px; transition: color 0.15s, border-color 0.15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--green); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Account page ────────────────────────────────────────── */
.account-body { max-width: 480px; }
.account-section { margin-bottom: 2.5rem; }
.account-section-title { font-size: 0.9rem; font-weight: 700; color: var(--text); margin-bottom: 0.35rem; }
.account-section-desc { font-size: 0.8rem; color: var(--muted); margin-bottom: 1.25rem; }
.account-divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.account-field { margin-bottom: 1rem; }
.account-field label { display: block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 0.5rem; }
.account-alert { padding: 0.65rem 0.9rem; border-radius: 6px; font-size: 0.82rem; margin-top: 1rem; display: none; }
.account-alert.error { background: #3a1a1a; border: 1px solid #6b2c2c; color: #f08080; }
.account-alert.success { background: #0f2a1a; border: 1px solid #1a5c32; color: var(--green); }

/* ── Account: Spotify tab ────────────────────────────────── */
.spotify-connect-prompt { padding: 3rem 2rem; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.spotify-connect-prompt p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.spotify-profile-card { display: flex; gap: 1.5rem; align-items: flex-start; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 1.5rem; }
.spotify-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.spotify-avatar-placeholder { width: 72px; height: 72px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; }
.spotify-profile-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.2rem; }
.spotify-profile-id { font-size: 0.78rem; color: var(--muted); margin-bottom: 1rem; }
.info-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.info-row { display: flex; gap: 1rem; font-size: 0.85rem; }
.info-row .label { color: var(--muted); min-width: 80px; flex-shrink: 0; }
.info-row .value { color: var(--text); font-weight: 500; }
.info-row a.value { color: var(--green); text-decoration: none; }
.info-row a.value:hover { text-decoration: underline; }

/* ── Upgrade page ────────────────────────────────────────── */
.upgrade-hero { text-align: center; padding: 2rem 1rem 3rem; max-width: 600px; margin: 0 auto; }
.upgrade-hero-eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--green); margin-bottom: 0.75rem; }
.upgrade-hero-title { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 0.75rem; }
.upgrade-hero-sub { font-size: 1rem; color: var(--muted); line-height: 1.6; }

.plan-cards { display: flex; gap: 1.25rem; max-width: 780px; margin: 0 auto 3rem; }
.plan-card { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.75rem; display: flex; flex-direction: column; position: relative; }
.plan-card--premium { border-color: var(--green); background: linear-gradient(160deg, rgba(29,185,84,0.06) 0%, var(--surface) 60%); }
.plan-card-badge { position: absolute; top: -1px; right: 1.5rem; background: var(--green); color: #000; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 0.25rem 0.65rem; border-radius: 0 0 8px 8px; }
.plan-card-header { margin-bottom: 1.5rem; }
.plan-name { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.5rem; }
.plan-price { font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; }
.plan-price span { font-size: 1rem; font-weight: 400; color: var(--muted); }
.plan-price-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }
.plan-features { list-style: none; flex: 1; margin-bottom: 1.75rem; display: flex; flex-direction: column; gap: 0.65rem; }
.feature { display: flex; align-items: center; gap: 0.6rem; font-size: 0.875rem; }
.feature::before { content: ''; display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; background-size: contain; background-repeat: no-repeat; background-position: center; }
.feature--check { color: var(--text); }
.feature--check::before { background-color: rgba(29,185,84,0.15); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%231db954' stroke-width='2.5'%3E%3Cpolyline points='3 8 6.5 11.5 13 5'/%3E%3C/svg%3E"); }
.feature--cross { color: var(--muted); }
.feature--cross::before { background-color: rgba(255,255,255,0.04); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23555' stroke-width='2.5'%3E%3Cline x1='4' y1='4' x2='12' y2='12'/%3E%3Cline x1='12' y1='4' x2='4' y2='12'/%3E%3C/svg%3E"); }
.plan-card-footer { margin-top: auto; }

.waitlist-section {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    max-width: 780px;
    margin: 0 auto 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
}
.waitlist-icon { color: var(--green); flex-shrink: 0; margin-top: 0.15rem; }
.waitlist-body { flex: 1; }
.waitlist-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.35rem; }
.waitlist-sub { font-size: 0.85rem; color: var(--muted); line-height: 1.55; margin-bottom: 1rem; }
.waitlist-form { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.waitlist-input {
    flex: 1;
    min-width: 200px;
    padding: 0.55rem 0.85rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}
.waitlist-input:focus { outline: none; border-color: var(--green); }
.waitlist-btn { flex-shrink: 0; }
.waitlist-feedback { margin-top: 0.65rem; font-size: 0.85rem; }
.waitlist-feedback--success { color: var(--green); }
.waitlist-feedback--error { color: #f08080; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.upgrade-callouts { display: flex; flex-direction: column; gap: 1rem; max-width: 780px; margin: 0 auto; }
.callout { display: flex; align-items: flex-start; gap: 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem 1.5rem; }
.callout-icon { color: var(--green); flex-shrink: 0; margin-top: 0.1rem; }
.callout-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.3rem; }
.callout-desc { font-size: 0.85rem; color: var(--muted); line-height: 1.55; }

/* ── Mobile chrome (hidden on desktop) ──────────────────────── */
.mobile-header   { display: none; }
.mobile-nav      { display: none; }
.sidebar-overlay { display: none; }

/* ═══════════════════════════════════════════════════════════
   Responsive — mobile (≤ 768 px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Mobile top header ─────────────────────────────────── */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 52px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 0 1rem;
        z-index: 60;
    }
    .mobile-header-logo { font-size: 1.3rem; font-weight: 800; color: var(--green); letter-spacing: -0.5px; }
    .mobile-header-btn  { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0.4rem; border-radius: 6px; display: flex; align-items: center; justify-content: center; }
    .mobile-header-btn:hover { color: var(--text); }

    /* ── Sidebar: slide-in drawer on mobile ────────────────── */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 70;
        width: 260px;
    }
    .sidebar.open { transform: translateX(0); }

    /* ── Backdrop overlay ──────────────────────────────────── */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.55);
        z-index: 65;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s;
    }
    .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

    /* ── Main content ──────────────────────────────────────── */
    .main {
        margin-left: 0;
        padding: 1rem;
        padding-top: calc(52px + 1rem);
        padding-bottom: calc(60px + 1rem);
    }
    .main.drawer-open { margin-right: 0; }

    /* ── Bottom navigation bar ─────────────────────────────── */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: 60px;
        background: var(--surface);
        border-top: 1px solid var(--border);
        z-index: 60;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .mobile-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        color: var(--muted);
        text-decoration: none;
        font-size: 0.62rem;
        font-weight: 600;
        letter-spacing: 0.02em;
        transition: color 0.15s;
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-nav a.active { color: var(--green); }
    .mobile-nav a svg { flex-shrink: 0; }

    /* ── Auth pages ────────────────────────────────────────── */
    body.auth .card { margin: 1rem; padding: 1.75rem 1.25rem; }

    /* ── Page header ───────────────────────────────────────── */
    .page-header { flex-wrap: wrap; gap: 0.4rem; }

    /* ── Spotify banner ────────────────────────────────────── */
    .spotify-banner { flex-direction: column; align-items: flex-start; }

    /* ── Stats grid: 2 × 2 ─────────────────────────────────── */
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 1.6rem; }

    /* ── Charts: stack ─────────────────────────────────────── */
    .charts-row.two-one,
    .charts-row.one-one { grid-template-columns: 1fr; }
    .chart-card { min-width: 0; overflow: hidden; }

    /* ── Playlists toolbar ─────────────────────────────────── */
    .toolbar { flex-wrap: wrap; }
    .search-wrap { order: -1; max-width: 100%; }
    .filter-btns { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
    .filter-btn  { white-space: nowrap; flex-shrink: 0; }
    .view-toggle { flex-shrink: 0; }

    /* ── Rule cards ────────────────────────────────────────── */
    .rule-card { flex-direction: column; gap: 0.75rem; }
    .rule-card-actions { flex-direction: row; align-items: center; justify-content: flex-end; width: 100%; gap: 0.75rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }

    /* ── Drawer: full width ────────────────────────────────── */
    .drawer { width: 100%; }

    /* ── Create-rule banner & sync toast ───────────────────── */
    .create-rule-banner { left: 0.75rem; right: 0.75rem; bottom: calc(60px + 0.75rem); }
    .sync-toast { left: 0.75rem; right: 0.75rem; bottom: calc(60px + 0.75rem); max-width: none; }

    /* ── Plan cards: stack ─────────────────────────────────── */
    .plan-cards { flex-direction: column; max-width: 420px; margin-left: auto; margin-right: auto; }

    /* ── Account ───────────────────────────────────────────── */
    .account-body { max-width: 100%; }

    /* ── Spotify profile card ──────────────────────────────── */
    .spotify-profile-card { flex-direction: column; gap: 1rem; }

    /* ── Upgrade hero ──────────────────────────────────────── */
    .upgrade-hero { padding: 1rem 0.5rem 2rem; }
    .upgrade-hero-title { font-size: 1.75rem; }
}
