@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --paper: #f4f7fb;
  --grid: #dde6f2;
  --ink: #14213d;
  --ink-soft: #4a5878;
  --pen: #2447b8;
  --pen-dark: #1a3690;
  --marker: #ffe14d;
  --red: #c02626;
  --green: #1e7f4f;
  --line: #c6d2e4;
  --card: #ffffff;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 18px/1.5 var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  min-height: 100vh;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
a { color: var(--pen); }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; }
.hint { color: var(--ink-soft); font-size: .92rem; }
.error { color: var(--red); font-weight: 700; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Layout ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 20px 18px 64px; }
.wrap.narrow { max-width: 640px; }
.topbar {
  background: var(--ink); color: #fff;
}
.topbar .in {
  max-width: 980px; margin: 0 auto; padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap;
}
.topbar .account { flex-wrap: nowrap; gap: 8px; margin-left: auto; }
.topbar a.brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.topbar form { margin: 0; }
.topbar .btn { color: #fff; border-color: #ffffff66; background: transparent; }
.topbar .btn:hover { background: #ffffff22; }
.topbar .who { color: #ffffffcc; font-size: .95rem; }
.narrow-block { max-width: 640px; margin: 0 auto; }
.notice {
  border: 2px solid var(--green); border-radius: 8px; background: #fff; color: var(--green);
  font-weight: 700; padding: .6em .9em; margin: 0 0 16px;
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 16px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font: 700 1rem/1.2 var(--font); color: var(--ink); background: #fff;
  border: 2px solid var(--ink); border-radius: 8px; padding: .55em 1em;
  cursor: pointer; text-decoration: none; min-height: 44px;
}
.btn:hover { background: #eef3fb; }
.btn.primary { background: var(--pen); border-color: var(--pen); color: #fff; }
.btn.primary:hover { background: var(--pen-dark); border-color: var(--pen-dark); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: #fdeeee; }
.btn.small { min-height: 36px; padding: .3em .75em; font-size: .92rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.spread { justify-content: space-between; }
.inline { display: inline; margin: 0; }

/* ---------- Formulare ---------- */
label { font-weight: 700; }
.field { margin-bottom: 16px; }
.field > label { display: block; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 2px solid var(--line); border-radius: 8px; padding: .55em .7em; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--pen); outline: none; box-shadow: 0 0 0 3px #2447b833; }
input[type=checkbox], input[type=radio] { width: 1.25em; height: 1.25em; accent-color: var(--pen); flex: none; }
.check { display: flex; gap: 10px; align-items: center; }
.check, .check label { font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- Status ---------- */
.pill {
  display: inline-block; border-radius: 999px; padding: .1em .8em; font-size: .9rem; font-weight: 700;
  border: 2px solid var(--ink-soft); color: var(--ink-soft); background: #fff; white-space: nowrap;
}
.pill.open { border-color: var(--green); color: var(--green); }
.pill.scheduled { border-color: var(--pen); color: var(--pen); }
.pill.ended { border-color: var(--red); color: var(--red); }

/* ---------- Admin-Übersicht ---------- */
.survey { display: grid; gap: 10px; }
.survey h2 { margin: 0; }
.survey .meta { color: var(--ink-soft); font-size: .95rem; }
.survey-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.survey-actions form { margin: 0; display: inline-flex; gap: 6px; align-items: center; }
.survey-actions select { width: auto; min-height: 36px; padding: .2em .5em; font-size: .92rem; }
details.more { position: relative; }
details.more > summary { list-style: none; cursor: pointer; }
details.more > summary::-webkit-details-marker { display: none; }
details.more .menu {
  position: absolute; z-index: 5; right: 0; top: calc(100% + 6px); min-width: 210px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px;
  box-shadow: 0 6px 20px #14213d33; display: grid; gap: 6px;
}
details.more .menu form { display: block; }
details.more .menu .btn { width: 100%; justify-content: flex-start; }
.empty { text-align: center; padding: 40px 20px; }

/* ---------- Editor ---------- */
.qcard { border: 1px solid var(--line); border-left: 6px solid var(--pen); border-radius: 10px; background: #fff; padding: 14px 16px; margin-bottom: 14px; }
.qhead { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.qhead .num { font-weight: 700; margin-right: auto; }
.qhead select { width: auto; min-height: 36px; }
.addbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 22px; }
.locked-list { padding-left: 1.2em; }
.copybox { display: flex; gap: 8px; }
.copybox input { font-size: .95rem; }

/* ---------- Teilnahme (Handy) ---------- */
.take .wrap { padding-top: 14px; }
.take h1 { font-size: 1.6rem; }
fieldset.card { min-width: 0; margin: 0 0 16px; }
.btn.block { width: 100%; }
.q { margin-bottom: 18px; }
.q .qtext { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.q .qnote { color: var(--ink-soft); font-size: .92rem; margin-bottom: 8px; }
.q.has-error { border-color: var(--red); }
.opts { display: grid; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 12px; font-weight: 400;
  border: 2px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; cursor: pointer; min-height: 52px;
}
.opt:has(input:checked) { border-color: var(--pen); background: #eaf0fd; font-weight: 700; }
.opt:has(input:focus-visible) { outline: 3px solid var(--pen); outline-offset: 2px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale .opt { justify-content: center; flex-direction: column; gap: 4px; padding: 12px 4px; font-weight: 700; font-size: 1.2rem; }
.scale-ends { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: .92rem; margin-top: 6px; gap: 12px; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.center { text-align: center; }
.bigmark { display: inline-block; background: linear-gradient(transparent 58%, var(--marker) 58%); padding: 0 .15em; }

/* ---------- Live-Ansicht / Beamer ---------- */
body.live { height: 100vh; overflow: hidden; }
.live-grid {
  height: 100vh; display: grid; gap: 16px; padding: 16px;
  grid-template-columns: minmax(230px, 21vw) 1fr;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "head head" "rail stage" "foot foot";
}
.live-head { grid-area: head; display: flex; align-items: center; gap: 16px; }
.live-head h1 { margin: 0; font-size: clamp(1.3rem, 2.4vw, 2.3rem); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-head .pill { font-size: clamp(.95rem, 1.5vw, 1.4rem); }
.countdown { font-size: clamp(1.3rem, 2.4vw, 2.4rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.conn { width: 12px; height: 12px; border-radius: 50%; background: var(--green); flex: none; }
.conn.off { background: var(--red); }

.rail { grid-area: rail; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.qrbox { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.qrbox img { width: 100%; height: auto; display: block; }
.qrbox .url { margin-top: 10px; font-weight: 700; font-size: clamp(.85rem, 1.3vw, 1.25rem); word-break: break-all; }
.count { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; text-align: center; }
.count .num { font-size: clamp(2.6rem, 6vw, 6rem); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.count .lbl { font-size: clamp(.95rem, 1.4vw, 1.3rem); color: var(--ink-soft); }

.stage { grid-area: stage; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: clamp(14px, 2vw, 28px); display: flex; flex-direction: column; min-height: 0; position: relative; }
.stage .qtitle { font-size: clamp(1.5rem, 3.1vw, 3.1rem); margin: 0; }
.stage .qsub { color: var(--ink-soft); font-size: clamp(.95rem, 1.4vw, 1.3rem); margin: .2em 0 .8em; }
.resultwrap { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.result { flex: 1; min-height: 0; position: relative; }
.result.textmode { display: flex; flex-direction: column; }
.textbody { flex: 1; min-height: 0; position: relative; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .btn { min-height: 38px; padding: .25em .8em; }
.toolbar .btn[aria-pressed=true] { background: var(--ink); color: #fff; }
.none { color: var(--ink-soft); font-size: clamp(1.1rem, 2vw, 1.8rem); }

.bars { --n: 4; overflow: auto; height: 100%; font-size: clamp(.95rem, min(2.6vw, calc(55vh / (var(--n) * 2.8))), 2.6rem); }
.bar-row { display: grid; grid-template-columns: minmax(0, 30%) 1fr auto; gap: 1rem; align-items: center; margin: .55em 0; }
.bar-label span { padding: 0; }
.bar-row.lead .bar-label span { background: linear-gradient(transparent 58%, var(--marker) 58%); }
.bar-track { height: 1.7em; background: #e8eef7; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--pen); transition: width .6s ease; }
.bar-val { min-width: 5.6em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-val small { font-weight: 400; color: var(--ink-soft); font-size: .75em; }

.scale-view { display: grid; grid-template-columns: 1fr auto; gap: 2vw; height: 100%; }
.cols { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.5vw; align-items: end; height: 100%; }
.col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-height: 0; }
.col .val { flex: none; text-align: center; font-weight: 700; font-size: clamp(1.1rem, 2.2vw, 2rem); font-variant-numeric: tabular-nums; }
.col .fillwrap { flex: 1; width: 100%; display: flex; flex-direction: column; min-height: 0; }
.col .spacer { flex: 1 1 0; min-height: 0; transition: flex-grow .6s ease; }
.col .fill { flex: 0 1 0; width: 100%; background: var(--pen); border-radius: 6px 6px 0 0; transition: flex-grow .6s ease; min-height: 0; }
.col .tick { font-weight: 700; font-size: clamp(1.2rem, 2.4vw, 2.2rem); border-top: 3px solid var(--ink); width: 100%; text-align: center; padding-top: 4px; }
.col .end { color: var(--ink-soft); font-size: clamp(.8rem, 1.2vw, 1.1rem); min-height: 1.4em; text-align: center; }
.avg { align-self: center; text-align: center; padding: 0 1vw; }
.avg .big { font-size: clamp(2.6rem, 6vw, 6rem); font-weight: 700; line-height: 1; }
.avg .lbl { color: var(--ink-soft); font-size: clamp(.95rem, 1.4vw, 1.3rem); }

.cloud-box { position: absolute; inset: 0; }
.cloud-box canvas { display: block; }
.chips { display: flex; flex-wrap: wrap; gap: .6rem; align-content: flex-start; overflow: auto; height: 100%; }
.chip { display: inline-flex; align-items: center; gap: .5em; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: .25em .4em .25em 1em; font-size: clamp(1rem, 1.8vw, 1.6rem); max-width: 100%; }
.chip.is-hidden { opacity: .5; }
.chip.is-hidden .t { text-decoration: line-through; }
.chip button { font: inherit; border: 0; background: #eef3fb; color: var(--ink); width: 1.7em; height: 1.7em; border-radius: 50%; cursor: pointer; }
.chip button:hover { background: var(--red); color: #fff; }

.veil { position: absolute; inset: 0; background: #fff; display: none; align-items: center; justify-content: center; text-align: center; flex-direction: column; gap: .5em; z-index: 3; border-radius: 12px; font-size: clamp(1.3rem, 2.6vw, 2.6rem); }
.veil.on { display: flex; }

.live-foot { grid-area: foot; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; transition: opacity .4s; }
.live-foot .dots { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 auto; }
.live-foot .dots .btn { min-width: 44px; padding: .2em .5em; }
.live-foot .dots .btn[aria-current=true] { background: var(--ink); color: #fff; }
body.idle .live-foot { opacity: 0; }
body.idle { cursor: none; }

.overlay { position: fixed; inset: 0; z-index: 20; background: #fff; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 1rem; padding: 2vw; text-align: center; }
.overlay.on { display: flex; }
.overlay img { height: min(72vh, 80vw); width: auto; max-width: 100%; }
.overlay .u { font-size: clamp(1.4rem, 3.4vw, 3.2rem); font-weight: 700; word-break: break-all; }
.overlay .hint { font-size: clamp(1rem, 1.6vw, 1.4rem); }

@media (max-width: 800px) {
  body.live { height: auto; overflow: auto; }
  .live-grid { height: auto; grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: "head" "stage" "rail" "foot"; }
  .stage { min-height: 70vh; }
  .rail { flex-direction: row; flex-wrap: wrap; }
  .rail > * { flex: 1 1 200px; }
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill, .col .fill, .col .spacer, .live-foot { transition: none; }
}

/* ---------- Ergebnisse für Lernende ---------- */
.res h2 { font-size: 1.15rem; }
.pbar { margin: 10px 0; }
.pl { display: flex; justify-content: space-between; gap: 12px; }
.pv { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; }
.ptrack { height: 14px; background: #e8eef7; border-radius: 6px; overflow: hidden; margin-top: 4px; }
.pfill { height: 100%; background: var(--pen); }
.pbar.lead .pl > span:first-child { background: linear-gradient(transparent 58%, var(--marker) 58%); }
.wordlist { margin: 0; padding-left: 1.2em; }
