/* Atkinson Hyperlegible – SIL Open Font License, lokal eingebunden */
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap;
  src: url("/static/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap;
  src: url("/static/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }

:root {
  --ink: #1b2540;
  --ink-soft: #4a5470;
  --paper: #eef1f6;
  --card: #ffffff;
  --line: #d3d9e4;
  --marker: #f7d84a;
  --marker-deep: #e9c21c;
  --alert: #b3321e;
  --ok: #1f7a4d;
  --radius: 10px;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8ecf6; --ink-soft: #aab3cc; --paper: #121829; --card: #1b2338; --line: #2f3957;
    --alert: #ff8a73; --ok: #6fd3a0;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 18px/1.5 var(--font); min-height: 100vh;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -.01em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: inherit; }
.muted { color: var(--ink-soft); }
.hidden { display: none !important; }
.wrap { width: min(860px, 100% - 2rem); margin-inline: auto; }
.wrap.wide { width: min(1100px, 100% - 2rem); }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Textmarker-Motiv: Hervorhebung wie mit einem Leuchtstift gezogen */
.marker {
  background: linear-gradient(transparent 55%, var(--marker) 55%, var(--marker) 92%, transparent 92%);
  padding: 0 .12em;
}

/* Kopfzeile */
.top { border-bottom: 1px solid var(--line); background: var(--card); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; }
.brand { font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.brand span { color: var(--ink-soft); font-weight: 400; }

/* Schaltflächen */
button, .btn {
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: .4rem;
  padding: .65rem 1.1rem; border-radius: var(--radius);
  border: 2px solid var(--ink); background: var(--card); color: var(--ink); min-height: 46px;
}
button:hover, .btn:hover { background: var(--paper); }
button.primary, .btn.primary { background: var(--marker); border-color: var(--ink); }
button.primary:hover, .btn.primary:hover { background: var(--marker-deep); }
button.danger { border-color: var(--alert); color: var(--alert); }
button.ghost, .btn.ghost { border-color: transparent; background: transparent; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.row.space { justify-content: space-between; }

/* Karten & Formulare */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem 1.3rem; margin-bottom: 1rem;
}
label.field { display: block; font-weight: 700; margin-bottom: .35rem; }
input[type=text], input[type=password], textarea, select {
  width: 100%; font: inherit; padding: .65rem .8rem; border-radius: 8px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
}
input[type=text]:focus, input[type=password]:focus, textarea:focus, select:focus {
  border-color: var(--ink); outline: none;
}
textarea { min-height: 7rem; resize: vertical; }
.hint { font-size: .9rem; color: var(--ink-soft); margin-top: .3rem; }
.error { color: var(--alert); font-weight: 700; margin: .6rem 0; }
.notice { background: var(--marker); color: #1b2540; padding: .7rem 1rem; border-radius: var(--radius); font-weight: 700; }

/* Startseite */
.hero { padding: clamp(2.5rem, 8vw, 5.5rem) 0 2rem; }
.hero p.lead { font-size: 1.3rem; max-width: 34rem; color: var(--ink-soft); }
.steps { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin: 2rem 0 3rem; }
.steps .card { margin: 0; }

/* Fragen-Editor */
.q-head { display: flex; gap: .6rem; align-items: flex-start; }
.q-head > :first-child { flex: 1; }
.q-type { width: auto; min-width: 11rem; }
.opt-row { display: flex; gap: .5rem; margin-bottom: .45rem; }
.opt-row input { flex: 1; }
.checks { display: flex; flex-wrap: wrap; gap: 1.2rem; margin-top: .7rem; }
.checks label { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; }
input[type=checkbox], input[type=radio] { width: 1.25rem; height: 1.25rem; accent-color: var(--ink); }

/* Umfragenliste */
.survey-item { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.survey-item h3 { margin: 0 0 .15rem; }
.pill { display: inline-block; padding: .1rem .6rem; border-radius: 99px; font-size: .85rem; font-weight: 700; border: 2px solid var(--ink); }
.pill.open { background: var(--marker); color: #1b2540; }
.pill.closed { color: var(--ink-soft); border-color: var(--line); }

/* Auswertung */
.result { margin-bottom: 1.1rem; }
.result h3 { margin-bottom: .2rem; }
.bar-row { display: grid; grid-template-columns: minmax(5.5rem, 14rem) 1fr 7rem; gap: .7rem; align-items: center; margin: .4rem 0; }
.bar-label { overflow-wrap: anywhere; }
.bar-track { height: 2rem; position: relative; }
.bar {
  height: 100%; background: var(--marker); border-radius: 3px 12px 5px 11px; min-width: 4px;
  transform: rotate(-.35deg); transition: width .5s ease;
}
.bar-num { white-space: nowrap; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.avg { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.avg small { font-size: 1rem; font-weight: 400; color: var(--ink-soft); }
.texts { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .5rem; }
.texts li { background: var(--paper); border-left: 6px solid var(--marker); padding: .6rem .9rem; border-radius: 4px 8px 8px 4px; overflow-wrap: anywhere; white-space: pre-wrap; }
.live-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--ok); margin-right: .4rem; }
@media (prefers-reduced-motion: no-preference) {
  .live-dot { animation: pulse 2s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: .35; } }

/* QR-Vollbild */
.qr-overlay {
  position: fixed; inset: 0; background: #fff; color: #1b2540; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem; padding: 1rem; text-align: center;
}
.qr-overlay h2 { font-size: clamp(1.4rem, 3.5vw, 2.4rem); margin: 0; }
.qr-box { width: min(70vh, 90vw); aspect-ratio: 1; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-url { font-size: clamp(1rem, 2.2vw, 1.5rem); font-weight: 700; overflow-wrap: anywhere; }
.qr-count { font-size: clamp(1.1rem, 2.5vw, 1.8rem); }
.qr-overlay button { position: absolute; top: 1rem; right: 1rem; }

/* Klassen-Seite */
.survey-page { padding: 1.5rem 0 4rem; }
.q-card h2 { font-size: 1.25rem; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.choice-grid { display: grid; gap: .5rem; }
.pick { position: relative; }
.pick input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pick span {
  display: flex; align-items: center; justify-content: center; text-align: center; gap: .5rem;
  min-height: 56px; padding: .6rem .8rem; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--card); font-weight: 700;
}
.choice-grid .pick span { justify-content: flex-start; text-align: left; }
.pick input:checked + span { background: var(--marker); border-color: var(--ink); color: #1b2540; }
.pick input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.scale-ends { display: flex; justify-content: space-between; font-size: .9rem; color: var(--ink-soft); margin-top: .35rem; }
.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.req { color: var(--alert); }
.thanks { text-align: center; padding: 3rem 0; }
.thanks h1 { font-size: 2.2rem; }

@media (max-width: 600px) {
  body { font-size: 17px; }
  .bar-row { grid-template-columns: 1fr 6.5rem; }
  .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .q-head { flex-direction: column; }
  .q-type { width: 100%; }
}
@media print {
  .top, .no-print, button { display: none !important; }
  body { background: #fff; }
}

/* Fragetyp-Auswahl im Editor */
.q-block { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.q-title { margin-bottom: .5rem; }
.q-block > input[type=text] { margin-bottom: .7rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
button.chip { min-height: 40px; padding: .4rem .9rem; font-size: .95rem; border-width: 1px; border-color: var(--line); }
button.chip[aria-pressed="true"] { background: var(--marker); border-color: var(--ink); border-width: 2px; color: #1b2540; }
button.small { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
button.ghost.small { padding: .2rem .5rem; }
