:root {
  --bg: #0f1115;
  --bg-soft: #161a21;
  --card: #1a1f28;
  --line: #262c37;
  --text: #e8ecf3;
  --muted: #98a2b3;
  --brand: #4c8dff;
  --brand-2: #7c5cff;
  --ok: #35c07a;
  --warn: #e8a33d;
  --err: #ef5a5a;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2434 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Microsoft YaHei', 'PingFang SC', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 21, .82); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--brand); }
.brand-logo { height: 26px; width: auto; display: block; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 4px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 0 12px rgba(76, 141, 255, .8);
}
.nav-links { display: flex; align-items: center; gap: 16px; }
.nav-links form.inline { display: inline; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }

.wrap { width: min(980px, 100% - 36px); margin: 26px auto 60px; flex: 1; }

.hero { text-align: center; padding: 26px 12px 34px; }
.hero-logo { width: min(340px, 76vw); height: auto; display: block; margin: 0 auto 16px; }
.hero h1 { font-size: 30px; margin: 8px 0 12px; line-height: 1.3; }
.hero p { color: var(--muted); max-width: 660px; margin: 0 auto 22px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer;
  transition: filter .15s ease, transform .05s ease;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.danger { background: transparent; border-color: #5a2a2a; color: #ff8a8a; }
.btn.small { padding: 7px 13px; font-size: 14px; }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 18px; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

.form { display: flex; flex-direction: column; gap: 14px; margin: 4px 0 10px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text); }
.form .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.form input {
  background: #10141b; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; color: var(--text); font: inherit; outline: none;
}
.form input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(76, 141, 255, .16); }
.form .btn { align-self: flex-start; margin-top: 4px; }
.inline-form { display: inline; margin: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; }

.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 7px 12px 7px 0; width: 92px; vertical-align: top; }
.kv td { padding: 7px 0; word-break: break-all; }
code { background: #10141b; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 13px; }

.tag {
  display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: #10141b; color: var(--muted); margin-right: 4px;
}
.tag.ok { color: var(--ok); border-color: #23543b; }
.tag.warn { color: var(--warn); border-color: #5a452a; }
.tag.off { color: #6b7280; }

.flash { border-radius: 10px; padding: 11px 14px; margin-bottom: 16px; font-size: 14px; border: 1px solid var(--line); background: #121821; }
.flash.ok { border-color: #23543b; color: #9ff0c4; }
.flash.error { border-color: #5a2a2a; color: #ffb3b3; }
.flash.info { border-color: #2a3f5a; color: #b9d4ff; }
.flash.dev { border-color: #5a452a; color: #ffd79a; }
.code { letter-spacing: 3px; font-size: 18px; color: #ffd79a; }
.errors { color: #ffb3b3; margin: 0 0 14px; padding-left: 20px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.pick { width: 34px; text-align: center; }
.pick input { width: 16px; height: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.sep { color: #3a4150; }

.details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.details summary { cursor: pointer; color: var(--muted); }

.foot {
  border-top: 1px solid var(--line); padding: 16px 22px; color: var(--muted);
  font-size: 13px; text-align: center; background: #0c0e12;
}

/* ==== 管理面板 ==== */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 9px 15px; border-radius: 10px 10px 0 0; color: var(--muted);
  border: 1px solid transparent; border-bottom: 0; font-size: 14px;
}
.tab:hover { color: var(--text); text-decoration: none; background: #141922; }
.tab.on { color: var(--text); background: var(--card); border-color: var(--line); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  display: flex; flex-direction: column; gap: 4px; color: var(--text);
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.stat:hover { text-decoration: none; border-color: #354054; }
.stat-num { font-size: 24px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; }

.card.sub { padding: 16px 18px; }
.card.sub h3 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card.sub h3 .right { margin-left: auto; font-weight: 400; font-size: 13px; }
.card.sub h3 code { font-weight: 400; }

.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 16px; }
.form .checks { margin: 2px 0 4px; }
.check {
  display: flex !important; flex-direction: row !important; align-items: center; gap: 9px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #10141b;
  font-size: 14px; cursor: pointer;
}
.check:hover { border-color: #354054; }
.check input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.check span { display: flex; align-items: center; gap: 6px; }
.check.inherited { opacity: .7; background: #0d1117; }
.check.inherited input[type=checkbox] { cursor: not-allowed; }

/* ==== 权限矩阵（条目 = 简短描述 + 分类徽标；鼠标悬停 / Tab 弹出这条权限具体干嘛） ==== */
.card.sub.tier h3 .muted { font-weight: 400; font-size: 13px; }
.tier-meta {
  margin-left: auto; display: flex; align-items: center; gap: 12px;
  font-weight: 400; font-size: 13px; color: var(--muted);
}
.tier-meta .link { font-size: 13px; }

.perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }

.perm {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: #10141b;
  font-size: 14px; cursor: pointer; transition: border-color .12s, background .12s;
}
.perm:hover { border-color: #3a4761; background: #121826; }
.perm.on { border-color: #33507f; background: linear-gradient(180deg, #16203a, #121826); }
.perm input[type=checkbox] {
  flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--brand); cursor: pointer;
}
.perm-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.perm-name { line-height: 1.3; }
.perm-cat {
  align-self: flex-start; font-size: 11px; line-height: 1.6; padding: 0 8px; border-radius: 999px;
  background: #161d2e; border: 1px solid #2b3a5c; color: #b9c6ff; white-space: nowrap;
}
.perm-off { align-self: flex-start; font-size: 11px; color: var(--warn); }
.perm-src {
  flex: none; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #0d1117; border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.perm.inherited { opacity: .75; cursor: default; }
.perm.inherited input[type=checkbox] { cursor: not-allowed; }
.perm-src.demo { display: inline-block; vertical-align: middle; margin: 0 3px; }

.perm-tip {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 30; display: none;
  flex-direction: column; gap: 7px; width: min(430px, 86vw); padding: 12px 14px;
  background: #0b0f16; border: 1px solid #33405a; border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
  font-size: 13px; color: var(--text); text-align: left; white-space: normal; cursor: default;
}
.perm-tip.flip { left: auto; right: 0; }
.perm:hover .perm-tip, .perm:focus-within .perm-tip { display: flex; }
.tip-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-weight: 700; }
.tip-cat { flex: none; font-weight: 400; font-size: 12px; color: #9fb4ff; }
.tip-body { display: flex; flex-direction: column; gap: 5px; color: #cbd5e1; line-height: 1.55; }
.tip-line { color: var(--text); }
.tip-li { position: relative; padding-left: 13px; }
.tip-li::before { content: '·'; position: absolute; left: 3px; color: var(--muted); }
.tip-foot { border-top: 1px solid var(--line); padding-top: 7px; color: var(--muted); font-size: 12px; }
.tip-foot code { font-size: 12px; }

.form select, .form input[type=number] {
  background: #10141b; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font: inherit; outline: none;
}
.form .row label { flex: 1 1 200px; }
.table td .btn { white-space: nowrap; }

/* 行内表单（退出、解绑、开始答题这类只有一个按钮的）：紧跟在文字后面 */
form.inline { display: inline; margin: 0; }

/* ==== 白名单问卷（/whitelist、/whitelist/exam、/whitelist/result/:id）==== */
.quiz-q {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 10px;
  margin: 0 0 12px; background: #0f1319;
}
.quiz-q legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.quiz-stem { margin: 6px 0 10px; line-height: 1.6; }
.quiz-opt {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 11px; margin-bottom: 6px; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; line-height: 1.5;
}
.quiz-opt:hover { border-color: #3b4a66; background: #121826; }
.quiz-opt input { margin: 3px 0 0; flex: none; }
.quiz-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.quiz-review {
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 12px;
  padding: 12px 15px; background: #0f1319;
}
.quiz-review.ok { border-left-color: var(--ok); }
.quiz-review.bad { border-left-color: #ff8a8a; }
.quiz-review p { margin: 4px 0; }
.quiz-opts { list-style: none; padding: 0; margin: 8px 0 0; }
.quiz-opts li { padding: 6px 10px; border-radius: 8px; margin-bottom: 4px; color: #cbd5e1; }
.quiz-opts li.right { background: rgba(52, 211, 153, .1); color: var(--text); }
.quiz-opts li.wrong { background: rgba(248, 113, 113, .1); color: #ffc9c9; text-decoration: line-through; }
#quiz-left { color: var(--warn); font-variant-numeric: tabular-nums; }

/* ==== My Account (2026-10-17 rework: account info + microsoft + wechat) ==== */
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-status { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-status .tag { margin-right: 0; }

.profile { display: flex; gap: 16px; align-items: flex-start; }
.avatar {
  flex: none; width: 56px; height: 56px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 18px rgba(76, 141, 255, .25);
}
.profile-main { flex: 1 1 auto; min-width: 0; }
.profile-name { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.profile-name h2 { margin: 0; font-size: 20px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 22px; margin: 14px 0 0; }
.meta > div { min-width: 0; }
.meta dt { color: var(--muted); font-size: 12px; letter-spacing: .02em; }
.meta dd { margin: 2px 0 0; word-break: break-all; }

/* open: demote the summary to a neutral button so only the confirm button is red */
.wx-box { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; margin-top: 12px; }
.wx-qr {
  flex: none; background: #fff; padding: 8px; border-radius: 12px; line-height: 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
}
/* 码要大到能扫：132px 时微信的小程序码解不出来（模块被压成 3~4px），220px 起才稳 */
.wx-qr img { width: 260px; height: 260px; display: block; image-rendering: auto; }
.wx-alt { width: 180px; height: 180px; display: block; background: #fff; padding: 6px; border-radius: 10px; image-rendering: pixelated; margin-top: 8px; }
/* 备用方式（小程序内再扫的小码 + 口令）：默认折叠，主流程只留「扫码」 */
.wx-alt-wrap { margin: 14px 0 0; padding-top: 10px; border-top: 1px dashed rgba(255, 255, 255, .12); }
.wx-alt-wrap > summary { cursor: pointer; color: #9fb0c8; font-size: 14px; outline: none; }
.wx-alt-wrap > summary:hover { color: #cfe0f5; }
.wx-alt-wrap[open] > summary { margin-bottom: 8px; }
.wx-side { flex: 1 1 200px; min-width: 0; }
.wx-steps { margin: 0 0 10px; padding-left: 18px; line-height: 1.65; font-size: 14px; }
.wx-steps li { margin-bottom: 2px; }
.short-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 17px; letter-spacing: 2px; color: #ffd79a;
  background: #12161e; border: 1px solid #3a3226; border-radius: 8px; padding: 3px 9px;
}
.wx-side .row { margin-top: 10px; }
#wx-poll { margin-top: 10px; }

/* two-step confirm (pure <details>, never window.confirm) */
details.confirm { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details.confirm > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
}
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm > summary::marker { content: ''; }
details.confirm[open] { display: inline-flex; align-items: center; gap: 6px; }
/* open: demote the summary to a neutral button so only the confirm button is red */
details.confirm[open] > summary { background: #1a212b; border-color: var(--line); color: #d5e0ea; }
details.confirm form { display: inline; margin: 0; }

/* 危险操作区（账号详情 → 删除这个账号）：默认收起，展开后占满整行，避免误点 */
.danger-zone { display: block; margin-top: 4px; }
.danger-zone > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.danger-zone > summary::-webkit-details-marker { display: none; }
.danger-zone > summary::marker { content: ''; }
.danger-zone[open] > summary { background: #1a212b; border-color: var(--line); color: #d5e0ea; }
.danger-zone .form { margin-top: 14px; padding-top: 12px; border-top: 1px dashed #3a2a2a; }
.danger-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: #ffb4b4; }
.danger-list li { margin-bottom: 4px; }

@media (max-width: 620px) {
  .profile { flex-direction: column; }
  .wx-qr img { width: 220px; height: 220px; }
}
/* 管理员专属的横排卡片（首页「服务器面板」） */
.card-wide { grid-column: 1 / -1; }
.card-wide .wide-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.card-wide .wide-row p { margin: 0; }
