:root {
  --bg: #0f1115; --card: #181b22; --line: #262a33; --text: #e8eaee; --muted: #9097a3;
  --accent: #4f8cff; --accent-2: #3a74e6; --danger: #e5484d; --ok: #3ccf91; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
main { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: .2px; }
h2 { font-size: 19px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.narrow { max-width: 400px; margin: 10vh auto 0; }
.narrow h1 { margin-bottom: 4px; }
label { display: block; margin: 14px 0 0; font-size: 14px; color: var(--muted); }
input, textarea {
  display: block; width: 100%; margin-top: 6px; min-height: 44px; padding: 10px 12px;
  background: #0b0d11; color: var(--text); border: 1px solid var(--line); border-radius: 10px; font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { font: 13px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; resize: none; word-break: break-all; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost:hover { background: #20242c; }
.btn.small { min-height: 44px; padding: 0 12px; font-size: 14px; font-weight: 550; }
.btn.wide { width: 100%; margin-top: 16px; }
.btn[disabled] { opacity: .6; cursor: default; }
.err { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.list { margin-top: 16px; display: grid; gap: 10px; }
.user { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.user .head { display: flex; align-items: center; gap: 8px; }
.user .name { font-weight: 650; font-size: 17px; overflow-wrap: anywhere; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #4a505c; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(60,207,145,.18); }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin: 10px 0 12px; font-size: 14px; }
.meta span { color: var(--muted); display: block; font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 auto; }
.actions .revoke { color: #ff8a8d; border-color: #4a2a2d; }
.help { margin-top: 22px; }
.help summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 650; list-style: none; }
.help summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.help[open] summary::after { content: "▴"; }
.help ol { padding-left: 20px; margin: 6px 0 10px; }
.help li { margin: 6px 0; }
.help ul { padding-left: 18px; margin: 6px 0; }
dialog {
  width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 18px;
}
dialog::backdrop { background: rgba(0,0,0,.6); }
.row { display: flex; gap: 10px; margin-top: 14px; }
.row .btn { flex: 1; }
.keybox { display: flex; flex-direction: column; }
.keybox img { width: 260px; height: 260px; max-width: 100%; align-self: center; background: #fff; border-radius: 12px; padding: 6px; margin-bottom: 12px; }
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2a2f39; color: var(--text); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s; font-size: 14px; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; }
@media (min-width: 760px) {
  main { padding-top: 32px; }
  .list { grid-template-columns: 1fr 1fr; }
}
