/* Feedback Loop: warm paper (light) and ink (dark), each with soft colour
   glows and film grain behind frosted-glass panels. One vivid accent (violet).
   Type: Bricolage Grotesque for titles and anything bold, Newsreader (serif)
   for everything else, JetBrains Mono for times and counts. The fonts come
   from Google Fonts; without internet each falls back to a system face. */
:root {
  --font-display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --bg: #f3f0ea;
  --glow-1: rgba(255, 164, 116, 0.55);   /* peach, top left */
  --glow-2: rgba(140, 126, 255, 0.45);   /* periwinkle, top right */
  --glow-3: rgba(104, 214, 186, 0.38);   /* mint, bottom */
  --grain-opacity: 0.22;
  --grain-blend: multiply;
  --glow-saturate: 1.2;

  --panel: rgba(255, 255, 255, 0.55);
  --panel-alt: rgba(24, 22, 30, 0.045);
  --border: rgba(24, 22, 30, 0.09);
  --border-strong: rgba(24, 22, 30, 0.17);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 10px 30px -12px rgba(30, 24, 50, 0.18);

  --text: #17161b;
  --text-dim: #54525a;
  --text-faint: #8a8790;
  --strong: #0f0e12;       /* headings and emphasized text */
  --fill: #0f0e12;         /* selected buttons, play button, switches */
  --fill-ink: #f6f3ec;
  --accent: #0f0e12;       /* primary buttons */
  --accent-ink: #f6f3ec;
  --bar-rule: rgba(24, 22, 30, 0.09);
  --field: #ffffff;                 /* buttons and dropdowns: solid, no glass */
  --field-hover: #f4f2ee;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2354525a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  --vivid: #5a45ff;        /* the one colour: upmix, links */
  --vivid-on: #ffffff;
  --vivid-soft: rgba(90, 69, 255, 0.12);
  --vivid-ink: #4a35ea;

  --good: #12a077;
  --good-soft: rgba(18, 160, 119, 0.13);
  --good-ink: #0a7153;
  --warn: #ec7a2f;
  --warn-soft: rgba(236, 122, 47, 0.14);
  --warn-ink: #a9500f;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  /* Soft charcoal rather than pure black, dusty glows, and warm off-whites. */
  --bg: #141418;
  --glow-1: rgba(150, 132, 232, 0.32);  /* dusty lavender */
  --glow-2: rgba(226, 150, 128, 0.2);   /* dusty rose */
  --glow-3: rgba(122, 188, 168, 0.18);  /* sage */
  --glow-saturate: 0.85;
  --grain-opacity: 0.07;
  --grain-blend: screen;

  --panel: rgba(255, 255, 255, 0.05);
  --panel-alt: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 16px 40px -18px rgba(0, 0, 0, 0.55);

  --text: #e3e0da;
  --text-dim: #a6a39e;
  --text-faint: #797671;
  --strong: #ece9e3;
  --fill: #e6e2da;
  --fill-ink: #17171b;
  --accent: #e6e2da;
  --accent-ink: #17171b;
  --bar-rule: rgba(255, 255, 255, 0.07);
  --field: #202026;
  --field-hover: #2a2a31;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a6a39e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  --vivid: #aaa1ee;
  --vivid-on: #17171b;
  --vivid-soft: rgba(170, 161, 238, 0.15);
  --vivid-ink: #c3bcf4;

  --good: #86cdb2;
  --good-soft: rgba(134, 205, 178, 0.12);
  --good-ink: #9ad6bf;
  --warn: #eab48f;
  --warn-soft: rgba(234, 180, 143, 0.13);
  --warn-ink: #efc3a4;
}

/* The logo is black; on the dark theme it's reversed so it stays visible. */
.logo-reverse { display: none; }
:root[data-theme="dark"] .logo-standard { display: none; }
:root[data-theme="dark"] .logo-reverse { display: inline; }

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-optical-sizing: auto;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* Background texture: colour glows, then grain over them. Both sit behind everything
   and stay put while the page scrolls. */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
/* Big overlapping glows, then blurred heavily so the colours melt into each other.
   The layer overhangs the screen so the blur doesn't fade out at the edges. */
body::before {
  inset: -20%;
  background:
    radial-gradient(60vmax 50vmax at 12% 8%, var(--glow-1), transparent 72%),
    radial-gradient(55vmax 55vmax at 92% 18%, var(--glow-2), transparent 72%),
    radial-gradient(70vmax 50vmax at 40% 95%, var(--glow-3), transparent 72%),
    radial-gradient(45vmax 40vmax at 78% 70%, var(--glow-1), transparent 75%);
  filter: blur(90px) saturate(var(--glow-saturate));
}
body::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
}

a {
  color: inherit;
  text-decoration: none;
}

/* Bold means the display face, wherever it's set (including inline styles). */
h1, h2, h3, b, strong,
.btn, .pill, .back-link, .switch, .song-title, .assign-instrument, .field-label, .moment-link,
[style*="font-weight: 700"], [style*="font-weight: 600"] {
  font-family: var(--font-display);
}

h1, h2, h3 {
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--strong);
  margin: 0;
}

.mono {
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}

button, input, select, textarea {
  font-family: var(--font-body);
  color: var(--text);
}

button {
  cursor: pointer;
}

.btn {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--border-strong);
  background: var(--field);
  color: var(--strong);
  box-shadow: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--field-hover); border-color: var(--strong); }

/* Dropdowns: the browser's own (sometimes glossy) look replaced by a flat one with a plain arrow. */
select {
  -webkit-appearance: none;
  appearance: none;
  background-color: var(--field);
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px !important;
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
  cursor: pointer;
}
select:hover { background-color: var(--field-hover); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.pill-ready, .pill-complete, .pill-submitted { background: var(--good-soft); color: var(--good-ink); }
.pill-needs_review, .pill-in_progress, .pill-failed { background: var(--warn-soft); color: var(--warn-ink); }
.pill-not_started, .pill-processing, .pill-imported { background: var(--panel-alt); color: var(--text-dim); }

/* Frosted glass. */
.card, .mode-card, .top-bar {
  background: var(--panel);
  -webkit-backdrop-filter: blur(36px) saturate(1.6);
  backdrop-filter: blur(36px) saturate(1.6);
}
.card {
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 44px;
  border-bottom: 1px solid var(--bar-rule);
}

.back-link {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 700;
}
.back-link:hover { color: var(--strong); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text-dim);
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--strong); border-color: var(--strong); }
.theme-toggle.floating { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 10; }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 30px 44px 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading, .empty {
  color: var(--text-faint);
  font-size: 14px;
  font-style: italic;
  padding: 20px 0;
}

.error-banner {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
}

/* ---- Song and team rows on the service page ---- */
.song-row { display: grid; grid-template-columns: 22px 1fr auto 92px; align-items: center; gap: 16px; padding: 13px 18px; }
.song-pos { font-size: 12px; color: var(--text-faint); }
.song-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; cursor: text; min-width: 0; overflow-wrap: anywhere; }
.song-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-faint); }
.song-meta span:last-child { color: var(--text-dim); width: 44px; text-align: right; }
.song-key { font: inherit; color: var(--text-faint); background: none; border: 1px dashed var(--border-strong); border-radius: 999px; padding: 1px 8px; cursor: pointer; }
.song-key:hover { color: var(--strong); border-color: var(--strong); }
.song-action { text-align: center; }
.song-action .btn { font-size: 12px; padding: 7px 14px; display: inline-block; width: 92px; }
.song-pending { font-size: 13px; font-style: italic; color: var(--text-faint); }

.assign-row { display: flex; align-items: center; gap: 16px; }
.assign-instrument { width: 150px; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.assign-name { width: 150px; font-size: 15px; color: var(--text-dim); }
.assign-select { font-size: 13px; padding: 6px 10px; border-radius: 999px; }
.assign-spacer { flex-grow: 1; }
.assign-remove { font-size: 13px; padding: 3px 9px; line-height: 1.2; }
.assign-feedback { font-size: 12px; padding: 7px 13px; }
.rating-row { display: flex; align-items: center; gap: 14px; }
.rating-label { width: 140px; font-size: 13.5px; color: var(--text-dim); }

button, a, input, select, textarea { touch-action: manipulation; }

/* ---- Phones ---- */
@media (max-width: 640px) {
  body { -webkit-text-size-adjust: 100%; }

  .top-bar {
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  }
  .top-bar > div[style*="width: 1px"] { display: none; }
  /* The theme button sits in the corner instead of wrapping onto a line of its own. */
  .top-bar { position: relative; padding-right: 64px; }
  .top-bar .theme-toggle { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 16px; }
  .page { padding: 18px 16px max(40px, env(safe-area-inset-bottom)); gap: 18px; }
  .center-page { padding: 16px; }
  #who { display: none; }

  /* Comfortable thumb targets, and no zoom-on-focus in iOS (which happens under 16px). */
  .btn, .mode-btn, .assign-select, .switch { min-height: 44px; }
  .btn { display: inline-flex; align-items: center; justify-content: center; }
  input, select, textarea { font-size: 16px !important; }
  input:not([type="range"]), select { min-height: 44px; }

  .intro-row { flex-wrap: wrap; }

  .song-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "title action" "meta action";
    gap: 4px 12px;
    padding: 12px 14px;
  }
  .song-pos { display: none; }
  .song-title { grid-area: title; font-size: 16px; padding: 4px 0; }
  .song-meta { grid-area: meta; gap: 10px; }
  .song-meta span:last-child { width: auto; text-align: left; }
  .song-action { grid-area: action; display: flex; align-items: center; }
  .song-action .btn { display: inline-flex; align-items: center; justify-content: center; width: 84px; height: 44px; padding: 0; }

  .assign-row { flex-wrap: wrap; gap: 8px 12px; }
  .assign-instrument { width: auto; flex: 1 1 40%; }
  .assign-name { width: auto; flex: 1 1 40%; }
  .assign-select { flex: 1 1 100%; order: 3; }
  .assign-spacer { display: none; }
  .assign-remove { min-width: 44px; margin-left: auto; }

  .rating-row { flex-wrap: wrap; gap: 6px 14px; padding: 8px 0; }
  .rating-label { width: 100%; }
  .rating-dot { width: 34px !important; height: 34px !important; }

  /* Mixer: keep the player in reach while scrolling through the parts. */
  .player {
    position: sticky;
    top: 8px;
    z-index: 5;
    box-shadow: var(--shadow);
    padding: 14px 16px !important;
  }
  #play { width: 52px !important; height: 52px !important; }
  .mode-card { padding: 12px; }
  .mode-btn { font-size: 15px; }
  #full-btn { flex: 0 0 96px !important; }
  input[type="range"] { min-height: 36px; }
}

/* ---- Celebration stickers (high fives): die-cut look, white edge, a little tilt ---- */
.sticker {
  --s: 64px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.6), transparent 42%),
    linear-gradient(145deg, var(--c1), var(--c2));
  background-clip: padding-box;   /* color stops inside the white edge, no fringe around it */
  border: calc(var(--s) * 0.065) solid #fff;
  box-shadow: 0 7px 16px -7px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.06);
  transform: rotate(var(--tilt, -6deg));
  font-size: calc(var(--s) * 0.44);
  line-height: 1;
}
.sticker-label {
  position: absolute;
  bottom: calc(var(--s) * -0.16);
  left: 50%;
  transform: translateX(-50%);
  background: #17161b;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: max(10px, calc(var(--s) * 0.15));
  letter-spacing: 0.02em;
  padding: 2px 8px 3px;
  border-radius: 999px;
  border: 2px solid #fff;
  white-space: nowrap;
}
.sticker-lg { --s: 84px; }
.sticker-sm { --s: 38px; }
.sticker-sm .sticker-label { display: none; }
.sticker-picker { display: flex; gap: 14px 18px; flex-wrap: wrap; padding: 6px 2px 14px; }
.sticker-choice { position: relative; background: none; border: none; padding: 4px; border-radius: 50%; cursor: pointer; transition: transform 0.12s; }
.sticker-choice:hover { transform: scale(1.06); }
.sticker-choice[aria-pressed="true"] { transform: scale(1.14); }
.sticker-choice[aria-pressed="false"] .sticker { filter: saturate(0.7); opacity: 0.8; }
/* The chosen one gets a small check badge rather than a ring, so the white edge stays the edge. */
.sticker-choice[aria-pressed="true"]::after {
  content: "✓";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--fill);
  color: var(--fill-ink);
  border: 2px solid #fff;
  font: 800 12px var(--font-display);
  box-shadow: 0 3px 8px -3px rgba(0, 0, 0, 0.5);
}
