:root {
  --bg: #ffffff;
  --fg: #141414;
  --muted: #7a7a7a;
  --line: #e8e8e8;
  --hover: #f5f5f5;
  --placeholder: #ececec;
  --ok: #2f8f4e;
  --bad: #c0392b;
  color-scheme: light;
}
[data-theme='paper'] {
  --bg: #f6f1e7; --fg: #2b2620; --muted: #8a7f70; --line: #e3dac8; --hover: #efe8da; --placeholder: #e8dfcc;
  --ok: #4f7f3a; --bad: #b0412e;
}
[data-theme='rose'] {
  --bg: #fbf3f3; --fg: #2a1d20; --muted: #9a8287; --line: #eedcdf; --hover: #f6e8ea; --placeholder: #f0dfe2;
  --ok: #3f8a5a; --bad: #c0394b;
}
[data-theme='dark'], [data-theme='midnight'], [data-theme='black'] {
  --ok: #5cc27e; --bad: #e5735f;
  color-scheme: dark;
}
[data-theme='dark'] {
  --bg: #101010; --fg: #ececec; --muted: #8c8c8c; --line: #262626; --hover: #1a1a1a; --placeholder: #1f1f1f;
}
[data-theme='midnight'] {
  --bg: #0e1420; --fg: #e3e8f2; --muted: #8590a6; --line: #1f2a3d; --hover: #141d2e; --placeholder: #1a2436;
}
[data-theme='black'] {
  --bg: #000000; --fg: #f2f2f2; --muted: #8a8a8a; --line: #1c1c1c; --hover: #0c0c0c; --placeholder: #141414;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 12px; cursor: pointer;
}
button:hover { background: var(--hover); }
button.link { border: 0; padding: 0; color: var(--muted); }
button.link:hover { background: none; color: var(--fg); }
button.danger { color: var(--bad); }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--muted); }
h1, h2, h3 { font-weight: 600; margin: 0; }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 36px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* top bar */
#bar {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  display: flex; align-items: center; gap: 16px;
  max-width: 1040px; margin: 0 auto; padding: 14px 24px;
}
#search { flex: 1; }
#search input { width: 100%; max-width: 420px; border-radius: 999px; padding: 8px 16px; }
#bar nav { margin-left: auto; display: flex; align-items: center; gap: 18px; font-size: 14px; }
#bar nav a { color: var(--muted); }
#bar nav a.active, #bar nav a:hover { color: var(--fg); text-decoration: none; }
#theme { border: 0; padding: 4px; font-size: 16px; line-height: 1; color: var(--muted); }
#theme:hover { background: none; color: var(--fg); }

main { max-width: 1040px; margin: 0 auto; padding: 12px 24px 80px; }

/* tabs */
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs button {
  border: 0; border-radius: 0; padding: 8px 0; margin-bottom: -1px; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tabs button:hover { background: none; color: var(--fg); }
.tabs button.on { color: var(--fg); border-bottom-color: var(--fg); }

/* cover grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 24px 18px; }
.card { display: block; min-width: 0; }
.card:hover { text-decoration: none; }
.card:hover .t { text-decoration: underline; text-underline-offset: 3px; }
.cover {
  position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--placeholder);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.round .cover { border-radius: 50%; }
.card .t { margin-top: 8px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.round { text-align: center; }
.badge {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.72); color: #fff;
  font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
}

/* list rows */
.rows { border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
  padding: 8px 4px; border-bottom: 1px solid var(--line);
}
.row:hover { background: var(--hover); }
.row .thumb { width: 44px; height: 44px; border-radius: 4px; overflow: hidden; background: var(--placeholder); }
.row .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row .main { min-width: 0; }
.row .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .note { font-size: 13px; color: var(--muted); font-style: italic; margin-top: 2px; white-space: pre-wrap; }
.row .meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row.tr { grid-template-columns: 28px minmax(0, 1fr) auto auto; }
.row.tr .n { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.disk { font-size: 13px; color: var(--muted); padding: 16px 4px 6px; border-bottom: 1px solid var(--line); }
.explicit {
  display: inline-block; font-size: 9px; font-weight: 700; border: 1px solid var(--muted); color: var(--muted);
  border-radius: 2px; padding: 0 3px; margin-left: 6px; vertical-align: 2px;
}

/* score input */
input.score {
  width: 58px; text-align: center; padding: 5px 4px; font-variant-numeric: tabular-nums; font-weight: 600;
  -moz-appearance: textfield; transition: border-color .3s;
}
input.score::-webkit-outer-spin-button, input.score::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.score::placeholder { color: var(--muted); font-weight: 400; }
input.score.ok { border-color: var(--ok); }
input.score.bad { border-color: var(--bad); }
input.score.big { width: 76px; font-size: 22px; padding: 6px; }
.scorebox { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.scorebox label { font-size: 13px; color: var(--muted); }

/* hero (album / artist header) */
.hero { display: flex; gap: 28px; align-items: flex-end; margin: 8px 0 8px; }
.hero .cover { width: 240px; flex: none; box-shadow: 0 4px 24px rgba(0,0,0,.12); }
.hero.artist .cover { border-radius: 50%; width: 200px; }
.hero .info { min-width: 0; }
.hero .kind { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.hero .by { margin-top: 6px; font-size: 16px; }
.hero .facts { margin-top: 4px; font-size: 13px; color: var(--muted); }
textarea.note { width: 100%; max-width: 520px; min-height: 38px; margin-top: 12px; resize: vertical; font-size: 14px; }

/* toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1; min-width: 180px; max-width: 320px; }
.toolbar .count { margin-left: auto; font-size: 13px; color: var(--muted); }

.confirm { display: inline-flex; gap: 10px; align-items: center; font-size: 13px; }
.more { display: block; margin: 24px auto 0; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* auth */
.auth { max-width: 320px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 10px; }
.auth input { padding: 10px 12px; }
.auth button[type=submit] { padding: 10px; background: var(--fg); color: var(--bg); border-color: var(--fg); }
.auth .switch { text-align: center; font-size: 13px; margin-top: 6px; }
.error { color: var(--bad); font-size: 13px; min-height: 18px; }

.panel { max-width: 420px; }
.panel section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.panel section:last-child { border-bottom: 0; }
.panel .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 6px; font-size: 14px;
  transition: opacity .2s, transform .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.skeleton { color: var(--muted); padding: 40px 0; }

@media (max-width: 640px) {
  #bar { padding: 10px 14px; gap: 10px; }
  #bar nav { gap: 12px; }
  main { padding: 8px 14px 60px; }
  .hero { flex-direction: column; align-items: flex-start; }
  .hero .cover, .hero.artist .cover { width: 100%; max-width: 280px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 18px 12px; }
  .row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .row .meta { display: none; }
  .row.tr { grid-template-columns: 22px minmax(0, 1fr) auto; }
}

.row .right { display: flex; align-items: center; gap: 12px; }
.row .right > button.link { font-size: 18px; line-height: 1; padding: 0 2px; }

/* theme menu */
.theme-wrap { position: relative; display: flex; }
#theme-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 150px; padding: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,.14); display: flex; flex-direction: column; gap: 2px;
}
#theme-menu[hidden] { display: none; }
#theme-menu button {
  border: 0; display: flex; align-items: center; gap: 10px; text-align: left; padding: 6px 8px; border-radius: 5px;
  font-size: 14px; color: var(--muted);
}
#theme-menu button:hover { color: var(--fg); }
#theme-menu button.on { color: var(--fg); font-weight: 600; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; border: 1px solid var(--line);
}
.swatch.sys { background: linear-gradient(135deg, #fff 50%, #111 50%); color: transparent; }

/* computed (song-average) scores */
input.score.auto { color: var(--muted); font-style: italic; font-weight: 500; }
.badge.auto { background: rgba(0,0,0,.45); font-style: italic; font-weight: 500; }

/* youtube link */
a.yt {
  display: inline-block; margin-left: 8px; font-size: 10px; color: var(--muted); opacity: 0; vertical-align: 1px;
  transition: opacity .15s;
}
a.yt:hover { color: #e62117; text-decoration: none; }
.row:hover a.yt, .facts a.yt, a.yt:focus { opacity: 1; }
@media (hover: none) { a.yt { opacity: .7; } }
.scorebox .small { max-width: 320px; }

/* back button */
#back { border: 0; padding: 2px 6px; font-size: 18px; line-height: 1; color: var(--muted); margin-left: -6px; }
#back:hover { background: none; color: var(--fg); }

/* every song rated */
.done { color: var(--ok); font-weight: 700; }
.badge.complete { background: var(--ok); color: #fff; font-style: normal; }
[data-theme='dark'] .badge.complete, [data-theme='midnight'] .badge.complete, [data-theme='black'] .badge.complete { color: #08130c; }

/* signed-in account */
.account-link { display: inline-flex; align-items: center; gap: 7px; max-width: 180px; }
.account-link .uname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--fg); color: var(--bg); font-size: 11px; font-weight: 700; line-height: 1;
}
#bar nav a.account-link { color: var(--fg); }
#bar nav a.account-link .uname { color: var(--muted); }
#bar nav a.account-link:hover .uname, #bar nav a.account-link.active .uname { color: var(--fg); }
.whoami { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; margin: 4px 0 6px; }
.avatar.big { width: 34px; height: 34px; font-size: 15px; }
@media (max-width: 640px) { .account-link .uname { display: none; } }
