/* Spotify Fuckery prototype — big, calm, obvious. */
:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #fffefb;
  --surface-2: #efece4;
  --border: #e2ded3;
  --text: #1d1c1a;
  --text-2: #57544d;
  --muted: #8a867c;
  --accent: #3d7a64;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe8;
  --danger: #b3382f;
  --grid: #e7e4dc;
  /* Ordinal tempo/intensity ramp (one hue, light -> dark) */
  --band-1: #cde2fb; --band-1-ink: #0d366b;
  --band-2: #9ec5f4; --band-2-ink: #0d366b;
  --band-3: #3987e5; --band-3-ink: #ffffff;
  --band-4: #1c5cab; --band-4-ink: #ffffff;
  --series: #2a78d6;
  --series-2: #eb6834;
  --shadow: 0 1px 2px rgba(30, 28, 20, .06), 0 4px 16px rgba(30, 28, 20, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151514; --surface: #1d1d1b; --surface-2: #262624; --border: #33332f;
    --text: #f4f3ef; --text-2: #c3c2b7; --muted: #8f8d85;
    --accent: #6fbf9f; --accent-ink: #0f1f18; --accent-soft: #1f3129;
    --danger: #e66767; --grid: #2c2c29;
    --band-1: #184f95; --band-1-ink: #ffffff;
    --band-2: #256abf; --band-2-ink: #ffffff;
    --band-3: #5598e7; --band-3-ink: #0b0b0b;
    --band-4: #9ec5f4; --band-4-ink: #0b0b0b;
    --series: #3987e5;
    --series-2: #d95926;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151514; --surface: #1d1d1b; --surface-2: #262624; --border: #33332f;
  --text: #f4f3ef; --text-2: #c3c2b7; --muted: #8f8d85;
  --accent: #6fbf9f; --accent-ink: #0f1f18; --accent-soft: #1f3129;
  --danger: #e66767; --grid: #2c2c29;
  --band-1: #184f95; --band-1-ink: #ffffff;
  --band-2: #256abf; --band-2-ink: #ffffff;
  --band-3: #5598e7; --band-3-ink: #0b0b0b;
  --band-4: #9ec5f4; --band-4-ink: #0b0b0b;
  --series: #3987e5;
  --series-2: #d95926;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.5 "Nunito Sans", system-ui, -apple-system, sans-serif;
}
a { color: inherit; }
h1, h2, h3 { font-family: "Nunito", system-ui, sans-serif; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.35rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.brand { font: 800 1.25rem "Nunito", system-ui; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; padding: 8px 14px; border-radius: 999px; font-weight: 700; color: var(--text-2); }
.nav a.on, .nav a:hover { background: var(--surface-2); color: var(--text); }
.topsearch { flex: 1; min-width: 180px; display: flex; }
.topsearch input { width: 100%; }
main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 80px; }

/* Controls */
input[type=text], input[type=search], textarea, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 10px 14px;
}
input:focus, textarea:focus, select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; min-height: 64px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1rem "Nunito Sans", system-ui; text-decoration: none; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 18px; border-radius: 999px; min-height: 44px;
}
.btn:hover { border-color: var(--text-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-big { font-size: 1.15rem; padding: 14px 28px; min-height: 56px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
.btn-icon { width: 40px; padding: 0; }
form.inline { display: inline; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 16px; }
.hero { text-align: center; padding: 56px 20px; }
.hero h1 { font-size: 2.4rem; }
.hero p { font-size: 1.15rem; color: var(--text-2); max-width: 560px; margin: 0 auto 28px; }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; background: var(--accent-soft); font-weight: 600; }
.flash.error { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }

/* Sync progress */
.progress { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; }
.stat b { display: block; font: 800 1.8rem "Nunito", system-ui; }
.stat span { color: var(--text-2); font-size: .9rem; }

/* Playlist grid */
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 24px 0 12px; }
.filterbar input { flex: 1; min-width: 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 14px; font: 700 .9rem "Nunito Sans", system-ui; cursor: pointer; color: var(--text-2); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.pl { text-decoration: none; display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; transition: transform .1s; }
.pl:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.pl img, .pl .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--surface-2); }
.pl .body { padding: 10px 12px 12px; }
.pl .name { font-weight: 800; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pl.locked { opacity: .55; }

/* Song rows */
.songs { list-style: none; margin: 0; padding: 0; }
.song { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 12px; text-decoration: none; }
.song + .song { border-top: 1px solid var(--border); }
a.song:hover, .song:hover { background: var(--surface-2); }
.song img, .song .noimg { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }
.song .meta { flex: 1; min-width: 0; }
.song .title { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song .sub { display: block; color: var(--text-2); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song .num { width: 24px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.song .dur { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; flex: none; }

/* Tempo pill: number + word, so meaning never rides on color alone */
.bpm { flex: none; display: inline-flex; flex-direction: column; align-items: center; min-width: 72px; padding: 4px 10px; border-radius: 12px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.bpm b { font-size: 1.1rem; }
.bpm small { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.bpm.calm { background: var(--band-1); color: var(--band-1-ink); }
.bpm.steady { background: var(--band-2); color: var(--band-2-ink); }
.bpm.flowing { background: var(--band-3); color: var(--band-3-ink); }
.bpm.energetic { background: var(--band-4); color: var(--band-4-ink); }
.bpm.none { background: var(--surface-2); color: var(--muted); }

/* Phase tags (ordinal intensity) */
.phase { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 800; font-size: .8rem; }
.phase.i1 { background: var(--band-1); color: var(--band-1-ink); }
.phase.i2 { background: var(--band-2); color: var(--band-2-ink); }
.phase.i3 { background: var(--band-3); color: var(--band-3-ink); }
.phase.i4 { background: var(--band-4); color: var(--band-4-ink); }

/* Chart */
.chart-wrap { position: relative; height: 320px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--text-2); margin-top: 10px; }
.chart-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.timeline { display: flex; height: 34px; gap: 2px; margin-top: 8px; border-radius: 8px; overflow: hidden; }
.timeline > div { display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 800; white-space: nowrap; overflow: hidden; min-width: 0; }
details.table-view summary { cursor: pointer; color: var(--text-2); font-weight: 700; margin-top: 10px; }
details.table-view table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .9rem; }
details.table-view td, details.table-view th { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); }

/* Page header */
.pagehead { display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px; }
.pagehead img { width: 140px; height: 140px; border-radius: 16px; object-fit: cover; box-shadow: var(--shadow); }
.pagehead .info { flex: 1; min-width: 220px; }
.back { display: inline-block; margin-bottom: 12px; color: var(--text-2); text-decoration: none; font-weight: 700; }

/* Flow builder */
.builder { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .builder { grid-template-columns: 1fr; } }
.fitem { border: 1px solid var(--border); border-radius: 14px; padding: 10px; background: var(--surface); }
.fitem + .fitem { margin-top: 8px; }
.fitem .song { padding: 4px; }
.fitem .song:hover { background: none; }
.fitem .tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.fitem textarea { min-height: 44px; margin-top: 6px; font-size: .95rem; }
.fitem select { padding: 6px 10px; font-size: .9rem; }
.phase-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.phase-pick a { text-decoration: none; text-align: center; padding: 10px 4px; border-radius: 12px; border: 1.5px solid var(--border); font-weight: 800; font-size: .92rem; }
.phase-pick a.on { border-color: var(--text); background: var(--text); color: var(--bg); }
.sticky { position: sticky; top: 76px; }
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); border: 2px dashed var(--border); border-radius: 16px; }

@media (max-width: 600px) {
  h1 { font-size: 1.6rem; }
  .pagehead img { width: 96px; height: 96px; }
  .song .dur { display: none; }
  .nav a { padding: 8px 10px; }
}
[hidden] { display: none !important; }

/* Builder sidebar: scrolls on its own so it can stay pinned */
.sidebar { max-height: calc(100vh - 92px); overflow-y: auto; }
@media (max-width: 860px) { .sidebar { max-height: none; position: static; } }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; margin-bottom: 12px; }
.tabs a { flex: 1; text-align: center; text-decoration: none; padding: 8px 6px; border-radius: 999px; font-weight: 800; font-size: .9rem; color: var(--text-2); }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Ranked bars */
.bars { list-style: none; margin: 0; padding: 0; }
.bars li + li { margin-top: 2px; }
.bar-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; text-decoration: none; }
a.bar-row:hover { background: var(--surface-2); }
.bar-row img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex: none; }
.bar-n { width: 22px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-size: .9rem; }
.bar-body { flex: 1; min-width: 0; }
.bar-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.bar-name { font-weight: 700; }
.bar-sub { color: var(--text-2); }
.bar-track { display: block; height: 8px; margin-top: 4px; }
.bar-fill { display: block; height: 100%; background: var(--series); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-value { flex: none; min-width: 84px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 700; font-size: .9rem; }

/* Stats page */
.section-nav { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 12px; margin-bottom: 8px; scrollbar-width: none; }
.section-nav a { flex: none; text-decoration: none; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--border); font-weight: 700; font-size: .88rem; color: var(--text-2); }
.section-nav a:hover { border-color: var(--text-2); color: var(--text); }
.stats-section { scroll-margin-top: 80px; margin-top: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.card-head { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.card-head > div { flex: 1; min-width: 200px; }
.card-head h2 { margin: 0; }
.card-head p { margin: 2px 0 0; }
.tabpanel[hidden] { display: none; }
.notice { border: 1.5px dashed var(--border); border-radius: 14px; padding: 14px 16px; }
.legend-inline { display: flex; gap: 14px; font-size: .85rem; color: var(--text-2); margin: 4px 0 8px; }
.legend-inline i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: 4px; margin-right: 6px; }
.badge { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

/* Sign-in & people */
.auth-card { max-width: 440px; margin: 40px auto; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .95rem; }
.field input { font-weight: 400; }
.people-list .person { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 4px; }
.people-list .person + .person { border-top: 1px solid var(--border); }
.people-list .meta { flex: 1; min-width: 240px; }
.people-list .title { font-weight: 800; }
.person.locked { opacity: .6; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; padding: 8px 14px; border-radius: 999px; font-weight: 700; color: var(--text-2); }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { background: var(--surface-2); color: var(--text); }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; min-width: 200px; z-index: 20; }
.usermenu .menu a, .usermenu .menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; text-decoration: none; font: inherit; font-weight: 600; background: none; border: 0; color: var(--text); cursor: pointer; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--surface-2); }
