/* Anmeldung: neutral pages on anmeldung.<domain>. System fonts only, light and dark, phone first.
   CSP: style-src 'self', so every rule lives here (no style attributes, no <style>). */

:root {
  color-scheme: light dark;
  --grund: #f2f3f6;
  --flaeche: #ffffff;
  --text: #1a1c23;
  --text-2: #555b6a;
  --rand: #cdd1db;
  --feld: #ffffff;
  --akzent: #2a55c9;
  --akzent-text: #ffffff;
  --fehler: #b3261e;
  --fehler-grund: #fcebea;
  --gut: #1d6b43;
  --gut-grund: #e5f4eb;
  --warn: #8a5300;
  --warn-grund: #fff3dc;
  --schatten: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.08);
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #111318;
    --flaeche: #1b1e26;
    --text: #eceef3;
    --text-2: #a9afbd;
    --rand: #3b404d;
    --feld: #14161c;
    --akzent: #8aa8ff;
    --akzent-text: #0c1020;
    --fehler: #ffb4ab;
    --fehler-grund: #3b1714;
    --gut: #8fd8ae;
    --gut-grund: #12301f;
    --warn: #ffcf86;
    --warn-grund: #35270d;
    --schatten: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--grund);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  font-family: var(--schrift);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--grund);
}

@media (min-width: 480px) and (min-height: 640px) {
  body:not([data-seite="verwaltung"]) { justify-content: center; }
}

h1, h2, h3 { margin: 0 0 0.75rem; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
p, ol, ul { margin: 0 0 0.875rem; }
a { color: var(--akzent); text-underline-offset: 0.15em; }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--akzent); outline-offset: 2px; }
[tabindex="-1"]:focus-visible { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Card ----------------------------------------------------------------------------------------------------------- */

.karte {
  width: 100%;
  max-width: 26rem;
  padding: 24px 20px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 16px;
  box-shadow: var(--schatten);
}

.unter, .feldhinweis { color: var(--text-2); }
.feldhinweis { font-size: 0.9375rem; margin: 0.375rem 0 0; }
p.feldhinweis:empty { margin: 0; }

/* The login page stays invisible until anmelden.js sets .bereit (no running session): with a session the page
   jumps on before anything is visible, and without JS there is nothing to fill in (the form only works with it). */
body:not(.bereit) .spaeter { visibility: hidden; }

/* Without JS: one sentence instead of a form that cannot work. */
.ohne-js { margin: 0 0 1rem; }

/* ---- Form ----------------------------------------------------------------------------------------------------------- */

form { margin: 0; }
.feld { margin: 0 0 1rem; }
.feld label { display: block; margin: 0 0 0.375rem; font-weight: 600; }

input[type="text"], input[type="password"] {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font: inherit;
  font-size: max(1rem, 16px); /* no zoom on iOS */
  color: var(--text);
  background: var(--feld);
  border: 1px solid var(--rand);
  border-radius: 10px;
}
input[type="text"]:focus-visible, input[type="password"]:focus-visible { border-color: var(--akzent); outline-offset: 0; }
input::placeholder { color: var(--text-2); opacity: 0.8; }

input[type="checkbox"] {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.15rem 0 0;
  accent-color: var(--akzent);
}

.haken {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  min-height: 44px;
  padding: 0.5rem 0;
  cursor: pointer;
}
.haken:has(input:disabled) { cursor: default; color: var(--text-2); }

fieldset { margin: 0 0 1rem; padding: 0; border: 0; min-width: 0; }
fieldset.felder { margin: 0; }   /* wraps a whole form; disabled in the HTML until the page script unlocks it */
legend { padding: 0; margin: 0 0 0.25rem; font-weight: 600; }

/* ---- Buttons -------------------------------------------------------------------------------------------------------- */

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  color: var(--akzent-text);
  background: var(--akzent);
  border: 1px solid var(--akzent);
  border-radius: 10px;
  cursor: pointer;
}
.knopf:hover { filter: brightness(1.08); }
.knopf:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }
.knopf[aria-busy="true"] { cursor: progress; }
.knopf.zweit { color: var(--akzent); background: transparent; }
.knopf.gefahr { color: var(--fehler); background: transparent; border-color: currentColor; }
.knopf.klein { width: auto; min-height: 44px; padding: 6px 14px; font-size: 0.9375rem; }

.verweis {
  min-height: 44px;
  padding: 8px 0;
  font: inherit;
  color: var(--akzent);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

.aktionen { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 0; }
.aktionen .knopf { flex: 1 1 auto; width: auto; }
.aktionen.spalte { flex-direction: column; }
.aktionen.spalte .knopf { width: 100%; }

.nebenweg { margin: 1rem 0 0; text-align: center; }
.nebenweg + .nebenweg { margin-top: 0.25rem; }

/* ---- Messages ------------------------------------------------------------------------------------------------------- */

.meldung {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  color: var(--fehler);
  background: var(--fehler-grund);
  border-radius: 10px;
}
.meldung:empty { margin: 0; padding: 0; }
.meldung.gut { color: var(--gut); background: var(--gut-grund); }
.meldung a { color: inherit; font-weight: 600; }
main > .meldung:last-child:not(:empty) { margin: 1rem 0 0; }

.hinweis { padding: 0.75rem 1rem; color: var(--gut); background: var(--gut-grund); border-radius: 10px; }
.warnung { padding: 0.75rem 1rem; color: var(--warn); background: var(--warn-grund); border-radius: 10px; }

/* ---- Codes, QR, secrets --------------------------------------------------------------------------------------------- */

.schritte { padding-left: 1.25rem; }
.schritte li + li { margin-top: 0.25rem; }

.qr {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  margin: 0.5rem auto 1rem;
  padding: 12px;
  background: #ffffff; /* QR codes need a light ground, also in dark mode */
  border-radius: 12px;
}

.geheim {
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 1.0625rem;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
  background: var(--grund);
  border: 1px dashed var(--rand);
  border-radius: 10px;
}
.geheim:empty { display: none; }

.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.5rem;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
}
.codes li { padding: 0.5rem; text-align: center; background: var(--grund); border-radius: 8px; user-select: all; -webkit-user-select: all; }

/* ---- Verwaltung ----------------------------------------------------------------------------------------------------- */

main.breit { width: 100%; max-width: 52rem; }
main.breit .karte { max-width: none; margin: 0 0 1rem; }

.kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin: 0 0 1rem; }
.kopf h1 { margin: 0; }

.personen { display: grid; gap: 0.75rem; padding: 0; list-style: none; }
.person { padding: 1rem; border: 1px solid var(--rand); border-radius: 12px; }
.person-kopf h3 { margin: 0 0 0.375rem; overflow-wrap: anywhere; }
.kennung { font-family: var(--mono); font-size: 0.875rem; font-weight: 400; color: var(--text-2); }

.marken { display: flex; flex-wrap: wrap; gap: 0.375rem; padding: 0; margin: 0 0 0.5rem; list-style: none; }
.marken li {
  padding: 0.125rem 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-2);
  background: var(--grund);
  border: 1px solid var(--rand);
  border-radius: 999px;
}
.marken li.warn { color: var(--warn); background: var(--warn-grund); border-color: transparent; }

.schalter { display: flex; flex-wrap: wrap; column-gap: 1.25rem; }
.rechte { margin: 0.5rem 0 0; }
.rechte-liste { display: flex; flex-wrap: wrap; column-gap: 1.25rem; }
.person .aktionen { margin-top: 0.5rem; }
.person .aktionen .knopf { flex: 0 1 auto; }

.meldung.leiste {
  position: sticky;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 5;
  margin: 1rem 0 0;
  box-shadow: var(--schatten);
}
.meldung.leiste:empty { box-shadow: none; margin: 0; }

dialog {
  width: min(32rem, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 20px;
  color: var(--text);
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 16px;
  box-shadow: var(--schatten);
}
dialog::backdrop { background: rgba(10, 12, 18, 0.55); }
dialog h2 { margin-top: 0; }

/* ---- Small phones --------------------------------------------------------------------------------------------------- */

@media (max-width: 360px) {
  body { padding-left: 8px; padding-right: 8px; }
  .karte { padding: 18px 14px; border-radius: 12px; }
  .person { padding: 0.75rem; }
}
