:root {
    --bg: #0b0d12;
    --panel: #171a21;
    --panel-hover: #1c202a;
    --border: #262b36;
    --text: #e8eaf0;
    --muted: #8a8f9c;
    --accent: #4f8cff;
    --accent-soft: rgba(79, 140, 255, 0.12);
    --danger: #e5484d;
    --warn: #f5a524;
    --ok: #2fb344;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    background:
        radial-gradient(900px 500px at 20% 0%, rgba(79, 140, 255, 0.10), transparent 60%),
        radial-gradient(700px 450px at 90% 100%, rgba(47, 179, 68, 0.06), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 14px 24px; background: rgba(23, 26, 33, 0.9); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.brand span { color: var(--muted); font-weight: 400; }
.userbox, .exam-status { display: flex; align-items: center; gap: 14px; }
.userbox form { margin: 0; }
.content { max-width: 860px; margin: 0 auto; padding: 32px 20px 72px; }
h1 { font-size: 26px; letter-spacing: -0.3px; margin: 0 0 20px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.panel {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.prewrap { white-space: pre-wrap; }

input[type="text"], input[type="password"], textarea {
    width: 100%; font: inherit; font-size: 15px; padding: 10px 13px; border-radius: 8px;
    border: 1px solid var(--border); background: #0b0d11; color: var(--text);
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea.code { font-family: "SF Mono", Consolas, monospace; font-size: 13px; tab-size: 4; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
button, .btn {
    font: inherit; font-size: 14px; font-weight: 600; padding: 9px 16px; border-radius: 8px; border: none;
    cursor: pointer; text-decoration: none; display: inline-block; color: var(--text);
}
button:hover, .btn:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.big { padding: 12px 22px; font-size: 16px; }

.auth-box {
    max-width: 380px; margin: 80px auto; background: var(--panel); border: 1px solid var(--border);
    border-radius: 16px; padding: 32px; box-shadow: var(--shadow); text-align: center;
}
.auth-box.wide { max-width: 520px; }
.auth-box form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; text-align: left; }
.auth-box h1 { font-size: 22px; margin-bottom: 8px; }
.logo {
    width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 14px; font-size: 26px;
    background: linear-gradient(135deg, var(--accent), var(--ok)); display: flex; align-items: center; justify-content: center;
}
.dots { display: flex; justify-content: center; gap: 6px; margin: 20px 0 8px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); opacity: 0.3; animation: pulse 1.4s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); } 40% { opacity: 1; transform: scale(1); } }

.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; padding: 4px 12px; border-radius: 8px; background: var(--accent-soft); }
.timer.warn { background: rgba(245, 165, 36, 0.18); color: var(--warn); }
.timer.crit { background: rgba(229, 72, 77, 0.18); color: var(--danger); }
.task { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.task:first-of-type { border-top: none; margin-top: 4px; }
.task-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.task-id { font-weight: 700; color: var(--accent); }
.points { font-size: 12px; color: var(--muted); font-weight: 600; }
.points.full { color: var(--ok); }
.points.none { color: var(--danger); }
.question { margin: 0 0 10px; }
.intro { color: var(--muted); }
.choice { flex-direction: row; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: 15px; cursor: pointer; }
.choice:hover { background: var(--panel-hover); }
.choice input { margin-top: 5px; }
.number-row { display: flex; align-items: center; gap: 10px; max-width: 320px; }
.table-wrap { overflow-x: auto; }
.answer-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.answer-table th, .answer-table td { border: 1px solid var(--border); padding: 4px; text-align: left; }
.answer-table th { background: #10131a; color: var(--muted); padding: 8px 10px; font-weight: 600; }
.answer-table td input { border: none; background: transparent; padding: 6px 8px; }
.image-upload .preview, .preview { max-width: 100%; max-height: 420px; margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; display: block; }
.submit-row { text-align: center; margin-top: 28px; }

.result-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-big { font-size: 24px; font-weight: 700; }
.stat-of { font-size: 14px; font-weight: 500; color: var(--muted); }
.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin: 12px 0 4px; }
.answer { background: #0b0d11; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.answer.solution { border-color: rgba(47, 179, 68, 0.4); }
.feedback { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.exam-list .panel p { margin: 0 0 12px; }

@media (max-width: 600px) {
    .topbar { padding: 10px 14px; }
    .content { padding: 20px 12px 56px; }
    .panel { padding: 16px; }
}
/* ─────────────────────────────────────────────────────────────────────────
   Diagramm-Patch für das Schüler-Portal
   Ziel: ASCII-/Unicode-Diagramme (Netzplan, ER-Modell, Tabellenblöcke) in den
   Prüfungstexten zeichengenau darstellen.

   Anhängen an:  /home/comcave_login/admin_panel/portal_static/portal.css
   Danach:       sudo systemctl restart portal     (bzw. Strg+F5 im Browser)

   Warum nötig:
   Das Portal rendert Prüfungstexte als <p class="prewrap"> mit
   white-space: pre-wrap in der Standardschrift (Segoe UI). Daraus folgen
   zwei Probleme:
     1. Proportionalschrift  -> Kästen und Linien verrutschen spaltenweise.
     2. pre-wrap bricht um   -> auf schmalen Fenstern zerfällt jedes Diagramm.
   Die Regel unten trifft gezielt den Prüfungs-Kopftext (hinweise) und die
   Aufgaben-Einleitungen (einleitung) – beide sind direkte Kinder von .panel.
   Der eigentliche Fragetext (.question) liegt in .task und bleibt unberührt,
   also weiterhin in der gut lesbaren Fließtextschrift.

   Keine Template-Änderung erforderlich.
   ───────────────────────────────────────────────────────────────────────── */

.panel > .prewrap {
    font-family: "SF Mono", Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre;      /* kein Umbruch: Spalten bleiben ausgerichtet */
    overflow-x: auto;      /* zu breite Diagramme werden horizontal scrollbar */
}

/* Optional: auch die Musterlösungen auf der Ergebnisseite zeichengenau
   darstellen. Betrifft z. B. das ER-Diagramm in 3e und die Subnetz-/
   Netzplan-Tabellen in 1c und 4a. Weglassen, wenn die Musterlösungen
   lieber als Fließtext erscheinen sollen. */
.answer.solution {
    font-family: "SF Mono", Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre;
    overflow-x: auto;
}

/* ─── Typ "diagramm": ASCII-Grafik mit Eingabefeldern an Ort und Stelle ───────
   Die Felder sind exakt FIELD_WIDTH (3) Zeichen breit, damit die Kaesten der
   Grafik in der Monospace-Darstellung buendig bleiben. Deshalb: box-sizing auf
   border-box, kein Padding, feste Hoehe in em (= line-height des <pre>). */
.diagram-wrap { overflow-x: auto; margin: 10px 0 14px; }
.diagram {
    font-family: "SF Mono", Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
    /* 11px: bei dieser Groesse ist die Zeichenbreite von Consolas mit 6,05 px fast genau
       ganzzahlig. Dadurch stossen die Linienzeichen (─ │ ┼) nahtlos aneinander und die
       Kaesten wirken geschlossen. Bei 13px entstehen sichtbare Luecken in den Linien. */
    font-size: 11px;
    line-height: 1.6;
    white-space: pre;
    margin: 0;
    color: var(--text);
}
.diagram input.dfield,
.diagram span.dfield {
    display: inline-block;
    width: 3ch;
    height: 1.6em;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    border: 1px solid var(--accent);
    border-radius: 2px;
    background: var(--accent-soft);
    color: var(--text);
    font: inherit;
    line-height: 1.5;
    text-align: center;
    vertical-align: top;
}
.diagram input.dfield:focus {
    outline: none;
    border-color: var(--ok);
    background: rgba(47, 179, 68, 0.16);
}
.diagram span.dfield {
    border-style: dashed;
    background: none;
    text-align: left;
    width: auto;
    min-width: 3ch;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Papier-Theme für das Schüler-Portal.

   Der Hintergrund der Seite bleibt dunkel wie bisher. Nur die Prüfungsblätter
   selbst (.panel) werden weiß mit schwarzer Schrift - wie ein Blatt Papier,
   das auf einem dunklen Tisch liegt.

   Anhängen an:  /home/comcave_login/admin_panel/portal_static/portal.css
   Danach:       sudo systemctl restart portal

   Technik: Die Farbvariablen werden nicht global, sondern NUR auf .panel neu
   gesetzt. Da CSS-Variablen sich nach unten vererben, übernehmen alle Elemente
   innerhalb eines Blattes automatisch die hellen Werte. Zusätzlich werden die
   wenigen Stellen überschrieben, an denen Farben fest im Stylesheet stehen
   (Eingabefelder, Tabellenkopf, Antwortkästen).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Das Blatt ────────────────────────────────────────────────────────────── */
.panel {
    /* Variablen nur für den Inhalt dieses Blattes umdefinieren */
    --text: #000000;
    --muted: #4a4a4a;
    --border: #b0b0b0;
    --panel: #ffffff;
    --panel-hover: #f2f2f2;
    --accent: #000000;
    --accent-soft: #eeeeee;
    --danger: #000000;
    --warn: #000000;
    --ok: #000000;

    background: #ffffff;
    color: #000000;
    border: 1px solid #c8c8c8;
    border-radius: 3px;
    /* Etwas Tiefe, damit das Blatt auf dem dunklen Grund aufliegt */
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    padding: 30px 34px;
    font-family: "Times New Roman", Georgia, serif;
    line-height: 1.55;
}

/* ── Texte im Blatt ───────────────────────────────────────────────────────── */
.panel h2 {
    color: #000000;
    border-bottom: 1px solid #000000;
    padding-bottom: 8px;
    margin-bottom: 16px;
}
.panel .hint { color: #4a4a4a; }
.panel .task { border-top: 1px solid #d8d8d8; padding-top: 14px; margin-top: 18px; }
.panel .task:first-of-type { border-top: none; }
.panel .task-id { color: #000000; font-weight: 700; }
.panel .points { color: #000000; }
.panel .label { color: #4a4a4a; }

/* ── Eingabefelder (im Original dunkel hinterlegt) ────────────────────────── */
.panel input[type="text"],
.panel input[type="password"],
.panel textarea {
    background: #ffffff;
    color: #000000;
    border: 1px solid #000000;
    border-radius: 2px;
    font-family: "Times New Roman", Georgia, serif;
}
.panel textarea.code {
    font-family: "SF Mono", Consolas, "DejaVu Sans Mono", monospace;
}
.panel input:focus,
.panel textarea:focus {
    outline: 2px solid #000000;
    outline-offset: -2px;
    border-color: #000000;
}

/* ── Tabellen ─────────────────────────────────────────────────────────────── */
.panel .answer-table,
.panel .answer-table th,
.panel .answer-table td { border-color: #000000; }
.panel .answer-table th { background: #ededed; color: #000000; }

/* ── Antwort- und Lösungskästen auf der Ergebnisseite ─────────────────────── */
.panel .answer {
    background: #ffffff;
    border: 1px solid #000000;
    border-radius: 2px;
    color: #000000;
}
.panel .answer.solution { border-color: #000000; border-left: 4px solid #000000; }
.panel .feedback { color: #000000; }

/* ── Diagrammfelder (Netzplan, ER-Modell) ─────────────────────────────────── */
.panel .diagram { color: #000000; }
.panel .diagram input.dfield,
.panel .diagram span.dfield {
    background: #ffffff;
    border: 1px solid #000000;
    border-radius: 0;
    color: #000000;
}
.panel .diagram input.dfield:focus {
    background: #ffffff;
    border: 2px solid #000000;
    outline: none;
}

/* ── Schaltflächen im Blatt (z. B. Bild-Upload) ───────────────────────────── */
.panel .btn-primary { background: #000000; color: #ffffff; border-radius: 2px; }
.panel .btn-ghost { background: #ffffff; color: #000000; border: 1px solid #000000; }
.panel input[type="file"] { color: #000000; }

/* ── Meldungen ohne Farbcodierung: Unterscheidung über den Schriftschnitt ─── */
.panel .error { color: #000000; font-weight: 700; text-decoration: underline; }
.panel .ok    { color: #000000; font-weight: 700; }
.panel .warn  { color: #000000; font-style: italic; }

/* ── Ausdruck: nur die Blätter, ohne Bedienelemente ───────────────────────── */
@media print {
    body { background: #ffffff; }
    .topbar, .submit-row, button, .btn { display: none !important; }
    .panel { box-shadow: none; border: 1px solid #000; page-break-inside: avoid; }
}
