:root {
  --ink: #1f2328;
  --muted: #5d6670;
  --paper: #fbfaf7;
  --card: #ffffff;
  --line: #e2ded6;
  --accent: #1d4e89;
  --accent-soft: #e8eef6;
  --ok: #1e7a46;
  --ok-soft: #e7f4ec;
  --bad: #b3261e;
  --bad-soft: #fbeaea;
  --warn: #9a5b00;
  --radius: 10px;
  --gap: 1.25rem;
  --topbar-h: 3.25rem;
  --wrap: 72rem;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.55 var(--sans); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
small { color: var(--muted); font-weight: 400; }
[hidden] { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 10; height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 max(1rem, calc((100% - var(--wrap)) / 2)); background: var(--accent); color: #fff; }
.brand { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; padding: .2rem .7rem; border-radius: 999px; background: rgba(255, 255, 255, .15); }
.clock:empty { display: none; }
.clock.is-low { background: #fff; color: var(--bad); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: var(--gap) 1rem 4rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 3vw, 2rem); margin-bottom: var(--gap); }
.start { max-width: 44rem; margin-inline: auto; }
.owner { color: var(--muted); margin-top: -.4rem; }
.instruction { color: var(--muted); font-style: italic; }
.example { font-size: .95rem; padding: .5rem .8rem; border-left: 3px solid var(--line); }
.note { font-size: .95rem; color: var(--muted); }
.hint { font-size: .9rem; color: var(--muted); }
.warn { color: var(--bad); font-weight: 600; }

.split { display: grid; grid-template-columns: minmax(15rem, 1fr) 2fr; gap: var(--gap); align-items: start; }
.split--even { grid-template-columns: 1fr 1fr; }
.sticky { position: sticky; top: calc(var(--topbar-h) + var(--notice-h, 0px) + 1rem);
  /* a panel taller than the space left under the top bar (and notice) scrolls inside itself, so its heading never slides under them */
  max-height: calc(100vh - var(--topbar-h) - var(--notice-h, 0px) - var(--below-split, 0px) - 2rem); overflow-y: auto; }
.box { background: var(--accent-soft); border-radius: var(--radius); padding: 1rem; }
.letters { list-style: none; margin: 0; padding: 0; }
.letters li { padding: .2rem 0; }
.letters b { display: inline-block; min-width: 1.4rem; color: var(--accent); }
.letters--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 0 .5rem; }

.passage, .text-card p, .letter p { font-family: var(--serif); font-size: 1.06rem; }
.passage .sub { font-style: italic; color: var(--muted); }
.text-card { border-bottom: 1px solid var(--line); padding: .5rem 0 1rem; }
.text-card:last-child { border-bottom: 0; }
.text-card header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.letter p { margin: 0 0 .9rem; line-height: 2.1; }
blockquote.letter { margin: 0 0 1rem; padding: 1rem 1.2rem; background: var(--paper); border-radius: var(--radius); }
blockquote.letter p { line-height: 1.6; }

.q { padding: .75rem 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; }
.q--row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.stem { margin: 0 0 .4rem; }
.situations { list-style: none; margin: 0; padding: 0; }
.ads { margin: 0; }
.ads img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius); display: block; }
.ads figcaption { font-size: .85rem; color: var(--muted); margin-top: .4rem; }

select.answer { font: inherit; font-size: 1rem; min-width: 4.5rem; min-height: 2.5rem; padding: .25rem .5rem; border: 1.5px solid var(--accent); border-radius: 8px; background: #fff; color: var(--ink); flex-shrink: 0; }
.radios { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.q--row .radios { flex-shrink: 1; }
.radio { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .7rem; border: 1.5px solid var(--line); border-radius: 8px; cursor: pointer; min-height: 2.5rem; }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio input { margin: 0; accent-color: var(--accent); }
.q:not(.q--row) .radios { flex-direction: column; }
.q:not(.q--row) .radio { width: 100%; }

.tabs { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: var(--gap); padding-bottom: .2rem; }
.tab { font: inherit; font-size: .95rem; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-start; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); cursor: pointer; }
.tab.is-on { border-color: var(--accent); background: var(--accent); color: #fff; }
.tab.is-on small { color: rgba(255, 255, 255, .85); }

.actions { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.btn { font: inherit; font-weight: 600; padding: .65rem 1.3rem; border-radius: 8px; border: 1.5px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; min-height: 2.75rem; }
.btn--ghost { background: #fff; color: var(--accent); }
.btn:focus-visible, .tab:focus-visible, select:focus-visible, textarea:focus-visible, .radio:has(input:focus-visible) { outline: 3px solid #f2b705; outline-offset: 2px; }

.field { display: block; margin: 1rem 0; font-weight: 600; }
.field input { display: block; width: 100%; margin-top: .3rem; font: inherit; font-weight: 400; padding: .6rem .7rem; border: 1.5px solid var(--line); border-radius: 8px; }
fieldset.field { border: 0; padding: 0; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
fieldset.field legend { width: 100%; margin-bottom: .3rem; }
textarea { width: 100%; min-height: 24rem; font: 1.05rem/1.6 var(--serif); padding: .8rem; border: 1.5px solid var(--line); border-radius: var(--radius); resize: vertical; }
.points li { margin: .2rem 0; }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; hyphens: auto; overflow-wrap: anywhere; }
th { color: var(--muted); font-weight: 600; }
.plan { margin: 1rem 0; }

.listen-part { padding: .5rem 0 1rem; border-top: 1px solid var(--line); }
.listen-part.is-current h3 { color: var(--accent); }
.player { position: sticky; top: calc(var(--topbar-h) + var(--notice-h, 0px)); z-index: 5; background: var(--accent-soft); border-radius: var(--radius); padding: 1rem; margin-bottom: var(--gap); }
.player p { margin: 0 0 .6rem; }
.bar { height: .5rem; background: #fff; border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }

.result .big { font-size: 2.6rem; font-weight: 700; margin: .5rem 0; }
.meter { position: relative; height: .9rem; background: var(--line); border-radius: 999px; margin: .5rem 0 1rem; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter i { position: absolute; top: -.3rem; bottom: -.3rem; width: 2px; background: var(--ink); }
.review audio { width: 100%; margin-bottom: .8rem; }
.review tr.ok td:nth-child(3) { color: var(--ok); }
.review tr.bad td:nth-child(3) { color: var(--bad); }
.mark { font-weight: 700; }
.evidence { margin-top: .3rem; font-size: .88rem; color: var(--muted); font-family: var(--serif); }
.essay { white-space: pre-wrap; font: 1rem/1.6 var(--serif); background: var(--paper); padding: 1rem; border-radius: var(--radius); }

@media (max-width: 860px) {
  .split, .split--even { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .q--row { flex-direction: column; align-items: stretch; }
  .q--row select.answer { align-self: flex-start; }
}
@media (max-width: 480px) {
  body { font-size: 16px; }
  .wrap { padding-inline: .6rem; }
  th, td { padding: .45rem .3rem; }
}
@media print {
  .topbar, .no-print, .review audio { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .card { border: 0; padding: 0; margin-bottom: 1.2rem; break-inside: auto; }
  tr { break-inside: avoid; }
}

/* Antwortbogen grid, R/F table, Schreiben counter */
.gap-mark { color: var(--accent); font-family: var(--sans); font-size: .85rem; }
.sheet { margin-top: var(--gap); padding: 1rem; border: 1.5px dashed var(--accent); border-radius: var(--radius); background: #fff; }
.sheet__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: .6rem; }
.sheet__cell { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; font-weight: 600; color: var(--muted); }
.sheet__cell select.answer { width: 100%; }
.sheet .sheet__cell select.answer[data-q] { min-width: 0; }
.tf { margin-top: .5rem; }
.tf th:nth-child(1), .tf td:nth-child(1) { width: 3rem; }
.tf th:nth-child(3), .tf th:nth-child(4) { width: 3.5rem; text-align: center; }
.tf__pick { padding: 0; text-align: center; vertical-align: middle; }
.tf__pick label { display: flex; align-items: center; justify-content: center; gap: .3rem; min-height: 2.75rem; cursor: pointer; font-weight: 600; }
.tf__pick input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; margin: 0; }
.tf tr:has(input:checked) td:nth-child(2) { color: var(--ink); }
.tf__pick:has(input:checked) { background: var(--accent-soft); }
.counter[data-state="ok"] .counter__state { color: var(--ok); font-weight: 600; }
.counter[data-state="out"] .counter__state { color: var(--warn); font-weight: 600; }
.verdict { font-size: 1.1rem; font-weight: 600; }
.q--row > b { min-width: 2rem; }

/* Server save status and the scoring wait */
/* its own full-width line under the top bar: pushes the page down instead of covering it */
.save-status { position: sticky; top: var(--topbar-h); z-index: 9; font-size: .9rem; font-weight: 600; padding: .45rem 1rem; text-align: center; background: #fff7e6; color: var(--warn); border-bottom: 1px solid var(--line); }
.bar--busy span { width: 30%; animation: busy 1.4s ease-in-out infinite alternate; }
@keyframes busy { from { margin-left: 0; } to { margin-left: 70%; } }
@media (prefers-reduced-motion: reduce) { .bar--busy span { animation: none; width: 100%; opacity: .5; } }

/* Teacher summary (lehrkraft.html): wide table scrolls inside its own box, never the page */
.table-scroll { overflow-x: auto; }
.teacher { min-width: 52rem; }
.teacher tr.is-open td { background: var(--accent-soft); }
.link { font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; text-decoration: underline; }
.link:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }
.account { color: var(--muted); }
.account .link { margin-left: .5em; }
