/* Lifeline — Erste Hilfe & CPR Trainer */

:root {
  --bg: #0a0d12;
  --bg2: #11161e;
  --bg3: #1a2230;
  --fg: #e6edf6;
  --fg-dim: #a4b1c2;
  --fg-mute: #6c7a8c;
  --line: #243140;
  --accent: #ff3b30;
  --accent-2: #ff6b5e;
  --accent-glow: rgba(255,59,48,.35);
  --ok: #34c759;
  --warn: #ffcc00;
  --info: #4fc3f7;
  --card: #161e2a;
  --tap-min: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

/* Skip-link for keyboard users */
.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  z-index: 999;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}
.skip-link:focus {
  top: calc(var(--safe-t) + 8px);
}

/* Focus-visible — make keyboard nav obvious */
:focus-visible {
  outline: 3px solid var(--info);
  outline-offset: 2px;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--info);
  outline-offset: 2px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; }

/* --- Header --- */
.hdr {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-t) + 10px) 14px 10px;
  background: linear-gradient(180deg, rgba(10,13,18,.96), rgba(10,13,18,.85));
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
}
.brand:active { background: var(--bg3); }
.brand .logo { color: var(--accent); display: inline-flex; }
.brand-name {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: .2px;
}
.hdr-right { display: flex; align-items: center; gap: 8px; }
.lang {
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  min-width: 44px;
  min-height: 38px;
}
.install {
  background: var(--ok);
  color: #06120a;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* --- Main --- */
main {
  padding: 14px 14px calc(100px + var(--safe-b));
  max-width: 720px;
  margin: 0 auto;
}

h1, h2, h3 { line-height: 1.2; margin: .2em 0 .35em; }
h1 { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
h2 { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: .35em 0 .8em; color: var(--fg-dim); }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg3);
  color: var(--fg-dim);
  border: 1px solid var(--line);
}
.tag.danger { background: var(--accent); color: #fff; border-color: var(--accent); }
.tag.ok { background: var(--ok); color: #06120a; border-color: var(--ok); }
.tag.warn { background: var(--warn); color: #18140a; border-color: var(--warn); }

/* --- Home Cards --- */
.hero {
  background: linear-gradient(135deg, #1a2230, #0e1320);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  pointer-events: none;
}
.hero h1 { margin-bottom: .2em; }
.hero .sub { color: var(--fg-dim); font-size: 15px; }
.hero .ctas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 14px 18px;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  min-height: var(--tap-min);
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 6px 20px var(--accent-glow);
}
.btn-primary:active { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }

.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}
@media (min-width: 540px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 12px;
  text-align: left;
  cursor: pointer;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card:active { background: var(--bg3); }
.card-ico { font-size: 28px; line-height: 1; }
.card-title { font-weight: 700; font-size: 14px; color: var(--fg); }
.card-sub { font-size: 12px; color: var(--fg-mute); line-height: 1.3; }

/* --- CPR Screen --- */
.cpr-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 14px 8px;
  background: linear-gradient(180deg, #0e1320, #0a0d12);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  position: relative;
}
.cpr-pulse {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, var(--accent-2) 50%, transparent 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  color: #fff;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  position: relative;
  transition: transform 80ms ease-out;
  box-shadow: 0 0 60px var(--accent-glow);
  user-select: none;
}
.cpr-pulse.beat { transform: scale(1.08); }
.cpr-pulse .num {
  font-size: 84px;
  font-weight: 900;
  letter-spacing: -2px;
  text-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.cpr-meta {
  display: flex;
  gap: 18px;
  font-size: 14px;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.cpr-meta b { color: var(--fg); font-weight: 700; }
.cpr-cycle {
  font-size: 13px;
  color: var(--fg-mute);
  text-align: center;
}
.cpr-cycle .big {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--fg);
  letter-spacing: .5px;
}

.cpr-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.cpr-controls .btn { flex: 1 1 130px; }

.cpr-hint {
  background: rgba(255,204,0,.08);
  border: 1px solid rgba(255,204,0,.25);
  border-radius: var(--r-md);
  padding: 12px;
  font-size: 14px;
  color: var(--fg);
}
.cpr-hint b { color: var(--warn); }

.cpr-mode-toggle {
  display: flex;
  gap: 6px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.cpr-mode-toggle button {
  background: transparent;
  border: 0;
  color: var(--fg-dim);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.cpr-mode-toggle button.active {
  background: var(--accent);
  color: #fff;
}

/* --- Protocol Stepper --- */
.proto-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.proto-step {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-md);
  padding: 14px 14px 14px 16px;
}
.proto-step.done { border-left-color: var(--ok); opacity: .82; }
.proto-step h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 0;
}
.proto-step .letter {
  background: var(--accent);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}
.proto-step.done .letter { background: var(--ok); color: #06120a; }
.proto-step p { margin-bottom: 8px; }
.proto-step .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.proto-step .actions .btn { flex: 1 1 auto; min-height: 44px; padding: 10px 14px; font-size: 14px; }

/* --- Emergencies list --- */
.elist {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 480px) {
  .elist { grid-template-columns: 1fr 1fr; }
}
.eitem {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 72px;
}
.eitem .eico {
  font-size: 28px;
  width: 44px;
  text-align: center;
}
.eitem .etxt { flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.eitem .ettl { font-weight: 700; color: var(--fg); display: block; font-size: 15px; line-height: 1.2; }
.eitem .esub { font-size: 12px; color: var(--fg-mute); display: block; line-height: 1.3; }

/* --- Emergency Detail --- */
.edetail {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
}
.edetail h2 { margin-top: 0; }
.edetail .lede { font-size: 15px; color: var(--fg-dim); margin-bottom: 14px; }
.edetail ol, .edetail ul { padding-left: 20px; margin: .35em 0 .8em; }
.edetail li { margin: 6px 0; color: var(--fg); }
.edetail .callout {
  border: 1px solid var(--accent);
  background: rgba(255,59,48,.08);
  border-radius: var(--r-md);
  padding: 12px;
  margin: 12px 0;
}
.edetail .callout.warn { border-color: var(--warn); background: rgba(255,204,0,.08); }
.edetail .callout.info { border-color: var(--info); background: rgba(79,195,247,.08); }
.edetail .callout b { display: block; margin-bottom: 4px; color: var(--fg); }
.edetail .nope {
  font-weight: 700;
  color: var(--warn);
}

/* --- Numbers --- */
.numbers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 540px) {
  .numbers { grid-template-columns: 1fr 1fr; }
}
.nitem {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  text-decoration: none;
  color: var(--fg);
  min-height: 60px;
}
.nitem .flag { font-size: 28px; }
.nitem .cname { font-size: 13px; color: var(--fg-mute); }
.nitem .cnum {
  font-size: 24px;
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.5px;
}
.nitem.local { background: linear-gradient(135deg, rgba(255,59,48,.15), var(--card)); border-color: var(--accent); }

/* --- Emergency-Bar (bottom nav) --- */
.ebar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  padding-bottom: var(--safe-b);
  border-top: 1px solid var(--line);
}
.ebar-btn {
  background: var(--bg2);
  border: 0;
  color: var(--fg-dim);
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  min-height: 60px;
}
.ebar-btn:active { background: var(--bg3); color: var(--fg); }
.ebar-btn.active { color: var(--accent); }
.ebar-cpr { background: linear-gradient(180deg, rgba(255,59,48,.18), var(--bg2)); }
.ebar-cpr .ebar-ico { color: var(--accent); }
.ebar-ico { font-size: 22px; line-height: 1; }
.ebar-lbl { font-size: 11px; font-weight: 700; letter-spacing: .3px; }

/* --- Misc --- */
.spacer { height: 14px; }
.sect-hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 16px 0 8px;
}
.sect-hd h2 { margin: 0; }
.sect-hd .meta { font-size: 12px; color: var(--fg-mute); }

.footer {
  margin-top: 28px;
  padding: 16px;
  text-align: center;
  color: var(--fg-mute);
  font-size: 12px;
  line-height: 1.7;
}
.footer a { color: var(--fg-dim); }

/* Small mobile <360px */
@media (max-width: 360px) {
  .cpr-pulse { width: 180px; height: 180px; }
  .cpr-pulse .num { font-size: 64px; }
  h1 { font-size: 24px; }
  .hero { padding: 16px; }
  main { padding-left: 10px; padding-right: 10px; }
}

/* Tablet 720px+ */
@media (min-width: 720px) {
  main { max-width: 920px; padding: 22px 22px calc(110px + var(--safe-b)); }
  .hero { padding: 32px 36px; }
  .hero h1 { font-size: 36px; }
  .hero .sub { font-size: 17px; }
  .cards { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .elist { grid-template-columns: 1fr 1fr; gap: 12px; }
  .numbers { grid-template-columns: 1fr 1fr 1fr; }
  .cpr-pulse { width: 260px; height: 260px; }
  .cpr-pulse .num { font-size: 100px; }
  .cpr-stage { padding: 28px; }
}

/* Desktop 1024px+ — bottom-nav becomes side-rail-less, content centered, CPR-mode bigger */
@media (min-width: 1024px) {
  main { max-width: 1080px; padding: 28px 32px calc(110px + var(--safe-b)); }
  .hdr { padding: 14px 32px; }
  .brand-name { font-size: 22px; }

  h1 { font-size: 34px; }
  .hero h1 { font-size: 42px; letter-spacing: -.8px; }
  .hero .sub { font-size: 18px; }
  .hero .ctas .btn { padding: 16px 24px; font-size: 16px; }

  .cards { grid-template-columns: repeat(4, 1fr); }
  .card { min-height: 130px; padding: 18px; }
  .card-ico { font-size: 36px; }
  .card-title { font-size: 16px; }

  .cpr-pulse { width: 320px; height: 320px; box-shadow: 0 0 100px var(--accent-glow); }
  .cpr-pulse .num { font-size: 130px; }
  .cpr-meta { font-size: 18px; gap: 36px; }
  .cpr-cycle .big { font-size: 28px; }

  .ebar {
    max-width: 720px;
    margin: 0 auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border-radius: 18px 18px 0 0;
  }

  .footer { font-size: 13px; }
}

/* Large desktop 1280px+ */
@media (min-width: 1280px) {
  main { max-width: 1200px; }
  .elist { grid-template-columns: 1fr 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .cpr-pulse { transition: none; }
  .cpr-pulse.beat { transform: none; }
}

/* Wake-Lock hint */
.wake-hint {
  font-size: 11px;
  color: var(--fg-mute);
  text-align: center;
  margin-top: 4px;
}

/* CPR audio health indicator */
.cpr-audio-health {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 6px 10px;
  border-radius: 999px;
  margin-top: 6px;
  letter-spacing: .2px;
}
.cpr-audio-health[data-state="idle"] { color: var(--fg-mute); background: transparent; }
.cpr-audio-health[data-state="ok"] {
  color: var(--ok);
  background: rgba(52,199,89,.10);
  border: 1px solid rgba(52,199,89,.35);
}
.cpr-audio-health[data-state="warn"] {
  color: var(--warn);
  background: rgba(255,204,0,.10);
  border: 1px solid rgba(255,204,0,.45);
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 12px;
}

/* Version stamp (permanent legal-cover element) */
.version-stamp {
  font-size: 10.5px;
  color: var(--fg-mute);
  text-align: center;
  margin-top: 10px;
  letter-spacing: .3px;
  font-feature-settings: "tnum";
}
.version-stamp b { color: var(--fg-dim); font-weight: 600; }

/* Active route highlight */
.ebar-btn[data-active="1"] { color: var(--accent); }
.ebar-btn[data-active="1"] .ebar-lbl { color: var(--accent); }

/* First-run disclaimer modal */
.disc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(var(--safe-t) + 16px);
  padding-bottom: calc(var(--safe-b) + 16px);
}
.disc-modal {
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 18px;
  max-width: 540px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.disc-modal h2 {
  margin: 0 0 12px;
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.disc-modal h2::before {
  content: "⚕";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 20px;
}
.disc-modal p {
  font-size: 14.5px;
  margin: 8px 0;
  color: var(--fg);
  line-height: 1.55;
}
.disc-modal .disc-legal {
  font-size: 12px;
  color: var(--fg-mute);
  margin-top: 16px;
}
.disc-modal .disc-links {
  margin-top: 12px;
  font-size: 12px;
  color: var(--fg-mute);
}
.disc-modal .disc-links a {
  color: var(--info);
  text-decoration: underline;
}
.disc-modal .disc-cta {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 14px 18px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 16px;
  margin-top: 18px;
  cursor: pointer;
  min-height: var(--tap-min);
  box-shadow: 0 6px 20px var(--accent-glow);
}
.disc-modal .disc-cta:active { background: var(--accent-2); }

/* Source-footnote inside emergency detail */
.edetail .src {
  font-size: 11px;
  color: var(--fg-mute);
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  line-height: 1.5;
}
.edetail .src b { color: var(--fg-dim); font-weight: 600; }
