/* FeedbackLab -- Handy-first (Fragebogen), Beamer (Ergebnis), hell/dunkel nach Systemeinstellung
   oder Umschalter. Keine externen Ressourcen. Grundgerüst und Kopfzeile aus BusLab übernommen. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #5f6b7f;
  --line: #d5dae2;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --ok-bg: #e8f6ec;
  --bad: #dc2626;
  --bad-bg: #fdecec;
  --radius: 12px;
  --logo: #2a2068;
  /* Diagramme: Zustimmung rot ↔ blau, zweiseitig blau ↔ orange, Mitte grau, Kategorie eine Blau-Rampe.
     Stufe 1–5 von links nach rechts; *-ink = Schrift auf dem Segment. */
  --z1: #c43d3c; --z2: #f0a3a2; --z3: #cfcdc7; --z4: #86b6ef; --z5: #2a78d6;
  --t1: #256abf; --t2: #86b6ef; --t3: #cfcdc7; --t4: #f5b192; --t5: #d95926;
  --k1: #9ec5f4; --k2: #6da7ec; --k3: #3987e5; --k4: #256abf; --k5: #184f95;
  --seg-ink-strong: #ffffff; --seg-ink-light: #1d2433;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

/* Dunkles Schema: per Systemeinstellung oder per Umschalter (data-theme, theme.ts) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f; --panel: #1b212d; --ink: #e6e9ef; --muted: #9aa5b7; --line: #2f3747;
    --accent: #5b8cff; --ok: #4ade80; --ok-bg: #173323; --bad: #f87171; --bad-bg: #3a1c1c;
    --logo: #c9c3f2;
    --z1: #e66767; --z2: #7f3a3a; --z3: #4a4945; --z4: #1c5cab; --z5: #5598e7;
    --t1: #5598e7; --t2: #1c5cab; --t3: #4a4945; --t4: #7d3a1e; --t5: #ec835a;
    --k1: #184f95; --k2: #1c5cab; --k3: #2a78d6; --k4: #5598e7; --k5: #86b6ef;
    --seg-ink-strong: #0b0f17; --seg-ink-light: #e6e9ef;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161f; --panel: #1b212d; --ink: #e6e9ef; --muted: #9aa5b7; --line: #2f3747;
  --accent: #5b8cff; --ok: #4ade80; --ok-bg: #173323; --bad: #f87171; --bad-bg: #3a1c1c;
  --logo: #c9c3f2;
  --z1: #e66767; --z2: #7f3a3a; --z3: #4a4945; --z4: #1c5cab; --z5: #5598e7;
  --t1: #5598e7; --t2: #1c5cab; --t3: #4a4945; --t4: #7d3a1e; --t5: #ec835a;
  --k1: #184f95; --k2: #1c5cab; --k3: #2a78d6; --k4: #5598e7; --k5: #86b6ef;
  --seg-ink-strong: #0b0f17; --seg-ink-light: #e6e9ef;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
main { padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom))
       max(16px, env(safe-area-inset-left)); margin: 0 auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }

/* ---------------------------------------------------------------- Kopfzeile mit Logo */

.site-header {
  display: flex; align-items: center; gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px
           max(16px, env(safe-area-inset-left));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.site-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
              max-width: 1500px; width: 100%; margin: 0 auto; }
.theme-toggle { flex: none; display: grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: 50%; background: var(--bg); color: var(--ink); cursor: pointer; }
.theme-toggle .icon { width: 22px; height: 22px; }
.hs-logo { height: 30px; width: auto; color: var(--logo); flex: none; }
.site-org { font-weight: 600; color: var(--logo); }
.site-name { font-weight: 800; padding-left: 10px; border-left: 2px solid var(--line); }
.site-brand a { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.site-brand .hs-link:hover .site-org { text-decoration: underline; }
.site-footer { text-align: center; font-size: .8rem; color: var(--muted);
               padding: 24px 16px max(16px, env(safe-area-inset-bottom)); }
.site-footer a { color: inherit; }

@media (max-width: 500px) {
  .site-org { display: none; }
  .site-name { padding-left: 0; border-left: 0; }
}

/* ---------------------------------------------------------------- Knöpfe, Hinweise */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 0 20px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: var(--panel); }
.btn.danger.solid { background: var(--bad); color: #fff; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.notice { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; text-align: center; }
.notice h1 { font-size: 1.4rem; margin: 0 0 8px; }
.notice p { margin: 0 0 12px; color: var(--muted); }
.error { color: var(--bad); font-weight: 600; }

/* ---------------------------------------------------------------- Fragebogen */

#app { max-width: 720px; }
.form-head h1 { font-size: 1.6rem; margin: 4px 0; }
.form-head p { margin: 0 0 4px; color: var(--muted); }
.gruppe { margin: 24px 0 8px; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em;
          color: var(--muted); }
.frage { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
         padding: 14px; margin: 0 0 12px; min-width: 0; }
.frage legend, .frage .q { font-weight: 600; font-size: 1.05rem; padding: 0; margin-bottom: 10px; float: left; width: 100%; }
.optionen { clear: both; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.opt { position: relative; display: flex; }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt span { flex: 1; display: grid; place-items: center; text-align: center; min-height: 56px; padding: 6px 4px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); font-size: .82rem;
  line-height: 1.15; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; cursor: pointer; }
.opt input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-weight: 700; }
.opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.frage textarea { clear: both; display: block; width: 100%; min-height: 96px; padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--bg); resize: vertical; }
.frage .zaehler { text-align: right; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.tipp { font-size: .85rem; color: var(--muted); margin: 8px 0 0; }
.absenden { position: sticky; bottom: 0; padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 30%); display: flex; flex-direction: column; gap: 6px; }
.absenden .btn { width: 100%; font-size: 1.1rem; }
.danke .haken { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px;
  background: var(--ok-bg); color: var(--ok); }
.danke .haken .icon { width: 36px; height: 36px; }
.privacy { color: var(--muted); font-size: .85rem; margin-top: 1.5rem; }

/* ---------------------------------------------------------------- Verteilungs-Balken */

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .9rem; color: var(--muted); margin: 0 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.result { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
          display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.result .q { font-weight: 600; font-size: 1.05rem; }
.result .kpi { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; color: var(--muted); }
.result .kpi strong { font-size: 1.6rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar { display: flex; gap: 2px; height: 36px; border-radius: 4px; overflow: hidden; background: var(--panel); }
.bar.leer { background: var(--bg); border-radius: 4px; }
.seg { display: grid; place-items: center; min-width: 0; font-weight: 700; font-size: .9rem;
       font-variant-numeric: tabular-nums; overflow: hidden; white-space: nowrap; }
.seg.strong { color: var(--seg-ink-strong); }
.seg.light { color: var(--seg-ink-light); }
.enden { display: flex; justify-content: space-between; gap: 12px; font-size: .85rem; color: var(--muted); }
.texte { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.texte li { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- Ergebnis (Beamer) */

#live { max-width: 1500px; }
#live header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
#live .brand { font-weight: 800; font-size: 1.4rem; margin-right: auto; }
.pill { padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: .95rem; }
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.off { background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
.pill.warn { background: var(--bad-bg); color: var(--bad); }
.hero { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; background: var(--panel);
        border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 24px; margin-bottom: 16px; }
.hero .num { font-size: clamp(3.5rem, 9vw, 7rem); font-weight: 800; line-height: 1; color: var(--accent);
             font-variant-numeric: tabular-nums; }
.hero .sub { font-size: 1.2rem; color: var(--muted); }
.hero .url { margin-left: auto; font-size: 1.3rem; font-weight: 700; }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 14px; }
#live .result .q { font-size: 1.2rem; }

/* ---------------------------------------------------------------- Admin und Verlauf */

.admin { max-width: 960px; display: flex; flex-direction: column; gap: 16px; }
.admin h1 { margin: 0; }
.admin h2 { margin: 16px 0 0; font-size: 1.2rem; }
.admin .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.admin input, .admin select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); min-height: 48px; flex: 1; min-width: 200px; }
.runden { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.runden th, .runden td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.runden th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.runden td.n { font-variant-numeric: tabular-nums; text-align: right; }
.runden tr.sel td { background: var(--bg); }
.runden .aktionen { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.detail { display: flex; flex-direction: column; gap: 12px; }
.detail .results { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.table-wrap { overflow-x: auto; }

.verlauf { max-width: 1500px; }
.verlauf .results { grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); }
.trend { max-width: 100%; height: auto; display: block; overflow: visible; } /* nicht hochskalieren */
.trend text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.trend text.wert { fill: var(--ink); font-weight: 700; font-size: 13px; }
.trend .leer { fill: var(--bg); }
.trend rect:hover { opacity: .8; }
