:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1c2433;
  --muted: #6b7788;
  --line: #e3e8f0;
  --brand: #1f6feb;
  --brand-dark: #1558c0;
  --danger: #d7263d;
  --ok: #11845b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -200px, #e6efff 0%, var(--bg) 60%) no-repeat, var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.center-page { align-items: center; }

.wrap { width: 100%; max-width: 640px; }
.wrap.narrow { max-width: 420px; }
.wrap.wide { max-width: 900px; }

.site-head { text-align: center; margin: 8px 0 20px; }
.site-head h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: .5px; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 6px 24px rgba(23, 43, 77, .06);
}

.card.center { text-align: center; }
.card-title { margin: 0 0 12px; font-size: 20px; }

.label {
  display: block;
  margin: 16px 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: #34405a;
}

input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}

textarea { resize: vertical; min-height: 168px; line-height: 1.7; }

input:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, .12);
  background: #fff;
}

.btn {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, transform .06s;
}

.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn-ghost {
  width: auto; margin: 0; padding: 7px 14px; font-size: 14px;
  color: var(--muted); background: #fff; border: 1px solid var(--line);
}
.btn-ghost:hover { background: #f3f6fb; color: var(--text); }

.who {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  margin-bottom: 6px;
  background: #f7f9fd;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.avatar {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #4d8cff, #1f6feb);
  color: #fff; font-weight: 700; font-size: 18px;
  text-transform: uppercase;
}

.avatar.small { width: 28px; height: 28px; font-size: 13px; }

.who-txt { display: flex; flex-direction: column; min-width: 0; }
.who-txt strong { font-size: 16px; word-break: break-all; }
.who-txt small { color: var(--muted); font-size: 12px; }

.row-between { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; }

.alert {
  margin-bottom: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  background: #fff1f3;
  border: 1px solid #ffd3da;
  color: var(--danger);
  font-size: 14px;
}

.msg { margin-top: 12px; font-size: 14px; min-height: 20px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }

.foot { margin-top: 22px; text-align: center; color: #9aa5b5; font-size: 12px; }
.link { color: var(--brand); text-decoration: none; }
.link:hover { text-decoration: underline; }
.code { margin: 0; font-size: 44px; font-weight: 800; color: #dbe3ef; }

/* ---------------- 后台 ---------------- */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.admin-head h1 { margin: 0; font-size: 22px; }
.logout-form { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 10px; text-align: center;
}
.stat-num { display: block; font-size: 22px; font-weight: 700; }
.stat-label { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

.list { display: grid; gap: 12px; }
.op {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 2px 10px rgba(23, 43, 77, .04);
}
.op-head { display: flex; align-items: center; gap: 8px; }
.op-nick { font-weight: 600; word-break: break-all; }
.op-time { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.op-body {
  margin: 10px 0 8px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.op-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: #9aa5b5; font-size: 12px; }
.op-meta .ua { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.empty { text-align: center; color: var(--muted); }

.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 20px 0 4px; font-size: 14px; }
.pager a { color: var(--brand); text-decoration: none; }
.pager span { color: var(--muted); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 480px) {
  body { padding-left: 12px; padding-right: 12px; }
  .site-head h1 { font-size: 22px; }
  .card { padding: 16px; border-radius: 12px; }
  .stats { gap: 8px; }
  .stat { padding: 12px 6px; }
  .stat-num { font-size: 19px; }
  .op { padding: 12px; }
  .op-head { flex-wrap: wrap; }
  .op-time { margin-left: 0; width: 100%; }
  .btn { padding: 14px 18px; font-size: 16px; }
}

@media (min-width: 768px) {
  body { font-size: 17px; }
  .site-head h1 { font-size: 30px; }
  .card { padding: 26px; }
  textarea { min-height: 200px; }
}

@media (min-width: 1024px) {
  body { padding-top: 48px; }
  .wrap { max-width: 680px; }
  .wrap.wide { max-width: 960px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141b; --card: #171d27; --text: #e7ecf5; --muted: #98a5b8;
    --line: #262f3d; --brand: #4d8cff; --brand-dark: #3b7cf0;
  }
  body { background: radial-gradient(1200px 600px at 50% -200px, #16233b 0%, var(--bg) 60%) no-repeat, var(--bg); }
  input[type="text"], input[type="password"], textarea { background: #121821; }
  input:focus, textarea:focus { background: #0e141d; }
  .who { background: #121821; }
  .alert { background: #2a161c; border-color: #5c2030; }
  .btn-ghost { background: #171d27; }
  .btn-ghost:hover { background: #1e2632; }
  .code { color: #2a3445; }
  .op { box-shadow: none; }
}

/* ---------------- 后台账号体系 ---------------- */
.head-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.whoami { display: flex; flex-direction: column; line-height: 1.2; font-size: 14px; color: #34405a; text-align: right; }
.whoami small { color: var(--muted); font-size: 11px; }

.tabs { display: flex; gap: 6px; margin: 0 0 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  white-space: nowrap;
}
.tab.active { color: #fff; background: var(--brand); border-color: var(--brand); }

.notice {
  margin-bottom: 14px; padding: 11px 14px; border-radius: 10px;
  background: #eef7f1; border: 1px solid #c8e6d5; color: var(--ok); font-size: 14px;
}

.badge {
  flex: 0 0 auto; padding: 2px 8px; font-size: 12px; border-radius: 999px;
  color: var(--muted); background: #eef2f8; border: 1px solid var(--line);
}
.badge-super { color: #8a5b00; background: #fff5e0; border-color: #f3dcaa; }
.badge-ok { color: var(--ok); background: #eaf7f0; border-color: #c8e6d5; }
.badge-off { color: var(--danger); background: #fff1f3; border-color: #ffd3da; }

.grid-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.grid-form .label { margin-top: 0; }
.grid-form select {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--text);
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
.btn-inline { width: auto; margin: 0; padding: 12px 22px; white-space: nowrap; }

.acct-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.inline-form { display: flex; gap: 6px; margin: 0; align-items: center; }
.inline-form input[type="text"] { width: 150px; padding: 7px 10px; font-size: 13px; }
.inline-form .btn { width: auto; margin: 0; padding: 7px 12px; font-size: 13px; }
.btn-danger-ghost { color: var(--danger); background: #fff; border: 1px solid #ffd3da; }
.btn-danger-ghost:hover { background: #fff1f3; color: var(--danger); }

@media (max-width: 720px) {
  .grid-form { grid-template-columns: 1fr; }
  .btn-inline { width: 100%; }
  .admin-head { flex-wrap: wrap; }
  .whoami { text-align: left; }
  .inline-form { flex: 1 1 100%; }
  .inline-form input[type="text"] { flex: 1 1 auto; width: auto; }
}

@media (prefers-color-scheme: dark) {
  .tab { background: #171d27; }
  .notice { background: #14261d; border-color: #204a35; }
  .badge { background: #1b2230; }
  .badge-super { background: #2a2214; border-color: #4a3a1c; color: #e0b661; }
  .badge-ok { background: #14261d; border-color: #204a35; }
  .badge-off { background: #2a161c; border-color: #5c2030; }
  .grid-form select { background: #121821; }
  .btn-danger-ghost { background: #171d27; border-color: #5c2030; }
  .btn-danger-ghost:hover { background: #2a161c; }
  .whoami { color: #c9d3e3; }
}
