/* Perplexa App-Server
   Markenfarben: Anthrazit #231F20, Grün #A6D71C
   Alle Farbpaare sind auf mindestens 4.5:1 Kontrast geprüft. */

:root {
  --ink: #231F20;
  --muted: #5F5B5C;
  --paper: #F4F3F1;
  --surface: #FFFFFF;
  --surface-sunken: #F7F6F4;
  --rule: #DEDBD7;

  --accent: #A6D71C;
  --accent-hover: #96C40F;
  /* Weiß auf dem Grün ergibt nur 1.7:1 - deshalb Anthrazit darauf. */
  --accent-ink: #231F20;
  --accent-deep: #5C7A0F;

  --accent-tint: #EDF7D2;

  --alert: #A33422;
  --alert-bg: #FBF2F0;
  --ok: #2C6B3F;
  --ok-bg: #F0F6F1;

  --hover-fill: #F1EFEC;

  --step: 0.5rem;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-menu: 0 8px 24px rgb(35 31 32 / 0.13);
}

/* Ohne ausdrückliche Wahl folgt die Darstellung dem Betriebssystem. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="hell"]) {
    --ink: #F2F0EE;
    --muted: #A8A2A0;
    --paper: #1A1719;
    --surface: #232022;
    --surface-sunken: #2B2729;
    --rule: #383336;
    --accent-hover: #B6E52C;
    --accent-deep: #A6D71C;
    --alert: #F0917F;
    --alert-bg: #2E2220;
    --ok: #8FD4A6;
    --ok-bg: #1F2A23;
    --accent-tint: #2F3A1A;
    --hover-fill: #302B2D;
    --shadow-menu: 0 8px 24px rgb(0 0 0 / 0.45);
  }
}

/* Ausdrücklich gewählter Dunkelmodus. */
:root[data-theme="dunkel"] {
  --ink: #F2F0EE;
  --muted: #A8A2A0;
  --paper: #1A1719;
  --surface: #232022;
  --surface-sunken: #2B2729;
  --rule: #383336;
  --accent-hover: #B6E52C;
  --accent-deep: #A6D71C;
  --accent-tint: #2F3A1A;
  --alert: #F0917F;
  --alert-bg: #2E2220;
  --ok: #8FD4A6;
  --ok-bg: #1F2A23;
  --hover-fill: #302B2D;
  --shadow-menu: 0 8px 24px rgb(0 0 0 / 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 30rem;
  margin: 0 auto;
  /* env(safe-area-inset-*) hält Inhalte aus Aussparung und
     Home-Indikator heraus. Ohne diese Ergänzung klebt die Kopfzeile
     im Standalone-Modus unter der Kamera. */
  padding:
    calc(var(--step) * 6 + env(safe-area-inset-top))
    calc(var(--step) * 3 + env(safe-area-inset-right))
    calc(var(--step) * 10 + env(safe-area-inset-bottom))
    calc(var(--step) * 3 + env(safe-area-inset-left));
}
/* Drei Breiten, je nach Aufgabe der Seite:
   Standard  30rem - Formulare, eine Sache pro Seite
   --wide    76rem - Verwaltung mit mehrspaltigen Tabellen
   --breit   90rem - Dashboard mit Kachelraster */
.shell--wide { max-width: 76rem; }
.shell--breit { max-width: 90rem; }

/* ---------- Kopfzeile ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--step) * 2);
  margin-bottom: calc(var(--step) * 4);
  min-height: 44px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius-sm);
}
/* Das Logo erbt die Textfarbe: anthrazit im Hellmodus, hell im
   Dunkelmodus. Das Grün bleibt in beiden Fällen unverändert. */
.wordmark svg { width: 130px; height: auto; display: block; }
.wordmark--gross svg { width: 190px; }

/* ---------- Menü (details/summary, kein JavaScript nötig) ---------- */

.menu { position: relative; }

.menu__button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
  color: var(--ink);
}
.menu__button::-webkit-details-marker { display: none; }
.menu__button:hover { background: var(--surface-sunken); }

.menu__bars { display: block; width: 18px; height: 2px; background: currentColor; position: relative; }
.menu__bars::before, .menu__bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: currentColor;
}
.menu__bars::before { top: -6px; }
.menu__bars::after { top: 6px; }

.menu[open] .menu__bars { background: transparent; }
.menu[open] .menu__bars::before { top: 0; transform: rotate(45deg); }
.menu[open] .menu__bars::after { top: 0; transform: rotate(-45deg); }

.menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--step));
  min-width: 15rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-menu);
  padding: var(--step);
  z-index: 20;
}

.menu__label {
  display: block;
  padding: var(--step) calc(var(--step) * 1.5) calc(var(--step) * 0.5);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: calc(var(--step) * 1.25) calc(var(--step) * 1.5);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 400;
  min-height: 0;
  text-decoration: none;
  cursor: pointer;
}
.menu__item, .menu__panel button.menu__item {
  border: 0;
  background: transparent;
  font-weight: 400;
}
.menu__item:hover, .menu__panel button.menu__item:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}
.menu__item[aria-current="true"] { font-weight: 600; }
.menu__item[aria-current="true"]::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 1em;
  margin-right: var(--step);
  background: var(--accent);
  vertical-align: -0.15em;
  border-radius: 2px;
}

.menu__trenner { height: 1px; background: var(--rule); margin: var(--step) calc(var(--step) * 0.5); border: 0; }

/* ---------- Karten und Text ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: calc(var(--step) * 4);
}

h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 calc(var(--step) * 2); }
h2 { font-size: 1.0625rem; font-weight: 600; margin: calc(var(--step) * 5) 0 calc(var(--step) * 1.5); }
p { margin: 0 0 calc(var(--step) * 2); max-width: 62ch; }
.lede { color: var(--muted); }

a { color: var(--ink); }
a:hover { color: var(--accent-deep); }

/* ---------- Ablaufanzeige (nur beim zweistufigen Login) ---------- */

.progress { display: flex; gap: var(--step); margin-bottom: calc(var(--step) * 3); }
.progress span { flex: 1; height: 4px; background: var(--rule); border-radius: 2px; }
.progress span.done { background: var(--accent); }

/* ---------- Formulare ---------- */

label { display: block; font-size: 0.875rem; color: var(--muted); margin-bottom: calc(var(--step) * 0.75); }

input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%;
  padding: calc(var(--step) * 1.5);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  margin-bottom: calc(var(--step) * 2.5);
}
input:focus-visible, select:focus-visible, button:focus-visible,
a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent-deep);
  outline-offset: 2px;
}

.code-input {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
  font-size: 1.3rem;
  text-align: center;
}

button {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: calc(var(--step) * 1.25) calc(var(--step) * 3);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }

/* Sekundärstufe: klare Kontur statt fast unsichtbarem Rahmen. Ein
   hellgrauer Rahmen auf weißer Karte hebt sich kaum ab und liest sich
   nicht als Schaltfläche. */
button.quiet {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  font-weight: 600;
}
button.quiet:hover { background: var(--hover-fill); }

/* Rückbaubare Alternative: statt Kontur eine grüne Tönung.
   Dafür in .quiet die drei Zeilen durch diese ersetzen:
     background: var(--accent-tint);
     border: 1.5px solid transparent;
     color: var(--accent-ink);  */

button.danger {
  background: transparent;
  color: var(--alert);
  border: 1.5px solid var(--alert);
  font-weight: 600;
}
button.danger:hover { background: var(--alert-bg); }

/* ---------- Hinweise ---------- */

.notice {
  border-left: 4px solid var(--rule);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: calc(var(--step) * 1.75) calc(var(--step) * 2);
  margin-bottom: calc(var(--step) * 3);
  background: var(--surface-sunken);
}
.notice--error { border-left-color: var(--alert); color: var(--alert); background: var(--alert-bg); }
.notice--ok { border-left-color: var(--ok); color: var(--ok); background: var(--ok-bg); }

.footnote { margin-top: calc(var(--step) * 3); font-size: 0.9375rem; color: var(--muted); }
.footnote a { color: var(--accent-deep); }

/* ---------- Zweiter Faktor ---------- */

.qr {
  display: block;
  width: min(200px, 60vw);
  height: auto;
  aspect-ratio: 1;
  margin: 0 0 calc(var(--step) * 2);
  background: #FFFFFF;
  border-radius: var(--radius-sm);
  padding: var(--step);
}

.secret {
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
  font-size: 0.9rem;
  background: var(--surface-sunken);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: calc(var(--step) * 1.5);
  word-break: break-all;
  margin-bottom: calc(var(--step) * 3);
}

.codes {
  list-style: none;
  padding: 0;
  margin: 0 0 calc(var(--step) * 3);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--step);
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
}
.codes li {
  background: var(--surface-sunken);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: calc(var(--step) * 1.5);
  text-align: center;
}

/* ---------- Tabellen ---------- */

table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td {
  text-align: left;
  padding: calc(var(--step) * 1.5);
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
th { font-weight: 600; color: var(--muted); font-size: 0.8125rem; }
td form { display: inline; }
td button { min-height: 36px; padding: calc(var(--step) * 0.75) calc(var(--step) * 1.5); font-size: 0.875rem; }

.tag { font-size: 0.875rem; color: var(--muted); }
.tag--warn { color: var(--alert); }

.inline-form { display: flex; gap: calc(var(--step) * 1.5); align-items: flex-end; flex-wrap: wrap; }
.inline-form > div { flex: 1 1 14rem; }
.inline-form input, .inline-form select { margin-bottom: 0; }

/* ---------- Schmale Bildschirme ---------- */

@media (max-width: 34rem) {
  .shell {
    padding:
      calc(var(--step) * 4 + env(safe-area-inset-top))
      calc(var(--step) * 2 + env(safe-area-inset-right))
      calc(var(--step) * 8 + env(safe-area-inset-bottom))
      calc(var(--step) * 2 + env(safe-area-inset-left));
  }
  .card { padding: calc(var(--step) * 3); }
  .wordmark svg { width: 108px; }
  .wordmark--gross svg { width: 150px; }
  .menu__panel { min-width: min(17rem, calc(100vw - var(--step) * 6)); }
  .inline-form { align-items: stretch; }
  .inline-form button { width: 100%; }

  /* Tabellenzeilen werden zu gestapelten Karten. Die Spaltenüberschrift
     wandert über data-label vor den Wert - sonst läuft eine
     fünfspaltige Tabelle über den Rand hinaus. */
  table.stapelbar thead { display: none; }
  table.stapelbar, table.stapelbar tbody, table.stapelbar tr, table.stapelbar td { display: block; width: 100%; }
  table.stapelbar tr {
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    margin-bottom: calc(var(--step) * 2);
    padding: var(--step);
  }
  table.stapelbar td { border: 0; padding: calc(var(--step) * 0.75) var(--step); }
  table.stapelbar td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
  }
  table.stapelbar td:empty { display: none; }
  table.stapelbar td button { width: 100%; margin-top: calc(var(--step) * 0.5); }
}

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

/* ---------- Dashboard ---------- */

/* Für Screenreader sichtbar, optisch nicht. Nicht display:none -
   das würde den Text auch dem Screenreader vorenthalten. */
.nur-vorlesen {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.kontohinweis {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: calc(var(--step) * 3);
}

.leerzustand {
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: calc(var(--step) * 5) calc(var(--step) * 4);
  text-align: center;
  color: var(--muted);
}
.leerzustand p { margin-left: auto; margin-right: auto; }
.leerzustand .footnote { margin-top: var(--step); }



/* ---------- Kacheln (Dashboard) ---------- */

.abschnitt {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 calc(var(--step) * 2);
}

.kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: calc(var(--step) * 2.5);
  margin: 0 0 calc(var(--step) * 4);
  padding: 0;
  list-style: none;
}

.kachel {
  display: flex;
  gap: calc(var(--step) * 2);
  align-items: flex-start;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: calc(var(--step) * 2.5);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.kachel:hover {
  background: var(--surface-sunken);
  border-color: var(--accent-deep);
  color: var(--ink);
}

/* Monogramm statt Symbolbibliothek: braucht keine Dateien, keinen
   Upload und keine Prüfung fremder Bilder - und sieht bei jedem
   Werkzeug gleich sauber aus. */
.kachel__zeichen {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.kachel__inhalt { min-width: 0; }

.kachel__name {
  display: block;
  font-weight: 600;
  font-size: 1.0625rem;
  margin-bottom: calc(var(--step) * 0.5);
}

.kachel__text {
  font-size: 0.9375rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* ---------- Passkeys ---------- */

.passkey-block { margin-bottom: calc(var(--step) * 2); }
.passkey-block button { width: 100%; }

.divider {
  display: flex;
  align-items: center;
  gap: calc(var(--step) * 1.5);
  color: var(--muted);
  font-size: 0.875rem;
  margin: calc(var(--step) * 3) 0;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

/* ---------- Posteingang ---------- */

.nachrichtentext {
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
  font-size: 0.9375rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-sunken);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: calc(var(--step) * 2);
  margin: 0 0 calc(var(--step) * 3);
  max-width: 80ch;
}

.anhaenge { margin: 0 0 calc(var(--step) * 2); padding-left: calc(var(--step) * 3); }

/* Auf breiten Seiten sollen Eingabefelder nicht über die ganze Breite
   laufen - ein 1000 Pixel breites Zahlenfeld hilft niemandem. */
.schmal { max-width: 26rem; }

.kopfdaten {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: calc(var(--step) * 0.5) calc(var(--step) * 2);
  margin: 0 0 calc(var(--step) * 3);
  font-size: 0.9375rem;
  max-width: 80ch;
}
.kopfdaten dt { color: var(--muted); }
.kopfdaten dd { margin: 0; word-break: break-word; }

input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent-deep);
  cursor: pointer;
}

/* ---------- Standalone (vom Home-Bildschirm gestartet) ---------- */

/* Rückweg. Im Browser eine schlichte Verknüpfung, im Standalone-Modus
   eine deutliche Schaltfläche - dort fehlt der Zurück-Knopf. */
.zurueck {
  display: inline-flex;
  align-items: center;
  gap: var(--step);
  margin-top: calc(var(--step) * 3);
  color: var(--accent-deep);
  text-decoration: none;
  font-size: 0.9375rem;
}
.zurueck::before { content: "\2190"; }
.zurueck:hover { text-decoration: underline; }

@media (display-mode: standalone) {
  .zurueck {
    padding: calc(var(--step) * 1.25) calc(var(--step) * 2.5);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-weight: 600;
  }
  .zurueck:hover { background: var(--hover-fill); color: var(--ink); text-decoration: none; }

  body { overscroll-behavior-y: none; }
}

/* Kuerzel in der Benutzerverwaltung: Eingabefeld und Knopf in einer
   Zeile, damit die Tabellenzeile nicht auseinanderfaellt. Das Feld ist
   kurz, weil das Kuerzel kurz ist - ein breites Feld wuerde einen
   langen Wert nahelegen. */
.kuerzel-form { display: flex; gap: var(--step); align-items: center; }
.kuerzel-form input {
  margin-bottom: 0;
  width: 7rem;
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
  text-transform: uppercase;
}
.kuerzel-form button { flex: 0 0 auto; }
