/* ------------------------------------------------------------------
   2FA Code — dark surface, orange accent
   ------------------------------------------------------------------ */

:root {
  --bg: #08080a;
  --bg-soft: #0c0c10;
  --surface: #111116;
  --surface-2: #17171d;
  --surface-3: #1d1d24;

  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.13);

  --text: #f4f4f7;
  --text-dim: #a2a2b0;
  --text-faint: #6d6d7b;

  --accent: #ff6b1a;
  --accent-warm: #ffa53d;
  --accent-deep: #e04f00;
  --accent-soft: rgba(255, 107, 26, 0.13);
  --accent-ring: rgba(255, 107, 26, 0.32);

  --danger: #ff5d5d;
  --success: #3ddc97;

  --radius-lg: 26px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono",
    Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* Component display rules below must never resurrect a [hidden] element. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 18px;
  overflow-x: hidden;
}

/* Ambient orange light behind the card */
.aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(620px 420px at 50% -8%, rgba(255, 107, 26, 0.20), transparent 68%),
    radial-gradient(520px 360px at 88% 108%, rgba(255, 165, 61, 0.09), transparent 70%),
    radial-gradient(420px 300px at 6% 92%, rgba(224, 79, 0, 0.07), transparent 72%);
  z-index: 0;
}

/* Subtle grid texture */
.aurora::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 32%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 32%, #000 0%, transparent 72%);
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 424px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

/* ---------------- Card ---------------- */

.card {
  width: 100%;
  background: linear-gradient(180deg, rgba(23, 23, 29, 0.92) 0%, rgba(14, 14, 18, 0.96) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 26px 22px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 30px 70px -30px rgba(0, 0, 0, 0.9),
    0 0 90px -40px rgba(255, 107, 26, 0.35);
  backdrop-filter: blur(14px);
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.card-head {
  text-align: center;
  margin-bottom: 24px;
}

.logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 15px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #14140f;
  background: linear-gradient(150deg, var(--accent-warm) 0%, var(--accent) 55%, var(--accent-deep) 100%);
  box-shadow:
    0 10px 24px -8px rgba(255, 107, 26, 0.65),
    0 0 0 1px rgba(255, 190, 120, 0.28) inset;
}

h1 {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

.demo-badge {
  display: inline-block;
  margin-top: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--accent-warm);
  background: var(--accent-soft);
  border: 1px solid rgba(255, 107, 26, 0.32);
}

/* ---------------- Form ---------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 13px;
  color: var(--text-faint);
  pointer-events: none;
  transition: color 0.18s ease;
}

.input-wrap input {
  width: 100%;
  height: 46px;
  padding: 0 42px 0 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.input-wrap input::placeholder { color: #55555f; }

.input-wrap input:hover { border-color: var(--border-strong); }

.input-wrap input:focus {
  border-color: rgba(255, 107, 26, 0.6);
  background: var(--surface-3);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

.input-wrap:focus-within .input-icon { color: var(--accent); }

.input-wrap input[type="password"] { letter-spacing: 0.14em; }

.clear-btn {
  position: absolute;
  right: 10px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  color: #cfcfda;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.clear-btn:hover { background: rgba(255, 255, 255, 0.17); color: #fff; }

/* Primary button */

.btn-primary {
  position: relative;
  height: 48px;
  margin-top: 2px;
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #16100a;
  background: linear-gradient(180deg, var(--accent-warm) 0%, var(--accent) 52%, var(--accent-deep) 100%);
  box-shadow:
    0 1px 0 rgba(255, 226, 190, 0.5) inset,
    0 12px 26px -12px rgba(255, 107, 26, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform 0.14s ease, box-shadow 0.2s ease, filter 0.2s ease;
  overflow: hidden;
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.55s ease;
}

.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 1px 0 rgba(255, 226, 190, 0.55) inset, 0 16px 34px -12px rgba(255, 107, 26, 0.95); }
.btn-primary:hover::after { transform: translateX(120%); }
.btn-primary:active { transform: translateY(1px) scale(0.994); }

.btn-primary:disabled {
  cursor: not-allowed;
  filter: saturate(0.45) brightness(0.85);
  box-shadow: none;
}

.btn-primary .spinner {
  display: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(22, 16, 10, 0.28);
  border-top-color: #16100a;
  animation: spin 0.7s linear infinite;
}

.btn-primary.loading .spinner { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Status ---------------- */

.status {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 12.5px;
  text-align: center;
  color: var(--text-faint);
  transition: color 0.2s ease;
}

.status.error { color: var(--danger); }
.status.ok { color: var(--text-dim); }

/* ---------------- Result ---------------- */

.result {
  margin-top: 16px;
  padding: 16px 16px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 107, 26, 0.22);
  background:
    radial-gradient(120% 130% at 50% -20%, rgba(255, 107, 26, 0.16), transparent 62%),
    var(--surface);
  animation: pop 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.code-block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 0 22px;
}

.code {
  font-family: var(--mono);
  font-size: clamp(34px, 10.5vw, 46px);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  line-height: 1.1;
  background: linear-gradient(180deg, #fff3e4 0%, var(--accent-warm) 42%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 34px rgba(255, 107, 26, 0.35);
  user-select: all;
}

.code.empty {
  background: none;
  color: var(--text-faint);
  text-shadow: none;
}

/* Non-code states (loading / not found) reuse the same slot so the card
   never jumps around when a lookup fails. */
.code.state-text {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0;
  text-indent: 0;
  background: none;
  text-shadow: none;
  color: var(--text-dim);
  -webkit-text-fill-color: currentColor;
}

.code.state-text.empty { color: var(--text-faint); }

.code.loading { animation: pulse 1.3s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.result-note {
  margin: -4px 0 16px;
  font-size: 12.5px;
  line-height: 1.55;
  text-align: center;
  color: var(--text-dim);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.btn-ghost {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.14s ease;
}

.btn-ghost:hover {
  background: var(--accent-soft);
  border-color: rgba(255, 107, 26, 0.45);
  color: var(--accent-warm);
}

.btn-ghost:active { transform: translateY(1px); }

.btn-ghost:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost:disabled:hover {
  background: rgba(255, 255, 255, 0.035);
  border-color: var(--border-strong);
  color: var(--text);
}

/* ---------------- Auto refresh ---------------- */

.auto-row {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.track {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #2a2a33;
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
  flex: none;
}

.thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #8b8b98;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}

.switch input:checked + .track {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  border-color: rgba(255, 165, 61, 0.5);
}

.switch input:checked + .track .thumb {
  transform: translateX(14px);
  background: #fff5e9;
}

.switch input:focus-visible + .track {
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

.switch-text {
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ---------------- Footer ---------------- */

.foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-faint);
}

.foot svg { flex: none; margin-top: 1px; color: rgba(61, 220, 151, 0.75); }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 18px);
  padding: 10px 18px;
  border-radius: 12px;
  background: rgba(28, 28, 34, 0.96);
  border: 1px solid rgba(255, 107, 26, 0.35);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 40;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Responsive ---------------- */

@media (max-width: 420px) {
  body { padding: 22px 12px; }
  .card { padding: 26px 18px 18px; border-radius: 22px; }
  h1 { font-size: 19px; }
}

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