/* ============================================================
   KEYSTUDIO · 手机端卡密解锁页
   ============================================================ */

:root {
  --bg: #070b15;
  --panel: #101827;
  --panel-2: #0b1220;
  --text: #f4f7ff;
  --muted: #9aa6bf;
  --faint: #5b6780;
  --line: rgba(255, 255, 255, 0.07);
  --blue: #4f7cf7;
  --blue-2: #6b9bff;
  --gold: #f6c84c;
  --green: #34d399;
  --red: #fb7185;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "SFMono-Regular", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(680px 420px at 50% -8%, rgba(74, 108, 255, 0.28), transparent 68%),
    radial-gradient(520px 460px at 4% 100%, rgba(0, 170, 255, 0.08), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body.modal-open { overflow: hidden; }

[hidden] { display: none !important; }

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(34px + env(safe-area-inset-top))
    20px
    calc(24px + env(safe-area-inset-bottom));
}

/* ---------------- 标题 ---------------- */

.hero {
  position: relative;
  margin: 12px 0 24px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(27px, 7.2vw, 33px);
  font-weight: 800;
  line-height: 1.28;
  letter-spacing: -0.045em;
}

.hero p {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ---------------- 卡片 ---------------- */

.content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card {
  margin-bottom: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(27, 37, 60, 0.92), rgba(13, 19, 33, 0.95));
  box-shadow:
    0 20px 44px -34px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.lock-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: #3b2a00;
  background: radial-gradient(circle at 32% 22%, #ffe9a3, #f6c84c 55%, #dcae2d);
  box-shadow:
    0 8px 20px -8px rgba(246, 200, 76, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.lock-badge svg { width: 24px; height: 24px; }

.card h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.015em;
}

.card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.8;
  color: #a8b3c9;
}

/* ---------------- 更新卡 ---------------- */

.update-card { padding: 20px; }

.update-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.update-dot {
  flex: none;
  width: 6px;
  height: 6px;
  margin-top: 9px;
  border-radius: 50%;
  background: #7b9cff;
  box-shadow: 0 0 0 4px rgba(123, 156, 255, 0.12);
}

.download-label {
  margin: 13px 0 5px !important;
  font-size: 12px !important;
  color: #7f8ca6 !important;
}

.download-url {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  letter-spacing: 0.01em;
  color: #c8d4ea;
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: color 0.15s;
}

.download-url:active,
.download-url:hover { color: #fff; }

/* ---------------- 按钮 ---------------- */

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: none;
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.14s, filter 0.16s, background 0.16s, box-shadow 0.16s;
}

.btn:active { transform: scale(0.985); }

.btn:focus-visible {
  outline: 2px solid #9db6ff;
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.primary {
  background: linear-gradient(135deg, #4f7cf7 0%, #6494ff 55%, #79a7ff 100%);
  box-shadow:
    0 16px 32px -14px rgba(79, 124, 247, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.primary:hover { filter: brightness(1.04); }

.secondary {
  background: rgba(19, 28, 47, 0.92);
  border-color: rgba(255, 255, 255, 0.055);
  color: #6f9bff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.secondary:hover { background: rgba(25, 36, 58, 0.98); }

.update-btn {
  background: rgba(22, 31, 50, 0.92);
  border-color: rgba(255, 255, 255, 0.055);
  color: #e7edfa;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.update-btn .heart {
  position: absolute;
  top: 50%;
  right: 18px;
  width: 24px;
  height: 24px;
  color: #fff;
  transform: translateY(-50%);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.page-footer {
  margin-top: auto;
  padding-top: 26px;
  text-align: center;
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.03em;
  color: var(--faint);
}

/* ---------------- 弹层 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in 0.2s ease both;
}

.sheet {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: 92vh;
  max-height: 92dvh;
  padding: 28px 22px calc(22px + env(safe-area-inset-bottom));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, #111a2c 0%, #0b1220 100%);
  box-shadow: 0 -30px 80px -20px rgba(0, 0, 0, 0.8);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: sheet-up 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #9aa6bf;
  cursor: pointer;
  touch-action: manipulation;
}

.sheet-close svg { width: 16px; height: 16px; }

.sheet-close:focus-visible {
  outline: 2px solid #9db6ff;
  outline-offset: 2px;
}

.sheet-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 6px 0 14px;
  border-radius: 14px;
  color: #3b2a00;
  background: radial-gradient(circle at 32% 22%, #ffe9a3, #f6c84c 55%, #dcae2d);
  box-shadow: 0 10px 24px -10px rgba(246, 200, 76, 0.45);
}

.sheet-icon svg { width: 24px; height: 24px; }

.sheet h2 {
  margin: 0;
  font-size: 23px;
  font-weight: 750;
  line-height: 1.3;
  letter-spacing: -0.035em;
}

.sheet-sub {
  margin: 7px 0 18px;
  font-size: 12px;
  line-height: 1.65;
  color: #8e9ab4;
}

.key-input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  background: #080e1b;
  color: #fff;
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.key-input::placeholder {
  color: #55617b;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.key-input:focus {
  border-color: #6b9bff;
  box-shadow: 0 0 0 3px rgba(107, 155, 255, 0.16);
}

.form-error {
  margin: 10px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: #fb8a99;
}

.form-error.warn { color: #fbbf24; }

.submit-btn { margin-top: 14px; }

/* 成功态 */

.sheet.is-success .sheet-icon,
.sheet.is-success #modalTitle,
.sheet.is-success #modalSub,
.sheet.is-success #verifyForm {
  display: none;
}

.sheet.is-success .success { display: flex; }

.success {
  display: none;
  flex-direction: column;
  align-items: flex-start;
}

.success-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 4px 0 16px;
  border-radius: 50%;
  background: rgba(52, 211, 153, 0.12);
  color: var(--green);
  box-shadow: 0 0 0 8px rgba(52, 211, 153, 0.05);
}

.success-icon svg { width: 26px; height: 26px; }

.success h2 {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: -0.035em;
}

.success-message {
  margin: 0;
  font-size: 13px;
  line-height: 1.8;
  color: #aab6cc;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.key-chip {
  width: 100%;
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: #d9e2f2;
  overflow-wrap: anywhere;
}

.success-link { margin-top: 16px; }

.success .secondary {
  min-height: 48px;
  margin-top: 16px;
}

/* ---------------- 提示 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 80;
  max-width: calc(100vw - 40px);
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(15, 23, 40, 0.96);
  color: #dfe7f8;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

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

.toast.error {
  border-color: rgba(251, 113, 133, 0.4);
  color: #ffd6dc;
}

/* ---------------- 动画 ---------------- */

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@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: 370px) {
  .page { padding-left: 16px; padding-right: 16px; }
  .hero h1 { font-size: 26px; }
  .card { padding: 17px; border-radius: 21px; }
  .card h2 { font-size: 15px; }
  .btn { min-height: 53px; font-size: 14px; }
  .sheet { padding-left: 18px; padding-right: 18px; }
}
