/* 手机端样式：深色、大按钮、单手可达。只用系统字体，不加载任何外部资源。 */
:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-soft: #12151c;
  --card: #171b23;
  --line: rgba(255, 255, 255, 0.09);
  --ink: #f2f4f7;
  --muted: rgba(242, 244, 247, 0.55);
  --faint: rgba(242, 244, 247, 0.35);
  --accent: #eef1f6;
  --accent-ink: #101318;
  --guard: #7d8bff;
  --guard-soft: rgba(125, 139, 255, 0.16);
  --alarm: #ff6b6b;
  --ok: #4ade80;
  --radius: 20px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(120% 60% at 50% 0%, #1a1f2e 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px calc(env(safe-area-inset-bottom, 0px) + 26px);
}

.pane[hidden] {
  display: none;
}

/* ── 配对 ─────────────────────────────────────────────────────────────── */
.pair-card {
  margin-top: 12vh;
  padding: 26px 22px 20px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--line), 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.glyph {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: #c9d3ff;
  background: var(--guard-soft);
  box-shadow: inset 0 0 0 1px rgba(140, 158, 255, 0.26);
}

.pair-card h1 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 650;
}

.lede {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.lede b {
  color: var(--ink);
  font-weight: 600;
}

.code {
  width: 100%;
  height: 54px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
}

.code::placeholder {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--faint);
}

.code:focus {
  box-shadow: inset 0 0 0 1.5px var(--guard);
}

/* ── 通用控件 ─────────────────────────────────────────────────────────── */
.primary {
  width: 100%;
  height: 52px;
  margin-top: 12px;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.primary:active {
  transform: scale(0.985);
}

.primary:disabled {
  opacity: 0.4;
}

.primary.alarm {
  background: var(--alarm);
  color: #1a0d0d;
}

.ghost {
  flex: 1;
  height: 44px;
  border: 0;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
}

.ghost:active {
  background: rgba(255, 255, 255, 0.09);
}

.ghost.danger {
  color: #ffb4b4;
}

.error {
  min-height: 20px;
  margin: 10px 0 0;
  font-size: 13px;
  color: #ff9d9d;
}

/* ── 顶部 ─────────────────────────────────────────────────────────────── */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-glyph {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  color: #c9d3ff;
  background: var(--guard-soft);
}

.pill {
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.pill[data-state="online"] {
  color: var(--ok);
  background: rgba(74, 222, 128, 0.12);
}

.pill[data-state="offline"] {
  color: #ffb4b4;
  background: rgba(255, 107, 107, 0.14);
}

/* ── 主状态卡 ─────────────────────────────────────────────────────────── */
.hero {
  padding: 22px 20px 20px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #1b2029, #14171e);
  box-shadow: inset 0 0 0 1px var(--line), 0 18px 40px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.hero[data-state="locked"] {
  background: linear-gradient(180deg, #2a1b24, #1a1218);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.3), 0 18px 40px rgba(0, 0, 0, 0.35);
}

.hero-state {
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.hero[data-state="locked"] .hero-state {
  color: #ffc9c9;
}

.hero-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.hero-btn {
  margin-top: 18px;
}

/* ── 卡片与控件 ───────────────────────────────────────────────────────── */
.card {
  margin-top: 14px;
  padding: 4px 16px 14px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--line);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0 12px;
}

.row-title {
  font-size: 14.5px;
  font-weight: 550;
}

.row-desc {
  margin-top: 2px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.switch {
  appearance: none;
  flex: none;
  width: 50px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  position: relative;
  cursor: pointer;
  transition: background 0.18s ease;
}

.switch::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease;
}

.switch:checked {
  background: var(--guard);
}

.switch:checked::before {
  transform: translateX(20px);
}

.chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 4px;
}

.chip {
  width: 100%;
  height: 40px;
  padding: 0 6px;
  border: 0;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.chip[aria-pressed="true"] {
  background: var(--guard-soft);
  color: #cdd5ff;
  box-shadow: inset 0 0 0 1px rgba(125, 139, 255, 0.4);
}

.chip:disabled {
  opacity: 0.4;
}

/* ── 页脚 ─────────────────────────────────────────────────────────────── */
.meta {
  margin: 18px 4px 0;
}

.meta-line {
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
}

.meta-line.muted {
  margin-top: 3px;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
}

.footer {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ── 通知设置 ─────────────────────────────────────────────────────────── */
.notify-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
}

.select,
.text-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.text-input::placeholder {
  color: var(--faint);
  font-size: 13px;
}

.text-input:focus,
.select:focus {
  box-shadow: inset 0 0 0 1.5px var(--guard);
}

.ghost.wide {
  width: 100%;
  height: 42px;
}

.events {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}

.events label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.events input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--guard);
}

.notify-status {
  padding: 8px 0 10px;
  font-size: 12.5px;
  line-height: 18px;
  color: var(--faint);
}

.notify-status[data-state="ok"] {
  color: rgba(74, 222, 128, 0.85);
}

.notify-status[data-state="error"] {
  color: #ffb4b4;
}

/* ── 轻提示 ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  translate: -50% 12px;
  max-width: 80vw;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(28, 32, 41, 0.96);
  box-shadow: inset 0 0 0 1px var(--line), 0 12px 30px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, translate 0.2s ease;
}

.toast[data-show="true"] {
  opacity: 1;
  translate: -50% 0;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
