:root {
  --bg: #0b0d0a;
  --bg2: #0f1210;
  --card: #15181366;
  --line: #262b23;
  --ink: #eef2e7;
  --dim: #8b9484;
  --acid: #c8ff3d;
  --acid-dim: #97c22e;
  --bad: #ff6b60;
  --good: #56d888;
  --radius: 16px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f7f0; --bg2: #eef1e7; --card: #ffffff; --line: #dde1d3;
    --ink: #14170e; --dim: #5b6252; --acid: #6f9c00; --acid-dim: #6f9c00;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a1f16 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
}
main {
  max-width: 560px; margin: 0 auto;
  padding: 14px 16px calc(28px + env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 22px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: .2px; font-size: 17px; }
.logo { width: 16px; height: 16px; border-radius: 5px; background: linear-gradient(135deg, var(--acid), var(--acid-dim)); box-shadow: 0 0 18px #c8ff3d55; }
.status {
  display: inline-flex; align-items: center; gap: 8px;
  font: 600 10.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em;
  color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); box-shadow: 0 0 10px currentColor; }
.status[data-state="ready"] .dot, .status[data-state="idle"] .dot { background: var(--good); color: var(--good); }
.status[data-state="error"] .dot { background: var(--bad); color: var(--bad); }
.status[data-state="active"] .dot { background: var(--acid); color: var(--acid); animation: pulse 1.4s ease-in-out infinite; }

/* stages */
.stage { animation: fadeUp .38s cubic-bezier(.2,.7,.2,1) both; }
.stage.center { display: grid; place-items: center; gap: 18px; text-align: center; padding: 40px 0; }
h1 { font-size: clamp(24px, 7vw, 32px); line-height: 1.12; letter-spacing: -.4px; margin: 4px 0 10px; }
.sub { color: var(--dim); margin: 0 0 20px; font-size: 15px; }
.note { font-size: 13px; margin: 10px 2px 0; }
.note.err { color: var(--bad); }

input {
  width: 100%; min-height: 54px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
  font: 18px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em;
}
input::placeholder { color: #5c6353; }
input:focus { outline: none; border-color: var(--acid); box-shadow: 0 0 0 3px #c8ff3d22; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; min-height: 54px; margin-top: 12px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
  font: 600 16px system-ui, sans-serif; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: transform .06s, filter .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: default; }
.btn.primary { background: linear-gradient(180deg, var(--acid), var(--acid-dim)); border-color: transparent; color: #10130a; box-shadow: 0 10px 30px -12px #c8ff3d99; }
.btn.primary:not(:disabled):hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.open { animation: glow 2s ease-in-out infinite; }

/* spinner */
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--acid); animation: spin .8s linear infinite; }
.loading-text { color: var(--ink); font-size: 16px; margin: 0; }

/* code stage */
.kicker { text-align: center; color: var(--dim); letter-spacing: .16em; text-transform: uppercase; font: 600 11px ui-monospace, monospace; margin: 8px 0 12px; }
.code {
  display: block; width: 100%; text-align: center; cursor: pointer;
  font: 800 clamp(38px, 14vw, 60px)/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em;
  color: var(--acid); background: var(--card);
  border: 1px solid var(--line); border-radius: 20px; padding: 22px 12px;
  box-shadow: 0 0 0 0 #c8ff3d00; animation: codeglow 2.4s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
.code:active { transform: scale(.99); }
.copied { text-align: center; color: var(--good); font-size: 13px; margin: 8px 0 0; animation: pop .3s ease both; }
.countdown { text-align: center; color: var(--dim); font-size: 13px; margin: 10px 0 0; }
.countdown b { color: var(--ink); }

/* steps */
.steps { list-style: none; margin: 24px 0 8px; padding: 0; display: grid; gap: 10px; }
.steps li {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  animation: fadeUp .4s both; opacity: .85;
}
.steps li:nth-child(1) { animation-delay: .02s; }
.steps li:nth-child(2) { animation-delay: .08s; }
.steps li:nth-child(3) { animation-delay: .14s; }
.steps li:nth-child(4) { animation-delay: .20s; }
.steps .num {
  flex: none; width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line); color: var(--dim);
  font: 700 13px ui-monospace, monospace;
}
.steps .txt { font-size: 14.5px; color: var(--ink); }
.steps b { color: var(--acid); font-weight: 700; }
.steps li.done { opacity: 1; border-color: #2f5a2f; }
.steps li.done .num { background: var(--good); border-color: var(--good); color: #06210f; }
.steps li.active { opacity: 1; border-color: var(--acid); box-shadow: 0 0 0 3px #c8ff3d1a; }
.steps li.active .num { border-color: var(--acid); color: var(--acid); animation: pulse 1.4s ease-in-out infinite; }

/* log */
.log-wrap { margin-top: 26px; border-top: 1px solid var(--line); }
.log-wrap summary {
  cursor: pointer; list-style: none; padding: 14px 2px 10px;
  font: 600 11px ui-monospace, monospace; letter-spacing: .12em; color: var(--dim);
}
.log-wrap summary::-webkit-details-marker { display: none; }
#log-count { color: #5c6353; }
#events { list-style: none; margin: 0; padding: 0 0 8px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
#events li { padding: 6px 2px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#events time { color: var(--dim); margin-right: 8px; }
#events b { color: var(--acid); font-weight: 700; margin-right: 6px; }
#events span { color: var(--ink); }
#events li[data-bad] b { color: var(--bad); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.18); opacity: .65; } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 60% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
@keyframes glow { 0%,100% { box-shadow: 0 10px 30px -12px #c8ff3d55; } 50% { box-shadow: 0 12px 40px -10px #c8ff3daa; } }
@keyframes codeglow { 0%,100% { box-shadow: 0 0 0 1px #c8ff3d18, 0 0 30px -18px #c8ff3d; } 50% { box-shadow: 0 0 0 1px #c8ff3d40, 0 0 44px -14px #c8ff3d; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
