:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e4e7ec;
  --text: #1f2430;
  --muted: #6b7280;
  --red: #e11e1e;
  --blue: #2f6fed;
  --green: #0f9d58;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 40px; height: 40px; border-radius: 10px; background: var(--red); color: #fff;
  display: grid; place-items: center; font-size: 20px;
}
.brand h1 { margin: 0; font-size: 17px; }
.brand h1 small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 10px; }
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 9px; padding: 8px 14px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: #c9cfd8; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; padding: 16px 22px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card h3 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }

.stage { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; }
.stage .dot { width: 9px; height: 9px; border-radius: 50%; background: #d6dae1; flex: none; }
.stage.done .dot { background: var(--green); }
.stage.running .dot { background: var(--blue); animation: pulse 1s infinite alternate; }
.stage.failed .dot { background: var(--red); }
.stage .msg { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; }
@keyframes pulse { from { opacity: .5 } to { opacity: 1 } }

.kv { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.kv b { font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; }
.badge.auto { background: #e6f6ec; color: var(--green); }
.badge.normal { background: #eaf1ff; color: var(--blue); }
.badge.confirm { background: #fff4e0; color: #c47b00; }
.badge.reject { background: #fde8e8; color: var(--red); }

.q-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; margin-bottom: 8px;
  cursor: pointer; transition: border-color .15s;
}
.q-item:hover { border-color: #c9cfd8; }
.q-item.active { border-color: var(--red); box-shadow: 0 0 0 2px rgba(225,30,30,.08); }
.q-item .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.q-item .ans { color: var(--muted); font-size: 12px; margin-top: 2px; }
.q-item .why { color: var(--muted); font-size: 12px; margin-top: 4px; }
.score-chip { font-weight: 700; font-variant-numeric: tabular-nums; }
.ok { color: var(--green); } .bad { color: var(--red); } .part { color: #c47b00; }

.viewer { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.toolbar {
  display: flex; align-items: center; gap: 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; flex-wrap: wrap;
}
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { border: 0; background: transparent; padding: 6px 14px; cursor: pointer; font-size: 13px; }
.seg-btn.active { background: var(--text); color: #fff; }
.chk { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.hint { color: #a3aab6; font-size: 12px; margin-left: auto; }

.canvas-wrap {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); min-height: 420px; display: grid; place-items: center; overflow: auto;
}
#photo { max-width: 100%; max-height: 78vh; display: block; border-radius: var(--radius); }
#overlay { position: absolute; inset: 0; pointer-events: none; }
#overlay svg { position: absolute; width: 100%; height: 100%; }
#overlay g[data-type] { pointer-events: auto; cursor: grab; }
#overlay g[data-type]:hover { opacity: .75; }
.empty { text-align: center; color: var(--muted); padding: 90px 0; }
.empty p { margin: 4px 0; font-size: 15px; }

.detail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.detail h3 { margin: 0 0 8px; font-size: 14px; }
.detail .row { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.detail textarea {
  width: 100%; min-height: 60px; border: 1px solid var(--line); border-radius: 8px; padding: 8px;
  font: inherit; resize: vertical;
}
.rubric { font-size: 12px; color: var(--muted); }
.rubric li { margin: 2px 0; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #22263a; color: #fff; padding: 9px 18px; border-radius: 20px; font-size: 13px;
  z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}

/* ---------------------------------------------------------------- 用户系统 */
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--muted); }
.user-chip #user-email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gate {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(24, 28, 36, .55); backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
.gate-card {
  width: 340px; background: var(--panel); border-radius: var(--radius);
  padding: 26px 26px 22px; box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.gate-card h2 { margin: 0 0 2px; font-size: 19px; }
.gate-sub { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.gate-form { display: flex; flex-direction: column; gap: 10px; }
.gate-form input, .gate-form select {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px;
  font-size: 13px; width: 100%;
}
.gate-form input:focus, .gate-form select:focus { outline: none; border-color: var(--blue); }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.code-row .btn { white-space: nowrap; }
.gate-form .hint { margin: 0; font-size: 12px; color: var(--muted); }
#auth-tabs { margin-bottom: 14px; display: flex; gap: 6px; }
.seg-btn {
  flex: 1; border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  border-radius: 8px; padding: 7px 0; cursor: pointer; font-size: 13px;
}
.seg-btn.active { background: var(--panel); color: var(--text); border-color: var(--blue); font-weight: 600; }

.modal {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(24, 28, 36, .45);
  display: grid; place-items: center;
}
.modal-card {
  width: 480px; max-height: 80vh; overflow: auto;
  background: var(--panel); border-radius: var(--radius); padding: 20px 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.invite-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.invite-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font-size: 12px;
}
.invite-row code { font: 600 13px Menlo, Consolas, monospace; letter-spacing: 1px; }
.tag { border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.tag.active { background: #e6f4ea; color: var(--green); }
.tag.used { background: #f1f2f4; color: var(--muted); }
.tag.expired { background: #fdecea; color: var(--red); }
