:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2129;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #eff4ff;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --code-bg: #f3f4f6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1a1d23;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --line: #2c3038;
    --accent: #4f8cff;
    --accent-soft: #1d2a44;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --code-bg: #23272e;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 640px; margin: 0 auto; padding: 20px 16px 4px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; white-space: nowrap; }
.logo {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; letter-spacing: .5px;
}
.env { font-size: 12px; font-weight: 500; color: var(--warn); border: 1px solid currentColor; border-radius: 999px; padding: 0 8px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); min-width: 0; }
#who-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 640px; margin: 0 auto; padding: 12px 16px 48px; }
.stack { display: grid; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 22px 20px;
}
.card.center { display: grid; place-items: center; min-height: 160px; }
h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h1 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; margin: 12px 0 0; }

.field-label { display: block; font-size: 14px; font-weight: 500; margin: 18px 0 6px; }
input, select {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.email-input { display: flex; align-items: stretch; }
.email-input input { border-radius: 10px 0 0 10px; min-width: 0; }
.suffix {
  display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line); border-left: 0;
  border-radius: 0 10px 10px 0; background: var(--code-bg); color: var(--muted); white-space: nowrap;
}
.code { font-size: 22px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.turnstile { margin-top: 16px; min-height: 65px; }

button { cursor: pointer; border-radius: 10px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.primary {
  width: 100%; height: 44px; margin-top: 18px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.ghost { height: 36px; padding: 0 14px; border: 1px solid var(--line); background: var(--card); white-space: nowrap; }
.ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.link { border: 0; background: none; padding: 0; color: var(--accent); white-space: nowrap; }
.row-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 14px; }

.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; font-size: 14px; }
.facts { margin: 16px 0 0; display: grid; gap: 8px; }
.facts > div { display: flex; gap: 12px; }
.facts dt { color: var(--muted); width: 72px; flex: none; }
.facts dd { margin: 0; }

.groups { border: 0; padding: 0; margin: 18px 0 0; }
.groups legend { font-size: 14px; font-weight: 500; padding: 0; margin-bottom: 8px; }
.radio-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.radio-list label {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.radio-list label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-list input { width: auto; height: auto; margin: 0; accent-color: var(--accent); }

.badge { font-size: 13px; padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }

.key-box { display: flex; align-items: center; gap: 10px; background: var(--code-bg); border-radius: 10px; padding: 10px 10px 10px 14px; }
.key-box code { flex: 1; min-width: 0; font: 14px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }
.key-actions { display: flex; gap: 6px; flex: none; }

.meter { height: 10px; background: var(--code-bg); border-radius: 999px; overflow: hidden; }
#meter-bar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .4s; }
#meter-bar.high { background: var(--warn); }
#meter-bar.full { background: var(--bad); }
.meter-text { display: flex; justify-content: space-between; margin-top: 8px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-text b { color: var(--text); font-weight: 600; margin-left: 4px; }

.inline { display: flex; gap: 10px; }
.inline select { flex: 1; min-width: 0; }
.inline .ghost { height: 42px; }

.urls { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.urls li { display: flex; align-items: center; gap: 10px; background: var(--code-bg); border-radius: 10px; padding: 6px 6px 6px 14px; }
.urls code { flex: 1; min-width: 0; font: 14px ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }

.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 10;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.toast.error { background: var(--bad); color: #fff; }

.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 480px) {
  .top { flex-wrap: wrap; row-gap: 6px; }
  .who { width: 100%; justify-content: space-between; }
  .card { padding: 18px 16px; }
  .radio-list { grid-template-columns: 1fr; }
  .key-box { flex-direction: column; align-items: stretch; }
  .key-actions .ghost { flex: 1; }
}
