/* ==========================================================================
   BW16 Keygen — 样式表
   设计基调：深色 + 荧光绿，系统字体（不依赖 Google Fonts，国内可正常渲染）
   ========================================================================== */

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

:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #1a1a1a;
  --border: #222222;
  --border-strong: #2e2e2e;
  --text: #e8e8e8;
  --text-dim: #666666;
  --text-muted: #444444;
  --accent: #2ed573;
  --accent-hover: #26c466;
  --accent-dim: rgba(46, 213, 115, 0.12);
  --danger: #ff4757;
  --warn: #ff9f43;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
}

[hidden] { display: none !important; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.container { width: 100%; max-width: 480px; }

/* ── Header ───────────────────────────────────────────────────────────── */

.header { margin-bottom: 28px; text-align: center; }

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  border: 1px solid rgba(46, 213, 115, 0.15);
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.header-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.header h1 {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header h1 span { color: var(--accent); }

.header p { margin-top: 8px; font-size: 13px; color: var(--text-dim); }

/* ── Card ─────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card + .card { margin-top: 12px; }

.card-section { padding: 22px 24px; }
.card-section + .card-section { border-top: 1px solid var(--border); }

/* ── 表单 ─────────────────────────────────────────────────────────────── */

.label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.mac-input,
.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.mac-input {
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.08em;
}

.mac-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.mac-input:focus,
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.mac-input.valid { border-color: var(--accent); }

.mac-input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 71, 87, 0.1);
}

.input-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  min-height: 18px;
  transition: color 0.2s;
}

.input-hint.ok { color: var(--accent); }
.input-hint.err { color: var(--danger); }
.input-hint.warn { color: var(--warn); }

.gen-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  margin-top: 16px;
}

.gen-btn:hover:not(:disabled) { background: var(--accent-hover); }
.gen-btn:active:not(:disabled) { transform: scale(0.985); }

.gen-btn:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

/* ── 结果区 ───────────────────────────────────────────────────────────── */

.result-area { text-align: center; }

.result-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.result-code {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  line-height: 1.5;
  word-break: break-all;
  transition: color 0.4s;
  user-select: all;
}

.result-code.active {
  color: var(--accent);
  animation: reveal-code 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes reveal-code {
  0% { opacity: 0; transform: translateY(8px) scale(0.96); filter: blur(4px); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.result-mac {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.actions { display: flex; gap: 8px; margin-top: 16px; }

.action-btn {
  flex: 1;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.action-btn:hover { background: var(--border); color: var(--text); }

.action-btn.copied {
  background: var(--accent-dim);
  border-color: rgba(46, 213, 115, 0.2);
  color: var(--accent);
}

/* ── 历史记录 ─────────────────────────────────────────────────────────── */

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.count-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0;
  vertical-align: 1px;
}

.history-tools { display: flex; align-items: center; gap: 6px; }

.search-input {
  width: 132px;
  padding: 6px 10px;
  font-size: 11px;
  font-family: var(--sans);
}

.search-input::placeholder { color: var(--text-muted); }

.history-list {
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  animation: fade-in 0.3s ease;
}

.history-item:last-child { border-bottom: none; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.history-mac { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

.history-time { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.history-code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  transition: opacity 0.15s;
  text-align: right;
  word-break: break-all;
}

.history-code:hover { opacity: 0.7; }

.history-del {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.history-del:hover { color: var(--danger); background: rgba(255, 71, 87, 0.08); }

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--sans);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.clear-btn:hover { color: var(--danger); background: rgba(255, 71, 87, 0.08); }

.empty-state {
  text-align: center;
  padding: 20px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.load-more {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.load-more:hover:not(:disabled) { background: var(--border); color: var(--text); }
.load-more:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── 统计 ─────────────────────────────────────────────────────────────── */

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

.stat-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 12px;
  text-align: center;
}

.stat-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  word-break: break-all;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
}

.stat-item.full { grid-column: 1 / -1; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 64px;
  margin-top: 14px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}

.chart-bar {
  width: 100%;
  min-height: 2px;
  background: var(--surface-2);
  border-radius: 3px 3px 2px 2px;
  position: relative;
  display: flex;
  align-items: flex-end;
}

.chart-fill {
  width: 100%;
  background: var(--accent);
  border-radius: 3px 3px 2px 2px;
  transition: height 0.6s ease;
}

.chart-label { font-size: 9px; color: var(--text-muted); font-family: var(--mono); }

/* ── Toast ────────────────────────────────────────────────────────────── */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.ok { border-color: rgba(46, 213, 115, 0.35); color: var(--accent); }
.toast.err { border-color: rgba(255, 71, 87, 0.35); color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── 密码遮罩 ─────────────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

html.authed .overlay { display: none; }

.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.login-box { width: 100%; max-width: 380px; text-align: center; }

.login-box .lock-icon { font-size: 44px; margin-bottom: 18px; display: block; }

.login-box h2 {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-box > p { font-size: 13px; color: var(--text-dim); margin-bottom: 24px; }

.pw-wrap { position: relative; margin-bottom: 4px; }

.pw-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 44px 14px 16px;
  font-family: var(--mono);
  font-size: 16px;
  color: var(--text);
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.pw-input::placeholder { color: var(--text-muted); }

.pw-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s, background 0.15s;
}

.pw-toggle:hover { opacity: 1; background: var(--surface-2); }

.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.login-btn:hover:not(:disabled) { background: var(--accent-hover); }
.login-btn:active:not(:disabled) { transform: scale(0.985); }
.login-btn:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }

.pw-error { font-size: 12px; color: var(--danger); min-height: 20px; margin: 8px 0; }

.pw-hint { font-size: 11px; color: var(--text-muted); margin-top: 14px; }

.shake { animation: shake 0.35s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ── Footer ───────────────────────────────────────────────────────────── */

.footer { margin-top: 24px; text-align: center; font-size: 11px; color: var(--text-muted); }

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  margin-left: 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.link-btn:hover { color: var(--accent); background: var(--accent-dim); }

/* ── 可访问性 / 动效偏好 ──────────────────────────────────────────────── */

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── 响应式 ───────────────────────────────────────────────────────────── */

@media (max-width: 520px) {
  body { padding: 16px; }
  .header h1 { font-size: 22px; }
  .result-code { font-size: 17px; }
  .mac-input { font-size: 15px; }
  .card-section { padding: 18px 16px; }
  .search-input { width: 104px; }
}
