:root {
  --grund: #f4f5f7;
  --karte: #ffffff;
  --rand: #d7dbe0;
  --schrift: #1d2329;
  --leise: #6b7681;
  --akzent: #0b6bcb;
  --akzent-dunkel: #08529c;
  --warn: #b3261e;
  --ok: #1f7a3d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--schrift);
  background: var(--grund);
}

/* ------------------------------------------------------------- Anmeldung */

.login-seite {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 32px;
  width: min(340px, 90vw);
  text-align: center;
}
.login-karte h1 { margin: 0; font-size: 20px; }
.login-karte .unter { margin: 4px 0 22px; color: var(--leise); }
.login-karte input { width: 100%; margin-bottom: 12px; }
.login-karte button { width: 100%; }
.fehler { color: var(--warn); margin: 0 0 12px; }

/* ------------------------------------------------------------------ Kopf */

.kopf {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  height: 50px;
  background: var(--karte);
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 5;
}
.kopf strong { font-size: 15px; }
.reiter { display: flex; gap: 4px; }
.reiter-knopf {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 14px 12px;
  cursor: pointer;
  color: var(--leise);
  font-size: 14px;
}
.reiter-knopf.aktiv { color: var(--akzent); border-bottom-color: var(--akzent); font-weight: 600; }
.abmelden { margin-left: auto; color: var(--leise); text-decoration: none; font-size: 13px; }
.abmelden:hover { color: var(--schrift); }

/* --------------------------------------------------------------- Tafeln */

.tafel { display: none; padding: 18px; }
.tafel.aktiv { display: block; }
.platzhalter { color: var(--leise); }

.zeile {
  display: grid;
  grid-template-columns: 150px 1fr auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.zeile.oben { align-items: start; }
.zeile > label { color: var(--leise); }

input, select, textarea, button {
  font: inherit;
  color: inherit;
  border-radius: 6px;
  border: 1px solid var(--rand);
  padding: 7px 9px;
  background: var(--karte);
}
textarea { resize: vertical; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--akzent); outline-offset: -1px; }

button { cursor: pointer; background: var(--karte); }
button:hover { background: #eef1f4; }
button.haupt { background: var(--akzent); border-color: var(--akzent); color: #fff; }
button.haupt:hover { background: var(--akzent-dunkel); }
button:disabled { opacity: .5; cursor: default; }

.zaehler { color: var(--leise); font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.zaehler.zulang { color: var(--warn); font-weight: 600; }
.zaehler.gut { color: var(--ok); }

.status { color: var(--leise); margin: 0 0 12px 160px; min-height: 1.4em; }
.status.fehler { color: var(--warn); }

.knopfleiste { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }

/* -------------------------------------------------------------- Editor */

.editorbereich { display: grid; grid-template-columns: 170px 1fr; gap: 12px; }
.werkzeuge { display: flex; flex-direction: column; gap: 5px; }
.werkzeuge button { text-align: left; }
#inhalt { min-height: 320px; font-family: inherit; }

.ausgabebereich {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}
.feld h2 { font-size: 13px; color: var(--leise); font-weight: 600; margin: 0 0 5px; }
#ausgabe, #vorschau {
  min-height: 220px;
  background: #fbfcfd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
#vorschau { font-family: inherit; font-size: 13.5px; }

/* -------------------------------------------------------------- Dialog */

dialog {
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 20px;
  width: min(460px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin: 0 0 14px; font-size: 16px; }
dialog label { display: block; color: var(--leise); margin: 10px 0 3px; }
dialog input { width: 100%; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 20px 0 0; padding: 0; }

@media (max-width: 950px) {
  .zeile { grid-template-columns: 1fr; }
  .status { margin-left: 0; }
  .editorbereich, .ausgabebereich { grid-template-columns: 1fr; }
  .werkzeuge { flex-direction: row; flex-wrap: wrap; }
}

/* ------------------------------------------------------- Bilder und PDFs */

.hinweis { color: var(--leise); margin: 0 0 14px; max-width: 70ch; }
.hinweis code { background: var(--grund); padding: 1px 4px; border-radius: 3px; }

.bildgitter {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.bildkachel {
  margin: 0;
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 8px;
}
.bildkachel label { display: block; position: relative; cursor: pointer; }
.bildkachel input { position: absolute; top: 6px; left: 6px; width: 17px; height: 17px; }
.bildkachel img {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: contain;
  background: var(--grund);
  border-radius: 5px;
}
/* Abgewaehlte Bilder blass, damit die Auswahl auf einen Blick stimmt. */
.bildkachel:has(input:not(:checked)) img { opacity: 0.3; }
.bildkachel figcaption {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--leise);
}
.bildkachel .nummer { font-variant-numeric: tabular-nums; }
.bildkachel a { color: var(--akzent); text-decoration: none; margin-left: auto; }
.bildkachel a:hover { text-decoration: underline; }

.liste { border-collapse: collapse; width: 100%; max-width: 900px; background: var(--karte); }
.liste td {
  border-bottom: 1px solid var(--rand);
  padding: 9px 10px;
  vertical-align: middle;
}
.liste tr:last-child td { border-bottom: none; }
.liste .titel { font-weight: 500; }
.liste .datei code { color: var(--leise); font-size: 12px; }
.liste .tun { text-align: right; white-space: nowrap; }
.liste .tun > * { margin-left: 6px; }

/* Ein Link, der aussieht wie ein Knopf - fuer den Download-Verweis. */
a.knopf {
  display: inline-block;
  padding: 5px 11px;
  border: 1px solid var(--rand);
  border-radius: 6px;
  background: var(--karte);
  color: var(--schrift);
  text-decoration: none;
  font-size: 13px;
}
a.knopf:hover { border-color: var(--akzent); color: var(--akzent); }
