/*
 * Prüfungsplattform – Grundstil
 * Idee: Karopapier und Füllfeder. Ruhige, gut lesbare Arbeitsflächen;
 * das Karomuster der Kopfzeile ist das einzige Schmuckelement.
 * Bewusst ohne externe Schriften (Datenschutz, Schulnetze): humanistische
 * Systemschriften, die auf allen Zielplattformen vorhanden sind.
 */
:root {
  --paper: #f6f8fb;
  --surface: #ffffff;
  --ink: #1b2a4a;
  --ink-soft: #55627a;
  --pen: #2647c4;
  --pen-dark: #1a339a;
  --pen-tint: #e8edfb;
  --red-pen: #c8102e;
  --red-tint: #fbe9ec;
  --green: #2e7d4f;
  --green-tint: #e6f3ea;
  --amber: #8a5a00;
  --amber-tint: #fdf3dc;
  --rule: #d8dee9;
  --grid: rgba(38, 71, 196, 0.09);
  --radius: 6px;
  --font: Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", source-sans-pro, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
}

a { color: var(--pen); text-underline-offset: 2px; }
a:hover { color: var(--pen-dark); }

:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; font-weight: 600; }
h1 { font-size: 1.85rem; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin-top: 1.6em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; max-width: 72ch; }

code, .mono { font-family: var(--mono); font-size: .92em; }

/* --- Kopfzeile mit Karopapier ----------------------------------------- */
.topbar {
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 18px 18px;
  background-position: -1px -1px;
  border-bottom: 2px solid var(--pen);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1.5rem;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  padding: .1rem .4rem;
  margin-left: -.4rem;
}
.brand-mark {
  display: inline-block;
  width: .9rem; height: .9rem;
  border: 2px solid var(--pen);
  border-radius: 2px;
  margin-right: .45rem;
  vertical-align: -1px;
  background: linear-gradient(135deg, transparent 45%, var(--pen) 45%, var(--pen) 55%, transparent 55%);
}
.brand { margin-right: auto; }
.mainnav { display: flex; flex-wrap: wrap; gap: .25rem; order: 3; flex-basis: 100%; margin-left: -.65rem; }
.mainnav a {
  color: var(--ink);
  text-decoration: none;
  padding: .35rem .65rem;
  border-radius: var(--radius);
  background: var(--surface);
}
.mainnav a:hover { background: var(--pen-tint); }
.mainnav a[aria-current="page"] { color: var(--pen); box-shadow: inset 0 -2px 0 var(--pen); }

.usermenu { display: flex; align-items: center; gap: .75rem; font-size: .95rem; background: var(--surface); padding: .1rem .3rem; }
.usermenu .who { color: var(--ink-soft); }

.lang-switch { display: inline-flex; gap: 2px; margin: 0; }
.lang-switch button {
  font: inherit; font-size: .85rem;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-soft);
  padding: .1rem .45rem;
  cursor: pointer;
}
.lang-switch button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.lang-switch button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.lang-switch button[aria-pressed="true"] { background: var(--pen); border-color: var(--pen); color: #fff; }

/* --- Inhalt ------------------------------------------------------------ */
main { max-width: 1120px; margin: 0 auto; padding: 2rem 1rem 4rem; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-head h1 { margin: 0; }
.page-head .lead { margin: .35rem 0 0; color: var(--ink-soft); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.panel > :last-child { margin-bottom: 0; }
.panel-narrow { max-width: 34rem; }

.muted { color: var(--ink-soft); }
.small { font-size: .9rem; }

.empty {
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  background: var(--surface);
  color: var(--ink-soft);
}
.empty strong { color: var(--ink); display: block; margin-bottom: .25rem; }

/* --- Meldungen --------------------------------------------------------- */
.messages { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.messages li {
  padding: .7rem 1rem;
  border-left: 4px solid var(--pen);
  background: var(--pen-tint);
  margin-bottom: .5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.messages .success { border-color: var(--green); background: var(--green-tint); }
.messages .error { border-color: var(--red-pen); background: var(--red-tint); }
.messages .warning { border-color: var(--amber); background: var(--amber-tint); }

/* --- Schaltflächen ----------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  font: inherit; font-size: .98rem; font-weight: 600;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--pen);
  background: var(--pen);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.3;
}
.btn:hover { background: var(--pen-dark); border-color: var(--pen-dark); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--pen); }
.btn-secondary:hover { background: var(--pen-tint); color: var(--pen-dark); }
.btn-danger { background: var(--surface); color: var(--red-pen); border-color: var(--red-pen); }
.btn-danger:hover { background: var(--red-pen); border-color: var(--red-pen); color: #fff; }
.btn-small { font-size: .88rem; padding: .25rem .6rem; font-weight: 500; }
.btn-link {
  font: inherit; background: none; border: 0; padding: 0;
  color: var(--pen); text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.btn-link.danger { color: var(--red-pen); }
form.inline { display: inline; margin: 0; }

/* --- Formulare --------------------------------------------------------- */
.field { margin-bottom: 1.1rem; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field .help { color: var(--ink-soft); font-size: .9rem; margin-top: .25rem; }
.field .errorlist { list-style: none; padding: 0; margin: .3rem 0 0; color: var(--red-pen); font-size: .95rem; }
.field.has-error input, .field.has-error select { border-color: var(--red-pen); }
.errorlist.nonfield { list-style: none; padding: .7rem 1rem; background: var(--red-tint); border-left: 4px solid var(--red-pen); margin: 0 0 1rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="file"], select, textarea {
  font: inherit;
  width: 100%;
  max-width: 30rem;
  padding: .5rem .65rem;
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--pen); outline: none; box-shadow: 0 0 0 3px var(--pen-tint); }
select[multiple] { min-height: 8rem; }

.checks { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .3rem 1rem; }
.checks label, .field > label.check, .check { font-weight: 400; display: flex; gap: .5rem; align-items: baseline; cursor: pointer; }
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--pen); }

.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.toolbar input[type="search"], .toolbar select { width: auto; min-width: 14rem; }

/* --- Tabellen ---------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: 1.5rem; }
table { border-collapse: collapse; width: 100%; font-size: .98rem; }
th, td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 600; color: var(--ink-soft); background: #fafbfd; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.is-error td { background: var(--red-tint); }
tr.is-inactive td { color: var(--ink-soft); }

.tag {
  display: inline-block;
  font-size: .82rem;
  padding: .05rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  white-space: nowrap;
  margin: 0 .2rem .2rem 0;
}
.tag-new { border-color: var(--green); color: var(--green); background: var(--green-tint); }
.tag-error { border-color: var(--red-pen); color: var(--red-pen); background: var(--red-tint); }
.tag-warn { border-color: var(--amber); color: var(--amber); background: var(--amber-tint); }
.tag-pen { border-color: var(--pen); color: var(--pen); background: var(--pen-tint); }

.issues { margin: .25rem 0 0; padding-left: 1.1rem; font-size: .9rem; }
.issues .err { color: var(--red-pen); }
.issues .warn { color: var(--amber); }

/* --- Kennzahlen im Import ---------------------------------------------- */
.summary { display: flex; flex-wrap: wrap; gap: 2rem; margin: 0 0 1.5rem; padding: 0; list-style: none; }
.summary li { display: flex; flex-direction: column; }
.summary .count { font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.summary .count.err { color: var(--red-pen); }
.summary .count.ok { color: var(--green); }

/* --- Login ------------------------------------------------------------- */
.login-page main { max-width: 26rem; padding-top: 4rem; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--pen);
  border-radius: var(--radius);
  padding: 1.75rem 1.75rem 1.5rem;
}
.login-card input { max-width: none; }
.login-card .btn { width: 100%; justify-content: center; margin-top: .5rem; }

/* --- Klassenliste im Dashboard ----------------------------------------- */
.class-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.class-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; padding: .75rem 0; border-bottom: 1px solid var(--rule); }
.class-list .name { font-weight: 600; font-size: 1.05rem; }

.two-col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 800px) { .two-col { grid-template-columns: minmax(0, 1fr); } }

.pagination { display: flex; gap: .75rem; align-items: center; }

/* --- Passwortliste (Druck) --------------------------------------------- */
.sheet-cards { padding: 1px 0 0 1px; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0; margin-bottom: 1.5rem; }
.sheet-card {
  background: var(--surface);
  border: 1px dashed #9aa6bd;
  padding: 1rem 1.1rem;
  margin: -1px 0 0 -1px;
  break-inside: avoid;
}
.sheet-card .who { font-weight: 700; font-size: 1.05rem; }
.sheet-card dl { display: grid; grid-template-columns: auto 1fr; gap: .15rem .75rem; margin: .5rem 0 0; font-size: .95rem; }
.sheet-card dt { color: var(--ink-soft); }
.sheet-card dd { margin: 0; word-break: break-all; }
.sheet-card .pw { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; letter-spacing: .04em; }

@media print {
  body { background: #fff; font-size: 11pt; }
  .topbar, .no-print, .messages { display: none !important; }
  main { padding: 0; max-width: none; }
  .sheet-cards { grid-template-columns: 1fr 1fr; }
  .sheet-card { border-color: #777; }
  a { color: inherit; text-decoration: none; }
}

@media (max-width: 600px) {
  h1 { font-size: 1.5rem; }
  main { padding-top: 1.25rem; }
  .panel { padding: 1rem; }
  .usermenu .who { display: none; }
}

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

/* Das hidden-Attribut gilt immer, auch wenn eine Klasse display setzt */
[hidden] { display: none !important; }

/* Gemeinsames Passwort (Import, Klasse) */
.shared-password { border: 2px solid var(--pen); border-radius: var(--radius); padding: .9rem 1.1rem; margin: 0 0 1.2rem; background: #f3f6ff; max-width: 34rem; }
.shared-password .pw { font-family: var(--mono); font-size: 2rem; font-weight: 700; letter-spacing: .12em; margin: .2rem 0; }
.check-col { width: 2rem; text-align: center; }

/* Code: keine Ligaturen. Schriften wie «Cascadia Code» (Windows 11) zeigen sonst
   != als ≠, == als langes Gleichheitszeichen usw. Der Text selbst bleibt gleich,
   aber die Anzeige verwirrt beim Programmieren. */
code, pre, kbd, samp, textarea, input, .mono, .code-input, .code-block, .codehilite,
.cm-editor, .cm-content, .cm-line, .ide-output, .ide-input, .parsons-code, .eq-output, .gap {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0, "dlig" 0;
}
.close-instance { margin-top: .6rem; display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; }
.close-instance .check-row { display: flex; gap: .4rem; align-items: center; }
