:root {
  --paper: #f4efe6;
  --paper-2: #fffdf9;
  --ink: #171412;
  --ink-2: #3d3733;
  --muted: #7a716a;
  --line: #e2d9cb;
  --orange: #ff4a1f;
  --orange-deep: #c93000;
  --green: #1f9d55;
  --radius: 18px;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background-image: radial-gradient(rgba(23,20,18,.07) 1px, transparent 1px);
  background-size: 18px 18px;
}
[hidden] { display: none !important; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--paper-2); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 6px; font-size: .9em;
}

.screen { max-width: 520px; margin: 0 auto; padding: 20px 18px 40px; }
.display { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; line-height: .95; margin: 0; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); margin: 0 0 10px; font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.45; }
.lede { color: var(--ink-2); font-size: 16px; line-height: 1.5; }
.error { color: var(--orange-deep); font-size: 14px; margin: 0; }
.warn { color: var(--orange-deep); margin: 6px 0 0; }

/* pairing */
#pair { padding-top: 12vh; text-align: center; }
#pair .display { font-size: 64px; margin: 24px 0 8px; }
.ring-wrap { display: flex; justify-content: center; }
.ring {
  width: 96px; height: 96px; border-radius: 50%;
  border: 7px solid var(--ink);
  display: grid; place-items: center;
  background: var(--paper-2);
}
.ring .dot { width: 40px; height: 40px; border-radius: 50%; background: var(--orange); }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }

input[type="text"] {
  font: inherit; font-size: 17px;
  padding: 16px 18px;
  border: 2px solid var(--ink); border-radius: 14px;
  background: var(--paper-2); color: var(--ink);
  outline: none; width: 100%;
  text-align: center; letter-spacing: .04em;
}
input[type="text"]:focus { border-color: var(--orange); }

/* buttons */
.btn {
  font: inherit; font-weight: 700; font-size: 16px;
  padding: 16px 20px;
  border-radius: 14px; border: 2px solid var(--ink);
  background: var(--paper-2); color: var(--ink);
  cursor: pointer; width: 100%;
  transition: transform .08s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.ghost { background: transparent; }
.btn.ack {
  background: var(--orange); border-color: var(--orange-deep); color: #fff;
  font-size: 22px; padding: 20px; letter-spacing: .02em;
  box-shadow: 0 6px 0 var(--orange-deep);
}
.btn.ack:active { box-shadow: 0 2px 0 var(--orange-deep); transform: translateY(4px); }
.btn.ack.big { font-size: 30px; padding: 28px; }
.btn[disabled] { opacity: .45; cursor: default; }
.link {
  background: none; border: 0; font: inherit; color: var(--ink-2);
  text-decoration: underline; text-underline-offset: 3px; padding: 0; cursor: pointer;
}
.link.danger { color: var(--orange-deep); }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.brand { font-family: var(--serif); font-size: 26px; display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%; background: var(--orange);
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink);
}
.watcher {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .12em; font-weight: 500;
  padding: 7px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--paper-2);
}
.watcher .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.watcher[data-state="online"] .pulse { background: var(--green); animation: beat 2s infinite; }
.watcher[data-state="offline"] { border-color: var(--orange); color: var(--orange-deep); }
.watcher[data-state="offline"] .pulse { background: var(--orange); }
@keyframes beat {
  0% { box-shadow: 0 0 0 0 rgba(31,157,85,.5); }
  70% { box-shadow: 0 0 0 8px rgba(31,157,85,0); }
  100% { box-shadow: 0 0 0 0 rgba(31,157,85,0); }
}

/* hero */
.hero {
  position: relative;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--paper-2);
  padding: 28px 22px 26px;
  margin-bottom: 14px;
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; bottom: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  border: 14px solid var(--ink); opacity: .06;
}
.hero .display { font-size: 46px; }
.hero-alarm { display: none; }
.hero[data-state="alarm"] { background: var(--orange); border-color: var(--orange-deep); color: #fff; animation: throb 1s infinite; }
.hero[data-state="alarm"] .hero-quiet { display: none; }
.hero[data-state="alarm"] .hero-alarm { display: block; }
.hero[data-state="alarm"] .eyebrow, .hero[data-state="alarm"] .meta { color: rgba(255,255,255,.8); }
.hero[data-state="alarm"] .link { color: #fff; }
.hero[data-state="alarm"] .btn.ack { background: var(--ink); border-color: var(--ink); box-shadow: 0 6px 0 #000; margin: 18px 0 14px; }
.hero[data-state="alarm"]::after { border-color: #fff; opacity: .25; }
@keyframes throb { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.012); } }
.preview { font-size: 18px; line-height: 1.4; margin: 12px 0 4px; word-break: break-word; }
.meta { font-size: 13px; margin: 0; }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* cards */
.card {
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--paper-2); padding: 18px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card h3 { margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.pill {
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em; padding: 4px 9px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--line); color: var(--muted);
}
.pill.on { background: var(--green); border-color: var(--green); color: #fff; }
.pill.bad { background: var(--orange); border-color: var(--orange-deep); color: #fff; }
.card .row { margin-top: 14px; }
.card .btn { padding: 13px 16px; font-size: 15px; }

/* settings */
.field { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.field:first-of-type { border-top: 0; }
.field > span { font-size: 14px; font-weight: 500; }
.field.toggle { flex-direction: row; align-items: center; justify-content: space-between; }
.seg { display: flex; border: 1.5px solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg button {
  flex: 1; font: inherit; font-weight: 500; font-size: 14px; padding: 10px 0;
  background: transparent; border: 0; border-left: 1.5px solid var(--ink); color: var(--ink); cursor: pointer;
}
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--ink); color: var(--paper); }
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 48px; height: 28px; border-radius: 999px;
  border: 2px solid var(--ink); background: var(--paper); position: relative; cursor: pointer; margin: 0; flex-shrink: 0;
}
input[type="checkbox"]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink);
  transition: transform .15s ease;
}
input[type="checkbox"]:checked { background: var(--orange); border-color: var(--orange-deep); }
input[type="checkbox"]:checked::after { transform: translateX(20px); background: #fff; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0 16px; }
.facts div { border-top: 1px solid var(--line); padding-top: 8px; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.facts dd { margin: 3px 0 0; font-size: 15px; font-weight: 500; }

.foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 24px; letter-spacing: .08em; text-transform: uppercase; }

/* alarm overlay while the app is open */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--orange); color: #fff;
  display: grid; place-items: center; text-align: center;
  padding: 24px;
  animation: flash .5s steps(2) infinite;
}
@keyframes flash { 50% { background: var(--orange-deep); } }
.overlay-inner { width: 100%; max-width: 420px; }
.overlay .display { font-size: 52px; margin-bottom: 8px; }
.overlay .eyebrow { color: rgba(255,255,255,.85); }
.overlay .preview { font-size: 20px; margin-bottom: 30px; }
.overlay .btn.ack { background: var(--ink); border-color: var(--ink); box-shadow: 0 8px 0 #000; }

@media (min-width: 640px) {
  .screen { padding-top: 40px; }
  .hero .display { font-size: 56px; }
}
