/* Prüfungen: Editor, Vorschau, Freigaben. Baut auf app.css auf. */

main.wide { max-width: 1360px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.crumbs { margin: 0 0 .35rem; font-size: .92rem; color: var(--ink-soft); }
.crumbs a { color: var(--ink-soft); }
.danger-link, .danger { color: var(--red-pen); }
.plain { list-style: none; padding: 0; margin: 0 0 .8rem; }
.plain li { margin-bottom: .2rem; }
.panel-title { font-size: 1.1rem; margin: 0 0 .8rem; }
.panel h3 { margin-top: 0; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 1.1rem 0; }

textarea { max-width: none; resize: vertical; line-height: 1.45; }
input.narrow, .narrow input { width: 7rem; }
input[type="number"], input[type="datetime-local"] {
  font: inherit; padding: .45rem .6rem; border: 1.5px solid var(--rule);
  border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
input[type="number"]:focus, input[type="datetime-local"]:focus { border-color: var(--pen); outline: none; box-shadow: 0 0 0 3px var(--pen-tint); }
input[type="number"] { width: 7rem; }

.row-fields { display: flex; flex-wrap: wrap; gap: 0 1.25rem; align-items: flex-start; }
.row-fields > .grow { flex: 1 1 18rem; min-width: 0; }
.row-fields input[type="text"] { max-width: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: var(--radius);
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1rem; cursor: pointer; list-style: none;
}
.icon-btn:hover:not([disabled]) { border-color: var(--pen); color: var(--pen); }
.icon-btn[disabled] { opacity: .35; cursor: default; }
summary.icon-btn::-webkit-details-marker { display: none; }

/* --- Aufgabentypen ------------------------------------------------------- */
.kind {
  display: inline-block; font-size: .78rem; font-weight: 600; letter-spacing: .01em;
  padding: .08rem .5rem; border-radius: 4px; vertical-align: .15em;
  border: 1px solid currentColor;
}
.kind-python { color: #1f5f99; background: #e8f1fa; }
.kind-mc { color: #6b3fa0; background: #f2ecfa; }
.kind-text { color: #7a5200; background: #fbf3e2; }
.kind-cloze { color: #2e7d4f; background: #e7f4ec; }
.kind-turtle { color: #0f6e6e; background: #e3f4f4; }
.kind-parsons { color: #8a3b12; background: #fbece3; }
.kind-output { color: #33508f; background: #e9eefb; }
.kind-matching { color: #7a2e5c; background: #f8e9f2; }
.kind-numeric { color: #4d5a12; background: #f1f4df; }

/* --- Aufgabenliste ------------------------------------------------------------ */
.intro-box {
  background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--rule);
  border-radius: var(--radius); padding: .9rem 1.2rem; margin-bottom: 1.25rem;
}
.question-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.question-item {
  display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto; gap: .9rem;
  align-items: start; background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .6rem;
  scroll-margin-top: 1rem;
}
.question-item:target { border-color: var(--pen); box-shadow: 0 0 0 3px var(--pen-tint); }
.q-num {
  font-weight: 700; font-size: 1.25rem; color: var(--pen); text-align: center;
  border: 2px solid var(--pen); border-radius: 50%; width: 2.4rem; height: 2.4rem; line-height: 2.1rem;
}
.q-head { display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: baseline; }
.q-title { font-weight: 600; font-size: 1.05rem; }
.q-points { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink-soft); font-weight: 600; }
.q-snippet { margin: .3rem 0 .2rem; color: var(--ink-soft); font-size: .95rem; overflow-wrap: anywhere; }
.q-actions { display: flex; gap: .3rem; align-items: center; }
.more { position: relative; }
.more-menu {
  position: absolute; right: 0; top: 2.3rem; z-index: 5; min-width: 13rem;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(27, 42, 74, .12); padding: .5rem .8rem;
}
.more-menu form { margin: .25rem 0; }
@media (max-width: 640px) {
  .question-item { grid-template-columns: minmax(0, 1fr); }
  .q-num { display: none; }
}

.add-question h3 { margin-bottom: .6rem; }
.kind-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .6rem; }
.kind-button {
  display: flex; flex-direction: column; gap: .2rem; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--rule); border-radius: var(--radius);
  padding: .75rem .9rem; border-left-width: 5px;
}
.kind-button:hover { border-color: var(--pen); color: var(--ink); }
.kind-button.kind-python { border-left-color: #1f5f99; }
.kind-button.kind-mc { border-left-color: #6b3fa0; }
.kind-button.kind-text { border-left-color: #b07a10; }
.kind-button.kind-cloze { border-left-color: #2e7d4f; }
.kind-button.kind-turtle { border-left-color: #0f6e6e; }
.kind-button.kind-parsons { border-left-color: #8a3b12; }
.kind-button.kind-output { border-left-color: #33508f; }
.kind-button.kind-matching { border-left-color: #7a2e5c; }
.kind-button.kind-numeric { border-left-color: #4d5a12; }
.kind-button .kind-name { font-weight: 600; }
.kind-button .kind-desc { color: var(--ink-soft); }

.instance-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.instance-list li { padding: .6rem 0; border-bottom: 1px solid var(--rule); }
.instance-list li:first-child { padding-top: 0; }

.status { display: inline-block; font-size: .82rem; padding: .05rem .5rem; border-radius: 999px; border: 1px solid var(--rule); white-space: nowrap; }
.status-draft { color: var(--ink-soft); background: var(--paper); }
.status-scheduled { color: var(--pen); border-color: var(--pen); background: var(--pen-tint); }
.status-open { color: var(--green); border-color: var(--green); background: var(--green-tint); font-weight: 600; }
.status-closed { color: var(--ink-soft); background: #eef0f4; }

/* --- Markdown-Feld mit Vorschau --------------------------------------------- */
.md-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 900px) { .md-split { grid-template-columns: minmax(0, 1fr); } }
.md-input, .code-input { width: 100%; }
.md-tools { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: baseline; margin-top: .35rem; }
.md-help summary { cursor: pointer; color: var(--pen); font-size: .9rem; }
.md-help table { margin-top: .4rem; background: var(--surface); border: 1px solid var(--rule); }
.md-help td { padding: .25rem .5rem; }
.md-preview-wrap { min-width: 0; }
.md-preview-label { font-size: .8rem; color: var(--ink-soft); margin-bottom: .2rem; }
.md-preview {
  border: 1.5px dashed var(--rule); border-radius: var(--radius); padding: .6rem .9rem;
  min-height: 6rem; background: #fcfdfe; overflow-wrap: anywhere;
}
.md-preview.is-empty::before { content: "…"; color: var(--ink-soft); }

.code-input {
  font-family: var(--mono); font-size: .92rem; line-height: 1.5; tab-size: 4;
  background: #fbfcfe; white-space: pre; overflow-x: auto;
}

/* --- Formatierter Text --------------------------------------------------------- */
.prose { line-height: 1.6; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose table, .prose pre, .prose blockquote { margin: 0 0 .8em; }
.prose h1, .prose h2, .prose h3 { margin: 1em 0 .4em; }
.prose img { max-width: 100%; height: auto; border-radius: 4px; }
.prose code { background: #eef1f7; padding: .05em .3em; border-radius: 3px; }
.prose pre code, .prose .codehilite code { background: none; padding: 0; }
.prose .codehilite, .prose pre, .code-block {
  background: #f5f7fb; border: 1px solid var(--rule); border-radius: var(--radius);
  padding: .6rem .8rem; overflow-x: auto; font-family: var(--mono); font-size: .9rem; line-height: 1.5;
}
.code-block { margin: .3rem 0 .6rem; white-space: pre; }
.prose .codehilite pre { margin: 0; padding: 0; border: 0; background: none; }
.prose table { border-collapse: collapse; width: auto; }
.prose th, .prose td { border: 1px solid var(--rule); padding: .3rem .6rem; }
.prose blockquote { border-left: 3px solid var(--rule); padding-left: .8rem; color: var(--ink-soft); }
.prose.inline p { display: inline; margin: 0; }

input.gap {
  width: auto; max-width: 100%; padding: .1rem .35rem; font: inherit;
  border: 0; border-bottom: 2px solid var(--pen); border-radius: 0; background: var(--pen-tint);
}
code input.gap { font-family: var(--mono); }
.gap-solution {
  display: inline-block; padding: 0 .35rem; background: var(--green-tint);
  border-bottom: 2px solid var(--green); font-weight: 600;
}

/* --- Aufgaben-Editor ------------------------------------------------------------ */
.mc-options { padding-left: 1.4rem; margin: 0 0 .8rem; }
.mc-row { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: .5rem; }
.mc-row::marker { color: var(--ink-soft); }
.mc-correct { display: flex; align-items: center; gap: .3rem; padding-top: .55rem; white-space: nowrap; cursor: pointer; }
.mc-correct input { width: 1.1rem; height: 1.1rem; accent-color: var(--green); }
.mc-text { flex: 1; min-height: 2.5rem; overflow: hidden; }

.explain { margin-bottom: 1rem; }
.explain summary { cursor: pointer; color: var(--pen); }
.explain ul { margin: .5rem 0 0; padding-left: 1.2rem; }

.test-card {
  border: 1px solid var(--rule); border-left: 4px solid #1f5f99; border-radius: var(--radius);
  padding: .8rem 1rem .4rem; margin: 0 0 .8rem; background: #fbfcfe; min-width: 0;
}
.test-card.is-deleted { opacity: .5; border-left-color: var(--red-pen); }
.test-card.has-error { border-color: var(--red-pen); }
.test-label { display: block; font-weight: 700; margin-bottom: .4rem; }
.test-label::after { content: " " attr(data-n); }
.test-card .field { margin-bottom: .7rem; }
.checks-inline { display: flex; flex-wrap: wrap; gap: 0 1.5rem; }
.test-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1.5rem; }
.danger-check { color: var(--red-pen); font-weight: 400; cursor: pointer; }

.form-actions {
  position: sticky; bottom: 0; z-index: 4;
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  background: rgba(246, 248, 251, .96); border-top: 1px solid var(--rule);
  padding: .8rem 0; margin-top: -0.5rem;
}

.field ul#id_scoring, .field ul#id_rounding, .field div#id_scoring, .field div#id_rounding { list-style: none; padding: 0; margin: 0; }
.field #id_scoring label, .field #id_rounding label { display: flex; gap: .5rem; align-items: baseline; font-weight: 400; margin-bottom: .3rem; }
.field-help { margin: -.6rem 0 1rem; }

/* Bildauswahl */
.image-dialog {
  width: min(52rem, calc(100vw - 2rem)); max-height: calc(100vh - 4rem);
  border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.25rem;
}
.image-dialog::backdrop { background: rgba(27, 42, 74, .35); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; font-size: 1.15rem; }
.upload-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .8rem 0; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .6rem; }
.image-choice {
  display: flex; flex-direction: column; gap: .3rem; align-items: stretch; font: inherit;
  background: var(--surface); border: 1.5px solid var(--rule); border-radius: var(--radius);
  padding: .4rem; cursor: pointer; text-align: left;
}
.image-choice:hover { border-color: var(--pen); }
.image-choice img { width: 100%; height: 6rem; object-fit: contain; background: var(--paper); }

.image-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.image-card { margin: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: .6rem; }
.image-card img { width: 100%; height: 9rem; object-fit: contain; background: var(--paper); display: block; }
.image-card figcaption { margin-top: .5rem; display: flex; flex-direction: column; gap: .3rem; }
.copy-row { display: flex; gap: .3rem; }
.copy-row input { flex: 1; min-width: 0; padding: .25rem .4rem; }
.upload-panel { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-end; }
.upload-panel .field { margin: 0; }

/* --- Notenskala ---------------------------------------------------------------- */
.grade-table { max-height: 32rem; overflow-y: auto; }
.grade-table th { position: sticky; top: 0; }
.grade-table tr.below td:last-child { color: var(--red-pen); }

/* --- Vorschau / Studentensicht -------------------------------------------------- */
.preview-banner {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem 1rem; align-items: center;
  background: var(--amber-tint); border: 1px solid #e8cf94; border-radius: var(--radius);
  padding: .6rem 1rem; margin-bottom: 1.5rem;
}
.preview-banner .small { margin-left: .5rem; }
.exam-sheet { max-width: 52rem; margin: 0 auto; }
.exam-sheet-head { border-bottom: 2px solid var(--pen); margin-bottom: 1.25rem; padding-bottom: .5rem; }
.exam-sheet-head h1 { margin-bottom: .2rem; }
.exam-question {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 1.1rem 1.4rem 1.3rem; margin-bottom: 1.25rem;
}
.eq-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; margin-bottom: .6rem; }
.eq-head h2 { margin: 0; font-size: 1.15rem; }
.eq-points { white-space: nowrap; color: var(--ink-soft); font-weight: 600; }
.eq-prompt { margin-bottom: 1rem; }
.eq-options { border: 0; padding: 0; margin: 0; }
.eq-options legend { padding: 0; margin-bottom: .5rem; }
.eq-option {
  display: flex; gap: .7rem; align-items: baseline; padding: .55rem .75rem;
  border: 1.5px solid var(--rule); border-radius: var(--radius); margin-bottom: .45rem; cursor: pointer;
}
.eq-option:hover { border-color: var(--pen); }
.eq-option input { flex: none; width: 1.1rem; height: 1.1rem; accent-color: var(--pen); }
.eq-option.is-correct { border-color: var(--green); background: var(--green-tint); }
.eq-text { width: 100%; max-width: none; }
.eq-cloze { line-height: 2.1; }
.eq-code { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.eq-code-bar { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem .7rem; background: #eef1f7; border-bottom: 1px solid var(--rule); }
.eq-code .code-input { border: 0; border-radius: 0; }
.example { margin-top: .8rem; }
.solution { margin-top: .9rem; padding: .7rem .9rem; border-left: 4px solid var(--green); background: var(--green-tint); border-radius: 0 var(--radius) var(--radius) 0; }
.tests-summary { margin-top: .8rem; }
.tests-summary ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* Ausgabe vorhersagen */
.eq-program .codehilite { margin: 0 0 .7rem; }
.eq-program .codehilite pre { margin: 0; }
.eq-label { display: block; font-weight: 600; margin: .3rem 0 .25rem; }
.eq-output { font-family: var(--mono); font-size: .92rem; white-space: pre; overflow-wrap: normal; overflow-x: auto; }

/* Zuordnung */
.eq-matching { border-collapse: collapse; width: 100%; }
.eq-matching td { padding: .45rem .5rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.eq-matching td:first-child { width: 50%; }
.eq-matching select { width: 100%; max-width: none; }
@media (max-width: 640px) {
  .eq-matching tr { display: block; padding: .4rem 0; border-bottom: 1px solid var(--rule); }
  .eq-matching td { display: block; width: auto !important; border: 0; padding: .2rem 0; }
}

/* Zahl */
.eq-numeric { display: flex; align-items: center; gap: .5rem; }
.eq-number { width: 12rem; max-width: 100%; font-size: 1.05rem; }
.eq-unit { font-weight: 600; color: var(--ink-soft); }

/* Code-Puzzle */
.parsons { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 1rem; --indent-step: 28px; }
@media (max-width: 760px) { .parsons { grid-template-columns: 1fr; } }
.parsons-title { font-weight: 600; color: var(--ink-soft); margin-bottom: .3rem; }
.parsons-pool, .parsons-program {
  list-style: none; margin: 0; padding: .45rem; min-height: 6rem;
  border: 1.5px dashed var(--rule); border-radius: var(--radius); background: #f8f9fc;
}
.parsons-program { border-style: solid; background: #fff; counter-reset: line; }
.parsons-program.is-target { border-color: var(--pen); background: #f2f5ff; }
.parsons-block {
  display: flex; align-items: center; gap: .4rem; margin: 0 0 .35rem; padding: .35rem .5rem;
  background: #fff; border: 1px solid #c9d1e0; border-radius: 6px; cursor: pointer;
  font-family: var(--mono); font-size: .9rem; touch-action: manipulation;
}
.parsons-block:last-child { margin-bottom: 0; }
.parsons-pool .parsons-block:hover, .parsons-block:focus-visible { border-color: var(--pen); outline: none; box-shadow: 0 0 0 2px rgba(31, 60, 170, .15); }
.parsons-block.is-dragging { opacity: .45; }
.parsons-code { flex: 1; white-space: pre; overflow-x: auto; background: none !important; padding: 0 !important; }
.parsons-program .parsons-block { cursor: default; margin-left: calc(var(--indent, 0) * var(--indent-step)); background: #fdfdff; }
.parsons-program .parsons-block::before {
  counter-increment: line; content: counter(line); color: var(--ink-soft); font-size: .75rem; min-width: 1.2rem;
}
.parsons-tools { display: flex; gap: .15rem; flex: none; }
.parsons-btn {
  border: 1px solid var(--rule); background: #f3f5fa; border-radius: 4px; min-width: 1.9rem; height: 1.9rem;
  font-size: .95rem; line-height: 1; cursor: pointer; color: var(--ink);
}
.parsons-btn:hover { border-color: var(--pen); }
.parsons-btn.remove { color: var(--red, #c8102e); }
.parsons.is-locked .parsons-block { cursor: default; }
.parsons-help { margin-top: .5rem; }

/* --- Freigaben ------------------------------------------------------------------ */
.notice { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1.5rem; }
.notice p { margin-bottom: .6rem; }
.notice-warn { background: var(--amber-tint); border-left: 4px solid var(--amber); }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .45rem 1.25rem; margin: 0 0 1rem; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; }
@media (max-width: 600px) { .facts { grid-template-columns: minmax(0, 1fr); gap: .1rem; } .facts dd { margin-bottom: .5rem; } }

/* Studenten-Übersicht */
.exam-cards { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.exam-card {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .8rem 1.5rem; align-items: center;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: .7rem;
}
.exam-card.is-open { border-left: 5px solid var(--green); }
.exam-card-title { font-weight: 700; font-size: 1.1rem; margin-bottom: .2rem; }
.exam-card-action { text-align: right; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Zuordnung: Paare im Editor */
.pair-head, .pair-row { display: grid; grid-template-columns: 1fr 1fr 2rem; gap: .6rem; align-items: start; }
.pair-head { padding-left: 1.4rem; margin-bottom: .2rem; }
.pair-list { padding-left: 1.4rem; margin: 0 0 .8rem; }
.pair-row { margin-bottom: .5rem; }
.pair-row::marker { color: var(--ink-soft); }
.pair-row textarea { min-height: 2.4rem; overflow: hidden; resize: vertical; }
@media (max-width: 640px) {
  .pair-head { display: none; }
  .pair-row { grid-template-columns: 1fr 2rem; }
  .pair-row textarea[name=pair_right] { grid-column: 1; }
}
.solution-inline { color: var(--green); font-weight: 600; }
