:root {
  --grund: #f2f2f7;
  --karte: #ffffff;
  --text: #1c1c1e;
  --leise: #6e6e73;
  --linie: #d1d1d6;
  --feld: #f7f7fa;
  --akzent: #0a66d8;
  --akzent-text: #ffffff;
  --gut: #1f7a35;
  --gut-grund: #e5f5e9;
  --schlecht: #b3261e;
  --schlecht-grund: #fdecea;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #000000;
    --karte: #1c1c1e;
    --text: #f2f2f7;
    --leise: #a1a1a6;
    --linie: #3a3a3c;
    --feld: #2c2c2e;
    --akzent: #4c9bff;
    --akzent-text: #001a3d;
    --gut: #7fd894;
    --gut-grund: #12301b;
    --schlecht: #ff8a80;
    --schlecht-grund: #3b1513;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; margin-bottom: 0.75rem; display: inline; }
[hidden] { display: none !important; }
.nur-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.kopf {
  display: flex; align-items: center; gap: 0.6rem;
  max-width: 1120px; margin: 0 auto; padding: 1rem 16px 0.25rem;
}
.kopf .abmelden { margin-left: auto; color: var(--leise); font-size: 0.9rem; }

.raster {
  display: grid; gap: 16px;
  max-width: 1120px; margin: 0 auto; padding: 12px 16px 48px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  align-items: start;
}
.spalte { display: grid; gap: 16px; min-width: 0; }
.vorschau-spalte { position: sticky; top: 12px; }
@media (max-width: 860px) {
  .raster { grid-template-columns: minmax(0, 1fr); }
  .vorschau-spalte { position: static; order: -1; }
}

.karte {
  background: var(--karte); border-radius: var(--radius);
  padding: 16px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.karte > h2 { display: block; }

label { display: block; font-size: 0.85rem; color: var(--leise); margin: 0 0 0.7rem; }
label small, .hinweis, .klein { color: var(--leise); font-size: 0.8rem; }
.feld { margin-bottom: 0.7rem; }
.feldname { display: block; font-size: 0.85rem; color: var(--leise); margin-bottom: 0.25rem; }
input:not([type]), input[type=url], input[type=email], input[type=tel], input[type=password], input[type=text], select, textarea {
  display: block; width: 100%; margin-top: 0.25rem;
  font: inherit; font-size: 1rem; color: var(--text);
  background: var(--feld); border: 1px solid var(--linie); border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--akzent); outline-offset: 1px;
}
input.initialen { text-transform: uppercase; font-weight: 700; letter-spacing: 0.15em; font-size: 1.15rem; }
input[type=color] {
  display: block; width: 100%; height: 2.5rem; margin-top: 0.25rem;
  border: 1px solid var(--linie); border-radius: 10px; background: var(--feld); padding: 3px;
}
.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 420px) { .zwei { grid-template-columns: 1fr; } }
.haken { display: flex; align-items: center; gap: 0.5rem; padding-top: 1.6rem; color: var(--text); }
.hinweis { margin: -0.2rem 0 0.7rem; }
code { font-size: 0.85em; }

.regler output { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
.regler input { display: block; width: 100%; margin: 0.35rem 0 0; accent-color: var(--akzent); }

.segmente {
  display: flex; gap: 2px; padding: 2px; margin-bottom: 0.9rem;
  background: var(--feld); border: 1px solid var(--linie); border-radius: 10px;
  overflow-x: auto;
}
.segmente button {
  flex: 1 1 auto; min-width: max-content;
  font: inherit; font-size: 0.9rem; color: var(--text);
  border: 0; border-radius: 8px; background: transparent;
  padding: 0.45rem 0.6rem; cursor: pointer;
}
.segmente button.aktiv { background: var(--karte); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); font-weight: 600; }
.feld .segmente { margin: 0.25rem 0 0; }
.klein-seg button { font-size: 0.85rem; }

details > summary { cursor: pointer; color: var(--leise); font-size: 0.9rem; margin-bottom: 0.7rem; }
.karte > details > summary { color: var(--text); margin-bottom: 0; }
.karte > details[open] > summary { margin-bottom: 0.9rem; }

button { font: inherit; }
.downloads button, .anmeldekarte button {
  border: 1px solid var(--linie); background: var(--feld); color: var(--text);
  border-radius: 10px; padding: 0.55rem 0.9rem; cursor: pointer;
}
button.primaer { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); font-weight: 600; }
button:disabled { opacity: 0.45; cursor: default; }
button.link { border: 0; background: none; color: var(--akzent); padding: 0; cursor: pointer; font-size: 0.85rem; }

.datei {
  border: 1.5px dashed var(--linie); border-radius: 10px; padding: 0.8rem; color: var(--text); cursor: pointer;
}
.datei input { display: block; margin-top: 0.4rem; max-width: 100%; font-size: 0.85rem; }
.bildinfo { display: flex; align-items: center; gap: 0.6rem; margin: -0.2rem 0 0.8rem; font-size: 0.85rem; min-width: 0; }
.bildinfo img { width: 36px; height: 36px; object-fit: contain; background: #fff; border-radius: 6px; border: 1px solid var(--linie); }
.bildinfo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }

.vorschau .leinwand {
  background: #fff; border-radius: 10px; overflow: hidden; line-height: 0;
  border: 1px solid var(--linie);
}
.vorschau canvas { width: 100%; height: auto; image-rendering: pixelated; transition: opacity 0.15s; }
.vorschau canvas.blass { opacity: 0.15; }
.pruefung { margin: 0.8rem 0 0; padding: 0.5rem 0.7rem; border-radius: 10px; font-size: 0.88rem; }
.pruefung:empty { display: none; }
.pruefung.gut { background: var(--gut-grund); color: var(--gut); }
.pruefung.schlecht { background: var(--schlecht-grund); color: var(--schlecht); }
.fehler { color: var(--schlecht); background: var(--schlecht-grund); padding: 0.5rem 0.7rem; border-radius: 10px; font-size: 0.9rem; margin: 0.8rem 0 0; }
#info { margin: 0.6rem 0 0; }
.downloads { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 0.9rem; }
.pngwahl { margin: 0; flex: 1 1 110px; }
.pngwahl select { padding: 0.45rem 0.5rem; }
.inhalt-anzeige { margin-top: 0.9rem; }
.inhalt-anzeige pre {
  margin: 0 0 0.4rem; padding: 0.6rem; background: var(--feld); border-radius: 8px;
  font-size: 0.78rem; white-space: pre-wrap; word-break: break-all; max-height: 14rem; overflow: auto;
}

/* Anmeldung */
body.anmeldung { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.anmeldekarte { width: min(360px, 100%); text-align: center; padding: 28px 22px; }
.anmeldekarte h1 { margin: 0.5rem 0 1.2rem; }
.anmeldekarte label { text-align: left; }
.anmeldekarte button { width: 100%; margin-top: 0.4rem; }
.anmeldekarte .klein { margin: 1rem 0 0; }

/* Rahmen um die Mitte */
.aufbau { border-top: 1px solid var(--linie); margin-top: 0.4rem; padding-top: 0.9rem; }
.unterkopf { font-size: 0.95rem; margin: 0 0 0.6rem; }
.aufbau-raster { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 520px) { .aufbau-raster { grid-template-columns: minmax(0, 1fr); } .lupe { max-width: 220px; } }
.lupe { margin: 0; }
.lupe canvas { display: block; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--linie); image-rendering: pixelated; background: #fff; }
.lupe figcaption { font-size: 0.75rem; color: var(--leise); text-align: center; margin-top: 0.25rem; }
.punkt { display: inline-block; width: 0.75em; height: 0.75em; border-radius: 3px; margin-right: 0.4em; vertical-align: -0.05em; border: 1px solid var(--linie); }
.punkt.luecke { background: rgba(10, 132, 255, 0.45); }
.punkt.rahmen { background: #111; }
.punkt.aussen { background: rgba(255, 159, 10, 0.5); }

/* Sicherungsstatus in der Kopfzeile */
.sync { margin-left: auto; font-size: 0.8rem; color: var(--leise); white-space: nowrap; }
.sync.gut { color: var(--gut); }
.sync.warten { color: #b25e00; }
.sync.fehler { color: var(--schlecht); }
.sync + .abmelden { margin-left: 0.9rem; }
@media (prefers-color-scheme: dark) { .sync.warten { color: #ffb340; } }
