:root {
  --bg: #0e1116;
  --surface: #171b22;
  --surface-2: #1f242d;
  --line: #2a313c;
  --text: #e8ecf2;
  --muted: #929db0;
  --accent: #5b9dff;
  --accent-dim: #1d3557;
  --good: #3ecf8e;
  --warn: #f5a524;
  --bad: #f26d6d;
  --radius: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --line: #dde2ea;
    --text: #12161d;
    --muted: #5d6779;
    --accent: #2563eb;
    --accent-dim: #dbe6ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 460px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen { display: flex; flex-direction: column; gap: 20px; flex: 1; }
.screen.center { justify-content: center; align-items: center; text-align: center; }

/* ---------- brand ---------- */
.brand { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 8px; }
.brand.small { flex-direction: row; gap: 10px; align-items: center; justify-content: flex-start; margin-bottom: 4px; }
.brand-mark {
  width: 52px; height: 52px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #7b5bff);
  border-radius: 15px; font-size: 26px; color: #fff;
}
.brand.small .brand-mark { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }
.brand h1 { font-size: 22px; margin: 6px 0 0; letter-spacing: -0.02em; }
.brand.small h1 { font-size: 18px; margin: 0; }
.brand-sub { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }

.welcome { justify-content: center; }
.welcome-copy { text-align: center; }
.welcome-copy h2 { font-size: 27px; margin: 0 0 8px; letter-spacing: -0.02em; }
.welcome-copy p { margin: 0; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%; padding: 15px 18px; border-radius: var(--radius);
  border: 1px solid transparent; font-size: 16px; font-weight: 600;
  text-align: center; text-decoration: none; cursor: pointer;
  transition: transform .06s ease, opacity .15s ease;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-door { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.btn:disabled { opacity: .55; }

/* ---------- welcome extras ---------- */
.consent { font-size: 12.5px; color: var(--muted); margin: 0; text-align: center; line-height: 1.5; }
.consent a { color: var(--accent); }
.tip {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--warn);
  border-radius: 10px; padding: 12px 14px; font-size: 13.5px; color: var(--muted);
}
.tip strong { color: var(--text); }

/* ---------- spinner ---------- */
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* ---------- home ---------- */
.home-head { display: flex; justify-content: space-between; align-items: flex-start; }
.eyebrow { margin: 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.home-head h2 { margin: 4px 0 0; font-size: 24px; letter-spacing: -0.02em; }
.signout { text-decoration: none; color: var(--muted); font-size: 20px; padding: 6px; }

.verified-card {
  background: linear-gradient(145deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center;
}
.verified-badge { color: var(--good); font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.verified-number { font-size: 24px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.verified-network { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-title { font-weight: 600; font-size: 15px; }
.state { color: var(--muted); font-size: 13px; }

.toggles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.toggle {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); cursor: pointer; font: inherit; transition: all .15s ease;
}
.toggle-icon { font-size: 21px; }
.toggle-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.toggle-state { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.toggle.on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.toggle.on .toggle-icon { filter: drop-shadow(0 0 8px var(--accent)); }

.thermo-row { display: flex; align-items: baseline; gap: 12px; }
.thermo-temp { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; }

/* ---------- manual login ---------- */
.alert {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--bad);
  border-radius: 10px; padding: 14px 16px;
}
.alert h2 { margin: 0 0 6px; font-size: 18px; }
.alert p { margin: 0 0 4px; font-size: 14px; }

.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 6px; }
.form input {
  width: 100%; padding: 14px; font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
}
.form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form .btn { margin-top: 12px; }
.form-error { color: var(--bad); font-size: 13.5px; margin: 0; text-align: center; }

.diag { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.diag summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.diag dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 8px; }
.diag dt { color: var(--muted); }
.diag dd { margin: 0; word-break: break-word; }
.diag code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.diag a { color: var(--accent); }

/* ---------- footer ---------- */
.foot {
  margin-top: auto; padding-top: 18px; display: flex; gap: 8px; align-items: center;
  justify-content: center; flex-wrap: wrap; font-size: 11.5px; color: var(--muted);
}
.foot a { color: var(--muted); }
.pill {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px;
  padding: 2px 9px; letter-spacing: .04em; text-transform: uppercase; font-weight: 600;
}
.pill-production { color: var(--warn); border-color: var(--warn); }
.pill-sandbox { color: var(--good); border-color: var(--good); }

.muted { color: var(--muted); }

/* ---------- log viewer ---------- */
.logview {
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; overflow-x: auto;
}
