:root {
  --bg: #f4f5f7; --card: #fff; --text: #1c1e21; --muted: #6b7280; --line: #e5e7eb;
  --primary: #2563eb; --primary-text: #fff; --danger: #dc2626;
  --ok: #15803d; --ok-bg: #dcfce7; --bad: #b91c1c; --bad-bg: #fee2e2;
  --warn: #a16207; --warn-bg: #fef3c7; --chip: #f1f5f9; --input: #fff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #181b21; --text: #e6e8eb; --muted: #9aa3af; --line: #2a2f37;
    --primary: #3b82f6; --danger: #ef4444;
    --ok: #4ade80; --ok-bg: #14301f; --bad: #f87171; --bad-bg: #3a1717;
    --warn: #fbbf24; --warn-bg: #3a2e10; --chip: #232831; --input: #11141a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
body.noscroll { overflow: hidden; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px; }
h2 { font-size: 20px; margin: 8px 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.link { cursor: pointer; }
.card-title { font-weight: 600; font-size: 16px; }
.card .actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.card .actions .btn { flex: 1; min-width: 88px; }
.banner { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; display: block; text-decoration: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.info { background: var(--primary); color: var(--primary-text); }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font-size: 15px; cursor: pointer; min-height: 40px;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.block { display: block; width: 100%; text-align: left; margin-bottom: 8px; }
.btn[disabled] { opacity: .5; cursor: default; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--input);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-height: 42px;
}
textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
input[type=checkbox] { width: auto; min-height: 0; margin: 0 6px 0 0; }
.check { display: flex; align-items: center; margin: 6px 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

pre.log {
  background: #0b0d10; color: #d1d5db; border-radius: 10px; padding: 12px; font-size: 12px;
  line-height: 1.55; overflow: auto; max-height: 65vh; white-space: pre-wrap; word-break: break-all; margin: 0;
}

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10;
}
#tabs[hidden] { display: none; }
#tabs a { flex: 1; text-align: center; padding: 8px 0 6px; color: var(--muted); text-decoration: none; font-size: 12px; }
#tabs a .ti { display: block; font-size: 18px; line-height: 1.2; }
#tabs a.on { color: var(--primary); }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--card); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
@media (min-width: 600px) { .modal-bg { align-items: center; } .modal { border-radius: 16px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.modal-head .x { border: 0; background: none; font-size: 26px; color: var(--muted); cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-foot { display: flex; gap: 8px; margin-top: 16px; }
.modal-foot .btn { flex: 1; }

#toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 30; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

.auth { max-width: 380px; margin: 8vh auto 0; }
.auth .logo { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.qr { display: block; width: 200px; height: 200px; margin: 8px auto; background: #fff; border-radius: 8px; }
.list-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt20 { margin-top: 20px; }
.mb10 { margin-bottom: 10px; } .tight { margin: -4px 0 12px; } .pointer { cursor: pointer; }
.pre-wrap { white-space: pre-wrap; } textarea.short { min-height: 70px; }
