:root {
  color-scheme: dark;
  --bg: #120d16;
  --surface: #1d1520;
  --surface-2: #281e2c;
  --line: #3a2c40;
  --text: #f7eff4;
  --muted: #b5a4b2;
  --accent: #ffb238;
  --accent-2: #ff4f8b;
  --accent-ink: #1a1009;
  --good: #4ade80;
  --bad: #fb7185;
  --radius: 16px;
  --gutter: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(255, 79, 139, .16), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.4;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.error { color: var(--bad); min-height: 1.4em; margin: .5rem 0 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* ---------- Buttons & Eingaben ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 999px; padding: .65rem 1.1rem; font-weight: 600; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none;
}
.btn:hover { border-color: #5a4561; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border: 0; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(251, 113, 133, .45); color: var(--bad); background: transparent; }
.btn.wide { width: 100%; margin-top: .5rem; }
.btn.small { padding: .4rem .8rem; font-size: .85rem; }

input[type="text"], input[type="search"], input[type="password"], input[type="number"], input:not([type]) {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: .75rem .9rem; outline: none; min-width: 0;
}
input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 178, 56, .2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon-btn { background: none; border: 0; padding: .25rem .5rem; cursor: pointer; color: var(--muted); font-size: 1rem; }

.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: .35rem .8rem; font-size: .9rem; cursor: pointer; max-width: 55vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.pill {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: .2rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.pill.live { background: rgba(74, 222, 128, .15); color: var(--good); }
.pill.warn { background: rgba(251, 113, 133, .15); color: var(--bad); }
.tag { font-size: .78rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .2rem .55rem; white-space: nowrap; }

/* ---------- Beitreten ---------- */
.join { min-height: 100dvh; display: grid; place-items: center; padding: var(--gutter); }
.join-card { width: min(380px, 100%); text-align: center; display: grid; gap: .9rem; justify-items: center; }
.join-card h1 { font-size: 2.2rem; letter-spacing: -.02em; }
.join-card form { width: 100%; display: grid; gap: .6rem; }
.join-card input { text-align: center; font-size: 1.4rem; letter-spacing: .25em; text-transform: uppercase; }
.join-logo { border-radius: 20px; box-shadow: 0 10px 40px rgba(255, 79, 139, .25); }

/* ---------- App ---------- */
.app { max-width: 640px; margin: 0 auto; padding: 0 var(--gutter) calc(2rem + env(safe-area-inset-bottom)); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: 14px 0; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.brand img { border-radius: 8px; }

.now {
  display: grid; grid-template-columns: 112px 1fr; gap: 1rem; align-items: center;
  background: linear-gradient(160deg, var(--surface-2), var(--surface)); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.now-art { position: relative; width: 112px; height: 112px; }
.now-art img { width: 112px; height: 112px; border-radius: 12px; object-fit: cover; position: relative; z-index: 1; box-shadow: 0 8px 30px rgba(0, 0, 0, .45); }
.disc {
  position: absolute; inset: 0; border-radius: 50%;
  background: repeating-radial-gradient(circle, #0b080d 0 2px, #1b141e 2px 4px);
  box-shadow: inset 0 0 0 30px #0b080d;
}
.disc::after { content: ""; position: absolute; inset: 38%; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.now-art img:not([hidden]) + .disc { inset: 6px -14px 6px 14px; z-index: 0; }
.disc.spin { animation: spin 3.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .disc.spin { animation: none; } }
.now-info { min-width: 0; display: grid; gap: .2rem; }
.now-info h2 { font-size: 1.15rem; margin-top: .3rem; }
.now-info p { margin: 0; }
.by { color: var(--accent); font-size: .85rem; min-height: 1.2em; }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: .4rem; }
.bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s linear; }
.times { display: flex; justify-content: space-between; font-size: .75rem; font-variant-numeric: tabular-nums; }

.upnext {
  display: flex; gap: .6rem; align-items: center; margin-top: 10px; padding: .6rem .9rem;
  border: 1px dashed var(--line); border-radius: 12px; font-size: .9rem;
}
.upnext .label { color: var(--accent); font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }

.search { margin-top: 18px; }
.search-box {
  position: sticky; top: 8px; z-index: 5; display: flex; align-items: center; gap: .5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 .4rem 0 .8rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { color: var(--muted); flex: none; }
.search-box input { border: 0; background: transparent; padding: .85rem 0; box-shadow: none; }
.search-box input::-webkit-search-cancel-button { display: none; }
#searchHint { margin: .8rem 0; }

.queue { margin-top: 22px; }
.queue h3 { font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.queue > p { margin: .2rem 0 .6rem; }
.count { font-size: .8rem; background: var(--surface-2); border-radius: 999px; padding: .05rem .5rem; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 1.5rem 1rem; border: 1px dashed var(--line); border-radius: var(--radius); }

.list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: 6px; }
.row-item {
  display: flex; align-items: center; gap: .7rem; padding: 8px 10px 8px 8px;
  background: var(--surface); border: 1px solid transparent; border-radius: 12px; min-width: 0;
}
.row-item.mine { border-color: rgba(255, 178, 56, .35); }
.row-item .pos { width: 1.4rem; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; flex: none; }
.cover { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }
.meta { flex: 1; min-width: 0; }
.title { font-weight: 600; }
.sub { color: var(--muted); font-size: .85rem; }
.e { display: inline-block; margin-left: .35rem; font-size: .62rem; font-weight: 800; background: var(--muted); color: var(--bg); border-radius: 3px; padding: 0 .25rem; vertical-align: 2px; }

.add {
  width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; cursor: pointer; font-size: 1.4rem; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  display: grid; place-items: center; transition: transform .08s ease;
}
.add:active { transform: scale(.9); }
.add.done { background: var(--surface-2); color: var(--accent-2); font-size: 1.1rem; }

.votes { display: flex; flex-direction: column; align-items: center; flex: none; }
.vote {
  background: none; border: 0; cursor: pointer; color: var(--muted); padding: 2px 8px; border-radius: 8px; line-height: 0;
  min-width: 40px; min-height: 28px; display: grid; place-items: center;
}
.vote:hover { color: var(--text); }
.vote.up.on { color: var(--good); }
.vote.down.on { color: var(--bad); }
.score { font-weight: 700; font-variant-numeric: tabular-nums; font-size: .9rem; }
.score.neg { color: var(--bad); }

/* ---------- Dialog & Toast ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 1.2rem; width: min(360px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(5, 3, 8, .7); backdrop-filter: blur(3px); }
dialog form { display: grid; gap: .8rem; }
dialog p { margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: .7rem 1rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { border-color: rgba(74, 222, 128, .5); }
.toast.bad { border-color: rgba(251, 113, 133, .6); }

@media (max-width: 380px) {
  .now { grid-template-columns: 84px 1fr; }
  .now-art, .now-art img { width: 84px; height: 84px; }
}

/* ---------- Admin ---------- */
.admin { max-width: 1100px; margin: 0 auto; padding: 0 var(--gutter) 3rem; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; display: grid; gap: .75rem; }
.card h2 { font-size: 1rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card.span-2 { grid-column: span 2; }
@media (max-width: 720px) { .card.span-2 { grid-column: auto; } .grid { grid-template-columns: 1fr; } }
.field { display: grid; gap: .3rem; }
.field label, .field .lbl { font-size: .85rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .8rem; font-size: .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.controls { display: flex; gap: .5rem; flex-wrap: wrap; }
.controls .btn { flex: 1 1 auto; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: 220px; max-width: 100%; justify-self: center; }
.qr img { width: 100%; height: auto; }
.code-big { font-size: 1.8rem; font-weight: 800; letter-spacing: .2em; text-align: center; font-variant-numeric: tabular-nums; }
.mini-actions { display: flex; gap: .25rem; flex: none; }
.mini-actions button { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: .35rem .55rem; cursor: pointer; font-size: .85rem; }
.mini-actions button:hover { border-color: var(--accent); }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: .4rem; vertical-align: 1px; }
.status-dot.ok { background: var(--good); }
.status-dot.bad { background: var(--bad); }
.notice { background: rgba(255, 178, 56, .1); border: 1px solid rgba(255, 178, 56, .35); border-radius: 12px; padding: .7rem .9rem; font-size: .9rem; }
.notice.bad { background: rgba(251, 113, 133, .1); border-color: rgba(251, 113, 133, .4); }
.devices { display: grid; gap: 6px; }
.devices button { text-align: left; }
.history .row-item { opacity: .8; }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 6px; font-size: .85em; overflow-wrap: anywhere; }

/* Poster drucken: nur QR-Karte */
.print-only { display: none; }
@media print {
  body { background: #fff !important; color: #000; }
  body > *:not(#poster) { display: none !important; }
  #poster { display: grid !important; place-items: center; gap: 1.2rem; text-align: center; padding-top: 3cm; color: #000; }
  #poster h1 { font-size: 42pt; }
  #poster img { width: 11cm; height: 11cm; }
  #poster p { font-size: 18pt; margin: 0; }
}

/* Hilfsklassen (keine Inline-Styles wegen CSP) */
.row-item.np { padding: 0; background: none; }
.cover.lg { width: 64px; height: 64px; }
.list.flush { margin: 0; }
.m0 { margin: 0; }
.flex1 { flex: 1; }
.field.roomy { gap: .8rem; }

/* Feinschliff nach Screenshot-Check */
a.btn { color: var(--text); }
a.btn.primary { color: var(--accent-ink); }
.now-info .pill { justify-self: start; }
.topbar .row { flex-wrap: nowrap; }
.brand { white-space: nowrap; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; }
.score-tag { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--muted); min-width: 2.2rem; text-align: right; }
.score-tag.pos { color: var(--good); }
.score-tag.neg { color: var(--bad); }
@media (max-width: 420px) { .topbar .btn.small { padding: .35rem .6rem; font-size: .8rem; } .brand { font-size: 1rem; } }
