:root {
  --bg: #0d1117;
  --card: #161b22;
  --card-2: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --dim: #484f58;
  --accent: #2f81f7;
  --accent-dim: #1f6feb;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ===== Topbar ===== */
.topbar {
  text-align: center;
  margin-bottom: 24px;
}
.topbar h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
}
.tabs {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}
.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--accent-dim);
  color: #fff;
}

/* ===== Panel ===== */
.panel { display: none; }
.panel.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}
.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}
.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}
.badge-local {
  background: rgba(63,185,80,.12);
  color: var(--success);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* ===== Input ===== */
.input-group { margin-bottom: 18px; }
.input-group label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 14px 16px;
  font-size: 14px;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  resize: vertical;
  min-height: 80px;
  transition: border-color .2s;
  line-height: 1.5;
}
textarea.tall { min-height: 140px; }
textarea:focus { outline: none; border-color: var(--accent); }
textarea::placeholder { color: var(--dim); }

/* ===== Parsed info ===== */
.parsed-info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
  display: none;
}
.parsed-info.active { display: block; }
.parsed-info .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  font-size: 13px;
}
.parsed-info .row + .row { border-top: 1px solid var(--border); }
.parsed-info .label { color: var(--muted); font-weight: 500; flex-shrink: 0; }
.parsed-info .value {
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
.mode-badge {
  background: rgba(47,129,247,.15);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit !important;
}

/* ===== Code display ===== */
.code-display { text-align: center; padding: 26px 0 18px; }
.code-display .code {
  font-size: 54px;
  font-weight: 800;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  letter-spacing: 10px;
  line-height: 1.1;
  margin-bottom: 6px;
}
.code-display .code.empty { color: var(--dim); letter-spacing: 6px; }
.code-display .hint { font-size: 13px; color: var(--muted); }

/* ===== Timer ===== */
.timer-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin: 14px 0 10px;
}
.timer-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 100%;
  transition: width .95s linear, background-color .3s;
}
.timer-bar .fill.warning { background: var(--warning); }
.timer-bar .fill.danger { background: var(--danger); }
.countdown {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
  margin-bottom: 16px;
}

/* ===== Buttons ===== */
.btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent-dim); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #388bfd; }
.btn-copy { background: var(--success); color: #0d1117; }
.btn-copy:hover:not(:disabled) { background: #46c75a; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-ghost:hover { background: var(--card-2); color: var(--text); }
.batch-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.batch-actions .btn { flex: 1; }
.batch-actions .btn-ghost { flex: 0 0 90px; }

/* ===== Batch table ===== */
.batch-summary { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.batch-summary b { color: var(--text); }
.batch-summary b.ok { color: var(--success); }
.batch-summary b.err { color: var(--danger); }
.batch-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.batch-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.batch-table th {
  background: var(--card-2);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  white-space: nowrap;
}
.batch-table td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}
.batch-table tr:hover td { background: rgba(255,255,255,.02); }
.cell-user {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.cell-code {
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--success);
}
.cell-code.err { color: var(--danger); font-size: 13px; letter-spacing: 0; }
.cell-rem { color: var(--muted); font-size: 12px; white-space: nowrap; }
.mini-btn {
  background: var(--border);
  border: none;
  color: var(--text);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.mini-btn:hover:not(:disabled) { background: var(--accent-dim); color: #fff; }
.mini-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ===== Steps ===== */
.steps { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.steps h3 { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.steps .step {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.steps .step .num {
  width: 20px; height: 20px;
  background: var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ===== Formats ===== */
.formats {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.formats strong { color: var(--text); display: block; margin-top: 10px; }
.formats strong:first-child { margin-top: 0; }
.formats ul { margin: 4px 0 0 18px; }
.formats code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--accent);
  font-family: "SF Mono", Consolas, monospace;
  word-break: break-all;
}

/* ===== API doc ===== */
.api-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--bg);
}
.api-method {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 8px;
  letter-spacing: .5px;
}
.api-method.post { background: rgba(63,185,80,.15); color: var(--success); }
.api-method.get  { background: rgba(47,129,247,.15); color: var(--accent); }
.api-path {
  display: inline-block;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.api-desc { font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.code-block {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 11px;
  color: #a5d6ff;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.5;
}
.notice {
  margin-top: 18px;
  padding: 14px 16px;
  background: rgba(210,153,34,.08);
  border: 1px solid rgba(210,153,34,.3);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.notice strong { color: var(--warning); display: block; margin-bottom: 6px; }
.notice ul { margin-left: 18px; }
.notice code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent);
  font-size: 11px;
}

/* ===== Error / Toast ===== */
.error-msg {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(248,81,73,.08);
  border: 1px solid rgba(248,81,73,.25);
  border-radius: 8px;
  display: none;
  word-break: break-word;
}
.error-msg.active { display: block; }

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--success);
  color: #0d1117;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== Footer ===== */
.footer {
  text-align: center;
  margin-top: 28px;
  font-size: 12px;
  color: var(--dim);
}

/* ===== 买家页：邮箱验证码区 ===== */
.buyer-email-box {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid #d0a020;
  border-radius: 10px;
  background: rgba(210, 160, 32, .07);
}
.email-warn {
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 10px;
  color: #c9a227;
}
.warn-yellow {
  color: #ffd633;
  font-weight: 700;
}

/* 邮箱验证码显示在按钮下方 */
.email-code-line {
  text-align: center;
  margin-top: 12px;
}
.email-code-line .mono {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #ffd633;
}

/* 可点击复制的账号/密码 */
.parsed-info .value.copyable {
  cursor: pointer;
  transition: color .15s;
}
.parsed-info .value.copyable:hover {
  color: #58a6ff;
  text-decoration: underline;
}
.parsed-info .value.copyable::after {
  content: "⧉";
  margin-left: 6px;
  opacity: .5;
  font-size: 12px;
}

/* ===== Responsive ===== */
@media (max-width: 560px) {
  .app { padding: 16px 14px 50px; }
  .card { padding: 20px 18px; }
  .code-display .code { font-size: 42px; letter-spacing: 6px; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 8px 10px; font-size: 13px; }
  .parsed-info .value { max-width: 180px; }
  .batch-actions { flex-direction: column; }
  .batch-actions .btn-ghost { flex: 1; }
}
