/* Anmeldung und Account-Verwaltung — Kopie von Wissment (auth.css), dort gleich halten.
   Alles liegt unter #auth-root, damit die Styles von Indica (h2, p, .group …) nicht greifen. */

/* Ohne Anmeldung bleibt Indica verborgen. */
html:not([data-auth="signedIn"]) body > :not(#auth-root) { display: none !important; }

#auth-root {
  --au-bg: #ffffff;
  --au-bg-grouped: #f2f2f7;
  --au-bg-elevated: #ffffff;
  --au-bg-fill: rgba(120, 120, 128, 0.12);
  --au-bg-fill-strong: rgba(120, 120, 128, 0.2);
  --au-text: #000000;
  --au-text-secondary: rgba(60, 60, 67, 0.62);
  --au-text-tertiary: rgba(60, 60, 67, 0.36);
  --au-separator: rgba(60, 60, 67, 0.18);
  --au-accent: #087e73;
  --au-on-accent: #ffffff;
  --au-destructive: #ff3b30;
  --au-glass-border: rgba(0, 0, 0, 0.06);
  --au-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
  --au-shadow-menu: 0 12px 40px rgba(0, 0, 0, 0.18);
  --au-backdrop: rgba(0, 0, 0, 0.32);
  --au-gutter: 16px;
  color: var(--au-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  #auth-root {
    --au-bg: #000000;
    --au-bg-grouped: #000000;
    --au-bg-elevated: #1c1c1e;
    --au-bg-fill: rgba(118, 118, 128, 0.24);
    --au-bg-fill-strong: rgba(118, 118, 128, 0.36);
    --au-text: #ffffff;
    --au-text-secondary: rgba(235, 235, 245, 0.62);
    --au-text-tertiary: rgba(235, 235, 245, 0.32);
    --au-separator: rgba(84, 84, 88, 0.6);
    --au-accent: #33e0d1;
    --au-on-accent: #000000;
    --au-destructive: #ff453a;
    --au-glass-border: rgba(255, 255, 255, 0.08);
    --au-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    --au-shadow-menu: 0 12px 40px rgba(0, 0, 0, 0.6);
    --au-backdrop: rgba(0, 0, 0, 0.55);
  }
}
/* Das Anmeldefenster hat wie in Listig einen weißen bzw. schwarzen Hintergrund. */
html:not([data-auth="signedIn"]) body { background: #fff; }
@media (prefers-color-scheme: dark) {
  html:not([data-auth="signedIn"]) body { background: #000; }
}

#auth-root [hidden] { display: none !important; }
/* Wie in Wissment (dort global): Breiten inkl. Innenabstand – sonst ragt z. B. die Schalter-Zeile (label) über den Rand. */
#auth-root *, #auth-root *::before, #auth-root *::after { box-sizing: border-box; }
#auth-root button, #auth-root input { font: inherit; color: inherit; }
#auth-root button { cursor: pointer; }
#auth-root button:disabled { cursor: default; }
#auth-root svg { flex: none; }
#auth-root :focus, #auth-root :focus-visible { outline: none; }
/* Highlight only while the keyboard is used (nav.js sets html[data-keyboard]); opening a sheet focuses its first button. */
html[data-keyboard] #auth-root button:focus-visible:not(.au-primary) { background: var(--au-bg-fill); }
#auth-root h1, #auth-root h2, #auth-root h3, #auth-root p { margin: 0; }

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

/* MARK: Bildschirme */

.au-center { min-height: 100dvh; display: grid; place-items: center; }

.au-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--au-bg-fill-strong);
  border-top-color: var(--au-text-secondary);
  animation: au-spin 0.8s linear infinite;
}
@keyframes au-spin { to { transform: rotate(360deg); } }

.au-auth {
  max-width: calc(420px + 2 * var(--au-gutter));
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) var(--au-gutter) max(32px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.au-brand { text-align: center; display: grid; justify-items: center; gap: 6px; padding-top: 20px; }
.au-brand img { width: 128px; height: 128px; border-radius: 28px; margin-bottom: 8px; }
#auth-root .au-brand h1 { font-size: 34px; line-height: 1.2; font-weight: 700; letter-spacing: 0.01em; }
#auth-root .au-brand h1.au-title2 { font-size: 22px; }
#auth-root .au-brand p { font-size: 17px; line-height: 1.35; color: var(--au-text-secondary); font-weight: 600; text-wrap: balance; }
.au-brand .au-hero-icon { width: 60px; height: 60px; color: var(--au-accent); margin-bottom: 8px; }
#auth-root :is(#au-screen-verify, #au-screen-link, #au-screen-finish) .au-brand p { font-weight: 400; }
/* Hinweise unter den Bestätigungs-Buttons stehen mittig wie der Text darüber. */
#auth-root :is(#au-screen-verify, #au-screen-link) .au-message { text-align: center; }
#auth-root .au-hint { font-size: 15px; line-height: 1.35; color: var(--au-text-secondary); }
#au-finish-cancel { align-self: center; margin-top: -16px; }

.au-card { background: var(--au-bg-grouped); border-radius: 24px; box-shadow: var(--au-shadow); padding: 24px; }
@media (prefers-color-scheme: dark) { .au-card { background: var(--au-bg-elevated); } }

.au-auth-card { display: flex; flex-direction: column; gap: 14px; }

.au-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--au-bg-fill);
  border-radius: 9px;
  padding: 2px;
  margin-bottom: 4px;
}
.au-segmented label { position: relative; }
.au-segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.au-segmented span { display: block; text-align: center; padding: 6px 8px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.au-segmented input:checked + span { background: var(--au-bg-elevated); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); font-weight: 600; }
@media (prefers-color-scheme: dark) { .au-segmented input:checked + span { background: #636366; } }
html[data-keyboard] .au-segmented input:focus-visible + span { background: var(--au-bg-fill-strong); }

.au-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--au-bg);
  border: 1px solid var(--au-glass-border);
  border-radius: 12px;
}
@media (prefers-color-scheme: dark) { .au-input-row { background: #2c2c2e; } }
.au-input-row svg { width: 22px; height: 22px; color: var(--au-text-secondary); }
.au-input-row input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; min-height: 24px; }

#auth-root .au-footnote { margin: -12px 0 0; text-align: center; font-size: 13px; line-height: 1.35; color: var(--au-text-secondary); text-wrap: balance; }

.au-stack { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }

#auth-root .au-message { font-size: 15px; line-height: 1.35; }
#auth-root .au-message.au-error { color: var(--au-destructive); }
#auth-root .au-message.au-info { color: var(--au-text-secondary); }

/* MARK: Buttons */

.au-button {
  border: 0;
  border-radius: 14px;
  padding: 10px 18px;
  min-height: 44px;
  font-weight: 600;
  background: var(--au-bg-fill);
  color: var(--au-accent);
}
#auth-root .au-button.au-primary { background: var(--au-accent); color: var(--au-on-accent); }
.au-button.au-large { min-height: 52px; font-size: 17px; }
#auth-root .au-button.au-plain { background: transparent; color: var(--au-accent); font-weight: 400; }
.au-button:disabled { opacity: 0.4; }
.au-button:not(:disabled):active { filter: brightness(0.92); }

#auth-root .au-link-button { border: 0; background: none; padding: 6px 0; color: var(--au-accent); font-size: 16px; min-height: 32px; }
#auth-root .au-link-button.au-secondary { color: var(--au-text-secondary); }
.au-link-button.au-align-start { align-self: flex-start; margin-top: -6px; }
.au-link-button:disabled { opacity: 0.4; }
#auth-root .au-link-button.au-group-link { margin: 2px var(--au-gutter) 0; font-size: 15px; }

/* MARK: Account */

.au-sheet {
  width: min(100%, 560px);
  max-width: 100%;
  /* Höhe nach Inhalt, ohne Prozent-Höhen im Inneren: Safari lässt das Fenster sonst
     auf null zusammenfallen, Chrome streckt es bis zur Maximalhöhe. */
  height: -webkit-fit-content;
  height: fit-content;
  max-height: min(100dvh - 40px, 860px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--au-bg-grouped);
  color: var(--au-text);
  overflow: hidden;
}
.au-sheet::backdrop, .au-alert::backdrop { background: var(--au-backdrop, rgba(0, 0, 0, 0.32)); }
@media (prefers-color-scheme: dark) {
  .au-sheet { background: #1c1c1e; }
  .au-sheet .au-group-card { background: #2c2c2e; }
}
@media (max-width: 600px) {
  .au-sheet {
    margin: auto 0 0;
    width: 100%;
    height: calc(100dvh - max(12px, env(safe-area-inset-top)));
    max-height: none;
    border-radius: 14px 14px 0 0;
  }
}

.au-sheet[open] { display: flex; flex-direction: column; }
.au-sheet-inner { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

.au-sheet-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px;
  min-height: 56px;
  border-bottom: 1px solid var(--au-separator);
}
#auth-root .au-sheet-bar h2 { font-size: 17px; line-height: 1.35; font-weight: 600; text-align: center; }
.au-bar-slot { display: flex; justify-self: start; }
.au-bar-slot.au-end { justify-self: end; }

#auth-root .au-bar-button {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--au-accent);
  border-radius: 10px;
}
.au-bar-button svg { width: 20px; height: 20px; }
.au-bar-button.au-strong { font-weight: 600; }
#auth-root .au-bar-button:disabled { color: var(--au-text-tertiary); }
.au-bar-button:not(:disabled):hover { background: var(--au-bg-fill); }

.au-sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px var(--au-gutter) 32px; -webkit-overflow-scrolling: touch; }

.au-group { margin-top: 20px; }
#auth-root .au-group-header {
  display: block;
  margin: 0 0 6px var(--au-gutter);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 400;
  text-transform: uppercase;
  color: var(--au-text-secondary);
}
#auth-root .au-group-footer { margin: 6px var(--au-gutter) 0; font-size: 13px; line-height: 1.35; color: var(--au-text-secondary); }
.au-group-card { background: var(--au-bg-elevated); border-radius: 12px; overflow: hidden; }
.au-group-card > * + * { border-top: 1px solid var(--au-separator); }

.au-row, #auth-root .au-row-button, .au-row-input {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px var(--au-gutter);
  border: 0;
  background: transparent;
  text-align: left;
}
.au-row-input { outline: 0; }
.au-row-input::placeholder { color: var(--au-text-tertiary); }
#auth-root .au-row-button { color: var(--au-accent); }
.au-row-button svg { width: 22px; height: 22px; }
#auth-root .au-row-button.au-nav { color: var(--au-text); }
.au-row-button.au-nav svg { color: var(--au-accent); }
#auth-root .au-row-button.au-destructive { color: var(--au-destructive); }
.au-row-button:hover { background: var(--au-bg-fill); }
.au-row-button:disabled { opacity: 0.4; }

/* Profilkopf: Initiale im Wissment-Verlauf, darunter Name und E-Mail. */
.au-profile { display: grid; justify-items: center; text-align: center; gap: 4px; padding: 4px 0 8px; }
.au-avatar {
  width: 84px; height: 84px;
  margin-bottom: 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #33e0d1, #087e73);
  box-shadow: 0 6px 22px rgba(51, 224, 209, 0.35);
}
#auth-root .au-profile h3 { font-size: 22px; line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; }
#auth-root .au-profile p { font-size: 15px; line-height: 1.35; color: var(--au-text-secondary); overflow-wrap: anywhere; }

/* Farbige Symbolkacheln wie in den iOS-Einstellungen. */
.au-tile { width: 30px; height: 30px; flex: none; border-radius: 8px; display: grid; place-items: center; color: #fff; }
#auth-root .au-tile svg { width: 18px; height: 18px; color: #fff; }
/* Account rows share one tile colour: the teal of the support button. */
.au-tile-brand { background: linear-gradient(135deg, #33e0d1, #087e73); }
.au-tile-blue { background: #0a84ff; }
.au-tile-green { background: #30b158; }
.au-tile-orange { background: #ff9500; }
.au-tile-gray { background: #8e8e93; }
.au-tile-red { background: #ff3b30; }
.au-row-label { flex: 1; min-width: 0; }
#auth-root .au-row-button.au-nav > svg:last-child { width: 14px; height: 14px; color: var(--au-text-tertiary); }
#auth-root .au-row-button { min-height: 52px; }
/* Trennlinien beginnen wie in iOS erst hinter der Symbolkachel. */
.au-group-card > .au-row-button + .au-row-button { border-top: 0; position: relative; }
.au-group-card > .au-row-button + .au-row-button::before { content: ""; position: absolute; top: 0; left: 58px; right: 0; height: 1px; background: var(--au-separator); }
.au-group > .au-message { margin: 10px var(--au-gutter) 0 !important; }

.au-sheet-body > .au-message { margin: 16px var(--au-gutter) 0 !important; }

/* MARK: Anleitung (guide.js) — gleiches Fenster wie der Account; es zeigt immer einen Schritt mit Fortschrittsbalken. */

#auth-root .gd-hero .au-avatar svg { width: 44px; height: 44px; }
.gd-dots { display: flex; gap: 6px; margin-top: 14px; }
.gd-dots span { width: 8px; height: 8px; border-radius: 99px; background: var(--au-bg-fill-strong); transition: width .2s ease; }
.gd-dots .is-done { background: color-mix(in srgb, var(--au-accent) 55%, transparent); }
.gd-dots .is-viewed { width: 22px; background: var(--au-accent); }
.gd-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
#auth-root .gd-pager-button { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--au-bg-elevated); color: var(--au-accent); font-size: 16px; font-weight: 600; }
.au-sheet .gd-pager-button { background: var(--au-bg-elevated); }
@media (prefers-color-scheme: dark) { .au-sheet .gd-pager-button { background: #2c2c2e; } }
.gd-pager-button svg { width: 18px; height: 18px; }
.gd-pager-button.gd-forward { margin-left: auto; }
#auth-root .gd-pager-button:disabled { color: var(--au-text-tertiary); }
#auth-root .gd-pager-button.gd-finish { padding: 0 22px; background: var(--au-accent); color: var(--au-on-accent); box-shadow: 0 4px 14px color-mix(in srgb, var(--au-accent) 40%, transparent); }
.gd-pager-button:not(:disabled):hover { filter: brightness(.96); }
#auth-root .gd-pager-hint { margin-top: 12px; text-align: center; }
.gd-pager-hint a { color: var(--au-accent); text-underline-offset: 2px; }
.gd-step-main { display: grid; gap: 10px; padding: 14px var(--au-gutter); }
.gd-step-head { display: flex; align-items: center; gap: 12px; }
#auth-root .gd-step h4 { flex: 1; min-width: 0; margin: 0; font-size: 17px; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
#auth-root .gd-step-text { margin: 0; font-size: 15px; line-height: 1.4; color: var(--au-text-secondary); }
.gd-progress { display: grid; gap: 6px; }
#auth-root .gd-status { display: inline-flex; align-items: center; gap: 6px; justify-self: start; margin: 0; padding: 5px 12px 5px 9px; border-radius: 999px; font-size: 14px; font-weight: 600; line-height: 1.3; background: var(--au-bg-fill); color: var(--au-text-secondary); }
#auth-root .gd-status svg { width: 17px; height: 17px; }
#auth-root .gd-status-done { background: color-mix(in srgb, var(--au-accent) 15%, transparent); color: var(--au-accent); }
.gd-bar { height: 6px; border-radius: 99px; background: var(--au-bg-fill-strong); overflow: hidden; }
.gd-bar span { display: block; height: 100%; border-radius: inherit; background: var(--au-accent); transition: width .2s ease; }
#auth-root .gd-progress p { margin: 0; font-size: 13px; line-height: 1.35; color: var(--au-text-secondary); }
.gd-badge { display: grid; place-items: center; width: 24px; height: 24px; flex: none; color: var(--au-text-tertiary); }
#auth-root .gd-badge svg { width: 20px; height: 20px; }
.gd-badge-done { border-radius: 50%; background: var(--au-accent); color: var(--au-on-accent); }
#auth-root .gd-badge-done svg { width: 15px; height: 15px; }
#auth-root a.au-row-button { text-decoration: none; }
#auth-root .au-row-button.gd-link { color: var(--au-accent); }
#auth-root .au-row-button.gd-link > svg:last-child { color: var(--au-accent); }
.au-group-card > .gd-link + .gd-link::before { left: var(--au-gutter); }
#auth-root .gd-check { color: var(--au-text); }
.gd-checkbox { display: grid; place-items: center; width: 24px; height: 24px; flex: none; margin: 0 3px; border-radius: 50%; border: 2px solid var(--au-text-tertiary); color: transparent; }
#auth-root .gd-checkbox svg { width: 15px; height: 15px; }
.gd-check[aria-pressed="true"] .gd-checkbox { border-color: var(--au-accent); background: var(--au-accent); color: var(--au-on-accent); }
.gd-tile-teal { background: linear-gradient(135deg, #33e0d1, #087e73); }
.gd-tile-pink { background: #ff2d55; }
.gd-tile-purple { background: #af52de; }
.au-tile img { width: 18px; height: 18px; object-fit: contain; }

@media (prefers-reduced-motion: reduce) { .gd-bar span, .gd-dots span { transition: none; } }

/* MARK: Rückfragen */

.au-alert {
  width: min(calc(100% - 2 * var(--au-gutter)), 300px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--au-bg-elevated);
  color: var(--au-text);
  text-align: center;
  box-shadow: var(--au-shadow-menu);
}
@media (prefers-color-scheme: dark) { .au-alert { background: #2c2c2e; } }
.au-alert-inner { display: flex; flex-direction: column; }
#auth-root .au-alert h2 { margin: 20px 16px 4px; font-size: 17px; line-height: 1.35; font-weight: 600; }
#auth-root .au-alert p { margin: 0 16px 16px; font-size: 13px; line-height: 1.35; color: var(--au-text); }
#auth-root .au-alert p:empty { display: none; }
.au-alert-buttons { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--au-separator); }
#auth-root .au-alert-button { min-height: 44px; border: 0; background: none; color: var(--au-accent); font-size: 17px; }
.au-alert-button + .au-alert-button { border-left: 1px solid var(--au-separator); }
.au-alert-buttons.au-single { grid-template-columns: 1fr; }
.au-alert-input {
  margin: 0 16px 16px;
  padding: 8px 10px;
  border: 1px solid var(--au-separator);
  border-radius: 8px;
  background: var(--au-bg);
  color: var(--au-text);
  font-size: 15px;
  text-align: left;
  outline: 0;
}
.au-alert-input:focus { border-color: var(--au-accent); }

.au-alert-button.au-strong { font-weight: 600; }
#auth-root .au-alert-button.au-destructive { color: var(--au-destructive); }
/* Gesperrt (z. B. bis der Benutzername stimmt): grau, auch bei roten Buttons. */
#auth-root .au-alert-button:disabled { color: var(--au-text-tertiary); cursor: default; }
.au-alert-button:disabled:hover { background: none; }
.au-alert-button:hover { background: var(--au-bg-fill); }

@media (prefers-reduced-motion: reduce) {
  #auth-root *, #auth-root *::before, #auth-root *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Impressum and Datenschutz links on the sign-in screen: reachable without an account. */
#auth-root .au-legal { margin-top: -20px; }
#auth-root .au-legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* MARK: E-Mail-Einwilligung — Kästchen beim Account erstellen, Schalter in der Account-Verwaltung */

#auth-root .au-check { display: flex; align-items: flex-start; gap: 12px; font-size: 15px; line-height: 1.4; color: var(--au-text-secondary); cursor: pointer; }
#auth-root .au-check[hidden] { display: none; }
.au-check em { font-style: normal; color: var(--au-text-tertiary); }
.au-check input {
  -webkit-appearance: none; appearance: none; flex: none; width: 22px; height: 22px; margin: 0; border-radius: 6px;
  border: 2px solid var(--au-text-tertiary); background: transparent; cursor: pointer; display: grid; place-items: center;
}
.au-check input:checked { background: var(--au-accent); border-color: var(--au-accent); }
.au-check input:checked::after { content: ""; width: 5px; height: 10px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
html[data-keyboard] .au-check input:focus-visible { box-shadow: 0 0 0 3px var(--au-bg-fill-strong); }

#auth-root .au-switch-row { min-height: 52px; cursor: pointer; }
.au-switch {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; width: 51px; height: 31px; margin: 0;
  border-radius: 16px; background: var(--au-bg-fill-strong); cursor: pointer; transition: background 0.2s;
}
.au-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: transform 0.2s;
}
.au-switch:checked { background: #34c759; }
.au-switch:checked::after { transform: translateX(20px); }
.au-switch:disabled { opacity: 0.5; cursor: default; }
