:root {
  --purple: #6c5ce7;
  --purple-2: #7b6ef6;
  --purple-soft: #ece9fe;
  --ink: #2b2b3a;
  --muted: #8a8a99;
  --line: #e9e9f2;
  --field: #f6f6fb;
  --green: #1fa463;
  --green-ink: #157a49;
  --green-soft: #ecfbf1;
  --green-line: #a6e5bf;
  --red: #e05563;
  --red-soft: #fdeef0;
  --shadow: 0 18px 50px rgba(92, 78, 180, 0.14);
  --radius: 16px;
}

* { box-sizing: border-box; }

/* 显式 display 会盖过 [hidden] 的 UA 隐藏，这里强制修复 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #efeafd 0%, rgba(239, 234, 253, 0) 60%),
    linear-gradient(180deg, #f3f2fb 0%, #f7f7fc 100%);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8vh 20px 40px;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 720px;
}

/* header */
.head {
  text-align: center;
  margin-bottom: 26px;
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.title {
  margin: 16px 0 8px;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #4b3fd6, #7b6ef6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* card */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 26px 22px;
}

.query-row {
  display: flex;
  gap: 12px;
}

.cred-input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 18px;
  font-size: 15px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.cred-input::placeholder { color: #b3b3c2; }
.cred-input:focus {
  border-color: var(--purple-2);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(124, 108, 246, 0.14);
}

.btn-primary {
  flex: 0 0 auto;
  min-width: 96px;
  height: 52px;
  padding: 0 26px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--purple-2), var(--purple));
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.32);
  transition: transform 0.08s, box-shadow 0.15s, opacity 0.15s;
}
.btn-primary:hover { box-shadow: 0 10px 26px rgba(108, 92, 231, 0.42); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}

.btn-ghost {
  height: 38px;
  padding: 0 18px;
  font-size: 14px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: #cfcfe0; color: var(--ink); }

/* 被风控时高亮“人工登录一次” */
.btn-attn {
  border-color: var(--purple-2);
  color: var(--purple);
  background: var(--purple-soft);
  animation: attn 1.1s ease-in-out infinite;
}
@keyframes attn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 108, 246, 0.28); }
  50% { box-shadow: 0 0 0 5px rgba(124, 108, 246, 0); }
}

.auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.auto-toggle input { accent-color: var(--purple); width: 15px; height: 15px; }

/* status (loading) */
.status {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--purple);
  font-size: 14px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid var(--purple-soft);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* result */
.result { margin-top: 8px; }
.result-divider {
  height: 1px;
  background: var(--line);
  margin: 22px 0 18px;
}
.result-label {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.code-box {
  background: var(--green-soft);
  border: 2px dashed var(--green-line);
  border-radius: 14px;
  padding: 30px 20px 22px;
  text-align: center;
}
.code {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: 10px;
  color: var(--green);
  line-height: 1.05;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.15s;
}
.code:hover { opacity: 0.82; }
.code.copied::after {
  content: " 已复制";
  font-size: 15px;
  letter-spacing: normal;
  color: var(--green-ink);
  font-weight: 600;
}
.code-meta {
  margin-top: 14px;
  color: #6b8a77;
  font-size: 14px;
}
.captured {
  margin-top: 16px;
  text-align: center;
  color: var(--green);
  font-size: 14px;
  font-weight: 600;
}

/* error */
.error {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--red-soft);
  border: 1px solid #f6cdd2;
  border-radius: 12px;
  color: var(--red);
  font-size: 14px;
  line-height: 1.5;
}

/* history */
.history {
  margin-top: 18px;
  padding: 20px 22px;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.history-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.history-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.history-count {
  font-size: 12px;
  color: var(--muted);
}
.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
}
.history-body {
  max-height: 320px;
  overflow: auto;
}
.history-empty {
  padding: 18px 0;
  text-align: center;
  color: #b3b3c2;
  font-size: 13px;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.history-table th {
  position: sticky;
  top: 0;
  background: #fff;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.history-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #f2f2f8;
  color: var(--ink);
  vertical-align: middle;
}
.history-table tr:hover td { background: #faf9ff; }
.h-code {
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  cursor: pointer;
}
.h-code:hover { text-decoration: underline; }
.h-email { color: #4a4a5a; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-subject { color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-time { color: #9a9aab; white-space: nowrap; }

/* footer */
.foot {
  margin-top: 22px;
  text-align: center;
  color: #a6a6b6;
  font-size: 12px;
}

@media (max-width: 560px) {
  .title { font-size: 30px; }
  .query-row { flex-direction: column; }
  .btn-primary { width: 100%; }
  .code { font-size: 42px; letter-spacing: 6px; }
}
