:root {
  --bg: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #e11d48;
  --warn: #d97706;
  --primary: #0284c7;
  --shadow: 0 8px 30px rgba(15, 23, 42, .18);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --line: #1f2937;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: #e5e7eb;
  overflow: hidden;
}
#map { position: fixed; inset: 0; }

/* Top banner */
.banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--danger); color: #fff;
  font-weight: 800; letter-spacing: .08em; font-size: 14px;
}
.banner.test { background: var(--warn); }
.banner.nofix { background: #475569; }
.banner-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #fff;
  animation: blink 1.2s ease-in-out infinite;
}
.banner.nofix .banner-dot { animation: none; opacity: .6; }
@keyframes blink { 50% { opacity: .25; } }

/* Info card: bottom sheet on phones, floating panel on wide screens */
.card {
  position: fixed; z-index: 5;
  left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 440px; margin: 0 auto;
  padding: 16px 18px 14px;
  background: var(--bg); border-radius: 18px; box-shadow: var(--shadow);
}
@media (min-width: 720px) {
  .card { left: 20px; right: auto; bottom: 20px; margin: 0; width: 400px; }
}
.card { max-height: calc(100dvh - 110px); overflow-y: auto; }

/* Sender */
.who { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.avatar {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--danger); color: #fff;
  font-size: 19px; font-weight: 800; letter-spacing: .02em;
}
.test-alert .avatar { background: var(--warn); }
.nofix-alert .avatar { background: #475569; }
.who-text { min-width: 0; }
.card h1 { margin: 0; font-size: 21px; line-height: 1.2; overflow-wrap: anywhere; }
.subtitle { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.subtitle strong { color: var(--danger); }
.test-alert .subtitle strong { color: var(--warn); }
.nofix-alert .subtitle strong { color: var(--muted); }
.error { margin: 0 0 12px; color: var(--danger); font-size: 14px; font-weight: 600; }

.details { margin: 0 0 14px; }
.details > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.details dt { flex: none; color: var(--muted); }
.details dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.details a { color: var(--text); font-weight: 700; font-size: 16px; text-decoration: none; }
.details a:hover { text-decoration: underline; }
.acc { margin-left: 8px; color: var(--muted); font-size: 13px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-wide { flex-basis: 100%; min-height: 50px; font-size: 17px; }
.btn {
  flex: 1 1 0; min-height: 44px; padding: 0 10px; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 12px; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 700; text-decoration: none;
}
.btn[hidden], [hidden] { display: none !important; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:focus-visible, .style-toggle:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.foot { margin: 12px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

.style-toggle {
  position: fixed; z-index: 5; top: calc(56px + env(safe-area-inset-top)); left: 12px;
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--bg); color: var(--text); box-shadow: var(--shadow);
  font: inherit; font-size: 13px; font-weight: 700;
}

/* Marker */
.sos-marker { position: relative; width: 26px; height: 26px; }
.sos-marker .core {
  position: absolute; inset: 3px; border-radius: 50%;
  background: var(--danger); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.sos-marker.test .core { background: var(--warn); }
.sos-marker .pulse {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--danger); opacity: .5; animation: pulse 1.8s ease-out infinite;
}
.sos-marker.test .pulse { background: var(--warn); }
@keyframes pulse { to { transform: scale(3.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sos-marker .pulse, .banner-dot { animation: none; }
}
