:root {
  /* Farben des bildungselemente-Themes */
  --bg: #fff4e4;
  --karte: #fff;
  --fuell: #edf3f3; /* Füllfarbe für Eingabefelder, Tags, Badges */
  --fg: #1c2b2e;
  --muted: #5b6b6e;
  --linie: #e0d8ca;
  --akzent: #2d6f7c;
  --akzent-fg: #fff;
  --fehler: #b3261e;
  --warnung-bg: #ffe9b8;
  --fehler-bg: #fde8e6;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12262a;
    --karte: #17323a;
    --fuell: #1f414a;
    --fg: #f4ede1;
    --muted: #b7c6c8;
    --linie: #2c4850;
    --akzent: #6cc0cd;
    --akzent-fg: #0c2a30;
    --fehler: #ffb4ab;
    --warnung-bg: #3a3118;
    --fehler-bg: #3b1d1a;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font:
    16px/1.5 system-ui,
    -apple-system,
    sans-serif;
}
.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--linie);
  background: var(--karte);
}
h1 {
  margin: 0;
  font-size: 1.25rem;
}
main {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1rem;
}
.karte {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 0.75rem;
  padding: 1rem;
}
label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
input,
select,
textarea,
button {
  font: inherit;
  color: inherit;
}
input,
select,
textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--fuell);
  border: 1px solid var(--linie);
  border-radius: 0.5rem;
}
button {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--linie);
  background: var(--karte);
  cursor: pointer;
}
button.primaer {
  background: var(--akzent);
  border-color: var(--akzent);
  color: var(--akzent-fg);
  font-weight: 600;
}
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
:focus-visible {
  outline: 3px solid var(--akzent);
  outline-offset: 2px;
}
.zeile {
  display: flex;
  gap: 0.5rem;
}
.zeile input {
  flex: 1;
  min-width: 0;
}
.hinweis {
  color: var(--muted);
  margin: 0.5rem 0;
  min-height: 1.5rem;
}
.treffer {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.treffer li {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  display: grid;
  gap: 0.5rem;
}
.quelle {
  font-size: 0.85rem;
  color: var(--muted);
}
.warnung,
.fehler {
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
}
.warnung {
  background: var(--warnung-bg);
}
.fehler {
  background: var(--fehler-bg);
  color: var(--fehler);
}
.warnung ul {
  margin: 0.25rem 0;
  padding-left: 1.25rem;
}
dialog {
  width: min(42rem, calc(100vw - 1rem));
  max-width: none;
  max-height: calc(100vh - 1rem);
  max-height: calc(100dvh - 1rem);
  margin: auto;
  padding: 0;
  overflow: hidden;
  background: var(--karte);
  color: var(--fg);
  border: 1px solid var(--linie);
  border-radius: 0.75rem;
}
/* Aufbau der Dialoge: Inhalt scrollt, die Schaltflächenleiste bleibt unten im Fenster stehen. */
dialog[open] {
  display: flex;
  flex-direction: column;
}
dialog > form {
  display: contents;
}
.dialog-inhalt {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 1rem 0.5rem;
}
.dialog-inhalt > :first-child {
  margin-top: 0;
}
body:has(dialog[open]) {
  overflow: hidden; /* der Hintergrund scrollt nicht mit */
}
dialog::backdrop {
  background: rgb(0 0 0 / 0.5);
}
fieldset {
  border: 1px solid var(--linie);
  border-radius: 0.5rem;
  margin: 0.75rem 0;
  padding: 0.5rem 0.75rem 0.75rem;
}
legend {
  font-weight: 700;
  padding: 0 0.25rem;
}
.feld {
  margin: 0.5rem 0;
}
.feld .klein {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 400;
}
.aktionen {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--linie);
  background: var(--karte);
  border-radius: 0 0 0.75rem 0.75rem;
}
#manuell {
  margin-top: 0.25rem;
}

.benutzer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.knopf {
  display: inline-block;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--linie);
  text-decoration: none;
  font-weight: 600;
}
a.knopf.primaer {
  background: var(--akzent);
  border-color: var(--akzent);
  color: var(--akzent-fg);
}
[hidden] {
  display: none !important;
}
h2 {
  font-size: 1.1rem;
  margin: 1rem 0 0.5rem;
}
.aktionszeile {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.konflikt-feld {
  margin: 0.5rem 0;
  padding: 0.5rem;
  border: 1px solid var(--linie);
  border-radius: 0.5rem;
}
.konflikt-feld label {
  font-weight: 400;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}
.konflikt-feld input {
  width: auto;
  min-height: 0;
}

/* --- Phase 4: Navigation, Liste, Filter, Dialoge --- */
.skip {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  padding: 0.5rem 1rem;
  background: var(--akzent);
  color: var(--akzent-fg);
  border-radius: 0.5rem;
  z-index: 10;
}
.skip:focus {
  top: 0.5rem;
}
.nur-screenreader {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.kopf {
  flex-wrap: wrap;
}
nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}
nav a {
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  color: inherit;
  text-decoration: none;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
}
nav a[aria-current='page'] {
  background: var(--akzent);
  color: var(--akzent-fg);
  font-weight: 600;
}
h2:focus {
  outline: none;
}
label.inline {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  font-weight: 400;
  min-height: 2.75rem;
}
input[type='checkbox'],
input[type='radio'] {
  width: 1.25rem;
  height: 1.25rem;
  min-height: 0;
  accent-color: var(--akzent);
}
.filter {
  margin: 0.75rem 0;
}
.filter summary::before {
  content: '▸';
  display: inline-block;
  width: 1.25rem;
}
.filter[open] summary::before {
  content: '▾';
}
.filter summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
}
.filtergitter {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}
.sortierung {
  max-width: 20rem;
}
.werkzeugleiste {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 1rem 0 0.25rem;
}
.werkzeugleiste .hinweis {
  margin: 0;
  min-height: 0;
  flex: 1;
}
.liste {
  list-style: none;
  margin: 0.5rem 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
.eintrag {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 0.75rem;
  padding: 0.6rem 0.9rem;
}
.auswahl {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  margin: -0.5rem 0 -0.5rem -0.6rem;
  cursor: pointer;
}
.eintrag .inhalt {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 0.2rem;
}
.eintrag h3 {
  margin: 0;
  font-size: 1rem;
}
.linkknopf {
  all: unset;
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  box-sizing: border-box;
  cursor: pointer;
  color: var(--akzent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.linkknopf:focus-visible {
  outline: 3px solid var(--akzent);
  outline-offset: 2px;
}
.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.ungelesen {
  font-style: italic;
}
.tags {
  margin: 0.15rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.tag {
  background: var(--fuell);
  border: 1px solid var(--linie);
  border-radius: 1rem;
  padding: 0 0.6rem;
  font-size: 0.8rem;
}
.sterne {
  letter-spacing: 1px;
}
.treffer-eintrag .inhalt button {
  justify-self: start;
}
.quelle {
  display: block;
}
.details {
  display: grid;
  grid-template-columns: minmax(7rem, 11rem) 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0.75rem 0;
}
.details dt {
  color: var(--muted);
}
.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.umbruch {
  white-space: pre-wrap;
}
button.gefahr {
  border-color: var(--fehler);
  color: var(--fehler);
}
.modus {
  border: 0;
  padding: 0;
  margin: 0 0 0.5rem;
}
.modus legend {
  padding: 0;
  margin-bottom: 0.25rem;
}
.aktionszeile {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.zitate {
  max-height: 40vh;
  overflow: auto;
  border: 1px solid var(--linie);
  border-radius: 0.5rem;
  padding: 0.25rem 0.75rem;
  margin: 0.5rem 0;
  background: var(--fuell);
}
.zitat {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
  text-indent: -1.5rem;
  overflow-wrap: anywhere;
}
#scan-video {
  width: 100%;
  max-height: 60vh;
  background: #000;
  border-radius: 0.5rem;
}
@media (max-width: 30rem) {
  .aktionen button {
    flex: 1 1 8rem; /* mehrere Schaltflächen teilen sich die Breite statt aus dem Fenster zu laufen */
  }
  .details {
    grid-template-columns: 1fr;
  }
  .details dt {
    margin-top: 0.4rem;
  }
  .kopf {
    padding-inline: 0.75rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
@media (forced-colors: active) {
  .tag,
  .eintrag {
    border: 1px solid CanvasText;
  }
}

/* --- Phase 5: Offline, Synchronisierung --- */
.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 0.75rem;
  padding: 0.5rem 0.9rem;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.9rem;
}
.status > span:first-of-type:not(.marke),
#status-text {
  flex: 1;
  min-width: 12rem;
}
.status-knoepfe {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.marke {
  border-radius: 1rem;
  padding: 0.1rem 0.7rem;
  font-weight: 600;
  background: var(--fuell);
  border: 1px solid var(--linie);
}
.warnmarke {
  background: var(--warnung-bg);
  border-color: var(--fehler);
}
.hinweisbox {
  background: var(--warnung-bg);
  border-radius: 0.75rem;
  padding: 0.5rem 0.9rem;
  margin: 0.75rem 0;
}
.hinweisbox p {
  margin: 0.25rem 0 0.5rem;
}
.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.5rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--linie);
  background: var(--warnung-bg);
  vertical-align: middle;
}
.badge.problem {
  border-color: var(--fehler);
  color: var(--fehler);
  background: var(--fehler-bg);
}
.op {
  display: grid;
  gap: 0.35rem;
}

/* --- Phase 6: Import --- */
.spalten {
  display: grid;
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.spalten .feld {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(10rem, 1fr);
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin: 0;
}
.spalten .beispiel {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.badge.neu {
  background: var(--fuell);
}
@media (max-width: 30rem) {
  .spalten .feld {
    grid-template-columns: 1fr;
  }
}

/* --- Gruppierte Ansicht --- */
.ansicht {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.25rem 0.75rem;
}
.gruppe-eintrag {
  list-style: none;
}
details.gruppe {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 0.75rem;
  padding: 0 0.9rem;
}
details.gruppe[open] {
  padding-bottom: 0.6rem;
}
details.gruppe > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  cursor: pointer;
  font-weight: 600;
}
details.gruppe > summary .gruppenname {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.gruppenliste {
  margin: 0.25rem 0 0.5rem;
}
details.gruppe .eintrag {
  background: var(--fuell);
}

/* Beiträge unter ihrem Sammelband */
details.beitraege {
  margin-top: 0.4rem;
}
details.beitraege > summary {
  cursor: pointer;
  color: var(--akzent);
  font-size: 0.9rem;
}
ul.kinder {
  margin: 0.4rem 0 0;
  padding: 0 0 0 0.75rem;
  border-left: 3px solid var(--linie);
  list-style: none;
}
.beitragsliste {
  margin: 0;
  padding-left: 1.1rem;
}
.linkknopf.klein {
  font-size: inherit;
  font-weight: normal;
}
