:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --surface: #121214;
  --surface-2: #181819;
  --border: #262629;
  --text: #f4f4f5;
  --muted: #8a8a92;
  --red: #e11d2a;
  --red-bright: #ff2d3c;
  --red-dim: rgba(225, 29, 42, 0.12);
  --ok: #e11d2a;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  font-size: 1.05rem;
}
.brand .dot {
  color: var(--red);
  font-size: 1.2rem;
  animation: beat 1.6s ease-in-out infinite;
}

/* Main */
main {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}
.hero {
  width: 100%;
  max-width: 460px;
  text-align: center;
}
.heart {
  font-size: 3.4rem;
  line-height: 1;
  filter: drop-shadow(0 0 18px rgba(225, 29, 42, 0.45));
  animation: beat 1.6s ease-in-out infinite;
}
h1 {
  font-size: 1.9rem;
  font-weight: 650;
  margin: 0.9rem 0 0.35rem;
  letter-spacing: 0.3px;
}
.tagline {
  color: var(--muted);
  margin: 0 0 2rem;
  font-size: 0.98rem;
}

/* Status card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
}
.row + .row { border-top: 1px solid var(--border); }
.row .label { color: var(--text); font-size: 0.95rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.pill .led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3a3a40;
}
.pill.up   { color: var(--text); }
.pill.up .led   { background: var(--red); box-shadow: 0 0 10px var(--red); }
.pill.down .led { background: #555; }

footer {
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
}

/* Formular / Setup-Wizard */
.wizard { width: 100%; max-width: 440px; text-align: left; }
.step { display: none; }
.step.active { display: block; }
.step h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 0.35rem; }
.step .hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 1.2rem; }

label { display: block; font-size: 0.82rem; color: var(--muted); margin: 0.9rem 0 0.35rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.7rem 0.85rem;
  outline: none;
}
textarea { font-family: inherit; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus { border-color: var(--red); }

button {
  width: 100%;
  margin-top: 1.4rem;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
button:hover { background: var(--red-bright); }
button:disabled { background: #3a2326; color: #9a8a8c; cursor: not-allowed; }
button.secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.secondary:hover { border-color: var(--muted); background: transparent; }

.error { color: var(--red-bright); font-size: 0.85rem; margin-top: 0.8rem; min-height: 1.1em; }
.note { color: var(--muted); font-size: 0.82rem; margin-top: 0.8rem; }

.secret-box {
  background: var(--surface-2);
  border: 1px dashed var(--red);
  border-radius: 10px;
  padding: 1rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.05rem;
  letter-spacing: 1px;
  word-break: break-all;
  text-align: center;
  color: var(--text);
}
.checkbox { display: flex; align-items: flex-start; gap: 0.55rem; margin-top: 1rem; font-size: 0.9rem; color: var(--text); }
.checkbox input { margin-top: 0.2rem; accent-color: var(--red); }

/* QR-Code (TOTP) */
.qr-card {
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  width: max-content;
  max-width: 100%;
  margin: 0.4rem auto 0.2rem;
  box-shadow: 0 0 0 1px var(--border), 0 8px 30px rgba(0, 0, 0, 0.4);
}
.qr-card svg { display: block; width: 230px; height: 230px; max-width: 60vw; }
details.manual { margin-top: 0.9rem; }
details.manual summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
}
details.manual summary::-webkit-details-marker { display: none; }
details.manual summary:hover { color: var(--text); }

/* Dashboard / Kontrollzentrum */
.dash { max-width: 540px; margin: 0 auto; }

.tabs {
  display: flex; gap: 0.25rem; overflow-x: auto;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.tab {
  width: auto; margin: 0; border-radius: 0;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 0.95rem; font-weight: 500;
  padding: 0.85rem 1rem; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); background: transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--red); }

.tabpanel { display: none; }
.tabpanel.active { display: flex; flex-direction: column; gap: 1.1rem; }

.banner {
  background: var(--red-dim);
  border-bottom: 1px solid var(--red);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 0.6rem 1.25rem;
  text-align: center;
}
.banner a { color: var(--red-bright); text-decoration: none; font-weight: 600; white-space: nowrap; }
.banner a:hover { text-decoration: underline; }

select, input[type=number], input[type=time], input[type=datetime-local] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.7rem 0.85rem;
  outline: none;
}
select:focus, input[type=number]:focus, input[type=time]:focus, input[type=datetime-local]:focus { border-color: var(--red); }

.badge { font-size: 0.78rem; padding: 0.28rem 0.65rem; border-radius: 999px; font-weight: 600; }
.badge-ok { color: var(--red-bright); background: var(--red-dim); border: 1px solid var(--red); }
.badge-danger { color: #fff; background: var(--red-bright); }
.badge-muted { color: var(--muted); background: #1f1f24; border: 1px solid var(--border); }

.field-row { display: flex; gap: 0.8rem; }
.field-row > div { flex: 1; }

.seg { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.seg-opt {
  display: flex; align-items: center; gap: 0.45rem; flex: 1;
  font-size: 0.88rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.55rem 0.7rem; cursor: pointer;
}
.seg-opt input { accent-color: var(--red); margin: 0; }

.msg { font-size: 0.85rem; margin-top: 0.7rem; min-height: 1em; }
.msg-ok { color: #cfcfd4; }
.msg-err { color: var(--red-bright); }

.linkbtn {
  width: auto; margin: 0 0 0 0.4rem; padding: 0.3rem 0.5rem;
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); font-size: 0.95rem; cursor: pointer;
}
.linkbtn:hover { color: var(--text); border-color: var(--muted); background: transparent; }

/* Datei-Upload + Fortschritt */
input[type=file] { width: 100%; color: var(--muted); font-size: 0.9rem; margin-top: 0; }
input[type=file]::file-selector-button {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.5rem 0.8rem; margin-right: 0.7rem; cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--muted); }

.progress { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--red); transition: width 0.15s ease; }
.progress-bar.indet { width: 35%; animation: indet 1.1s infinite ease-in-out; }
@keyframes indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* Regeln-Auswahl (welcher Kontakt bekommt welche Items) */
.rules-box {
  display: flex; flex-direction: column; gap: 0.3rem;
  max-height: 220px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.6rem 0.7rem;
}
.rule-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text); cursor: pointer; padding: 0.2rem 0; }
.rule-item input { accent-color: var(--red); margin: 0; width: auto; }

@keyframes beat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(1); }
  45% { transform: scale(1.08); }
}

/* „So funktioniert's" — Phasen auf der Startseite */
.phase { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.6rem 0; border-top: 1px solid var(--border); }
.phase:first-of-type { border-top: none; padding-top: 0.2rem; }
.phase .pico { font-size: 1.2rem; line-height: 1.35; flex: none; }
.phase strong { color: var(--text); font-size: 0.95rem; }
.pmuted { color: var(--muted); font-size: 0.88rem; line-height: 1.55; }

@media (prefers-reduced-motion: reduce) {
  .heart, .brand .dot { animation: none; }
}

/* ----- Geheimnis-Modal (Passwort/Notiz anzeigen) ----- */
.modal-ov {
  position: fixed; inset: 0; background: rgba(0,0,0,.66);
  display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 460px; max-height: 88vh; overflow: auto;
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
}
.srow {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem 0; border-bottom: 1px solid var(--border);
}
.srow:last-child { border-bottom: 0; }
.srow .slabel { color: var(--muted); font-size: .8rem; width: 5.5rem; flex: none; }
.srow .sval { flex: 1; word-break: break-all; font-size: .95rem; }
.seg { display: flex; gap: .4rem; }
.seg .rule-item { flex: 1; }
