/* ============================================
   ПЕРЕМЕННЫЕ
   ============================================ */
:root {
  --bg-1: #0a0a0f;
  --accent-1: #6366f1;
  --accent-2: #ec4899;
  --text: #f5f5f7;
  --text-dim: #b4b4bd;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-1);
  color: var(--text);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* ---------- ФОН ---------- */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.3;
  z-index: 0;
  pointer-events: none;
}
body::before {
  width: 600px; height: 600px;
  background: var(--accent-1);
  top: -200px; left: -200px;
  animation: float1 18s ease-in-out infinite;
}
body::after {
  width: 550px; height: 550px;
  background: var(--accent-2);
  bottom: -200px; right: -200px;
  animation: float2 22s ease-in-out infinite;
}
@keyframes float1 {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(80px, 60px); }
}
@keyframes float2 {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(-70px, -50px); }
}

/* ---------- КАРТОЧКА ---------- */
.card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  padding: 40px 32px 32px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  animation: cardIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: max-width 0.3s ease;
}
.card-wide { max-width: 480px; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- ИКОНКА ЗАМКА ---------- */
.lock-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}
.lock-icon svg { width: 24px; height: 24px; color: #fff; }

/* ---------- ЗАГОЛОВКИ ---------- */
h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #c7c7d1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 300;
  line-height: 1.55;
  margin-bottom: 26px;
}

/* ============================================
   ПЛИТКИ ПРИЛОЖЕНИЙ
   ============================================ */
.app-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.app-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 8px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: all 0.2s ease;
}

.app-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.app-card.selected {
  background: rgba(99, 102, 241, 0.05);
  border-color: rgba(99, 102, 241, 0.3);
}

/* ---------- Иконка в рамке ---------- */
.app-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  transition: all 0.22s ease;
}

.app-icon svg {
  width: 18px;
  height: 18px;
}

.app-icon[data-color="indigo"] { color: #818cf8; }
.app-icon[data-color="pink"]   { color: #f472b6; }
.app-icon[data-color="cyan"]   { color: #22d3ee; }

/* Подсветка рамки иконки при выборе */
.app-card.selected .app-icon {
  border-color: var(--accent-1);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ---------- Название ---------- */
.app-name {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-align: center;
}

/* ---------- Цена ---------- */
.app-price {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: -0.01em;
}

/* ============================================
   БЛОК ОПЛАТЫ
   ============================================ */
.payment-block {
  margin-top: 4px;
  padding: 22px 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--card-border);
  animation: fadeUp 0.5s ease both;
}
.payment-block.hidden { display: none; }

.payment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding: 0 2px;
  gap: 12px;
  flex-wrap: wrap;
}
.payment-label {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 400;
}
.payment-label strong {
  color: #fff;
  font-weight: 500;
}
.payment-price {
  font-size: 22px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}
.qr-image {
  width: 200px;
  height: 200px;
  border-radius: 10px;
  background: #fff;
  padding: 6px;
}
.qr-hint {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 300;
  text-align: center;
}

.payment-note {
  font-size: 12.5px;
  color: #55555f;
  margin-top: 14px;
  line-height: 1.5;
  text-align: center;
}

/* ============================================
   ПОЛЕ ВВОДА И КНОПКИ
   ============================================ */
.field {
  text-align: left;
  margin-bottom: 20px;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.field input {
  width: 100%;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  outline: none;
  transition: all 0.22s ease;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}
.field input::placeholder {
  color: #55555f;
  letter-spacing: 0.08em;
  font-weight: 400;
}
.field input:focus {
  border-color: var(--accent-1);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.22s ease;
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(99, 102, 241, 0.5);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--card-border);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.09);
  transform: translateY(-1px);
}

/* ============================================
   СООБЩЕНИЯ
   ============================================ */
.message {
  display: none;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  margin-top: 18px;
  text-align: left;
  animation: fadeUp 0.4s ease both;
}
.message.show { display: block; }
.message.success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}
.message.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   БЛОК С КЛЮЧОМ
   ============================================ */
.key-block {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--card-border);
}
.key-block.hidden { display: none; }
.key-block .hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.key-block .hint a {
  color: var(--accent-1);
  text-decoration: none;
  font-weight: 500;
}
.key-block .hint a:hover { text-decoration: underline; }
#keyForm.hidden { display: none; }
#keyForm { animation: fadeUp 0.4s ease both; }
#keyForm .field { margin-top: 16px; }

/* ============================================
   ПЛАНШЕТ
   ============================================ */
@media (min-width: 700px) {
  body { padding: 48px 32px; }
  .card, .card-wide {
    max-width: 620px;
    padding: 48px 44px 40px;
  }
  h1 { font-size: 28px; }
  .subtitle { font-size: 15px; margin-bottom: 30px; }
  .app-grid { gap: 14px; }
  .app-card { padding: 22px 10px 18px; border-radius: 16px; }
  .app-icon { width: 46px; height: 46px; border-radius: 12px; }
  .app-icon svg { width: 20px; height: 20px; }
  .app-name { font-size: 14px; }
  .app-price { font-size: 12.5px; }
}

/* ============================================
   ДЕСКТОП
   ============================================ */
@media (min-width: 1000px) {
  body { padding: 64px 32px; }
  .card, .card-wide {
    max-width: 760px;
    padding: 56px 64px 48px;
    border-radius: 28px;
  }
  h1 { font-size: 32px; }
  .subtitle { font-size: 16px; margin-bottom: 34px; }
  .lock-icon { width: 60px; height: 60px; border-radius: 16px; margin-bottom: 24px; }
  .lock-icon svg { width: 28px; height: 28px; }
  .app-grid { gap: 18px; margin-bottom: 28px; }
  .app-card { padding: 26px 14px 22px; border-radius: 18px; gap: 12px; }
  .app-icon { width: 52px; height: 52px; border-radius: 14px; }
  .app-icon svg { width: 22px; height: 22px; }
  .app-name { font-size: 15px; }
  .app-price { font-size: 13px; }
  .qr-image { width: 220px; height: 220px; }
  .payment-price { font-size: 26px; }
}

/* ============================================
   ТЕЛЕФОН
   ============================================ */
@media (max-width: 480px) {
  body { padding: 16px 12px; }
  .card { padding: 32px 20px 26px; border-radius: 20px; }
  h1 { font-size: 21px; }
  .subtitle { font-size: 13.5px; margin-bottom: 22px; }
  .lock-icon { width: 46px; height: 46px; border-radius: 12px; }
  .lock-icon svg { width: 22px; height: 22px; }
  .app-grid { gap: 8px; }
  .app-card { padding: 14px 6px 12px; gap: 8px; border-radius: 12px; }
  .app-icon { width: 36px; height: 36px; border-radius: 9px; }
  .app-icon svg { width: 16px; height: 16px; }
  .app-name { font-size: 12px; }
  .app-price { font-size: 11px; }
  .qr-image { width: 180px; height: 180px; }
  .payment-price { font-size: 20px; }
  .field input { font-size: 15px; padding: 13px 14px; }
  .btn { padding: 13px 18px; font-size: 14px; }
}

/* ============================================
   РЕЗУЛЬТАТ: НОВЫЙ КЛЮЧ
   ============================================ */
.key-result {
  margin-top: 20px;
  padding: 24px 22px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(236, 72, 153, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.25);
  animation: fadeUp 0.5s ease both;
}
.key-result.hidden { display: none; }

.key-result-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 16px;
  text-align: center;
}

/* Плашка с ключом */
.key-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  margin-bottom: 14px;
}

.key-display code {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.08em;
  user-select: all;
  word-break: break-all;
}

.copy-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s ease;
}
.copy-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.copy-btn svg { width: 17px; height: 17px; }
.copy-btn.copied {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
}

.key-hint {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 18px;
  line-height: 1.5;
}

/* Отправка на email */
.email-row {
  display: flex;
  gap: 8px;
}
.email-row input {
  flex: 1;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  outline: none;
  transition: all 0.2s ease;
}
.email-row input::placeholder { color: #55555f; }
.email-row input:focus {
  border-color: var(--accent-1);
  background: rgba(99, 102, 241, 0.06);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.email-row .btn {
  width: auto;
  padding: 12px 20px;
  font-size: 14px;
  flex-shrink: 0;
}

/* ---------- Мобильный ---------- */
@media (max-width: 480px) {
  .key-display code { font-size: 16px; }
  .copy-btn { width: 34px; height: 34px; }
  .email-row { flex-direction: column; }
  .email-row .btn { width: 100%; }
}