/* AIM Live: gemeinsames Stylesheet für Teilnehmerseite, Notsteuerung, Prüfseite, Datenschutz.
   Keine externen Ressourcen, keine Webfonts. */

:root {
  --navy: #1D4E89;
  --navy-dark: #143A68;
  --navy-ink: #0E2A4D;
  --orange: #F7931E;
  --orange-soft: #FFF3E3;
  --grey: #B4B4B4;
  --grey-border: #6E6E6E;   /* Formularränder: mind. 3:1 gegen Weiß */
  --text: #1C2430;
  --muted: #4A5361;         /* 7.4:1 auf Weiß */
  --bg: #F3F5F8;
  --card: #FFFFFF;
  --ok: #1B6E2E;
  --ok-soft: #E7F4EA;
  --warn: #7A4B00;
  --warn-soft: #FFF3D6;
  --err: #A4231B;
  --err-soft: #FCEBEA;
  --radius: 14px;
  --focus: #0B2E59;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.125rem; /* 18 px */
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

[hidden] { display: none !important; }

a { color: var(--navy); text-underline-offset: 3px; }
a:hover { color: var(--navy-dark); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

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

/* ---------- Kopf und Rahmen ---------- */

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}
.topbar .brand { display: flex; align-items: center; height: 32px; }
.topbar .brand img { height: 28px; width: auto; display: block; }
.topbar .session-title {
  font-size: 1rem;
  opacity: .95;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

main {
  flex: 1;
  width: 100%;
  max-width: 592px; /* 560 px Karte plus Rand */
  margin: 0 auto;
  padding: 16px 16px 32px;
}
main.wide { max-width: 760px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(14, 42, 77, .08), 0 4px 16px rgba(14, 42, 77, .06);
  margin-bottom: 16px;
}
.card.accent { border-top: 5px solid var(--orange); }

h1, h2, h3 { color: var(--navy-ink); line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 1rem; } /* nur für Nebeninfos, nie unter 16 px */

footer.site {
  text-align: center;
  padding: 16px;
  font-size: 1rem;
  color: var(--muted);
}
footer.site a { margin: 0 8px; display: inline-block; padding: 8px 4px; }

/* ---------- Knöpfe ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 12px 22px;
  border-radius: 12px;
  border: 2px solid var(--navy);
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  width: 100%;
  touch-action: manipulation;
}
.btn:hover { background: var(--navy-dark); border-color: var(--navy-dark); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] {
  background: #E4E7EC; border-color: #C9CED6; color: #5A6270; cursor: not-allowed;
}
.btn.secondary { background: #fff; color: var(--navy); }
.btn.secondary:hover { background: #EEF3FA; color: var(--navy-dark); }
.btn.secondary:disabled { background: #F4F5F7; color: #5A6270; }
.btn.danger { background: #fff; color: var(--err); border-color: var(--err); }
.btn.danger:hover { background: var(--err-soft); }
.btn.small-btn { min-height: 48px; padding: 8px 14px; font-size: 1rem; width: auto; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn-row .btn { flex: 1 1 140px; width: auto; }

/* ---------- Formulare ---------- */

label.field-label, .field-label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="text"], textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 2px solid var(--grey-border);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 56px;
}
textarea { min-height: 120px; resize: vertical; }
input[type="text"]:focus, textarea:focus { border-color: var(--navy); }
input:disabled, textarea:disabled { background: #F4F5F7; color: #4A5361; }

.code-input {
  font-size: 2rem !important;
  letter-spacing: .3em;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace !important;
  padding-left: .3em !important; /* Ausgleich letter-spacing */
}
.code-input::placeholder { color: #9AA1AC; letter-spacing: .3em; }

.hint { color: var(--muted); font-size: 1rem; margin-top: 6px; }
.counter { color: var(--muted); font-size: 1rem; text-align: right; margin-top: 4px; }
.counter.full { color: var(--warn); font-weight: 600; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; font-weight: 700; font-size: 1.25rem; color: var(--navy-ink); margin-bottom: 14px; line-height: 1.3; }

/* ---------- Fragekarten ---------- */

.q-card { position: relative; }
.q-meta { font-size: 1rem; color: var(--muted); margin: -6px 0 12px; }
.q-image {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 10px;
  background: #EEF1F5;
  margin-bottom: 14px;
}

.options { display: grid; gap: 10px; }
.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  padding: 12px 16px;
  border: 2px solid var(--grey-border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-weight: 500;
}
.option:hover { border-color: var(--navy); }
.option input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
}
.option .mark {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border: 2px solid var(--grey-border);
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; line-height: 1;
}
.option .mark.radio { border-radius: 50%; }
.option .mark.check { border-radius: 6px; }
.option .label-text { flex: 1; }
.option .opt-img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.option input:checked ~ .mark { background: var(--orange); border-color: #C66E00; }
.option input:checked ~ .mark::after { content: "✓"; color: #1C2430; font-weight: 700; }
.option:has(input:checked) { border-color: var(--orange); background: var(--orange-soft); }
.option.is-checked { border-color: var(--orange); background: var(--orange-soft); }
.option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.option.disabled { cursor: default; }
.option.disabled:hover { border-color: var(--grey-border); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.correct:hover { border-color: var(--ok); }
.option .tag {
  font-size: .95rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.option .tag.ok { background: var(--ok); color: #fff; }
.option .tag.mine { background: var(--navy); color: #fff; }

.word-fields { display: grid; gap: 12px; }
.word-field label { font-weight: 600; display: block; margin-bottom: 4px; }

.scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.scale .option {
  flex-direction: column;
  justify-content: center;
  padding: 10px 4px;
  min-height: 64px;
  font-size: 1.4rem;
  font-weight: 700;
  gap: 0;
}
.scale .option .mark { display: none; }
.scale-labels {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 1rem; color: var(--muted); margin-top: 8px;
}
.scale-labels span:last-child { text-align: right; }

/* ---------- Status und Meldungen ---------- */

.status-line {
  margin-top: 14px;
  min-height: 1.5em;
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.status-line.center-row { justify-content: center; margin-top: 0; }
.status-line.ok { color: var(--ok); }
.status-line.pending { color: var(--muted); font-weight: 500; }
.status-line.error { color: var(--err); }
.status-line.closed { color: var(--muted); font-weight: 500; }

.notice {
  border-radius: 10px;
  padding: 12px 14px;
  background: #EEF3FA;
  border-left: 5px solid var(--navy);
  margin: 0 0 14px;
}
.notice.warn { background: var(--warn-soft); border-left-color: var(--orange); color: #3D2A00; }
.notice.error { background: var(--err-soft); border-left-color: var(--err); }
.notice.ok { background: var(--ok-soft); border-left-color: var(--ok); }

.conn-banner {
  position: sticky; top: 0; z-index: 10;
  background: var(--warn-soft);
  color: #3D2A00;
  border-bottom: 2px solid var(--orange);
  padding: 8px 16px;
  font-size: 1rem;
  text-align: center;
}

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid #C9D3E0; border-top-color: var(--navy);
  animation: spin 1s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.waiting { text-align: center; padding: 36px 20px; }
.waiting .dots { display: inline-flex; gap: 8px; margin: 8px 0 18px; }
.waiting .dots span {
  width: 12px; height: 12px; border-radius: 50%; background: var(--orange);
  animation: pulse 1.6s ease-in-out infinite;
}
.waiting .dots span:nth-child(2) { animation-delay: .25s; }
.waiting .dots span:nth-child(3) { animation-delay: .5s; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

.big-icon {
  width: 64px; height: 64px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700; margin-bottom: 12px;
}
.big-icon.info { background: #E3ECF7; color: var(--navy); }
.big-icon.warn { background: var(--warn-soft); color: var(--warn); }
.big-icon.err { background: var(--err-soft); color: var(--err); }
.big-icon.ok { background: var(--ok-soft); color: var(--ok); }
.center { text-align: center; }

details.ask {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(14, 42, 77, .08);
  margin-top: 8px;
}
details.ask summary {
  cursor: pointer;
  padding: 16px 20px;
  min-height: 56px;
  font-weight: 600;
  color: var(--navy);
  list-style: none;
  display: flex; align-items: center; gap: 10px;
}
details.ask summary::-webkit-details-marker { display: none; }
details.ask summary::before {
  content: "+"; font-size: 1.4rem; line-height: 1; width: 1.2em; text-align: center;
}
details.ask[open] summary::before { content: "−"; }
details.ask .ask-body { padding: 0 20px 20px; }

/* ---------- Notsteuerung ---------- */

.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  flex: 1 1 120px;
  background: #EEF3FA; border-radius: 10px; padding: 10px 14px;
}
.stat .num { font-size: 1.8rem; font-weight: 700; color: var(--navy-ink); line-height: 1.1; }
.stat .lbl { font-size: 1rem; color: var(--muted); }

.qrow { border: 2px solid #D5DAE2; border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fff; }
.qrow.active { border-color: var(--orange); background: var(--orange-soft); }
.qrow-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.qrow-key { font-weight: 700; color: var(--navy-ink); word-break: break-all; }
.pill {
  display: inline-block; font-size: .95rem; font-weight: 700;
  padding: 2px 10px; border-radius: 999px; background: #E4E7EC; color: #2A323D;
}
.pill.open { background: var(--ok); color: #fff; }
.pill.closed { background: #4A5361; color: #fff; }
.pill.revealed { background: var(--navy); color: #fff; }
.pill.flag { background: var(--err); color: #fff; }
.pill.hidden-p { background: #E4E7EC; color: #2A323D; }
.pill.approved { background: var(--ok-soft); color: var(--ok); }
.pill.pending-p { background: var(--warn-soft); color: var(--warn); }

.items { list-style: none; padding: 0; margin: 12px 0 0; }
.items li { border-top: 1px solid #E1E5EB; padding: 10px 0; }
.items .item-text { display: block; margin-bottom: 6px; word-break: break-word; }
.items .item-text.is-hidden { text-decoration: line-through; color: var(--muted); }
.items .item-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Prüfseite ---------- */

.traffic {
  display: flex; gap: 16px; align-items: flex-start;
}
.traffic .lamp {
  flex: 0 0 auto; width: 56px; height: 56px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff;
}
.lamp.green { background: var(--ok); }
.lamp.yellow { background: var(--orange); color: #1C2430; }
.lamp.red { background: var(--err); }
.lamp.grey { background: #8A929E; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid #E1E5EB; }
.checklist li:first-child { border-top: 0; }
.checklist .sym { font-weight: 700; width: 1.4em; flex: 0 0 auto; text-align: center; }
.checklist .sym.ok { color: var(--ok); }
.checklist .sym.warn { color: var(--warn); }
.checklist .sym.err { color: var(--err); }

details.tech { margin-top: 12px; }
details.tech summary { cursor: pointer; font-weight: 600; color: var(--navy); min-height: 48px; display: flex; align-items: center; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 0; font-size: 1rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- Textseiten ---------- */

.prose h2 { margin-top: 28px; }
.prose ul { padding-left: 1.3em; margin: 0 0 12px; }
.prose li { margin-bottom: 6px; }
.prose address { font-style: normal; margin-bottom: 12px; }

@media (min-width: 700px) {
  main { padding-top: 32px; }
  .card { padding: 28px; }
}

@media (max-width: 360px) {
  .card { padding: 16px; }
  .scale { gap: 6px; }
  .code-input { font-size: 1.6rem !important; letter-spacing: .2em; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner, .waiting .dots span { animation: none; }
}

/* Nachträge */
.q-card fieldset .notice { margin-top: 14px; margin-bottom: 0; }
.btn.danger:disabled { background: #F4F5F7; border-color: #C9CED6; color: #5A6270; }
.btn-row .btn.small-btn { flex: 1 1 90px; }
@media (max-width: 480px) {
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
}

/* ---------- v1.3: Hinweis „Antwort ändern“ ---------- */
.change-hint { margin: 10px 0 0; }

/* ---------- v1.3: Rangfolge (ranking) ---------- */
.rank-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.rank-row { display: flex; gap: 8px; align-items: stretch; }
.rank-opt {
  appearance: none;
  flex: 1 1 auto;
  min-width: 0;
  display: flex; align-items: center; gap: 14px;
  min-height: 60px;
  padding: 10px 14px;
  border: 2px solid var(--grey-border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.rank-opt:hover { border-color: var(--navy); }
.rank-opt .label-text { flex: 1; min-width: 0; overflow-wrap: break-word; }
.rank-opt .opt-img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.rank-badge {
  flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px dashed var(--grey-border);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.15rem; line-height: 1;
}
.rank-row.is-ranked .rank-opt { border-color: var(--orange); background: var(--orange-soft); }
.rank-row.is-ranked .rank-badge { border: 2px solid #C66E00; background: var(--orange); color: #1C2430; }
.rank-opt:disabled { cursor: default; color: var(--text); }
.rank-opt:disabled:hover { border-color: var(--grey-border); }
.rank-row.is-ranked .rank-opt:disabled:hover { border-color: var(--orange); }
.rank-moves { display: flex; gap: 6px; flex: 0 0 auto; }
.rank-move {
  appearance: none;
  width: 48px; min-height: 60px;
  border: 2px solid var(--navy);
  border-radius: 12px;
  background: #fff; color: var(--navy);
  font: inherit; font-size: 1.1rem; font-weight: 700;
  cursor: pointer; touch-action: manipulation;
}
.rank-move:hover { background: #EEF3FA; }
.rank-move:disabled { border-color: #C9CED6; color: #8A929E; background: #F4F5F7; cursor: not-allowed; }
.rank-summary { margin: 12px 0 0; color: var(--navy-ink); font-weight: 600; }
.rank-tools { margin-top: 10px; }
.rank-tools .btn.small-btn { min-height: 56px; flex: 0 1 auto; }
@media (max-width: 420px) {
  /* schmal: Pfeile übereinander, damit die Option genug Breite für ihren Text behält */
  .rank-moves { flex-direction: column; gap: 6px; }
  .rank-move { width: 52px; min-height: 56px; }
  .rank-opt { padding: 10px 12px; gap: 10px; }
}

/* ---------- v1.3: Fragen aus der Gruppe (+1) ---------- */
.asks-list { margin-top: 16px; }
.asks-list h2 { font-size: 1.2rem; }
.ask-items { list-style: none; padding: 0; margin: 8px 0 0; }
.ask-item { display: flex; gap: 12px; align-items: center; border-top: 1px solid #E1E5EB; padding: 10px 0; }
.ask-item:first-child { border-top: 0; }
.ask-item-body { flex: 1; min-width: 0; }
.ask-item-text { display: block; overflow-wrap: anywhere; }
.ask-item-votes { display: block; color: var(--muted); font-size: 1rem; }
.ask-item .tag {
  flex: 0 0 auto; font-size: .95rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.ask-item .tag.mine { background: var(--navy); color: #fff; }
.vote-btn {
  appearance: none; flex: 0 0 auto;
  min-width: 64px; min-height: 56px; padding: 8px 12px;
  border: 2px solid var(--navy); border-radius: 12px;
  background: #fff; color: var(--navy);
  font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.vote-btn:hover { background: #EEF3FA; }
.vote-btn.is-on { background: var(--navy); color: #fff; }
.vote-btn[aria-busy="true"] { opacity: .7; cursor: progress; }

/* ---------- v1.3: Signal-Leiste „Wie geht's?“ ---------- */
body.is-live { padding-bottom: 136px; }
.signal-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid #D5DAE2;
  box-shadow: 0 -2px 12px rgba(14, 42, 77, .08);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
}
.signal-head, .signal-btns { max-width: 560px; margin: 0 auto; }
.signal-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
  font-size: 1rem; min-height: 1.5em; margin-bottom: 6px;
}
.signal-h { font-weight: 700; color: var(--navy-ink); }
.signal-status { font-weight: 600; }
.signal-status.ok { color: var(--ok); }
.signal-status.warn { color: var(--warn); }
.signal-status.error { color: var(--err); }
.signal-wait { color: var(--muted); }
.signal-btns { display: flex; gap: 8px; }
.sig-btn {
  appearance: none;
  min-height: 56px; padding: 6px 6px;
  border: 2px solid #C9D3E0; border-radius: 12px;
  background: #fff; color: var(--navy);
  font: inherit; font-size: 1.125rem; font-weight: 600; line-height: 1.2;
  cursor: pointer; touch-action: manipulation;
  flex: 1 1 auto; min-width: min-content;
}
.sig-btn:hover { border-color: var(--navy); background: #EEF3FA; }
.sig-btn:disabled { color: #5A6270; background: #F4F5F7; border-color: #E1E5EB; cursor: not-allowed; }
.sig-btn.is-sent:disabled { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
@media (max-width: 360px) {
  .signal-bar { padding-left: 10px; padding-right: 10px; }
  .signal-btns { gap: 6px; }
  .sig-btn { padding: 4px 2px; font-size: 1rem; }
}
