:root {
  --bg: #14121a;
  --card: #1e1b26;
  --card-2: #272331;
  --text: #f5f2ff;
  --hint: #a8a2b8;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-theme="light"] {
  --bg: #f6f4fb;
  --card: #ffffff;
  --card-2: #efecf8;
  --text: #1a1725;
  --hint: #6b6579;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

body { overflow: hidden; }

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: var(--safe-top);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.2px;
}

.logo { margin-right: 4px; }

.badge {
  font-size: 12px;
  color: var(--hint);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 10px;
}

.screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.preview {
  position: relative;
  width: min(100%, 64vw);
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(160deg, #2a2438, #191622);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

html[data-theme="light"] .preview { background: linear-gradient(160deg, #e7e2f5, #f8f6ff); }

.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.preview img.ready { opacity: 1; }

.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hint);
  font-size: 14px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--hint);
  margin: 0 0 6px 2px;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.chip:active { transform: scale(0.97); }

.chip.active {
  background: color-mix(in srgb, var(--accent) 22%, var(--card));
  border-color: var(--accent);
}

.phrase { display: flex; flex-direction: column; gap: 8px; }

.phrase-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--hint); }

textarea {
  width: 100%;
  resize: none;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  padding: 12px 14px;
  font-family: inherit;
}

textarea:focus { outline: none; border-color: var(--accent); }

.phrase-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.counter { font-size: 12px; color: var(--hint); }

.ghost {
  border: none;
  background: var(--card-2);
  color: var(--text);
  border-radius: 12px;
  min-height: 40px;
  padding: 8px 14px;
  font-size: 14px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
}

button { font-family: inherit; cursor: pointer; }

.primary, .secondary {
  min-height: 52px;
  border-radius: 16px;
  border: none;
  font-size: 16px;
  font-weight: 600;
}

.primary {
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: #fff;
}

.primary:disabled, .secondary:disabled { opacity: 0.55; }

.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 14, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
}

.overlay-card {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border-radius: 22px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.overlay-title { font-size: 16px; font-weight: 600; }
.overlay-hint { font-size: 13px; color: var(--hint); text-align: center; }

.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--card-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: 86%;
  background: var(--card-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.result { display: flex; flex-direction: column; gap: 10px; }

.result video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  aspect-ratio: 9 / 16;
  max-height: 52vh;
}
/* --- вкладки и личный кабинет ------------------------------------------- */
.tabs { display: flex; gap: 8px; padding: 0 16px 10px; }
.tab { flex: 1; min-height: 40px; border-radius: 12px; border: none; background: var(--card); color: var(--hint); font-size: 14px; }
.tab.active { background: var(--card-2); color: var(--text); }
.screen[hidden], .actions[hidden] { display: none !important; }

.balance-card { background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 28%, var(--card)), var(--card)); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.balance-label { font-size: 13px; color: var(--hint); text-transform: uppercase; letter-spacing: 0.06em; }
.balance-value { font-size: 34px; font-weight: 700; line-height: 1.1; }
.balance-value span { font-size: 15px; font-weight: 500; color: var(--hint); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--hint); margin: 18px 0 8px; }

.packs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pack { background: var(--card); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.pack-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.bonus { color: #4ade80; font-size: 12px; }
.pack-price { font-size: 17px; font-weight: 600; }
.pack-buy { min-height: 34px; font-size: 12px; padding: 4px 8px; }
.pay-note { margin-top: 10px; font-size: 13px; }

.history { background: var(--card); border-radius: 14px; padding: 4px 14px; }
.history-row { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--card-2); font-size: 14px; }
.history-row:last-child { border-bottom: none; }
.up { color: #4ade80; font-weight: 600; }
.down { color: #f87171; font-weight: 600; }

.docs { display: flex; flex-direction: column; gap: 6px; }
.doc-link { width: 100%; display: flex; justify-content: space-between; align-items: center; background: var(--card); border: none; color: var(--text); border-radius: 12px; min-height: 48px; padding: 0 14px; font-size: 15px; }
.providers { display: flex; flex-direction: column; gap: 6px; }
.provider { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 12px 14px; }
.status { font-size: 12px; color: var(--hint); white-space: nowrap; }
.operator { background: var(--card); border-radius: 12px; padding: 14px; font-size: 14px; display: flex; flex-direction: column; gap: 3px; }
.result-video { width: 100%; height: 100%; object-fit: cover; }
.result-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2; background: #000; }
