:root {
  color-scheme: dark;
  --bg: #101419;
  --panel: rgba(31, 41, 48, 0.74);
  --panel-strong: rgba(37, 49, 58, 0.88);
  --line: rgba(220, 230, 236, 0.13);
  --text: #eef5f8;
  --muted: #a8b6bf;
  --sky: #62c6f2;
  --teal: #53d6c4;
  --mint: #7be3a3;
  --rose: #fb7185;
  --amber: #f3bf5f;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% -8%, rgba(98, 198, 242, 0.22), transparent 32rem),
    radial-gradient(circle at 92% 6%, rgba(83, 214, 196, 0.18), transparent 28rem),
    linear-gradient(180deg, #11171d 0%, #101419 58%, #111814 100%);
  background-attachment: fixed;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.6; }

.shell { width: min(560px, calc(100% - 32px)); margin: 0 auto; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(16, 20, 25, 0.74);
  backdrop-filter: blur(18px);
}
.topbar-inner {
  height: 64px; display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon-text { font-size: 28px; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 16px; }
.brand-copy span { font-size: 12px; color: var(--muted); }

.page { padding: 28px 0 56px; display: grid; gap: 18px; }

.panel {
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--panel-strong), var(--panel));
  box-shadow: 0 24px 56px -36px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(22px);
  border-radius: var(--radius);
  padding: 22px;
}
.flow { display: grid; gap: 16px; }

.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
h2 { margin: 0; font-size: 17px; }
p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

input[type="text"] {
  width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(0, 0, 0, 0.28); color: var(--text); padding: 0 14px;
  font-family: "Cascadia Mono", Consolas, monospace; font-size: 14px; outline: none;
}
input[type="text"]:focus {
  border-color: rgba(98, 198, 242, 0.5);
  box-shadow: 0 0 0 3px rgba(98, 198, 242, 0.12);
}

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.digit-option {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.04); font-size: 13px; cursor: pointer;
}
.digit-option:has(input:checked) {
  border-color: rgba(83, 214, 196, 0.5);
  background: rgba(83, 214, 196, 0.1);
}
.digit-option input { width: auto; height: auto; }

.primary-action {
  width: 100%; min-height: 48px; border: 0; border-radius: 13px;
  background: linear-gradient(90deg, #2563eb, #0891b2, #16a34a);
  color: white; font-size: 15px; font-weight: 800;
  box-shadow: 0 18px 38px -22px rgba(45, 212, 191, 0.9);
}

.small-btn {
  border: 0; padding: 6px 12px; border-radius: 8px;
  background: rgba(255,255,255,0.08); color: var(--text); font-size: 12px;
}
.small-btn:hover { background: rgba(255,255,255,0.14); }

.progress-bar-wrap {
  height: 5px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden;
}
.progress-bar {
  height: 100%; width: 100%; border-radius: 3px;
  background: var(--sky); transition: width 1s linear;
}
.progress-bar.warn { background: var(--amber); }
.progress-bar.danger { background: var(--rose); }

.code-display {
  text-align: center; font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 48px; font-weight: 800; color: var(--sky);
  letter-spacing: 8px; cursor: pointer; padding: 16px 0;
  user-select: none; transition: color 0.2s;
}
.code-display:hover { color: #9de8ff; }
.code-display.error { color: var(--rose); }

.countdown { text-align: center; color: var(--muted); font-size: 13px; }
.copy-hint { text-align: center; color: var(--mint); font-size: 12px; min-height: 18px; }

.history-list { max-height: 200px; overflow-y: auto; }
.history-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.history-time { color: var(--muted); font-size: 12px; }
.history-key { color: #cbdbe2; font-family: "Cascadia Mono", Consolas, monospace; }
.history-code { color: var(--sky); font-family: "Cascadia Mono", Consolas, monospace; font-weight: 700; }

.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

@media (max-width: 600px) {
  .shell { width: min(100% - 24px, 560px); }
  .code-display { font-size: 36px; letter-spacing: 4px; }
}
