:root {
  --bg: #fafafa;
  --card: #ffffff;
  --text: #16161a;
  --muted: #6b6b76;
  --line: #e7e7ec;
  --soft: #f1f1f5;
  --yes: #12a150;
  --yes-soft: #e3f6eb;
  --no: #e0245e;
  --no-soft: #fde7ee;
  --wait: #b7791f;
  --wait-soft: #fdf3e1;
  --posted: #6d4aff;
  --posted-soft: #ece8ff;
  --grad: linear-gradient(45deg, #f9ce34, #ee2a7b 50%, #6228d7);
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f12;
    --card: #19191e;
    --text: #f2f2f5;
    --muted: #9a9aa6;
    --line: #2a2a31;
    --soft: #22222a;
    --yes-soft: #12301f;
    --no-soft: #3a1422;
    --wait-soft: #33280f;
    --posted-soft: #241c4d;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted, .sub { color: var(--muted); }
.sub { font-size: 13px; display: block; }

/* ---------- Logo ---------- */
.logo-ring {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--grad); padding: 3px; margin: 0 auto 14px;
}
.logo-ring img {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--card); border: 3px solid var(--card); display: block;
}
.logo-ring.small { width: 40px; height: 40px; margin: 0; padding: 2px; }
.logo-ring.small img { border-width: 2px; }

/* ---------- Anmeldung ---------- */
.join { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.join-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 24px; padding: 32px 24px; box-shadow: var(--shadow);
}
.join-card h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.join-card form { display: grid; gap: 12px; margin-top: 24px; text-align: left; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, textarea {
  font: inherit; color: var(--text); background: var(--soft);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid #ee2a7b55; border-color: #ee2a7b; }
textarea { resize: vertical; min-height: 44px; }
.err { color: var(--no); margin: 0; min-height: 1.2em; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); margin: 16px 0 0; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 11px 16px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--grad); color: #fff; border: 0; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--no); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Kopf ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { font-size: 16px; letter-spacing: -.01em; }
.chip-btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 12px; font-size: 13px; white-space: nowrap; max-width: 55vw; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Filter ---------- */
.filters {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px;
  scrollbar-width: none; max-width: 1100px; margin: 0 auto;
}
.filters::-webkit-scrollbar { display: none; }
.filters button {
  flex: none; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; white-space: nowrap;
}
.filters button b { font-weight: 600; color: var(--muted); margin-left: 2px; }
.filters button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters button.on b { color: inherit; opacity: .7; }

/* ---------- Raster ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 120px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.thumb {
  position: relative; aspect-ratio: 1; background: var(--soft); border: 0; padding: 0; display: block; width: 100%;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.thumb .badge { position: absolute; left: 10px; top: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.card-body { padding: 12px; display: grid; gap: 10px; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.card-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.progress { height: 5px; border-radius: 99px; background: var(--soft); overflow: hidden; display: flex; }
.progress i { display: block; height: 100%; background: var(--yes); transition: width .3s; }
.progress i.no { background: var(--no); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px;
  padding: 4px 10px; font-size: 12px; font-weight: 700; letter-spacing: .01em;
}
.badge.pending { background: var(--wait-soft); color: var(--wait); }
.badge.approved { background: var(--yes-soft); color: var(--yes); }
.badge.rejected { background: var(--no-soft); color: var(--no); }
.badge.posted { background: var(--posted-soft); color: var(--posted); }
.thumb .badge.pending { background: #fff6e3; }
.thumb .badge.approved { background: #e3f6eb; }
.thumb .badge.rejected { background: #fde7ee; }
.thumb .badge.posted { background: #ece8ff; }

/* ---------- Abstimmen ---------- */
.vote-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vote {
  border: 1.5px solid var(--line); background: transparent; border-radius: 12px;
  padding: 9px 8px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .1s; white-space: nowrap;
}
.vote:active { transform: scale(.97); }
.vote.yes.on { background: var(--yes); border-color: var(--yes); color: #fff; }
.vote.no.on { background: var(--no); border-color: var(--no); color: #fff; }
.vote.yes:not(.on):hover { border-color: var(--yes); color: var(--yes); }
.vote.no:not(.on):hover { border-color: var(--no); color: var(--no); }
.vote-row.big .vote { padding: 13px; font-size: 15px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 6;
  display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700;
  background: var(--grad); border-radius: 999px; padding: 14px 20px 14px 16px;
  box-shadow: 0 10px 30px rgba(238,42,123,.35); cursor: pointer; user-select: none;
}
.fab svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; fill: none; }
.fab.busy { opacity: .7; pointer-events: none; }

.drop {
  position: fixed; inset: 0; z-index: 20; background: rgba(15,15,18,.55);
  display: grid; place-items: center; padding: 24px;
}
.drop div {
  border: 3px dashed #fff; border-radius: 24px; color: #fff; font-size: 22px; font-weight: 700;
  padding: 60px 40px; text-align: center;
}

.empty { text-align: center; color: var(--muted); padding: 60px 16px; }
.empty .big { font-size: 44px; display: block; margin-bottom: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Dialoge ---------- */
dialog.sheet {
  border: 0; padding: 0; background: var(--card); color: var(--text);
  width: min(920px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  border-radius: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.35); overflow: auto;
}
dialog.sheet.narrow { width: min(440px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10,10,14,.6); backdrop-filter: blur(4px); }
dialog[open] { display: grid; grid-template-columns: 1.3fr 1fr; animation: pop .2s ease; }
dialog.narrow[open] { display: block; }
.close {
  position: absolute; right: 12px; top: 12px; z-index: 2; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 15px;
}
.narrow .close { background: var(--soft); color: var(--text); }
.detail-img { background: #000; display: grid; place-items: center; min-height: 300px; }
.detail-img img { max-width: 100%; max-height: calc(100dvh - 24px); display: block; object-fit: contain; }
.detail-body { padding: 20px; display: grid; gap: 14px; align-content: start; }
.detail-body h2, .detail-body h3 { margin: 0; }
.detail-body h3 { font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.d-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-right: 36px; }
.caption-box { display: grid; gap: 6px; }
.caption-box label { font-size: 13px; }

.voters { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.voters li {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line);
}
.voters li:last-child { border-bottom: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 13px; color: #fff;
}
.voters .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voters .v { font-size: 13px; font-weight: 600; }
.v.yes { color: var(--yes); } .v.no { color: var(--no); } .v.wait { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 720px) {
  dialog[open] { grid-template-columns: 1fr; }
  dialog.sheet { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  dialog.sheet.narrow { height: auto; max-height: 85dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  .detail-img { min-height: 0; }
  .detail-img img { max-height: 60dvh; }
  .detail-body { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .close { top: calc(12px + env(safe-area-inset-top)); }
  .grid { gap: 10px; grid-template-columns: repeat(2, 1fr); }
  .card-body { padding: 10px; gap: 8px; }
  .vote { padding: 8px 4px; font-size: 13px; }
}
