:root {
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1a1c23;
  --muted: #6b7280;
  --line: #e4e6ee;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #7c7cf0;
    --brand-soft: #23234a;
    --bg: #0f1117;
    --surface: #181b23;
    --text: #e8eaf0;
    --muted: #9aa1b1;
    --line: #262a35;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 20px calc(32px + env(safe-area-inset-bottom));
}

.head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
}

h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.01em;
}

.sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.state {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.dot.on { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.off { background: var(--muted); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }

.state-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field em {
  font-style: normal;
  font-weight: 400;
  color: var(--muted);
}

input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 小於 16px 時 iOS 會自動放大整頁 */
}

input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: transparent;
}

.btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}

.btn:disabled { opacity: 0.55; cursor: default; }
.btn:not(:disabled):active { filter: brightness(0.94); }

.btn.primary {
  background: var(--brand);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
  margin-top: 10px;
}

.btn.install { margin-bottom: 14px; }

.msg {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  background: var(--brand-soft);
  color: var(--text);
  word-break: break-word;
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.who strong { color: var(--text); }

.linkbtn {
  margin-left: auto;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.linkbtn:active { background: var(--brand-soft); }

.msg.error { background: color-mix(in srgb, var(--err) 15%, transparent); }
.msg.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); }

.hint {
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--warn) 35%, var(--line));
}

.hint p { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.hint em { font-style: normal; font-weight: 600; color: var(--text); }

.meta h2, .log h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 26px 0 10px;
}

dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0;
  font-size: 14px;
}

dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.log ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.log li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 14px;
}

.log time {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.foot {
  margin-top: 28px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
