:root {
  --bg: #0b0b10;
  --surface: #15151d;
  --surface-2: #1d1d28;
  --border: #2a2a38;
  --text: #f4f4f8;
  --muted: #9b9bb0;
  --accent: #ff3d81;
  --accent-2: #8b5cf6;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

[hidden] { display: none !important; }

a { color: var(--accent); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-top: 2rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

main { max-width: 640px; margin: 0 auto; padding: 0 16px 6rem; }

/* -- form elements -------------------------------------------------------- */

input, textarea, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem .9rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .25);
}
textarea { resize: vertical; min-height: 4.5rem; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); transform: scale(1.2); }

label { display: block; font-size: .9rem; color: var(--muted); margin: .9rem 0 .35rem; }
label.check { display: flex; gap: .7rem; align-items: center; color: var(--text); font-size: 1rem; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 600; font-size: .92rem;
  color: #fff; background: var(--gradient);
  border: 0; border-radius: 999px;
  padding: .55rem 1rem; min-height: 2.5rem;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform .1s, opacity .15s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn.ok { background: #065f46; color: #d1fae5; }
.btn.bad { background: #7f1d1d; color: #fee2e2; }
.btn.small { min-height: 2rem; padding: .3rem .75rem; font-size: .85rem; }
.btn.icon { width: 2.5rem; padding: 0; }
.btn.block { width: 100%; min-height: 3rem; font-size: 1rem; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .8rem; font-weight: 600;
  padding: .3rem .65rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: rgba(52, 211, 153, .35); }
.badge.warn { color: var(--warn); border-color: rgba(251, 191, 36, .35); }
.badge.bad { color: var(--bad); border-color: rgba(248, 113, 113, .35); }
.badge.accent { color: #fff; background: var(--gradient); border-color: transparent; }

.notice {
  background: rgba(251, 191, 36, .1);
  border: 1px solid rgba(251, 191, 36, .35);
  color: var(--warn);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  margin: 1rem 0;
}
.notice.error { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .35); color: var(--bad); }

.hint { color: var(--muted); font-size: .9rem; margin: -.25rem 0 .75rem; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 1.5rem 0; }

/* -- track lists ---------------------------------------------------------- */

.list { display: flex; flex-direction: column; gap: .5rem; }

.track {
  display: flex; align-items: center; gap: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem .75rem .7rem 1rem;
}
.track-main { flex: 1; min-width: 0; }
.track-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-sub { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-actions { display: flex; gap: .4rem; align-items: center; flex-shrink: 0; }
.votes {
  min-width: 2.2rem; text-align: center; font-weight: 700; font-size: 1.05rem;
  background: var(--surface-2); border-radius: 10px; padding: .3rem .4rem;
}

/* -- guest page ----------------------------------------------------------- */

.hero {
  text-align: center;
  padding: 2.5rem 16px 1.5rem;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(139, 92, 246, .35), transparent 60%),
    radial-gradient(80% 60% at 85% 10%, rgba(255, 61, 129, .25), transparent 60%);
}
.eyebrow {
  margin: 0 0 .4rem; font-size: .8rem; font-weight: 700; letter-spacing: .18em;
  text-transform: uppercase; color: var(--accent);
}
.brand-logo { display: inline-block; margin-bottom: 1.1rem; }
.brand-logo img { display: block; width: auto; height: auto; max-width: 200px; max-height: 72px; }
.legal { max-width: 40rem; line-height: 1.55; }
.legal h2 { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 1.05rem; margin: 1.6rem 0 .4rem; }
.legal p, .legal li { color: #d4d4e0; }
.legal ul { padding-left: 1.2rem; }
.legal-text { white-space: pre-line; color: #d4d4e0; }
.legal-address { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.legal a { color: var(--muted); }
.hero h1 { font-size: clamp(1.7rem, 7vw, 2.4rem); margin: 0; }
.lead { color: #d4d4e0; max-width: 34rem; margin: .7rem auto 0; white-space: pre-line; }

.search-box {
  position: sticky; top: 0; z-index: 5;
  padding: .75rem 0;
  background: linear-gradient(var(--bg) 75%, transparent);
}
.search-box input {
  font-size: 1.05rem; padding: .95rem 1.1rem; border-radius: 999px;
  background: var(--surface-2);
}

#results:not(:empty) { margin-bottom: 1rem; }

.limit-info { color: var(--muted); font-size: .9rem; margin: 0 0 1rem; }

dialog {
  width: min(92vw, 440px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.4rem;
}
dialog::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(3px); }
dialog h3 { font-size: 1.2rem; }
.dialog-track { background: var(--surface-2); border-radius: 12px; padding: .75rem .9rem; margin: .5rem 0; }
.dialog-actions { display: flex; gap: .6rem; margin-top: 1.2rem; }
.dialog-actions .btn { flex: 1; min-height: 2.9rem; }

#toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom));
  transform: translate(-50%, 150%);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .75rem 1.1rem; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  opacity: 0; visibility: hidden;
  transition: transform .25s ease, opacity .25s, visibility .25s;
  z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
#toast.error { border-color: rgba(248, 113, 113, .5); color: var(--bad); }

footer { text-align: center; color: #5e5e72; font-size: .78rem; padding: 2rem 16px 3rem; }
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { text-decoration: underline; }
.guest-tabs { margin: 1.25rem 0 1rem; }
.tab-panel > .hint:first-child { margin: 0 0 1rem; }
.tab-panel h2 { margin-top: 0; }
.tab-panel > section:not([hidden]) ~ section:not([hidden]) { margin-top: 2rem; }
.dialog-note { color: var(--muted); font-size: .85rem; margin: .25rem 0 .75rem; }
.guest-tabs { gap: .3rem; }
.guest-tabs .tab { flex: 1 1 auto; text-align: center; padding: .45rem .55rem; font-size: .86rem; }
.mood-list { display: grid; gap: .6rem; }
.mood-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .9rem .35rem; }
.mood-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.mood-name { font-weight: 600; }
.mood-value { color: var(--muted); font-size: .85rem; }
.mood-value.more { color: var(--ok); }
.mood-value.less { color: var(--bad); }
.mood-row input[type=range] { width: 100%; accent-color: var(--accent); margin: .45rem 0 .1rem; }
.mood-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; }
.mood-board { display: grid; gap: .9rem; margin: .5rem 0 1rem; }
.mood-track { position: relative; height: .7rem; background: var(--surface-2); border-radius: 999px; margin: .35rem 0 .2rem; overflow: hidden; }
.mood-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--border); }
.mood-bar { position: absolute; top: 0; bottom: 0; }
.mood-bar.more { background: var(--ok); border-radius: 0 999px 999px 0; }
.mood-bar.less { background: var(--bad); border-radius: 999px 0 0 999px; }
.track-note { color: var(--muted); font-size: .85rem; margin-top: .2rem; font-style: italic; }
.reject-form { display: flex; gap: .5rem; flex-wrap: wrap; width: 100%; }
.reject-form input { flex: 1 1 14rem; }

/* -- admin ---------------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 16px; border-bottom: 1px solid var(--border);
  background: rgba(11, 11, 16, .9); position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
}
.topbar { flex-wrap: wrap; row-gap: .5rem; }
.topnav { display: flex; gap: .2rem; margin-left: auto; margin-right: .5rem; }
@media (max-width: 560px) {
  .topnav { order: 3; width: 100%; margin: 0; }
}
.topnav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; padding: .35rem .6rem; border-radius: 999px; }
.topnav a.active { color: var(--text); background: var(--surface-2); }
.logo-preview { display: flex; align-items: center; justify-content: center; min-height: 90px; background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius); padding: 1rem; margin: .5rem 0 .75rem; }
.logo-preview img { max-width: 220px; max-height: 80px; }
.color-row { display: flex; gap: .6rem; align-items: center; }
.color-row input[type=color] { width: 3rem; height: 2.6rem; padding: .15rem; flex: none; }
.dj-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem 0; border-top: 1px solid var(--border); }
.dj-row:first-child { border-top: 0; }
.dj-row .grow { flex: 1 1 12rem; min-width: 0; }
.dj-row .track-sub { white-space: normal; }
.brand { font-weight: 800; letter-spacing: .02em; text-decoration: none; color: var(--text); font-size: 1.1rem; }
.brand span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

body.admin main { max-width: 960px; padding-top: 1.25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
}
.card h3 { margin-bottom: .75rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.stat { background: var(--surface-2); border-radius: 12px; padding: .8rem 1rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .82rem; }

.event-row {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1rem; border-radius: 12px; background: var(--surface-2);
  text-decoration: none; color: var(--text); margin-bottom: .5rem;
}
.event-row:hover { outline: 1px solid var(--accent-2); }
.event-row .grow { flex: 1; min-width: 0; }

.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row.spread { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.tabs { display: flex; gap: .35rem; overflow-x: auto; margin: 1rem 0; padding-bottom: .25rem; }
.tab {
  font: inherit; font-weight: 600; font-size: .92rem;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: .45rem .95rem; cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.tab .count { opacity: .7; margin-left: .25rem; }

.request {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: .6rem;
}
.request-head { display: flex; gap: .85rem; align-items: center; }
.request-meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.request-meta .badge { font-weight: 500; }
.voters { margin-top: .55rem; font-size: .88rem; color: #cfcfdc; }
.voters .msg { display: block; color: var(--muted); font-style: italic; margin-top: .15rem; }
.request-actions { display: flex; gap: .4rem; margin-top: .7rem; flex-wrap: wrap; }

.url-box {
  display: flex; gap: .5rem; align-items: center;
  background: var(--surface-2); border-radius: 12px; padding: .5rem .5rem .5rem .9rem;
  overflow: hidden; margin-top: .75rem;
}
.url-box span {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem;
}

.qr-preview { background: #fff; border-radius: 16px; padding: 1rem; width: min(100%, 320px); }
.qr-preview img { display: block; width: 100%; height: auto; }

.playlist-picker { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; padding: .25rem .75rem; margin-top: .5rem; }
.playlist-picker label.check { margin: .55rem 0; font-size: .95rem; }
.playlist-picker .count { color: var(--muted); font-size: .82rem; margin-left: auto; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.login { max-width: 380px; margin: 12vh auto 0; }

.live-dot {
  display: inline-block; width: .55rem; height: .55rem; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 0 rgba(52, 211, 153, .6);
  animation: pulse 2s infinite;
}
.live-dot.off { background: var(--bad); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); }
  70% { box-shadow: 0 0 0 .5rem rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* -- poster (printed) ----------------------------------------------------- */

body.poster {
  background: #fff; color: #111;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 2rem 16px;
}
.poster-sheet { width: min(100%, 180mm); }
.poster-eyebrow { font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: #8b5cf6; margin: 0; }
.poster h1 { font-size: clamp(2rem, 8vw, 3.4rem); margin: .4rem 0 .2rem; }
.poster-date { color: #555; font-size: 1.2rem; margin: 0; }
.poster-qr { width: min(100%, 120mm); margin: 2rem auto 1.5rem; }
.poster-qr svg { display: block; width: 100%; height: auto; }
.poster-cta { font-size: 1.6rem; font-weight: 700; margin: 0; }
.poster-steps { color: #444; font-size: 1.1rem; margin: .5rem 0 1rem; }
.poster-message { color: #444; white-space: pre-line; margin: 0 0 1rem; }
.poster-url { font-family: ui-monospace, Menlo, Consolas, monospace; color: #333; font-size: 1rem; word-break: break-all; }
.poster-toolbar { margin-top: 2rem; display: flex; gap: .6rem; justify-content: center; }

@media print {
  @page { size: A4; margin: 15mm; }
  body.poster { padding: 0; min-height: auto; }
  .poster-toolbar { display: none; }
}

.spacer { margin-top: 1.1rem; }
.poster-date:empty, .poster-message:empty { display: none; }

/* -- contract (printable, light) ------------------------------------------- */

body.paper { background: #fff; color: #111; max-width: 52rem; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.paper-toolbar { display: flex; gap: .6rem; margin-bottom: 1.5rem; }
.contract { line-height: 1.5; font-size: .95rem; }
.contract h1 { font-size: 1.45rem; margin-bottom: .2rem; overflow-wrap: anywhere; hyphens: auto; }
.contract-box .contract h1 { font-size: 1.15rem; }
.contract h2 { text-transform: none; letter-spacing: 0; color: #111; font-size: 1.05rem; margin: 1.5rem 0 .4rem; }
.contract-version { color: #555; margin-top: 0; }
.contract-party { border-left: 3px solid #999; padding-left: .8rem; }
.contract table { width: 100%; border-collapse: collapse; margin: .5rem 0; font-size: .88rem; }
.contract th, .contract td { border: 1px solid #ccc; padding: .4rem .5rem; text-align: left; vertical-align: top; }
.contract th { background: #f2f2f2; }
.contract ol { padding-left: 1.3rem; }
.contract-proof { color: #555; font-size: .78rem; word-break: break-all; margin-top: 2rem; border-top: 1px solid #ccc; padding-top: .6rem; }
.contract-box { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; max-height: 60vh; overflow: auto; }
.contract-box .contract h2, .contract-box .contract-proof, .contract-box .contract-version { color: var(--text); }
.contract-box .contract th { background: var(--surface-2); }
.contract-box .contract th, .contract-box .contract td { border-color: var(--border); }
@media print {
  .paper-toolbar { display: none; }
  body.paper { padding: 0; }
}

details { margin: .5rem 0; }
details summary { cursor: pointer; color: var(--muted); font-weight: 600; }
details ul { margin: .5rem 0 0; padding-left: 1.2rem; color: var(--muted); font-size: .9rem; }
details li { margin-bottom: .35rem; }
.pre { white-space: pre-line; }
