/* klicknkorrekt – Grundgestaltung
 *
 * Dunkelgrün gibt Struktur (Tafel), Gelb markiert nur, was die Lehrkraft gewählt hat (Textmarker).
 * Source Sans 3 für die Oberfläche, Source Serif 4 nur für das Wortgutachten.
 */

@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/source-sans-3-400.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/source-sans-3-500.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/source-sans-3-600.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/source-sans-3-700.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/source-serif-4-400.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/source-serif-4-600.woff2") format("woff2"); }

:root {
  --green-900: #133527;
  --green-700: #1F4D3A;
  --green-100: #E3ECE6;
  --green-50: #F3F6F3;
  --yellow: #FFCC00;
  --yellow-soft: #FFF1A8;
  --ink: #15201A;
  --muted: #5E6B63;
  --faint: #8C9790;
  --line: #D9E0DA;
  --danger: #B3261E;
  --paper: #FFFFFF;

  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --radius: 4px;
  --radius-sheet: 3px;
  --topbar-h: 48px;
}

[x-cloak] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.45;
}
h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 16px; }
h2 { font-size: 17px; font-weight: 700; margin: 0; }
p { margin: 8px 0; }
a { color: var(--green-700); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--green-700); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 13.5px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Kopfleiste ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 28px; padding: 0 24px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.topbar__brand { font-weight: 700; font-size: 16px; color: var(--green-700); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.topbar__brand::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--yellow); }
.topbar__nav { display: flex; gap: 22px; height: 100%; }
.topbar__link {
  display: inline-flex; align-items: center; height: 100%;
  color: var(--muted); font-weight: 500; text-decoration: none; border-bottom: 2px solid transparent;
}
.topbar__link:hover { color: var(--ink); }
.topbar__link--active { color: var(--ink); border-bottom-color: var(--green-700); }
.topbar__link[aria-disabled="true"] { color: var(--faint); cursor: default; }
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.topbar__user form { margin: 0; }

/* ---------- Kontextleiste ---------- */
.contextbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px;
  padding: 10px 24px; background: var(--green-50); border-bottom: 1px solid var(--line);
}
.contextbar__student { font-size: 17px; font-weight: 600; }
.contextbar__ctx { color: var(--muted); }
.contextbar__progress { margin-left: auto; color: var(--muted); }

/* ---------- Bedienelemente ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 5px 13px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.btn--primary { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--green-900); border-color: var(--green-900); }
.btn--link { border-color: transparent; background: none; color: var(--green-700); padding-left: 4px; padding-right: 4px; }
.btn--link:hover:not(:disabled) { border-color: transparent; text-decoration: underline; }
.btn--danger { color: var(--danger); }
.select, .input, .textarea {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  padding: 5px 9px; min-height: 34px;
}
.select:hover, .input:hover, .textarea:hover { border-color: var(--faint); }
.textarea { width: 100%; resize: vertical; line-height: 1.5; }
.field { display: inline-flex; align-items: center; gap: 8px; }
.field .input { width: 84px; }

/* ---------- Meldungen ---------- */
.notice {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  max-width: min(560px, calc(100vw - 32px)); padding: 10px 14px; border-radius: var(--radius);
  background: var(--ink); color: #fff; box-shadow: 0 6px 20px rgba(21, 32, 26, .22);
}
.notice--error { background: var(--danger); }
.field-error { color: var(--danger); font-size: 13.5px; margin-top: 4px; }

/* ---------- Seiten ohne Korrekturmaske ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.page--narrow { max-width: 380px; padding-top: 12vh; }
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list__item { display: flex; align-items: baseline; gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.list__item a { font-weight: 600; text-decoration: none; }
.list__item a:hover { text-decoration: underline; }
.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-row label { font-weight: 600; font-size: 14px; }
.form-row .input { width: 100%; }

/* ---------- Korrekturmaske: Raster ---------- */
.layout-correction { display: grid; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.layout-correction__main { padding: 4px 24px 48px; min-width: 0; }
.side {
  position: sticky; top: var(--topbar-h); max-height: calc(100vh - var(--topbar-h)); overflow: auto;
  padding: 18px 20px 24px; background: var(--green-50); border-left: 1px solid var(--line);
  align-self: stretch;
}
.mini-total { display: none; }

/* ---------- Blöcke und Gruppen ---------- */
.block { margin-top: 22px; }
.block__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 6px; }
.block__avg { color: var(--muted); font-size: 14px; }
.group-title { margin: 14px 0 2px; font-weight: 600; color: var(--green-700); font-size: 14.5px; }

/* ---------- Kriteriumszeile ---------- */
.crit { padding: 10px 0 12px; border-top: 1px solid var(--line); }
.crit__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.crit__name {
  all: unset; cursor: pointer; font-weight: 600; display: inline-flex; align-items: baseline; gap: 6px;
  border-radius: 2px;
}
.crit__name:focus-visible { outline: 2px solid var(--green-700); outline-offset: 2px; }
.crit__chev { color: var(--faint); width: 10px; display: inline-block; font-weight: 400; transition: transform .12s; }
.crit__name[aria-expanded="true"] .crit__chev { transform: rotate(90deg); }
.crit__meta { font-weight: 400; color: var(--muted); font-size: 13.5px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.seg__item {
  all: unset; box-sizing: border-box; width: 30px; height: 28px; display: grid; place-items: center;
  font-weight: 600; color: var(--muted); border-left: 1px solid var(--line); cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.seg__item:first-child { border-left: 0; color: var(--faint); font-weight: 400; }
.seg__item:hover, .seg__item--preview { background: var(--green-100); color: var(--ink); }
.seg__item--on, .seg__item--on:hover { background: var(--yellow); color: var(--ink); font-weight: 700; }
.seg__item:focus-visible { outline: 2px solid var(--green-700); outline-offset: -2px; }

.crit__chosen { margin-top: 8px; padding-left: 10px; border-left: 3px solid var(--yellow); }
.crit__chosen .textarea {
  border-color: transparent; background: transparent; padding: 3px 6px; min-height: 0; resize: none; color: #2A3730;
  field-sizing: content; min-block-size: 2lh;
}
@supports (field-sizing: content) { .crit__chosen .textarea { min-block-size: 1lh; } }
.crit__chosen .textarea:hover { border-color: var(--line); }
.crit__chosen .textarea:focus { border-color: var(--line); background: var(--paper); }
.crit__note { font-size: 13px; color: var(--muted); padding-left: 6px; }
.crit__note .btn--link { min-height: 0; padding: 0; font-weight: 500; font-size: 13px; }
.crit__zero { margin-top: 8px; padding-left: 13px; color: var(--muted); font-size: 14px; }
.crit__preview { margin-top: 8px; padding: 3px 6px 3px 13px; border-left: 3px dashed var(--line); color: var(--faint); font-style: italic; }

.crit__list { margin-top: 6px; }
.crit__option {
  all: unset; box-sizing: border-box; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px;
  width: 100%; padding: 5px 6px; border-radius: var(--radius-sheet); color: #2A3730; cursor: pointer;
}
.crit__option:hover { background: var(--green-50); }
.crit__option:focus-visible { outline: 2px solid var(--green-700); outline-offset: -2px; }
.crit__digit {
  height: 22px; display: grid; place-items: center; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--radius-sheet); background: var(--paper);
  font-variant-numeric: tabular-nums;
}
.crit__option--zero { color: var(--faint); }
.crit__option--zero .crit__digit { color: var(--faint); font-weight: 400; }
.crit__option--empty { color: var(--faint); font-style: italic; }

/* ---------- Rechtschreibung, Schlussbemerkung ---------- */
.spelling { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 10px 0 4px; border-top: 1px solid var(--line); }
.spelling__result { flex-basis: 100%; color: var(--muted); }
.spelling__result b { color: var(--ink); }
.remark { margin-top: 26px; }
.remark label { display: block; font-weight: 700; font-size: 17px; margin-bottom: 8px; }

/* ---------- Seitenspalte ---------- */
.total {
  display: flex; align-items: baseline; gap: 14px; padding: 12px 16px; margin-bottom: 18px;
  background: var(--green-900); color: #fff; border-radius: var(--radius);
}
.total__grade { font-size: 38px; font-weight: 700; line-height: 1; color: var(--yellow); font-variant-numeric: tabular-nums; min-width: 22px; }
.total__label { font-weight: 600; }
.total__detail { display: block; color: #B7CBBF; font-size: 13px; font-weight: 400; }
.report__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.report__head h2 { font-size: 15px; }
.sheet {
  width: 100%; min-height: 320px; padding: 16px 18px; resize: vertical;
  font-family: var(--serif); font-size: 15px; line-height: 1.62; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sheet);
}
.sheet:focus { border-color: var(--faint); }
.report__state { margin: 8px 0 12px; font-size: 13px; color: var(--muted); }
.report__state--manual { color: var(--ink); }
.report__state--manual strong { color: var(--danger); font-weight: 600; }
.side__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Schmale Bildschirme (iPad hochkant) ---------- */
@media (max-width: 1020px) {
  .layout-correction { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; border-left: 0; border-top: 1px solid var(--line); }
  .mini-total {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px;
    position: sticky; top: var(--topbar-h); z-index: 10; padding: 8px 24px;
    background: var(--paper); border-bottom: 1px solid var(--line);
  }
  .mini-total__grade { font-weight: 700; font-size: 18px; }
  .mini-total .btn { margin-left: auto; }
  .topbar { gap: 18px; padding: 0 16px; }
  .contextbar, .layout-correction__main { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 640px) {
  .topbar__nav { gap: 14px; overflow-x: auto; }
  .crit__head { grid-template-columns: 1fr; }
}

/* ---------- Touch ---------- */
@media (pointer: coarse) {
  .btn, .select, .input { min-height: 44px; }
  .seg__item { width: 40px; height: 44px; }
  .crit__option { padding: 9px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

#report-text { scroll-margin-top: calc(var(--topbar-h) + 64px); }
