:root {
  --bg: #f4f5f7; --card: #fff; --text: #1a1a1a; --muted: #777; --line: #e6e6e9;
  --accent: #2d5fa4; --ok: #2aa356; --bad: #d23f3f; --warn: #d98a12;
  --bubble: #fff; --tabbar: #fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101214; --card: #1b1e22; --text: #ececec; --muted: #9a9a9a; --line: #2a2e33;
    --accent: #7aa7e8; --bubble: #1b1e22; --tabbar: #15181b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; font-size: 13px; }

.screen { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card input { width: 100%; margin: 14px 0 10px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--card); border-bottom: 1px solid var(--line); font-weight: 600;
}
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(42,163,86,.2); }
.dot.off { background: var(--bad); box-shadow: 0 0 0 3px rgba(210,63,63,.2); }

main { padding: 12px 12px calc(70px + env(safe-area-inset-bottom)); }
.card {
  background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.card-title { font-weight: 600; margin-bottom: 6px; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); flex: none; }
.row .v { text-align: right; word-break: break-all; }
.v.ok { color: var(--ok); font-weight: 600; }
.v.bad { color: var(--bad); font-weight: 600; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px 16px; font-size: 15px; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.actions { display: flex; gap: 10px; margin: 8px 0; }
.actions .btn { flex: 1; }

input, select {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; position: sticky; top: 48px; z-index: 4; background: var(--bg); padding: 4px 0; }
.toolbar select { flex: 1; min-width: 0; }
.toolbar input { flex: 1; min-width: 0; }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
ul.plain li:last-child { border-bottom: 0; }

/* 聊天 */
.chat .older { display: block; margin: 0 auto 10px; }
.day { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 6px; }
.msg { background: var(--bubble); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.msg .who { font-weight: 600; color: var(--accent); font-size: 14px; }
.msg .who .role { font-weight: 400; font-size: 11px; color: var(--muted); margin-left: 4px; }
.msg .time { color: var(--muted); font-size: 11px; margin-left: 6px; }
.msg .text { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.msg img { max-width: 100%; max-height: 300px; border-radius: 8px; margin-top: 6px; display: block; background: var(--line); }
.msg .att { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 成员 */
.events li { display: flex; gap: 10px; align-items: flex-start; }
.events .tag { flex: none; font-size: 12px; padding: 2px 8px; border-radius: 8px; color: #fff; }
.tag.in { background: var(--ok); } .tag.out { background: var(--bad); }
.events .body { flex: 1; }
.events .meta { color: var(--muted); font-size: 12px; }

/* 登录 */
.qr { width: 100%; max-width: 280px; display: block; margin: 8px auto; border-radius: 8px; background: #fff; }
.steps { padding-left: 20px; margin: 8px 0; font-size: 14px; }
.steps li { margin: 4px 0; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; background: var(--tabbar); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; padding: 12px 0;
}
.tabbar button.active { color: var(--accent); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(0,0,0,.8); color: #fff; padding: 8px 16px; border-radius: 20px; font-size: 13px; z-index: 9;
}
