:root {
  --bg: #0e1014;
  --bg2: #161a21;
  --line: #262c37;
  --txt: #e8ecf3;
  --muted: #8b95a5;
  --accent: #3d7dff;
  --danger: #ff4d4f;
  --ok: #2ecc71;
  --logged: #ff3b30;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; }
.center { text-align: center; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

.screen { display: flex; flex-direction: column; min-height: 100dvh; }

/* ── 口令页 ── */
#authScreen { align-items: center; justify-content: center; padding: 24px; }
.auth-box { width: 100%; max-width: 340px; text-align: center; }
.auth-box .logo { font-size: 44px; color: var(--accent); line-height: 1; }
.auth-box h1 { font-size: 21px; margin: 12px 0 4px; font-weight: 600; }
.auth-box p { margin: 0 0 22px; }

input, textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 16px;
  outline: none;
  font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.7; font-size: 13.5px; }

/* ── 按钮 ── */
.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 500;
  color: var(--txt);
  background: var(--bg2);
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.65; }
.btn.block { width: 100%; margin-top: 12px; padding: 14px; }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.primary { background: var(--accent); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--txt); }
.btn.danger { color: var(--danger); border-color: rgba(255, 77, 79, 0.35); }
.btn:disabled { opacity: 0.35; }

/* ── 顶栏 ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px calc(10px + env(safe-area-inset-top)) 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.brand { font-size: 16px; font-weight: 600; }
.brand .dot { color: var(--accent); }
.top-actions { display: flex; gap: 8px; }

/* ── 导入面板 ── */
.panel { padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-size: 14px; }
.panel .row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }

/* ── 统计条 ── */
.statbar {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

/* ── 列表 ── */
.list { flex: 1; overflow-y: auto; padding: 10px 12px 140px 12px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 14px; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  margin-bottom: 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--bg2);
  transition: border-color 0.15s, background 0.15s;
}
.item.sel { border-color: var(--accent); background: rgba(61, 125, 255, 0.08); }
.item.logged {
  border-color: var(--logged);
  background: rgba(255, 59, 48, 0.13);
  box-shadow: inset 3px 0 0 var(--logged);
}

.item .cb {
  width: 22px; height: 22px; flex: 0 0 22px;
  border: 2px solid var(--line);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: transparent;
}
.item.sel .cb { border-color: var(--accent); background: var(--accent); color: #fff; }
.item.logged .cb { border-color: var(--logged); }

.item .body { flex: 1; min-width: 0; }
.item .name {
  font-size: 15px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item.logged .name { color: #ff8b85; }
.item .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item .tag {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.item.logged .tag { border-color: var(--logged); color: #ff8b85; }
.item .tag.online { border-color: rgba(46, 204, 113, 0.5); color: var(--ok); }

/* ── 底部 ── */
.footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)) 16px;
  background: linear-gradient(to top, var(--bg) 70%, rgba(14, 16, 20, 0));
  z-index: 6;
}
.btn.scan {
  width: 100%;
  padding: 16px;
  font-size: 17px;
  font-weight: 600;
  background: var(--accent);
  border-radius: 14px;
}
.footer p { margin: 8px 0 0; }

/* ── 扫码层 ── */
.scanner {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(66vw, 280px);
  height: min(66vw, 280px);
}
.scan-frame i {
  position: absolute;
  width: 26px; height: 26px;
  border: 3px solid var(--accent);
}
.scan-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.scan-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.scan-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.scan-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }

.scan-head {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: calc(18px + env(safe-area-inset-top)) 16px 18px;
  text-align: center;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent);
}
.scan-foot {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom)) 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
}
.scan-foot .hint { color: #dfe6f2; }

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: 86vw;
  padding: 11px 16px;
  border-radius: 11px;
  background: rgba(28, 33, 42, 0.97);
  border: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.45;
  z-index: 99;
  text-align: center;
  white-space: pre-wrap;
}
.toast.ok { border-color: rgba(46, 204, 113, 0.5); }
.toast.bad { border-color: rgba(255, 77, 79, 0.55); }

/* ── 管理员 ── */
.link { color: var(--accent); text-decoration: none; font-size: 13px; }
.auth-box .link { display: inline-block; margin-top: 14px; }

.token-box {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px dashed rgba(61, 125, 255, 0.5);
  border-radius: 12px;
  background: rgba(61, 125, 255, 0.07);
}
.token {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 17px;
  letter-spacing: 1.2px;
  color: var(--accent);
  margin: 8px 0 10px;
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}
.item .btn { flex: 0 0 auto; }
#adminScreen .item { align-items: center; }
#adminScreen .list { padding-bottom: 30px; }

/* ── 免责声明 ── */
.notice {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 8, 12, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.notice-box {
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.notice-box h2 { margin: 0 0 12px; font-size: 17px; font-weight: 600; }
.notice-body { overflow-y: auto; font-size: 13px; line-height: 1.75; color: #b9c2d0; }
.notice-body p { margin: 0 0 12px; }
.notice-body b { color: var(--txt); }
.notice-box .btn { margin-top: 14px; }
.auth-box .link { display: inline-block; margin-top: 12px; }