/* Fall Call: brand red, black and white, from the team logo. */
:root {
  --red: #E03138;
  --red-dark: #B9232A;
  --green: #1F9D55;
  --amber: #E89A00;
  --bg: #F4F4F5;
  --card: #FFFFFF;
  --text: #141414;
  --muted: #5F6368;
  --border: #E2E2E6;
  --free: #2F6FDE;
  --impact: #E03138;
  --radius: 18px;
  --font-head: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101011;
    --card: #1C1C1E;
    --text: #F2F2F3;
    --muted: #A1A1AA;
    --border: #303034;
    --free: #6FA0FF;
    --impact: #FF5A60;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h2 { font-family: var(--font-head); line-height: 1.2; margin: 0; }
p { margin: 0 0 1em; }
img { max-width: 100%; height: auto; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.topbar {
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  font: 800 1.15rem var(--font-head);
  letter-spacing: 0.08em;
}
.topbar img { border-radius: 8px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6); }

.container { width: 100%; max-width: 560px; margin: 0 auto; padding: 20px 16px 24px; flex: 1; }

.footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

/* --- buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 10px 24px;
  border-radius: 999px;
  border: 2px solid transparent;
  font: 700 1.05rem var(--font-head);
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn:focus-visible { outline: 3px solid var(--free); outline-offset: 3px; }
.btn-huge { min-height: 88px; font-size: 1.9rem; width: min(100%, 380px); }
.btn-block { width: 100%; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-light { background: #fff; color: #141414; }
.btn-ok { background: var(--green); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.55); }
a.btn { text-decoration: none; }
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--red);
  text-decoration: underline;
  cursor: pointer;
}

/* --- phone number setup --- */

.setup-title { font: 800 1.6rem/1.2 var(--font-head); margin: 0; }
.setup-form { display: grid; gap: 10px; width: 100%; justify-items: center; }
.setup-form label { font-weight: 700; justify-self: start; }
.setup-form input {
  width: 100%;
  font: 600 1.4rem var(--font-body);
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
}
.setup-form input:focus { outline: 3px solid var(--free); outline-offset: 1px; }
.error { color: var(--red); font-weight: 700; margin: 0; justify-self: start; }
.call-target { text-align: center; margin: 0; }

/* --- start screen --- */

.start { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; }
.start p { margin: 0; }
.start-logo { width: 100%; border-radius: var(--radius); }
.lead { font-size: 1.15rem; }

/* --- watching screen --- */

#live-screen { display: grid; gap: 16px; }

.status-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 28px 20px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
}
.status-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 800 3rem/1 var(--font-head);
  color: #fff;
  margin-bottom: 6px;
}
.status-card[data-level="ok"] .status-icon { background: var(--green); animation: pulse 2s infinite; }
.status-card[data-level="ok"] .status-icon::before { content: "✓"; }
.status-card[data-level="warn"] .status-icon { background: var(--amber); }
.status-card[data-level="warn"] .status-icon::before { content: "…"; }
.status-card[data-level="danger"] .status-icon { background: var(--red); }
.status-card[data-level="danger"] .status-icon::before { content: "!"; }
.status-title { font: 800 1.7rem/1.2 var(--font-head); }
.status-sub { color: var(--muted); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 157, 85, 0.55); }
  70% { box-shadow: 0 0 0 18px rgba(31, 157, 85, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 157, 85, 0); }
}

.profile-line { text-align: center; margin: 0; }
.center { text-align: center; }

.details summary { cursor: pointer; font-weight: 700; }
.details[open] summary { margin-bottom: 12px; }
.gauge { text-align: center; font-family: var(--font-head); line-height: 1; }
.gauge-value { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.gauge-unit { font-size: 1.3rem; font-weight: 700; color: var(--muted); margin-left: 4px; }
.phase-text { text-align: center; font-weight: 700; margin: 6px 0 10px; }
.chart { display: block; width: 100%; height: 150px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; font-size: 0.8rem; color: var(--muted); margin: 8px 0; }
.sw { display: inline-block; width: 18px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.sw-line { border-color: var(--text); }
.sw-free { border-top-style: dashed; border-color: var(--free); }
.sw-impact { border-top-style: dashed; border-color: var(--impact); }
.log { list-style: none; padding: 0; margin: 0; font: 0.85rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.log li + li { margin-top: 4px; }
.log-danger { color: var(--red); font-weight: 700; }

/* --- alarm --- */

.alarm {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center;
  gap: 20px;
  padding: 24px 16px;
  text-align: center;
  color: #fff;
  overflow-y: auto;
  animation: flash 0.6s infinite alternate;
}
.alarm h2 { font-size: clamp(2.4rem, 11vw, 4.5rem); font-weight: 800; line-height: 1.05; }
.alarm p { font-size: 1.3rem; margin: 0; max-width: 28em; }
.countdown { font: 800 clamp(4rem, min(35vw, 22vh), 12rem)/1 var(--font-head); font-variant-numeric: tabular-nums; }
.alarm-calling { animation: none; background: #141414; }
.alarm-calling h2 { color: var(--red); }

@keyframes flash {
  from { background: var(--red); }
  to { background: #141414; }
}

/* --- download page --- */

.download { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.download p { margin: 0; }
.download .btn-huge { text-decoration: none; }
.steps-card { text-align: left; width: 100%; display: grid; gap: 10px; }
.android-only {
  display: inline-block;
  background: #3DDC84; /* Android green */
  color: #0B2E1A;
  font: 800 1rem var(--font-head);
  letter-spacing: 0.04em;
  padding: 6px 16px;
  border-radius: 999px;
}

/* --- calibration (developers only) --- */

.topbar-dev { background: #141414; }
.cal { display: grid; gap: 16px; }
.cal .card { display: grid; gap: 12px; }
.cal p { margin: 0; }
.cal a { color: var(--red); font-weight: 700; }
.dev-note {
  background: rgba(232, 154, 0, 0.15);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.9rem;
}
.cal-h { font-size: 1.2rem; font-weight: 800; }
.cal-steps { margin: 0; padding-left: 1.2em; }
.cal-steps li + li { margin-top: 4px; }
.cal .btn-huge { justify-self: center; }
.cal-progress { text-align: center; font: 800 2.4rem/1 var(--font-head); }
.cal-progress span { color: var(--red); }
.cal-status { text-align: center; font-weight: 700; font-size: 1.15rem; }
.cal-list { margin: 0; padding: 0; list-style: none; font-size: 0.95rem; }
.cal-list li { padding: 8px 0; border-top: 1px solid var(--border); }
.cal-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.profile-table { display: grid; grid-template-columns: auto auto; gap: 6px 16px; margin: 0; }
.profile-table dt { color: var(--muted); }
.profile-table dd { margin: 0; font-weight: 800; font-family: var(--font-head); }
.warn-box { background: rgba(224, 49, 56, 0.12); color: var(--red); border-radius: 12px; padding: 10px 14px; font-weight: 600; }
.cal-row-start { justify-content: space-between; align-items: center; }
.cal-filter { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.cal-filter select, .threshold-grid input {
  font: inherit;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}
.table-wrap { overflow-x: auto; }
.results, .summary-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.results th, .results td, .summary-table th, .summary-table td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.results th:first-child, .results td:first-child, .summary-table th:first-child, .summary-table td:first-child { text-align: left; }
.results tr.missed td { color: var(--red); }
.trace { display: block; width: 160px; height: 48px; }
.threshold-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.threshold-grid label { display: grid; gap: 4px; font-weight: 600; font-size: 0.9rem; }
.threshold-grid input { width: 100%; font-size: 1.2rem; font-weight: 700; }
.coverage { font-weight: 700; }
.cal-hit { text-align: center; font-weight: 800; font-size: 1.2rem; color: var(--green); min-height: 1.5em; }
.cal-hit.flash { animation: hit 1.2s ease-out; }

@keyframes hit {
  from { background: rgba(31, 157, 85, 0.3); }
  to { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .alarm { animation: none; background: var(--red); }
  .status-card[data-level="ok"] .status-icon { animation: none; }
}
