:root {
  --bg: #fff7f1;
  --bg2: #f2f6ff;
  --panel: #ffffff;
  --border: #e8dcff;
  --text: #252a4a;
  --muted: #6a7196;
  --accent: #5a7cff;
  --accent2: #3d62ee;
  --surface: #fff9ff;
  --success: #2ebf74;
  --violet: #7b61ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Nunito", "SF Pro Display", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 420px at -8% -12%, #ffc6e055, transparent),
    radial-gradient(750px 380px at 108% -12%, #ffd6a34f, transparent),
    radial-gradient(860px 480px at 50% 114%, #b7c6ff55, transparent),
    linear-gradient(160deg, var(--bg), var(--bg2));
  min-height: 100vh;
}

.app {
  width: min(920px, 96vw);
  margin: 14px auto;
  display: grid;
  gap: 12px;
  padding-bottom: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(72, 67, 131, 0.1);
}

.hidden { display: none !important; }

h1 { margin: 0; font-size: 24px; font-weight: 900; }
h2 { margin: 0 0 10px; font-size: 20px; font-weight: 800; }
h3 { margin: 12px 0 8px; font-size: 24px; font-weight: 900; }
p { margin: 0; color: var(--muted); }

.small {
  font-size: 13px;
  color: var(--muted);
}

.error { color: #ff6f9d; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background:
    radial-gradient(120px 80px at 10% 0%, #ff9ccb2b, transparent),
    radial-gradient(120px 80px at 95% 20%, #84a4ff30, transparent),
    #fff;
}

.brand-wrap { display: grid; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; }
#statusText {
  font-size: 15px;
  font-weight: 800;
  color: #65709b;
  display: none;
}

.app-logo {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid #fff;
  box-shadow: 0 8px 20px rgba(90, 124, 255, 0.28);
}

.kv {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d7cbff;
  background: linear-gradient(135deg, #f6f0ff, #edf2ff);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

#btnTopUp {
  padding: 8px 10px;
  font-size: 14px;
}

.grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.single-col { grid-template-columns: 1fr; }
label { font-size: 12px; color: var(--muted); display: grid; gap: 6px; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

button.option-tile {
  min-height: 46px;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 12px;
  background: linear-gradient(180deg, #fff, #f7f3ff);
  border: 1px solid #dfd4ff;
  color: #2c3159;
  box-shadow: none;
}

button.option-tile:hover {
  background: linear-gradient(180deg, #fff, #f2ebff);
}

button.option-tile.selected {
  background: linear-gradient(135deg, #6f83ff, #5e4fff);
  border-color: #6558ff;
  color: #fff;
  box-shadow: 0 8px 18px rgba(94, 79, 255, 0.35);
}

.progress-steps {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6f7fa8;
  font-size: 13px;
}

.progress-step .num {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid #e5d9ff;
  background: #faf5ff;
  font-weight: 700;
}

.progress-step.active { color: #4d3fe0; font-weight: 700; }

.progress-step.active .num {
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  border-color: #5e58ff;
}

.progress-step.done { color: #2b9c61; }

.progress-step.done .num {
  background: #e7fff1;
  border-color: #9be0bc;
  color: #2b9c61;
}

.progress-line {
  flex: 1;
  min-width: 16px;
  height: 2px;
  background: #e8ddff;
}

input, select, textarea, button {
  border-radius: 14px;
  border: 1px solid #ded3ff;
  background: #ffffff;
  color: #252a4a;
  padding: 10px;
  font: inherit;
  font-size: 16px;
}

input, textarea {
  caret-color: #252a4a;
  -webkit-text-fill-color: #252a4a;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #9d8cff;
  box-shadow: 0 0 0 3px rgba(123, 97, 255, 0.16);
  opacity: 1;
}

textarea {
  min-height: 220px;
  resize: none;
  overflow-y: hidden;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder {
  color: #8a91b7;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.actions.center { justify-content: center; }

.screen { padding-bottom: 16px; }

.screen .actions.nav-actions {
  position: static;
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #e8ddff;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 28px rgba(82, 72, 153, 0.16);
}

.screen .actions.nav-actions button {
  flex: 1 1 0;
  min-height: 48px;
}

body.editing-text .screen .actions.nav-actions {
  backdrop-filter: none;
  background: #ffffff;
}

button {
  cursor: pointer;
  font-weight: 800;
  background: #f4f0ff;
  border-color: #d8ccff;
  color: #3b3f6f;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(98, 86, 191, 0.18);
  background: #ede5ff;
}

button.accent {
  color: #fff;
  border-color: #4f66ef;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}

button.accent:hover { box-shadow: 0 10px 24px rgba(79, 102, 239, 0.4); }

button.success {
  background: linear-gradient(135deg, #32c97d, #22a95f);
  color: #fff;
  border-color: #209d58;
}

button.success:hover { box-shadow: 0 8px 18px rgba(37, 155, 86, 0.3); }

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.hero-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

button.big {
  min-height: 72px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.2px;
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(79, 102, 239, 0.32);
}

.list { display: grid; gap: 8px; margin-top: 10px; }

.item,
.subitem {
  border: 1px solid #e5dcff;
  border-radius: 16px;
  padding: 12px;
  background: linear-gradient(180deg, #fff, #fefbff);
  box-shadow: 0 8px 18px rgba(111, 98, 188, 0.08);
}

.subitem {
  margin-top: 10px;
  border-color: #e7e0ff;
  background: #fff;
}

.item > .small {
  margin-top: 2px;
  font-weight: 700;
}

.price-row {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.old-price {
  font-size: 12px;
  color: #958db8;
  text-decoration: line-through;
}

.new-price {
  font-size: 15px;
  font-weight: 800;
  color: #3f2ea4;
}

.discount-badge {
  font-size: 11px;
  color: #fff;
  background: linear-gradient(135deg, #ff8b53, #ff5fa0);
  border-radius: 999px;
  padding: 2px 8px;
}

.variant-toggle {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid #dfd4ff;
  border-radius: 14px;
  overflow: hidden;
  background: #f6f1ff;
}

.variant-toggle-btn {
  border: 0;
  border-radius: 0;
  margin: 0;
  min-height: 44px;
  background: transparent;
  color: #5b5588;
  font-weight: 800;
  box-shadow: none;
}

.variant-toggle-btn + .variant-toggle-btn {
  border-left: 1px solid #dfd4ff;
}

.variant-toggle-btn:hover {
  transform: none;
  box-shadow: none;
  background: #efe8ff;
}

.variant-toggle-btn.active {
  background: linear-gradient(135deg, #6f83ff, #5e4fff);
  color: #fff;
}

#variantText {
  max-width: 100%;
  min-height: 220px;
  overflow-x: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

audio { width: 100%; margin-top: 8px; }

.btn-link {
  display: inline-block;
  border: 1px solid #d4c8ff;
  border-radius: 12px;
  padding: 8px 12px;
  color: #433e8d;
  font-weight: 800;
  text-decoration: none;
  background: #f5f0ff;
}

.state-chip {
  margin-top: 8px;
  display: inline-block;
  border: 1px solid #d9cdff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: #5c4c9f;
  background: #f6f1ff;
}

.state-chip.loading {
  border-color: #ac99ff;
  color: #4f3fb8;
}

.state-chip.ready {
  border-color: #9fd8b5;
  color: #288f56;
  background: #ebfff2;
}

.state-chip.error {
  border-color: #ffc5de;
  color: #c34172;
  background: #fff2f8;
}

.inline-loading {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #5e4baf;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #d6c8ff;
  border-top-color: #5f62ff;
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

.spinner-lg {
  width: 34px;
  height: 34px;
  border-width: 3px;
}

.loading-screen {
  min-height: 260px;
  display: grid;
  place-items: center;
}

.loading-wrap {
  text-align: center;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(42, 26, 84, 0.4);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: min(520px, 96vw);
  background:
    radial-gradient(130px 90px at 100% 0%, #ffd6ea77, transparent),
    radial-gradient(130px 90px at 0% 100%, #d7deff77, transparent),
    #fff;
}

.paywall-promo {
  margin-top: 4px;
  margin-bottom: 6px;
  color: #5a4aa7;
}

.paywall-pack {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
}

.paywall-pack-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1px;
}

.paywall-pack-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.paywall-credits {
  font-size: 12px;
}

.paywall-pack .price-row {
  margin-top: 0;
  gap: 6px;
}

.paywall-pack .old-price {
  font-size: 11px;
}

.paywall-pack .new-price {
  font-size: 14px;
}

.paywall-buy-btn {
  min-width: 84px;
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 10px;
}

.paywall-section-title {
  margin: 10px 2px 6px;
  font-size: 14px;
  color: #304164;
}

#starsPacksList {
  gap: 6px;
  margin-top: 8px;
}

#yookassaPacksList {
  gap: 6px;
  margin-top: 6px;
}

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

pre {
  margin: 0;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #e2d7ff;
  background: #faf5ff;
  overflow: auto;
  max-height: 220px;
  font-size: 12px;
  color: #304164;
}

.tips-modal-card {
  position: relative;
  width: min(640px, 96vw);
  max-height: min(88vh, 760px);
  overflow: auto;
}

.modal-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
}

.tips-modal-card h3 {
  margin-right: 40px;
}

.tips-lead {
  margin-top: 2px;
}

.tips-sections {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.tips-block {
  border: 1px solid #e5dcff;
  border-radius: 14px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(111, 98, 188, 0.06);
}

.tips-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inline-action-link {
  border: 0;
  background: transparent;
  color: #4f66ef;
  font-size: 13px;
  font-weight: 800;
  padding: 0;
  border-radius: 0;
}

.inline-action-link:hover {
  transform: none;
  box-shadow: none;
  background: transparent;
  text-decoration: underline;
}

.tips-pre {
  margin-top: 8px;
  max-height: 180px;
  white-space: pre-wrap;
}

@supports (-webkit-touch-callout: none) {
  input,
  textarea {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  input:focus,
  textarea:focus {
    -webkit-user-select: text;
  }
}

@media (max-width: 760px) {
  .app-logo {
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }

  .brand { gap: 8px; }

  h1 { font-size: 20px; }
  h3 { font-size: 22px; }

  button.big {
    font-size: 28px;
    min-height: 68px;
  }

  .grid { grid-template-columns: 1fr; }
  .hero-actions { grid-template-columns: 1fr; }

  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 6px;
    padding: 8px 10px;
  }

  .brand-wrap {
    flex: 1;
    min-width: 0;
  }

  #statusText {
    font-size: 14px;
  }

  .kv {
    width: auto;
    justify-content: flex-end;
    align-items: center;
    flex-direction: row;
    gap: 4px;
  }

  #btnTopUp {
    min-width: 190px;
  }

  .screen { padding-bottom: 16px; }

  .screen .actions.nav-actions {
    border-radius: 14px;
    padding: 8px;
  }
}
