:root {
  --blue: #1f4e8c;
  --blue-light: #2f6fbd;
  --ink: #1b2434;
  --muted: #67728a;
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #dde3ee;
  --green: #2e9e6b;
  --red: #c0392b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh;
}
body.center { display: flex; align-items: center; justify-content: center; padding: 16px; }
h1 { font-size: 1.4rem; margin: 0.2em 0 0.6em; }
h2 { font-size: 1.1rem; margin: 0 0 0.8em; }
a { color: var(--blue); }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--red); }
.hidden { display: none !important; }
.upper { text-transform: uppercase; }
form.inline { display: inline; }
.notice {
  background: #eaf3ff; border: 1px solid #c4dcf8; border-radius: 8px;
  padding: 10px 14px; color: var(--blue);
}
.brand { font-weight: 700; color: var(--blue); letter-spacing: 0.02em; }
.brand span { font-weight: 400; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px 28px; box-shadow: 0 4px 18px rgba(27, 36, 52, 0.06);
}
.card.slim { width: 100%; max-width: 420px; text-align: center; }

/* Teilnahme / Abstimmen */
.joinform { display: flex; gap: 8px; margin-top: 12px; }
.joinform input {
  flex: 1; font-size: 1.2rem; padding: 12px 14px; border: 2px solid var(--border);
  border-radius: 10px; text-align: center; letter-spacing: 0.15em;
}
.joinform input:focus { outline: none; border-color: var(--blue-light); }
button {
  font-size: 1rem; padding: 12px 18px; border: none; border-radius: 10px;
  background: var(--blue); color: #fff; cursor: pointer; font-weight: 600;
}
button:hover { background: var(--blue-light); }
.options { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
button.opt {
  background: #fff; color: var(--ink); border: 2px solid var(--border);
  font-size: 1.1rem; padding: 14px; text-align: left;
}
button.opt:hover { border-color: var(--blue-light); background: #f5f9ff; }
button.opt.selected { border-color: var(--blue); background: #eaf3ff; color: var(--blue); }
.scalegrid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
button.opt.scale { width: 52px; text-align: center; padding: 12px 0; }
.scalelabels { display: flex; justify-content: space-between; margin-top: 6px;
  color: var(--muted); font-size: 0.85rem; }
.status { min-height: 1.4em; color: var(--green); font-weight: 600; }
.status.err { color: var(--red); }

/* Ergebnisseite (Beamer) */
body.results {
  background: #fff; display: flex; flex-direction: column;
  height: 100vh; overflow: hidden; padding: 40px 56px;
}
.rhead h1 { font-size: 2.6rem; margin: 0; }
.rmeta { color: var(--muted); font-size: 1.3rem; margin-top: 6px; }
.badge {
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 0.85rem; padding: 3px 12px; margin-left: 10px; vertical-align: middle;
}
#chart { flex: 1; margin-top: 28px; overflow: hidden; }
.qrbox {
  position: fixed; right: 32px; bottom: 24px; text-align: center;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px;
}
.qrbox img { width: 130px; height: 130px; display: block; }
.qrtext { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.qrtext b { color: var(--ink); letter-spacing: 0.1em; }
body.results.compact { padding: 18px 24px; }
.compact .rhead h1 { font-size: 1.6rem; }
.compact .rmeta { font-size: 1rem; }
.compact #chart { margin-top: 12px; }
.compact .qrbox { right: 14px; bottom: 12px; padding: 6px; }
.compact .qrbox img { width: 90px; height: 90px; }

/* Balken (Multiple Choice) */
.crow { display: grid; grid-template-columns: minmax(140px, 28%) 1fr; align-items: center;
  gap: 16px; margin-bottom: 18px; }
.clabel { font-size: 1.4rem; text-align: right; }
.cbar { background: var(--bg); border-radius: 10px; height: 44px; position: relative; }
.cfill { background: linear-gradient(90deg, var(--blue), var(--blue-light));
  height: 100%; border-radius: 10px; width: 0; transition: width 0.6s ease; min-width: 6px; }
.ccount { position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-weight: 700; font-size: 1.2rem; }
.compact .clabel { font-size: 1rem; }
.compact .cbar { height: 30px; }
.compact .ccount { font-size: 0.95rem; }
.compact .crow { margin-bottom: 10px; }

/* Wortwolke: Woerter werden per JS spiralfoermig absolut platziert */
.cloud { position: relative; width: 100%; height: 100%; overflow: hidden; }
.cloud span { position: absolute; line-height: 1; font-weight: 700; white-space: nowrap;
  transition: left 0.6s ease, top 0.6s ease, font-size 0.6s ease, opacity 0.6s ease; }
.cloud .cloudhint { position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); color: var(--muted); font-weight: 400;
  font-size: 1.4rem; }

/* Skala */
.scalewrap { display: flex; flex-direction: column; height: 100%; }
.avg { text-align: center; font-size: 1.4rem; color: var(--muted); margin-bottom: 12px; }
.avg b { font-size: 2.6rem; color: var(--blue); }
.hist { flex: 1; display: flex; align-items: flex-end; gap: 10px; }
.hcol { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%;
  justify-content: flex-end; }
.hbar { width: 100%; background: linear-gradient(180deg, var(--blue-light), var(--blue));
  border-radius: 8px 8px 0 0; transition: height 0.6s ease; min-height: 3px; }
.hnum { margin-top: 6px; color: var(--muted); font-size: 1.1rem; }
.hcount { font-weight: 700; margin-bottom: 4px; }
.histlabels { display: flex; justify-content: space-between; color: var(--muted);
  margin-top: 4px; }

/* Abstimmen: Sammel-Senden + Skala-Legende + Sonstiges */
.sendbtn { width: 100%; margin-top: 6px; padding: 14px; }
.scalelegend { color: var(--muted); font-size: 0.95rem; margin-top: 10px; }
.otherrow { margin-top: 10px; }
.otherrow input { text-align: left; letter-spacing: normal; font-size: 1rem; }
.otherrow input.selected { border-color: var(--blue); background: #eaf3ff; }
.otherlist { margin-top: 18px; color: var(--muted); font-size: 1.3rem; }
.compact .otherlist { font-size: 1rem; margin-top: 8px; }
.movecell { white-space: nowrap; }
button.linklike.move { text-decoration: none; font-size: 0.75rem; color: var(--muted); }
button.linklike.move:disabled { opacity: 0.25; cursor: default; }
.bigjoin { display: block; background: var(--blue); color: #fff; text-decoration: none;
  font-weight: 600; padding: 14px; border-radius: 10px; margin: 14px 0 6px; }
.bigjoin:hover { background: var(--blue-light); }

/* Buehne */
.standby { flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; font-size: 1.8rem; color: var(--muted);
  text-align: center; }
.brand.big { font-size: 2.6rem; }
.stagenav { position: fixed; left: 24px; bottom: 24px; display: flex; gap: 10px;
  opacity: 0.35; transition: opacity 0.2s; }
.stagenav:hover { opacity: 1; }
.stagenav button { width: 48px; height: 48px; border-radius: 50%; font-size: 1.3rem;
  padding: 0; }
.onstage { color: var(--green); font-weight: 600; white-space: nowrap; }
tr.staged td { background: #eaf6ef; }
.stagelogo { position: fixed; top: 26px; right: 36px; }
.stagelogo .brand { font-size: 1.2rem; }
.stagelogo img { display: block; max-height: 56px; max-width: 240px; }
.standbylogo { max-height: 120px; max-width: 60vw; }
.compact .stagelogo { top: 12px; right: 14px; }
.compact .stagelogo .brand { font-size: 0.95rem; }
.compact .stagelogo img { max-height: 34px; }

/* Mobil (Teilnehmer kommen per QR vom Smartphone) */
button { touch-action: manipulation; }
.joinform.stacked { flex-direction: column; }
.joinform.stacked button { width: 100%; padding: 14px; }
@media (max-width: 520px) {
  body.center.mobile { align-items: flex-start; padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  body.center.mobile .card.slim { max-width: none; width: 100%; padding: 20px 16px; }
  .card.slim h1 { font-size: 1.3rem; }
  button.opt { font-size: 1.1rem; padding: 16px 14px; min-height: 56px; }
  .scalegrid { gap: 10px; }
  button.opt.scale { width: calc((100% - 4 * 10px) / 5); min-height: 54px; }
  .joinform { flex-direction: column; }
  .joinform button { width: 100%; padding: 14px; }
  .status { font-size: 1.05rem; }
}

/* Verwaltung */
body.admin { padding: 0; }
.ahead { display: flex; justify-content: space-between; align-items: center;
  background: #fff; border-bottom: 1px solid var(--border); padding: 14px 28px; }
.aactions { display: flex; gap: 18px; align-items: center; }
.awrap { max-width: 1080px; margin: 24px auto; padding: 0 16px;
  display: flex; flex-direction: column; gap: 20px; }
.createform { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.createform label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem;
  color: var(--muted); }
.createform input, .createform select, .createform textarea {
  font-size: 1rem; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--ink); font-family: inherit; }
.createform .row { display: flex; gap: 12px; flex-wrap: wrap; }
.createform .row label { flex: 1; min-width: 120px; }
.createform button { align-self: flex-start; }
label.chk { flex-direction: row !important; align-items: center; gap: 8px !important;
  color: var(--ink) !important; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.85rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.code { letter-spacing: 0.12em; color: var(--blue); }
.links { white-space: nowrap; }
button.linklike { background: none; border: none; color: var(--blue); padding: 0;
  font-size: inherit; font-weight: 400; cursor: pointer; text-decoration: underline; }
button.linklike.danger { color: var(--red); }
button.pill { font-size: 0.85rem; padding: 4px 14px; border-radius: 999px; }
button.pill.open { background: var(--green); }
button.pill.closed { background: var(--muted); }

/* Add-in */
body.addin { background: #fff; }
#frame { position: fixed; inset: 0; width: 100%; height: 100%; border: none; }
.gear { position: fixed; right: 10px; top: 10px; background: rgba(27, 36, 52, 0.08);
  color: var(--muted); border-radius: 50%; width: 36px; height: 36px; padding: 0;
  font-size: 1.1rem; line-height: 1; }
.gear:hover { background: rgba(27, 36, 52, 0.16); }
.addin label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0;
  text-align: left; font-size: 0.9rem; color: var(--muted); }
.addin label input[type="text"], .addin #codeinput {
  font-size: 1.2rem; padding: 10px 12px; border: 2px solid var(--border);
  border-radius: 10px; text-align: center; letter-spacing: 0.15em; }
