/* One layout for phone and laptop: a bottom tab bar under 900px, a left sidebar above. */
:root {
  --paper: #F7F7FB;
  --surface: #FFFFFF;
  --ink: #1C1A33;
  --ink-soft: #5A5775;
  --line: #E2E0EC;
  --note: #ECEBF6;
  --signal: #2B45D8;
  --on-signal: #FFFFFF;
  --amber: #A86400;
  --danger: #B3261E;
  --good: #1E7A46;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121120; --surface: #1B1A2C; --ink: #EDECF6; --ink-soft: #A9A6C2;
    --line: #2E2C45; --note: #24223A; --signal: #8C9BFF; --on-signal: #121120;
    --amber: #F0B055; --danger: #FF8A80; --good: #6FD39B;
  }
}
:root[data-theme="dark"] {
  --paper: #121120; --surface: #1B1A2C; --ink: #EDECF6; --ink-soft: #A9A6C2;
  --line: #2E2C45; --note: #24223A; --signal: #8C9BFF; --on-signal: #121120;
  --amber: #F0B055; --danger: #FF8A80; --good: #6FD39B;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--signal); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 .6rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }

/* Shell */
.view {
  padding: 20px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  max-width: 1180px;
  margin: 0 auto;
  outline: none;
}
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.brand { display: none; }
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: var(--ink-soft); text-decoration: none; font-size: .75rem; font-weight: 600;
}
.tab .ico { font-size: 1.3rem; line-height: 1; }
.tab[aria-current="page"] { color: var(--signal); }
/* The profile icon sits top left: fixed over the page on a phone, at the top of the side menu on a laptop. */
.nav-top { display: contents; }
.account-link { position: fixed; top: 12px; left: 12px; z-index: 11; text-decoration: none; border-radius: 999px; }
.account-link[aria-current="page"] .avatar { box-shadow: 0 0 0 2px var(--signal); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden; flex: none;
  border-radius: 999px; background: var(--note); color: var(--ink); font-weight: 800;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.small-avatar { width: 36px; height: 36px; font-size: 1rem; }
.big-avatar { width: 64px; height: 64px; font-size: 1.6rem; }
.profile { display: flex; align-items: center; gap: 16px; }
.public-profile { max-width: 420px; margin: 40px auto; text-align: center; display: grid; justify-items: center; gap: 6px; }
.public-profile h1 { margin: 10px 0 0; }
.public-profile p { margin: 8px 0 14px; }

.g-mark { font-weight: 800; margin-right: 8px; }
@media (max-width: 899px) { .view { padding-top: 60px; } }
/* On a phone the bottom bar has no room for sub-tabs, so Playlists shows them on the page. */
.subtab { display: none; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
  .nav {
    position: sticky; top: 0; height: 100vh; padding: 24px 12px;
    flex-direction: column; gap: 4px;
    border-top: 0; border-right: 1px solid var(--line);
  }
  .nav-top { display: flex; align-items: center; gap: 10px; padding: 0 12px 20px; }
  .account-link { position: static; }
  .brand {
    display: block; font-weight: 800; font-size: 1.25rem; color: var(--ink);
    text-decoration: none;
  }
  .tab {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 10px 12px; border-radius: 10px; font-size: .95rem;
  }
  .tab[aria-current="page"] { background: var(--note); }
  .subtab {
    display: block; padding: 7px 12px 7px 46px; border-radius: 10px;
    color: var(--ink-soft); text-decoration: none; font-size: .9rem; font-weight: 600;
  }
  .subtab[aria-current="page"] { color: var(--signal); }
  .view .playlist-tabs { display: none; }
  .view { padding: 40px 32px; }
}

/* Pieces */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.row { color: inherit; text-decoration: none; }
.row.unmatched .dim { opacity: .55; } /* R3: greyed, never dropped. The near link (ADR 0026) isn't. */
.chev { color: var(--ink-soft); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700;
  background: var(--note); color: var(--signal);
}
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: var(--note); color: var(--ink-soft);
}
.pill.good { color: var(--good); }
.pill.warn { color: var(--amber); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 20px; border-radius: 12px; border: 0;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--signal); color: var(--on-signal);
}
.btn.block { width: 100%; }
.btn.quiet { background: var(--note); color: var(--ink); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type="text"], input[type="url"], input[type="password"], input[type="email"], input[type="search"], textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
}
input:disabled { opacity: .55; }
.field-error { color: var(--danger); font-size: .875rem; margin-top: 6px; }

.notice {
  background: var(--note); border-radius: 12px; padding: 12px 14px;
  font-size: .9rem; margin-bottom: 16px;
}
.notice.error { color: var(--danger); }
.state {
  text-align: center; padding: 32px 16px; color: var(--ink-soft);
}
.state strong { display: block; color: var(--ink); margin-bottom: 4px; }

.meter { height: 8px; border-radius: 999px; background: var(--note); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--signal); }
.big-number { font-size: 2.5rem; font-weight: 800; line-height: 1; }

.segmented { display: flex; gap: 6px; }
.segmented button {
  flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
}
.segmented button[aria-pressed="true"] { border-color: var(--signal); color: var(--signal); font-weight: 700; }

.tabs-inline { display: flex; gap: 6px; margin: 16px 0 8px; }
.tabs-inline button {
  border: 0; background: none; font: inherit; font-weight: 600; color: var(--ink-soft);
  padding: 8px 4px; border-bottom: 2px solid transparent; cursor: pointer;
}
.tabs-inline button[aria-selected="true"] { color: var(--ink); border-color: var(--signal); }

.back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-weight: 600; }
dl.kv { margin: 0; }
dl.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
dl.kv div:last-child { border-bottom: 0; }
dl.kv dt { color: var(--ink-soft); flex: none; white-space: nowrap; }
dl.kv dd { margin: 0; text-align: right; }

/* Home */
.home { display: grid; gap: 8px 28px; }
.home section { margin-bottom: 8px; }
.col { min-width: 0; }
@media (min-width: 900px) {
  .home { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .span-all { grid-column: 1 / -1; }
}
.hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px;
}
.hero-form { display: flex; gap: 8px; margin-top: 12px; }
.hero-form input { flex: 1; min-width: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { margin-bottom: .6rem; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 92px; padding: 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  color: var(--ink); font: inherit; text-decoration: none; cursor: pointer;
}
.tile:hover:not([disabled]) { border-color: var(--signal); }
.tile[disabled] { opacity: .5; cursor: not-allowed; }
.tile-ico { font-size: 1.3rem; color: var(--signal); margin-bottom: 4px; }
.tile-label { font-weight: 700; font-size: .95rem; }
.tile-sub { font-size: .8rem; color: var(--ink-soft); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stats > .card, .stats > .state { grid-column: 1 / -1; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column; gap: 2px;
}
.stat-n { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat-l { font-size: .8rem; color: var(--ink-soft); }

.grid-cards { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 600px) { .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid-cards .card { margin: 0; }
.playlist-card { display: flex; gap: 12px; align-items: flex-start; }
.playlist-card .grow { min-width: 0; flex: 1; }

.art {
  width: 56px; height: 56px; border-radius: 10px; flex: none; object-fit: cover;
  background: var(--note);
}
.art-blank {
  display: grid; place-items: center; font-weight: 800; font-size: 1.3rem;
  color: var(--on-signal); background: linear-gradient(135deg, var(--signal), var(--them, #C2365B));
}
.hscroll {
  display: grid; grid-auto-flow: column; grid-auto-columns: 140px; gap: 12px;
  overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.song-card { scroll-snap-align: start; color: inherit; text-decoration: none; min-width: 0; }
.song-card .art { width: 140px; height: 140px; border-radius: 12px; margin-bottom: 8px; }
.song-card .title, .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-card .title { font-weight: 600; font-size: .9rem; }
.ranked .row { padding: 8px 0; }
.ranked .art { width: 44px; height: 44px; border-radius: 8px; }
.rank { width: 1.5em; text-align: right; font-weight: 800; color: var(--ink-soft); flex: none; }
a.pill { text-decoration: none; flex: none; }
.locked { display: flex; gap: 12px; align-items: flex-start; }
.lock { font-size: 1.2rem; }

/* Wide screens: put Settings and Friends sections side by side */
@media (min-width: 900px) {
  .two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; align-items: start; }
  .two-col .span-all { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .hero-form { flex-direction: column; }
}

/* Your links: rename and delete happen inline in the row (ADR 0010). */
.link-row { flex-wrap: wrap; }
.link-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.link-row button.pill { cursor: pointer; border: 0; font-family: inherit; }
.link-row button.pill:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { background: var(--danger); }

/* A song or link title that opens something: looks like a title, not a link. */
a.title { display: block; color: inherit; text-decoration: none; }
a.title:hover, a.title:focus-visible { text-decoration: underline; }
.list li > a.row { border-bottom: 0; }
a.playlist-card { color: inherit; text-decoration: none; }
/* ADR 0022: a song row is one link to Spotify. The li carries the divider so the link can fill it. */
.list li.song { border-bottom: 1px solid var(--line); }
.list li.song:last-child { border-bottom: 0; }
a.song-link { cursor: pointer; }
a.song-link:hover .title, a.song-link:focus-visible .title, a.song-card:hover .title { text-decoration: underline; }

/* ADR 0025: playlist pages open with a cover, the title, who made it, and Play in Spotify. */
.pl-head { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.pl-cover {
  width: min(100%, 280px); aspect-ratio: 1; border-radius: 14px; object-fit: cover; flex: none;
  background: var(--note); box-shadow: 0 8px 24px rgb(0 0 0 / .18);
}
.cover-blank { display: block; background: linear-gradient(135deg, var(--signal), var(--them, #C2365B)); }
.pl-meta { min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.pl-meta h1 { font-size: 1.9rem; overflow-wrap: anywhere; }
.pl-sub { margin: 2px 0 0; }
.pl-meta #match-headline { margin: 10px 0 0; }
.pl-play { margin-top: 16px; align-self: flex-start; min-width: 200px; }
@media (min-width: 640px) {
  .pl-head { flex-direction: row; align-items: stretch; gap: 28px; }
  .pl-cover { width: 240px; }
  .pl-meta h1 { font-size: 2.2rem; }
}
.list-head {
  display: flex; justify-content: space-between; padding: 0 0 8px; font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.row-art { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; flex: none; background: var(--note); }
.row .time { flex: none; font-variant-numeric: tabular-nums; }
a.near { display: block; margin-top: 4px; font-weight: 600; text-decoration: none; }
a.near:hover, a.near:focus-visible { text-decoration: underline; }
.row.unmatched > .dim:first-child { display: flex; flex: none; }
