:root {
  --bg: #f4eee5;
  --surface: #fffaf3;
  --surface-2: #efe7db;
  --ink: #1d1a16;
  --muted: #6f665c;
  --line: #e2d7c8;
  --accent: #e8590c;
  --accent-ink: #fff;
  --good: #2b8a3e;
  --shadow: 0 1px 2px rgb(40 30 20 / 6%), 0 8px 24px rgb(40 30 20 / 8%);
  --radius: 14px;
  --display: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131211;
    --surface: #1c1a18;
    --surface-2: #26231f;
    --ink: #f3ede4;
    --muted: #a39a8f;
    --line: #322d28;
    --accent: #ff7a3d;
    --accent-ink: #1a0c04;
    --good: #69db7c;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  min-height: 100vh;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Header */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-inner, .nav {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}
.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font: 700 20px/1 var(--display);
  letter-spacing: -0.01em;
}
.brand svg { width: 28px; height: 28px; color: var(--ink); }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); min-width: 0; }
.who strong { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 8px;
}
.nav a {
  flex: none;
  padding: 6px 14px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a.on { color: var(--accent-ink); background: var(--ink); }
@media (prefers-color-scheme: dark) { .nav a.on { background: var(--ink); color: var(--bg); } }

.view {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

/* Type */
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(30px, 6vw, 44px); line-height: 1.05; }
h2 { font-size: 24px; line-height: 1.15; }
h3 { font-size: 18px; }
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.muted { color: var(--muted); }
.small { font-size: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 36px 0 12px; }
.section-head:first-child { margin-top: 0; }

/* Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.5; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }
.link-btn:hover { color: var(--ink); }

.field { display: grid; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea.input { resize: vertical; min-height: 76px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pad { padding: 20px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.live { background: var(--accent); color: var(--accent-ink); }
.badge.todo { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

/* Login */
.login { max-width: 520px; margin: 6vh auto 0; }
.login h1 { margin: 8px 0 14px; }
.login p { color: var(--muted); margin: 0 0 24px; }
.login form { display: flex; gap: 8px; }
.login form .input { flex: 1; min-width: 0; }
.rules { margin: 32px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.rules li { display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start; color: var(--muted); }
.rules b { color: var(--ink); font-weight: 600; }
.rules .n {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink);
  font: 700 15px/1 var(--display);
}

/* Album hero */
.hero { display: grid; gap: 28px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .hero { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }
.cover {
  aspect-ratio: 1;
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--surface-2);
  object-fit: cover;
}
.hero .cover { max-width: 460px; }
.meta { margin-top: 18px; }
.meta h1 { margin: 6px 0 4px; }
.meta .artist { font-size: 19px; font-weight: 500; }
.note {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 10px 10px 0;
  font-style: italic;
}
.note cite { display: block; margin-top: 4px; font-style: normal; font-size: 13px; color: var(--muted); }
.countdown { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.side { display: grid; gap: 20px; }
.embed { width: 100%; border: 0; border-radius: 12px; display: block; }
.open-spotify { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }

/* Grading */
.grade-box h3 { margin-bottom: 4px; }
.grade-readout {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 10px 0 4px;
  font-family: var(--display);
}
.grade-readout .big { font-size: 56px; font-weight: 700; line-height: 1; color: var(--accent); min-width: 2.4ch; }
.grade-readout .of { font-size: 20px; color: var(--muted); }
.grade-readout .word { margin-left: auto; font-family: var(--sans); font-size: 14px; color: var(--muted); }
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 32px;
  margin: 0;
}
.ticks { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 0 4px; margin-bottom: 14px; }
.grade-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.yours { display: flex; align-items: center; gap: 14px; }
.score-pill {
  display: inline-grid;
  place-items: center;
  min-width: 52px;
  height: 52px;
  padding: 0 8px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 22px/1 var(--display);
}
.score-pill.sm { min-width: 40px; height: 34px; font-size: 16px; border-radius: 9px; }
.score-pill.dim { background: var(--surface-2); color: var(--ink); }

.grades-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 2px; }
.grades-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.grades-list li:first-child { border-top: 0; }
.grades-list .who-name { font-weight: 600; }
.grades-list .comment { grid-column: 1 / -1; color: var(--muted); font-size: 14px; white-space: pre-wrap; }
.avg-line { display: flex; align-items: center; gap: 12px; }
.notes-list { list-style: none; margin: 10px 0 0; padding: 0; }
.notes-list li { padding: 10px 0; border-top: 1px solid var(--line); }
.notes-list li:first-child { border-top: 0; }
.note-head { display: flex; align-items: baseline; gap: 8px; }
.note-head .link-btn { margin-left: auto; }
.notes-list p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-form { display: grid; gap: 8px; margin-top: 14px; }
.note-form textarea.input { min-height: 64px; }
.row .r .badge { font-size: 11px; padding: 1px 7px; }
.locked {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 16px; border-radius: 10px;
  background: var(--surface-2); color: var(--muted); font-size: 15px;
}
.locked svg { flex: none; width: 20px; height: 20px; }

/* Lists */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: auto 56px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  text-decoration: none;
}
.rows > li + li { border-top: 1px solid var(--line); }
.rows > li:first-child a.row { border-radius: var(--radius) var(--radius) 0 0; }
.rows > li:last-child a.row { border-radius: 0 0 var(--radius) var(--radius); }
.rows > li:only-child a.row { border-radius: var(--radius); }
a.row:hover { background: var(--surface-2); }
.row .rank { font: 700 20px/1 var(--display); color: var(--muted); width: 2ch; text-align: right; }
.rows > li:first-child .rank { color: var(--accent); }
.row img, .row .ph { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.row .t { min-width: 0; }
.row .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t span { display: block; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r { text-align: right; display: grid; justify-items: end; gap: 2px; }
.row .r small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.row.no-rank { grid-template-columns: 56px minmax(0, 1fr) auto; }

.people { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .people { grid-template-columns: 1fr 1fr; } }
.people table { width: 100%; border-collapse: collapse; font-size: 15px; }
.people th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 0 0 8px; }
.people td { padding: 9px 0; border-top: 1px solid var(--line); }
.people td.num, .people th.num { text-align: right; font-variant-numeric: tabular-nums; }
.people td small { color: var(--muted); display: block; font-size: 12px; }

.submit-grid { display: grid; gap: 28px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .submit-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }
.submit-form { display: grid; gap: 16px; }
.howto { font-size: 14px; color: var(--muted); margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; }
.chip b { font-weight: 600; }

.empty { text-align: center; padding: 48px 20px; }
.empty h2 { margin: 12px 0 8px; }
.empty p { color: var(--muted); margin: 0 auto 20px; max-width: 420px; }
.empty .disc { width: 72px; height: 72px; margin: 0 auto; color: var(--muted); }

.loading { padding: 60px 0; text-align: center; color: var(--muted); }
.error-box { padding: 16px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 14%, transparent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--accent); color: var(--accent-ink); }

/* Admin */
select.input { appearance: auto; }
.admin-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .admin-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }
.admin-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 16px; }
.admin-controls .field { flex: 1 1 220px; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.tile { padding: 14px 16px; display: grid; gap: 2px; box-shadow: none; }
.tile b { font: 700 28px/1 var(--display); }
.tile span { font-size: 13px; color: var(--muted); }
.admin-album { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.admin-album img, .admin-album .ph { width: 88px; height: 88px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.admin-avg { display: grid; justify-items: end; gap: 4px; }
.admin-avg small { color: var(--muted); font-size: 12px; }
.admin-split { display: grid; gap: 16px; grid-template-columns: 1fr; margin-top: 12px; }
@media (min-width: 720px) { .admin-split { grid-template-columns: 1fr 1fr; } }
.admin-split h3 { font-size: 15px; margin-bottom: 6px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 0 8px 8px 0; white-space: nowrap; }
.admin-table td { padding: 8px 8px 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
.admin-table tbody tr:first-child td { border-top: 0; }
.admin-table.members thead + tbody tr:first-child td { border-top: 1px solid var(--line); }
.admin-table td small { display: block; color: var(--muted); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-table .num { text-align: right; white-space: nowrap; }
.admin-table .actions { display: flex; gap: 12px; justify-content: flex-end; }
.admin-table tr.member-edit td { border-top: 0; padding-top: 0; }
.admin-round { border-top: 1px solid var(--line); }
.admin-round:first-child { border-top: 0; }
.admin-round summary {
  list-style: none; cursor: pointer;
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 16px;
}
.admin-round summary::-webkit-details-marker { display: none; }
.admin-round summary:hover { background: var(--surface-2); }
.admin-round summary img, .admin-round summary .ph { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--surface-2); }
.admin-round summary .t { min-width: 0; }
.admin-round summary .t b, .admin-round summary .t span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-round summary .t span { font-size: 13px; color: var(--muted); }
.admin-round summary .r { display: grid; justify-items: end; gap: 2px; }
.admin-round summary .r small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.admin-round[open] > :not(summary) { margin-left: 16px; margin-right: 16px; }
.admin-round[open] { padding-bottom: 14px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form .input { flex: 1 1 180px; width: auto; min-width: 0; padding: 8px 12px; }
.danger { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.row .t span + span { margin-top: 2px; font-style: italic; }
.row .t span b { display: inline; font-weight: 600; }
