:root {
  --bg: #f3f1ea;
  --ink: #14231d;
  --muted: #5e6b64;
  --card: #fffcf6;
  --line: #ddd6c8;
  --green: #16382e;
  --green-2: #1f5a45;
  --in: #e5f3ea;
  --in-ink: #145c3a;
  --out: #f4eee4;
  --warn: #fff3cc;
  --warn-line: #e2c56a;
  --shadow: 0 10px 30px rgba(20, 35, 29, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 400px at 10% -10%, #e7efe7, transparent 50%),
    var(--bg);
  color: var(--ink);
  line-height: 1.4;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 16px calc(148px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 44px; height: auto; display: block; }
.kicker {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
h1 { margin: 0; font-size: 1.85rem; letter-spacing: -0.03em; }
.pulse {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
  max-width: 46%;
}

.banner {
  background: var(--warn);
  border: 1px solid var(--warn-line);
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.toolbar { display: grid; gap: 10px; margin-bottom: 14px; }
.origin {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
#origin-label { margin: 0; color: var(--muted); font-size: 0.92rem; }
#locate, .chip, .dock button, #enable {
  font: inherit;
  cursor: pointer;
}
#locate {
  border: 0;
  background: transparent;
  color: var(--green-2);
  font-weight: 700;
  padding: 0;
  white-space: nowrap;
}

#search {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
}

.chips { display: flex; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.9rem;
}
.chip.on {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.list { display: grid; gap: 8px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
}
.card.in { background: var(--in); border-color: #cfe3d5; }
.card.alerting { outline: 2px solid var(--green-2); }
.card h2 { margin: 0; font-size: 1.08rem; }
.meta, .when { margin: 2px 0 0; color: var(--muted); font-size: 0.86rem; }
.count {
  margin: 4px 0 0;
  font-weight: 750;
  font-size: 0.95rem;
}
.card.in .count { color: var(--in-ink); }
.card.out .count { color: var(--muted); font-weight: 600; }

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 48px;
  height: 28px;
  margin: 0;
  cursor: pointer;
}
.slider {
  position: absolute;
  inset: 0;
  background: #cfc7b8;
  border-radius: 999px;
  pointer-events: none;
  transition: background 0.15s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.15s;
}
.switch input:checked + .slider { background: var(--green-2); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--green); outline-offset: 2px; }

.meta a { color: inherit; }
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 720px;
  background: rgba(255, 252, 246, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
#push-status { margin: 0; color: var(--muted); font-size: 0.92rem; }
.dock-actions { display: flex; gap: 8px; flex-shrink: 0; }
#enable, #disable {
  border-radius: 999px;
  padding: 10px 14px;
  border: 1px solid var(--green);
  background: var(--green);
  color: white;
  font-weight: 700;
}
#disable {
  background: transparent;
  color: var(--green);
}
#enable:disabled { opacity: 0.4; cursor: not-allowed; }

footer { margin-top: 22px; color: var(--muted); font-size: 0.85rem; }
footer a { color: var(--green-2); }

@media (max-width: 520px) {
  .origin { align-items: flex-start; flex-direction: column; gap: 4px; }
  .dock { flex-direction: column; align-items: stretch; }
  .dock-actions { justify-content: flex-end; }
}
