/* ===== Notfall-Karte – Design (Notfall-Rot #dc2626 + Weiss) ===== */
:root {
  --red: #dc2626;
  --red-strong: #b91c1c;
  --red-dark: #991b1b;
  --red-soft: #fee2e2;
  --red-softer: #fef2f2;

  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --line: #e5e7eb;
  --text: #111827;
  --text-soft: #4b5563;
  --muted: #6b7280;
  --shadow: 0 8px 24px rgba(17, 24, 39, .10);
  --shadow-sm: 0 2px 8px rgba(17, 24, 39, .08);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 64px;
}

[data-theme="dark"] {
  --bg: #0b0e14;
  --surface: #151a23;
  --surface-2: #1c222d;
  --line: #2a313d;
  --text: #f3f4f6;
  --text-soft: #cbd2dc;
  --muted: #9aa3b2;
  --red-soft: #3a1414;
  --red-softer: #25100f;
  --shadow: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--red);
  color: #fff;
  padding: 10px 14px;
  border-radius: 0 0 8px 0;
  z-index: 200;
}
.skip-link:focus { left: 0; }

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: linear-gradient(135deg, var(--red), var(--red-strong));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 1.2rem; margin: 0; letter-spacing: .3px; font-weight: 800; }
.brand-cross {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  background: rgba(255, 255, 255, .2);
  border-radius: 9px;
  color: #fff;
}

.icon-btn {
  border: 0;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  width: 42px; height: 42px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s ease, transform .1s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, .3); }
.icon-btn:active { transform: scale(.94); }

/* ===== Main / Views ===== */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}
.view[hidden] { display: none; }

/* ===== Notfall-Ansicht ===== */
.emerg-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  margin-bottom: 16px;
}
.emerg-icon { font-size: 1.4rem; }
.emerg-banner-text { font-size: 1.05rem; }

.emerg-content { display: flex; flex-direction: column; gap: 14px; }

.info-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--red);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.info-card .info-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 4px;
}
.info-card .info-value {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Hervorgehobene Kritisch-Karten */
.info-card.critical {
  background: var(--red-softer);
  border-color: var(--red);
}
.info-card.critical .info-value { color: var(--red-dark); }
[data-theme="dark"] .info-card.critical .info-value { color: #fca5a5; }

.info-card .info-value.big { font-size: 2rem; }

/* Name-Header der Person */
.person-head {
  background: linear-gradient(135deg, var(--red), var(--red-strong));
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.person-head .person-name {
  font-size: 1.9rem;
  font-weight: 800;
  margin: 0 0 4px;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.person-head .person-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 1rem;
  opacity: .95;
}
.person-head .person-sub b { font-weight: 800; }

/* Kontakt-Anruf-Buttons */
.contacts-call { display: flex; flex-direction: column; gap: 12px; }
.call-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  background: var(--surface);
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform .1s ease, background .15s ease;
}
.call-btn:hover { background: var(--red-softer); }
.call-btn:active { transform: scale(.98); }
.call-btn .call-ic {
  flex: 0 0 auto;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
}
.call-btn .call-meta { min-width: 0; flex: 1; }
.call-btn .call-name {
  font-weight: 800;
  font-size: 1.15rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.call-btn .call-rel { color: var(--muted); font-size: .85rem; }
.call-btn .call-num { color: var(--red-dark); font-weight: 700; font-size: 1.05rem; }
[data-theme="dark"] .call-btn .call-num { color: #fca5a5; }
.call-btn .call-go {
  flex: 0 0 auto;
  color: var(--red);
  font-weight: 800;
  font-size: .85rem;
  text-transform: uppercase;
}

.section-title {
  font-size: .95rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  font-weight: 800;
  margin: 6px 2px 2px;
}

.disclaimer {
  margin: 20px 4px 4px;
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-icon { font-size: 3rem; }
.empty-state h2 { margin: 12px 0 6px; }
.empty-state p { color: var(--text-soft); margin: 0 auto 18px; max-width: 38ch; line-height: 1.5; }

/* ===== Formular ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
  box-shadow: var(--shadow-sm);
}
.card legend {
  font-weight: 800;
  color: var(--red-dark);
  padding: 0 8px;
  font-size: 1.05rem;
}
[data-theme="dark"] .card legend { color: #fca5a5; }
.muted-tag { color: var(--muted); font-weight: 600; font-size: .8rem; }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: 6px;
  color: var(--text-soft);
}

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background: #0f141c;
}
textarea { resize: vertical; min-height: 48px; }
input::placeholder, textarea::placeholder { color: var(--muted); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .2);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }

/* Kontakt-Editor */
.contacts-edit { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.contact-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-2);
  position: relative;
}
[data-theme="dark"] .contact-row { background: #0f141c; }
.contact-row .contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 460px) { .contact-row .contact-grid { grid-template-columns: 1fr; } }
.contact-row .field { margin-bottom: 0; }
.remove-contact {
  margin-top: 10px;
  background: transparent;
  border: 1.5px solid var(--red);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.remove-contact:hover { background: var(--red-soft); }

/* ===== Buttons ===== */
.btn {
  font: inherit;
  font-weight: 800;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--red); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--red-strong); }
.btn-outline {
  background: transparent;
  border: 2px dashed var(--red);
  color: var(--red);
  width: 100%;
}
.btn-outline:hover { background: var(--red-softer); }
.btn-ghost { background: var(--line); color: var(--text); }
.btn-ghost:hover { opacity: .85; }
.btn-danger-ghost {
  background: transparent;
  border: 1.5px solid var(--red);
  color: var(--red);
}
.btn-danger-ghost:hover { background: var(--red-soft); }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.form-actions .btn { flex: 1 1 140px; }

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -4px 18px rgba(17, 24, 39, .08);
}
.nav-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 6px;
  height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: color .15s ease;
}
.nav-btn .nav-ic { font-size: 1.4rem; }
.nav-btn.is-active { color: var(--red); }
.nav-btn.is-active .nav-ic { transform: scale(1.06); }

/* ===== Install FAB ===== */
.install-fab {
  position: fixed;
  right: 14px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px);
  z-index: 70;
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 30px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.install-fab[hidden] { display: none; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(17, 24, 39, .55);
  backdrop-filter: blur(2px);
}
.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-title { margin: 0 0 8px; font-size: 1.25rem; color: var(--red-dark); }
[data-theme="dark"] .modal-title { color: #fca5a5; }
.modal-text { margin: 0 0 18px; color: var(--text-soft); line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 120px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px);
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 12px 18px;
  border-radius: 30px;
  font-weight: 700;
  z-index: 320;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
  animation: toastin .2s ease;
}
.toast[hidden] { display: none; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translateX(-50%); } }

/* ===== A11y ===== */
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
