@font-face {
  font-family: "Manrope";
  src: url("assets/fonts/Manrope-Variable.ttf") format("truetype");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/fonts/IBMPlexMono-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0b0f0d;
  --card: #161c19;
  --ink: #f3f6f4;
  --sub: #d2d6d4;
  --muted: #8b9892;
  --line: #2a322e;
  --accent: #00e08a;
  --accent-ink: #052016;
  --high: #ff3b3b;
  --watch: #ffd60a;
  --watch-ink: #111;
  --info: #e2e6e3;
  --info-ink: #1c201e;
  --ok-bg: #143226;
  --g-low: #1aa86c;
  --g-elev: #ffcc51;
  --g-high: #cc7638;
  --g-ext: #dc3e4e;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Manrope", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100dvh; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); }
#app {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

/* ---------- Splash ---------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #0b0f13;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.splash-map {
  position: absolute;
  inset: 0;
  background:
    url("assets/img/tile-threat-level.webp") center / cover no-repeat;
  filter: none;
}
.splash-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(11, 15, 19, 0.48) 0%,
    rgba(11, 15, 19, 0.22) 18%,
    rgba(11, 15, 19, 0.18) 42%,
    rgba(11, 15, 19, 0.42) 62%,
    rgba(11, 15, 19, 0.92) 100%
  );
}
.splash::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 8px;
  background: var(--accent);
  z-index: 3;
}
.splash-rain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 10%,
    rgba(0,0,0,0.5) 16%,
    rgba(0,0,0,0.82) 28%,
    rgba(0,0,0,0.82) 62%,
    rgba(0,0,0,0.3) 70%,
    transparent 78%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 10%,
    rgba(0,0,0,0.5) 16%,
    rgba(0,0,0,0.82) 28%,
    rgba(0,0,0,0.82) 62%,
    rgba(0,0,0,0.3) 70%,
    transparent 78%,
    transparent 100%
  );
}
.splash-inner {
  position: relative;
  z-index: 4;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(44px + var(--safe-top)) 24px calc(28px + var(--safe-bottom));
}
.splash-logo {
  height: 36px;
  width: auto;
  display: block;
  margin-bottom: auto;
}
.splash-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(44px, 14vw, 64px);
  line-height: 0.95;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.55);
}
.splash-line { display: block; }
.splash-line-2 { position: relative; display: inline-block; margin-top: 2px; }
.splash-line-2::after {
  content: "";
  display: block;
  height: 4px;
  margin-top: 8px;
  background: var(--accent);
  width: 7.2ch; /* under ALERTS, not the arrow */
}
.splash-arrow {
  color: var(--accent);
  font-size: 0.7em;
  letter-spacing: 0;
  margin-left: 0.12em;
  text-shadow: none;
}
.splash-sub {
  margin-top: 16px;
  color: var(--sub);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  max-width: 22em;
}
.splash-bar {
  margin-top: 18px;
  width: 120px;
  height: 8px;
  border-radius: 4px;
  background: #5a6660;
  overflow: hidden;
}
.splash-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 2.4s linear;
}
.splash.filling .splash-fill { width: 100%; }
.splash-url {
  margin-top: 16px;
  color: var(--sub);
  font-size: 14px;
  font-weight: 600;
}
.splash.off {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
.splash[hidden] {
  display: none !important;
}

/* ---------- Main ---------- */
.main {
  min-height: 100dvh;
  padding: calc(14px + var(--safe-top)) 0 calc(var(--tabbar-h) + 12px + var(--safe-bottom));
}
.view { padding: 0 16px 24px; }
.page-head { padding: 8px 0 10px; }
.page-head h1 {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.back {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 16px;
  font-weight: 650;
  padding: 4px 0 10px;
}
.muted { color: var(--muted); }
.note { font-size: 13px; font-weight: 500; margin-bottom: 12px; line-height: 1.4; }
.live-meta { color: var(--muted); font-size: 12px; font-weight: 500; margin-bottom: 12px; }
.fine { font-size: 12px; line-height: 1.4; margin-top: 14px; }

/* ---------- Cards / feed ---------- */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px 14px;
  text-align: left;
  width: 100%;
  color: inherit;
  display: block;
}
button.card { cursor: pointer; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.time { color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 9px;
  line-height: 1.2;
}
.tag-high { background: var(--high); color: #fff; }
.tag-watch { background: var(--watch); color: var(--watch-ink); }
.tag-info { background: var(--info); color: var(--info-ink); }
.card h2 {
  font-size: 15px;
  font-weight: 650;
  margin: 8px 0 6px;
  line-height: 1.3;
}
.byline { color: var(--muted); font-size: 12px; font-weight: 500; }
.source { color: var(--accent); font-size: 12px; font-weight: 600; margin-top: 4px; }
.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 24px 8px;
  line-height: 1.45;
}

/* ---------- Detail ---------- */
.detail .tag { margin-bottom: 12px; }
.detail h2 { font-size: 22px; font-weight: 750; line-height: 1.25; margin: 8px 0 10px; }
.detail .summary { font-size: 15px; font-weight: 500; color: #d7ddd9; line-height: 1.45; margin: 12px 0; }
.btn {
  display: block;
  width: 100%;
  text-align: center;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  margin-top: 8px;
}
.btn-ghost { color: var(--accent); }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.disclaimer, .notice {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  margin-top: 14px;
}
.notice { margin-top: 10px; }

/* ---------- Outages ---------- */
.outage-list { display: flex; flex-direction: column; gap: 9px; }
.outage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  color: inherit;
  text-decoration: none;
}
.outage h2 { font-size: 14px; font-weight: 650; grid-column: 1; }
.outage .sub { color: var(--muted); font-size: 11px; font-weight: 500; grid-column: 1; align-self: end; }
.badge {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: end;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 3px 8px;
  line-height: 1.2;
  white-space: nowrap;
}
.badge-issue { background: var(--high); color: #fff; text-transform: uppercase; }
.badge-degraded { background: var(--watch); color: var(--watch-ink); text-transform: uppercase; }
.badge-ok { background: var(--ok-bg); color: var(--accent); }
.badge-unknown { background: #2a322e; color: var(--muted); }

.group-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 14px 0 6px;
}

/* ---------- Score / gauge ---------- */
.score-wrap { text-align: center; }
.gauge { width: min(100%, 340px); margin: 8px auto 0; display: block; }
.score-name { font-size: 34px; font-weight: 750; margin-top: 4px; }
.score-num { font-size: 16px; font-weight: 650; color: var(--sub); margin-top: 4px; }
.score-cap { color: var(--muted); font-size: 12px; font-weight: 500; margin: 8px 20px 14px; line-height: 1.4; }
.score-card {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 10px;
}
.parts { text-align: left; margin-top: 8px; }
.part {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.part .lab { color: var(--ink); font-weight: 550; }
.part .val { color: var(--muted); white-space: nowrap; }
.part.failed .lab, .part.omitted .lab { color: var(--muted); }

/* ---------- Settings ---------- */
.sec {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  margin: 6px 0 4px;
}
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.row .lab { font-size: 14px; font-weight: 650; }
.row .hint { font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.row .val { color: var(--accent); font-size: 13px; font-weight: 650; text-align: right; }
.settings-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 12px;
  margin-top: 16px;
}
.switch {
  --w: 44px; --h: 26px;
  width: var(--w); height: var(--h);
  border: 0;
  border-radius: 999px;
  background: #2a322e;
  position: relative;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #9aa59f;
  transition: transform 0.18s ease, background 0.18s ease;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); background: var(--accent-ink); }

.sources-box { margin-top: 18px; }
.sources-box h2 { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.sources-box p { color: var(--muted); font-size: 12px; line-height: 1.45; margin-bottom: 8px; }

/* ---------- Subscribe ---------- */
.plan {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px 16px;
  margin-bottom: 10px;
}
.plan-paid { border-color: var(--accent); border-width: 2px; }
.plan h2 { font-size: 18px; font-weight: 750; }
.plan-paid h2 { color: var(--accent); }
.plan .price { color: var(--muted); font-size: 13px; font-weight: 500; margin: 4px 0 8px; }
.plan p { font-size: 14px; font-weight: 500; color: #d7ddd9; line-height: 1.4; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 430px;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #101513;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 20;
}
.tab {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.tab.on { color: var(--accent); }

/* ---------- A2HS ---------- */
.a2hs {
  margin: 0 16px 10px;
  background: #1d2622;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 32px 10px 12px;
  position: relative;
  color: var(--sub);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}
.a2hs-x {
  position: absolute;
  top: 4px; right: 6px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
}

/* hide tabbar on detail/subscribe? keep it on main tabs only — JS toggles */
.main.subpage .tabbar { display: none; }
.main.subpage { padding-bottom: calc(16px + var(--safe-bottom)); }

.push-msg { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.4; margin-top: 10px; }
.push-msg.err { color: #ffb4b4; }
.push-msg.ok { color: var(--accent); }
#btn-test-push { margin-top: 10px; }

/* ---------- Install walkthrough + notify prompt ---------- */
.ig {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  color: var(--ink);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.ig[hidden] { display: none !important; }
body.ig-open { overflow: hidden; }
.ig-inner {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  padding: calc(28px + var(--safe-top)) 24px calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.ig-panel[hidden] { display: none !important; }
.ig-logo {
  width: 56px;
  height: auto;
  display: block;
  margin: 8px auto 22px;
}
.ig-title {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-align: center;
  margin-bottom: 10px;
}
.ig-lead {
  color: var(--sub);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  margin-bottom: 22px;
}
.ig-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}
.ig-steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.ig-num {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 750;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.ig-step-title { font-size: 15px; font-weight: 700; line-height: 1.3; }
.ig-step-sub { color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.4; margin-top: 3px; }
.ig-share-demo {
  margin-top: 10px;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: #1d2622;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}
.ig-share-icon { display: block; color: var(--ink); }

/* Arrow aimed at Safari's center Share button */
.ig-panel[data-mode="ios-safari"] { padding-bottom: 108px; }
.ig-arrow-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 6px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 51;
  color: var(--accent);
}
.ig-arrow-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.ig-arrow-share { color: var(--accent); margin-bottom: 2px; }
.ig-arrow {
  font-size: 28px;
  line-height: 1;
  animation: ig-bounce 1.3s ease-in-out infinite;
}
@keyframes ig-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.ig-primary { width: 100%; margin-top: 4px; }
.ig-manual {
  color: var(--sub);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.ig-manual[hidden] { display: none !important; }
.ig-qr {
  width: 220px;
  height: 220px;
  margin: 0 auto 12px;
  padding: 12px;
  background: #fff;
  border-radius: 16px;
}
.ig-qr svg { display: block; width: 100%; height: 100%; }
.ig-url {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  word-break: break-all;
  margin-bottom: 10px;
}
.ig-msg {
  text-align: center;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0 0;
}
.ig-msg.err { color: #ffb4b4; }
.ig-msg[hidden] { display: none !important; }
.ig-continue {
  margin-top: auto;
  padding: 16px 8px 4px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ig-notify .ig-continue { margin-top: 8px; }

@media (min-width: 700px) {
  /* Desktop: no phone-toolbar arrow */
  .ig-arrow-wrap { display: none; }
  .ig-panel[data-mode="ios-safari"] { padding-bottom: 0; }
}
.ig.ig-ipad .ig-arrow-wrap { display: none; }
.ig.ig-ipad .ig-panel[data-mode="ios-safari"] { padding-bottom: 0; }
#btn-show-install { margin-top: 10px; }
.ig.ig-has-arrow .ig-inner {
  padding-bottom: calc(132px + var(--safe-bottom));
}
.ig.ig-has-arrow .ig-continue {
  margin-bottom: 8px;
}
