:root {
  --display: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --on-gold: #1a120c;
  --bg: #100e0c;
  --bg-2: #221b16;
  --ink: #f6efe4;
  --muted: #b3a89a;
  --line: rgba(246, 239, 228, 0.14);
  --gold: #e6a23c;
  --gold-2: #ffd27a;
  --red: #e23b3b;
  --red-deep: #4a1515;
  --surface: #1c1713;
  --input: #1a1410;
  --danger: #ffb4b4;
  --top: rgba(16, 14, 12, 0.92);
  --dot: rgba(246, 239, 228, 0.2);
  --soft: rgba(255, 255, 255, 0.04);
  --selected: rgba(230, 162, 60, 0.12);
  --selected-line: rgba(230, 162, 60, 0.5);
  --card: #221b16;
  --card-back: #18130f;
  --played-ink: #ffd0d0;
  --stamp: #ff6b6b;
  --stamp-ink: #ff8d8d;
  --chip-played-ink: #ffb4b4;
  --chip-played-line: rgba(255, 130, 130, 0.55);
  --recado: rgba(0, 0, 0, 0.22);
  --switch: #3a322c;
  --gate: rgba(16, 14, 12, 0.94);
  --glow: rgba(230, 162, 60, 0.22);
  --glow-red: rgba(140, 36, 28, 0.2);
  --logo-pad: #100e0c;
  --composer: #100e0c;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f6efe6;
  --bg-2: #fffaf4;
  --ink: #1c140e;
  --muted: #6b5e54;
  --line: rgba(28, 20, 14, 0.14);
  --gold: #c4841a;
  --gold-2: #8d5d10;
  --red: #c0392b;
  --red-deep: #f8d6d6;
  --surface: #ffffff;
  --input: #ffffff;
  --danger: #9d2424;
  --top: rgba(246, 239, 230, 0.94);
  --dot: rgba(28, 20, 14, 0.16);
  --soft: rgba(28, 20, 14, 0.05);
  --selected: rgba(196, 132, 26, 0.16);
  --selected-line: rgba(196, 132, 26, 0.5);
  --card: #fffaf4;
  --card-back: #efe4d6;
  --played-ink: #7a2424;
  --stamp: #c0392b;
  --stamp-ink: #8d1d1d;
  --chip-played-ink: #7a2424;
  --chip-played-line: rgba(192, 57, 43, 0.4);
  --recado: rgba(28, 20, 14, 0.06);
  --switch: #ddd4c8;
  --gate: rgba(246, 239, 230, 0.96);
  --glow: rgba(196, 132, 26, 0.2);
  --glow-red: rgba(192, 57, 43, 0.08);
  --logo-pad: #1c1713;
  --composer: #f6efe6;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"], html:not([data-theme]) {
    --bg: #f6efe6;
    --bg-2: #fffaf4;
    --ink: #1c140e;
    --muted: #6b5e54;
    --line: rgba(28, 20, 14, 0.14);
    --gold: #c4841a;
    --gold-2: #8d5d10;
    --red: #c0392b;
    --red-deep: #f8d6d6;
    --surface: #ffffff;
    --input: #ffffff;
    --danger: #9d2424;
    --top: rgba(246, 239, 230, 0.94);
    --dot: rgba(28, 20, 14, 0.16);
    --soft: rgba(28, 20, 14, 0.05);
    --selected: rgba(196, 132, 26, 0.16);
    --selected-line: rgba(196, 132, 26, 0.5);
    --card: #fffaf4;
    --card-back: #efe4d6;
    --played-ink: #7a2424;
    --stamp: #c0392b;
    --stamp-ink: #8d1d1d;
    --chip-played-ink: #7a2424;
    --chip-played-line: rgba(192, 57, 43, 0.4);
    --recado: rgba(28, 20, 14, 0.06);
    --switch: #ddd4c8;
    --gate: rgba(246, 239, 230, 0.96);
    --glow: rgba(196, 132, 26, 0.2);
    --glow-red: rgba(192, 57, 43, 0.08);
    --logo-pad: #1c1713;
    --composer: #f6efe6;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  background:
    radial-gradient(ellipse 90% 45% at 50% -10%, var(--glow), transparent 58%),
    radial-gradient(ellipse 42% 32% at 100% 100%, var(--glow-red), transparent 55%),
    var(--bg);
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.shell { width: min(720px, calc(100% - 28px)); margin: 0 auto; }
.mark {
  width: auto;
  height: 48px;
  display: block;
  flex: 0 0 auto;
}
.logo {
  display: block;
  width: min(168px, 46vw);
  height: auto;
  margin: 2px auto 14px;
}
html[data-theme="dark"] .for-light { display: none; }
html[data-theme="light"] .for-dark { display: none; }
html[data-theme="light"] img.mark {
  background: #1c1713;
  border-radius: 12px;
  padding: 4px;
  box-sizing: content-box;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .for-light,
  html:not([data-theme]) .for-light { display: none; }
}
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] .for-dark,
  html:not([data-theme]) .for-dark { display: none; }
  html[data-theme="auto"] img.mark,
  html:not([data-theme]) img.mark {
    background: #1c1713;
    border-radius: 12px;
    padding: 4px;
    box-sizing: content-box;
  }
}
.panel .logo { width: min(148px, 52%); margin: 0 auto; }
.logo-field { display: flex; flex-direction: column; gap: 8px; }
.logo-preview {
  display: block;
  width: min(180px, 72%);
  height: auto;
  margin: 0;
  padding: 12px;
  border-radius: 16px;
  background: var(--logo-pad);
}
.logo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.logo-actions .text-btn { width: auto; min-height: 48px; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  padding: 0;
  border: 0;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-kicker, .eyebrow, .composer-kicker, .strip-label {
  margin: 0;
  color: var(--gold-2);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 600;
}
.brand h1, .login h1, .gate h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 640;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.btn, .contact, .text-btn {
  appearance: none;
  border: 0;
  text-decoration: none;
  border-radius: 999px;
  min-height: 48px;
  padding: 12px 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn { background: var(--gold); color: var(--on-gold); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary, .contact {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--chip-played-line); }
.text-btn {
  background: transparent;
  color: var(--muted);
  min-height: 40px;
  width: 100%;
}
.contact { min-height: 44px; padding: 10px 14px; }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.field .aside, .hint { color: var(--muted); font-weight: 400; font-size: 0.92rem; }
.label-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
input, textarea {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
}
textarea { resize: vertical; min-height: 64px; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  width: min(520px, calc(100% - 24px));
  background: #f6efe4;
  color: #1a120c;
  border-radius: 16px;
  padding: 14px 16px;
  font-weight: 600;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.page-public .toast {
  top: 12px;
  bottom: auto;
  pointer-events: none;
}
.composer-kicker.is-sent {
  letter-spacing: 0;
  text-transform: none;
  font-size: 1rem;
  line-height: 1.35;
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 16px 0 12px;
  background: var(--top);
  backdrop-filter: blur(14px);
}
.top-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.theme-cycle {
  width: 44px;
  height: 44px;
  margin-left: auto;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.theme-cycle svg { width: 22px; height: 22px; display: block; }
.share-page { margin-left: 0; }
.page-public .top { padding: 10px 0 6px; }
.page-public .top-row { flex-direction: row; flex-wrap: wrap; align-items: center; }
.page-public .brand { flex: 1 1 auto; min-width: 0; }
.page-public .brand h1 { font-size: 1.45rem; }
.page-public .contact { flex: 1 0 100%; align-self: stretch; }
.page-public .quota { margin: 8px 0; }
.page-public .lede { margin: 0 0 2px; }
.page-public .rule { margin: 0 0 8px; }
.page-public .setlist { margin-top: 8px; }
.page-public .site-foot {
  justify-content: center;
  padding-top: 2px;
  padding-bottom: calc(4px + env(safe-area-inset-bottom));
  font-size: 0.72rem;
}
@media (min-width: 641px) {
  .page-public .top-row { flex-wrap: nowrap; }
  .page-public .contact { flex: 0 1 auto; width: auto; }
}
body.page-public {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.page-public .top { position: static; }
.page-public main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 0 12px;
}
.lede { margin: 8px 0 6px; color: var(--muted); }
.rule { margin: 0 0 14px; color: var(--gold-2); font-size: 0.92rem; }
.quota { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
.quota p { margin: 0; color: var(--muted); }
.dots { display: flex; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot); }
.dot.is-on { background: var(--gold); }
.dot.is-locked { background: var(--red); }

.search input { border-radius: 999px; background: var(--soft); }
.setlist { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.song {
  width: 100%;
  display: flex;
  gap: 14px;
  align-items: center;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  min-height: 68px;
}
.song[aria-pressed="true"] {
  background: var(--selected);
  border-color: var(--selected-line);
}
.song.is-asked { opacity: 0.72; }
.asked {
  margin-left: auto;
  color: var(--gold-2);
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}
.num { color: var(--gold); font-weight: 650; width: 2.2ch; font-variant-numeric: tabular-nums; }
.song-text { display: flex; flex-direction: column; gap: 2px; }
.song-text small { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }

.composer {
  position: relative;
  z-index: 6;
  background: var(--composer);
}
.composer-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.composer-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
#count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.lock strong { display: block; color: var(--danger); }
.lock p { margin: 4px 0 0; color: var(--muted); }

.page-kiosk {
  height: 100dvh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top);
}
.kiosk {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: min(860px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 10px;
  padding: 12px 14px 8px;
}
.kiosk > * { min-width: 0; }
.kiosk-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; min-width: 0; }
.kiosk-head .brand { min-width: 0; }
.kiosk-head .kiosk-count { margin: 0 0 0 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kiosk-head .theme-cycle { margin-left: 8px; flex: 0 0 auto; }
.kiosk-head h1 { margin: 0; font-size: 1.35rem; font-family: var(--display); letter-spacing: -0.03em; }
.kiosk-count { margin: 0; color: var(--muted); text-align: right; }
.stage { min-height: 0; }
.stack { position: relative; height: 100%; }
.card {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow: hidden;
  border-radius: 28px;
  padding: 26px 22px 18px;
  background:
    linear-gradient(180deg, var(--soft), transparent 28%),
    var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
  touch-action: pan-y;
  user-select: none;
}
.card-back {
  position: absolute;
  z-index: 0;
  inset: 14px -4px -10px 12px;
  height: auto;
  border-radius: 28px;
  background: var(--card-back);
  border: 1px solid var(--line);
}
.card.played, .card.preview-played {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 90, 90, 0.32), transparent 55%),
    var(--red-deep);
  border-color: var(--chip-played-line);
}
.card h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 640;
  font-size: clamp(2.3rem, 10vw, 4.8rem);
  letter-spacing: -0.035em;
  line-height: 0.95;
}
.card.played h2, .card.preview-played h2 { color: var(--played-ink); }
.artist { margin: 0; color: var(--muted); font-size: 1.15rem; }
.votes {
  align-self: flex-start;
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1208;
  font-weight: 750;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  line-height: 1;
}
.recados {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}
.recado {
  margin: 8px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--recado);
  font-size: 1.25rem;
  line-height: 1.35;
  overflow: auto;
  max-height: 34%;
}
.recados .recado { margin: 0; max-height: none; }
.when, .swipe-hint, .kbd-hint { margin: 0; color: var(--muted); }
.swipe-hint { margin-top: auto; }
.stamp {
  position: absolute;
  top: 18px;
  right: 16px;
  border: 3px solid var(--stamp);
  color: var(--stamp-ink);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(8deg);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.85rem;
}
.kiosk-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; }
.strip-wrap { min-height: 0; min-width: 0; max-width: 100%; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; min-width: 0; max-width: 100%; }
.chip {
  flex: 0 0 auto;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  padding: 8px 12px;
  font: inherit;
}
.chip.is-current { border-color: var(--gold); color: var(--gold-2); }
.chip strong { color: var(--gold-2); font-weight: 750; margin-right: 6px; }
.chip.played strong, .chip.is-viewing strong { color: var(--played-ink); }
.chip.played, .chip.is-viewing { background: var(--red-deep); color: var(--chip-played-ink); border-color: var(--chip-played-line); }
.kbd-hint { display: none; text-align: center; font-size: 0.85rem; }
.offline { margin: 0; color: var(--danger); text-align: center; }
.gate, .login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 14px;
}
.gate { position: fixed; inset: 0; z-index: 20; background: var(--gate); }
.panel {
  width: min(440px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.loading { text-align: center; color: var(--muted); padding-top: 30vh; }

.admin { width: min(880px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 48px; }
.admin-head, .menu { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.page-admin .admin-head { flex-direction: row; flex-wrap: nowrap; align-items: center; }
.page-admin .admin-head .brand { flex: 1 1 auto; min-width: 0; }
.page-admin .admin-head #logout { margin-left: auto; }
.page-admin .admin-head .theme-cycle { margin-left: 0; }
.login-wrap { position: relative; }
.theme-corner {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  z-index: 2;
  margin-left: 0;
}
.admin-head h1 { margin: 0; font-family: var(--display); font-size: 1.8rem; letter-spacing: -0.03em; }
.menu { margin: 16px 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.menu button {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  padding: 8px 10px;
}
.metric-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.metric { display: grid; grid-template-columns: 2.4ch 1fr auto; gap: 4px 12px; align-items: center; }
.metric-rank { color: var(--gold); font-weight: 650; font-variant-numeric: tabular-nums; }
.metric-name { font-weight: 600; min-width: 0; }
.metric-name small { display: block; color: var(--muted); font-weight: 400; }
.metric-count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-bar {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}
.metric-bar span { display: block; height: 100%; border-radius: inherit; background: var(--gold); }
.menu button[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); border-color: transparent; }
.banner {
  background: var(--selected);
  border: 1px solid var(--selected-line);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0;
}
.card-block, .song-row {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}
.card-block { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.stack-form { display: flex; flex-direction: column; gap: 12px; }
.song-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.song-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.song-row.is-off { opacity: 0.55; }
.song-row h3 { margin: 0; font-size: 1.05rem; }
.song-row p { margin: 2px 0 0; color: var(--muted); }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions button.link {
  background: transparent;
  border: 0;
  color: var(--gold-2);
  padding: 8px;
  min-height: 44px;
}
.switch {
  width: 48px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: var(--switch);
  position: relative;
  flex: 0 0 auto;
}
.switch[aria-checked="true"] { background: var(--gold); }
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
}
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.danger-zone { margin-top: 8px; }
.show-count { color: var(--muted); margin: 0 0 12px; }

.page-admin {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.page-admin .login-wrap { min-height: 0; }
.page-admin .login-wrap,
.page-admin .admin { flex: 1; }
.page-kiosk .site-foot {
  position: relative;
  z-index: 30;
  background: var(--bg);
  width: min(860px, calc(100% - 28px));
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.site-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  align-items: center;
  width: min(880px, calc(100% - 28px));
  margin: 0 auto;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.78rem;
}
.site-foot p { margin: 0; }
.theme { display: flex; gap: 4px; }
.theme button {
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.theme button[aria-pressed="true"] {
  background: var(--gold);
  color: var(--on-gold);
  border-color: transparent;
}

@media (max-width: 640px) {
  .top-row, .admin-head { align-items: stretch; flex-direction: column; }
  .contact, .btn.block { width: 100%; }
}
@media (max-width: 700px) {
  .kbd-hint { display: none; }
}
@media (hover: hover) and (pointer: fine) {
  .kbd-hint { display: block; }
  .card { cursor: grab; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
