:root {
  --bg: #fbeedc;
  --bg-soft: #fff8ed;
  --ink: #2b1130;
  --ink-soft: #6b5470;
  --accent: #ff3e7f;
  --accent-ink: #ffffff;
  --accent-2: #ffc93c;
  --accent2-ink: #2b1130;
  --teal: #0e8c8a;
  --surface: #ffffff;
  --border: rgba(43, 17, 48, 0.12);
  --shadow: rgba(43, 17, 48, 0.14);
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Instrument Serif', Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #190c21;
    --bg-soft: #22112b;
    --ink: #fbeedc;
    --ink-soft: #c9b7cc;
    --accent: #ff5c96;
    --accent-ink: #22112b;
    --accent-2: #ffd166;
    --teal: #2fd8d2;
    --surface: #291733;
    --border: rgba(255, 238, 220, 0.14);
    --shadow: rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* atrybut hidden musi zawsze wygrywać, nawet z elementami, które mają
   swoje własne display:flex (np. button.cta) - inaczej specificity klasy
   potrafi przykryć natywne [hidden]{display:none} przeglądarki i element
   z hidden nadal się renderuje */
[hidden] {
  display: none !important;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  padding-inline: 20px;
  padding-block: 32px 40px;
  display: flex;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
}

.myid-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: var(--ink);
  color: var(--bg);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.78rem;
}

.myid-banner[hidden] {
  display: none;
}

.myid-banner code {
  font-weight: 700;
  user-select: all;
}

.myid-banner button {
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--accent-2);
  color: var(--accent2-ink);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.72rem;
  cursor: pointer;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(480px 480px at 82% -6%, color-mix(in srgb, var(--accent-2) 40%, transparent), transparent 70%),
    radial-gradient(560px 560px at -10% 18%, color-mix(in srgb, var(--teal) 32%, transparent), transparent 70%),
    radial-gradient(520px 520px at 90% 78%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%);
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}

.brand .ball {
  font-size: 1.1rem;
  line-height: 1;
}

.hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 7vw, 2.7rem);
  line-height: 1.08;
  margin: 0;
  text-wrap: balance;
}

/* akcentowane fragmenty tekstu - gradient + kursywa */
em,
strong,
.hero h1 em {
  font-style: italic;
  font-weight: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: var(--accent);
  -webkit-text-fill-color: transparent;
}

.hero p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.5;
  text-wrap: balance;
}

.promise {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--teal);
  background: color-mix(in srgb, var(--teal) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--teal) 30%, transparent);
  border-radius: 999px;
  padding: 7px 14px;
}

.promise svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 22px;
  box-shadow: 0 20px 44px -24px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stage-label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

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

#charCount {
  font-variant-numeric: tabular-nums;
}

.clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.clear-btn svg {
  width: 12px;
  height: 12px;
}

.clear-btn:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-soft));
  color: var(--accent);
}

.clear-btn:active {
  transform: scale(0.9);
}

.clear-btn[hidden] {
  display: none;
}

textarea#prompt {
  width: 100%;
  min-height: 128px;
  max-height: 60vh;
  resize: none;
  overflow: hidden;
  border: 2px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 18px;
  padding: 16px 18px;
  font-family: var(--font-body);
  font-size: 1.08rem;
  line-height: 1.5;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, height 0.1s ease;
}

textarea#prompt::placeholder {
  color: var(--ink-soft);
  opacity: 0.75;
}

textarea#prompt:focus {
  outline: none;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 18%, transparent);
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding-block: 2px 4px;
}

.chip {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--ink);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.chip:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-soft));
}

.chip:active {
  transform: scale(0.96);
}

button.cta {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--accent2-ink);
  background: var(--accent-2);
  border: none;
  border-radius: 999px;
  padding: 18px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 14px 30px -14px color-mix(in srgb, var(--accent-2) 75%, transparent);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

button.cta:hover {
  transform: translateY(-1px);
}

button.cta:active {
  transform: translateY(0) scale(0.98);
}

button.cta:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

button.cta .disc {
  width: 22px;
  height: 22px;
  flex: none;
}

button.cta.is-loading .disc {
  animation: spin 0.9s linear infinite;
}

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

.status {
  text-align: center;
  font-size: 0.95rem;
  color: var(--ink-soft);
  min-height: 1.3em;
  margin: 0;
}

.status.error {
  color: var(--accent);
  font-weight: 700;
}

.result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result[hidden] {
  display: none;
}

#player {
  display: none;
}

.audio-player {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 16px;
}

.audio-player-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.audio-cover {
  flex: none;
  width: 50%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 8px 20px -10px var(--shadow);
}

.audio-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.3;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.audio-player-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.play-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 999px;
  background: var(--accent-2);
  color: var(--accent2-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.play-btn:hover {
  transform: scale(1.05);
}

.play-btn:active {
  transform: scale(0.95);
}

.play-btn svg {
  width: 18px;
  height: 18px;
}

.play-btn .icon-pause {
  display: none;
}

.play-btn.is-playing .icon-play {
  display: none;
}

.play-btn.is-playing .icon-pause {
  display: block;
}

.audio-track {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
  accent-color: var(--accent);
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.audio-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.download {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  padding: 12px;
  cursor: not-allowed;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.download:not(:disabled) {
  color: var(--accent2-ink);
  background: var(--accent-2);
  border: 1.5px solid transparent;
  cursor: pointer;
  box-shadow: 0 10px 24px -14px color-mix(in srgb, var(--accent-2) 75%, transparent);
}

.download:not(:disabled):hover {
  transform: translateY(-1px);
}

.download.is-downloaded {
  color: #fff;
  background: var(--teal);
  border: 1.5px solid transparent;
  cursor: pointer;
}

.install-app-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.92rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 10px 24px -14px color-mix(in srgb, var(--accent) 75%, transparent);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.install-app-btn:hover {
  transform: translateY(-1px);
}

.install-app-btn:active {
  transform: translateY(0);
}

.install-app-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.install-app-icon {
  font-size: 1.15em;
  line-height: 1;
}

.install-app-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.4;
}

.download:not(:disabled):active {
  transform: translateY(0) scale(0.98);
}

.debug-panel {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.debug-panel summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.debug-panel pre {
  margin: 10px 0 0;
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.76rem;
  line-height: 1.45;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.loading-overlay[hidden] {
  display: none;
}

/* pulsujący kolorowy gradient w tle, rytm "heartbeat" (lub-dub + odpoczynek) */
.loading-overlay::before {
  content: '';
  position: absolute;
  inset: -15%;
  background:
    radial-gradient(circle at 25% 25%, var(--accent) 0%, transparent 50%),
    radial-gradient(circle at 75% 30%, var(--accent-2) 0%, transparent 50%),
    radial-gradient(circle at 50% 80%, var(--teal) 0%, transparent 55%);
  filter: blur(70px) saturate(160%);
  opacity: 0.45;
  animation: heartbeat-pulse 1.8s ease-in-out infinite;
}

.loading-emoji {
  position: relative;
  z-index: 1;
  font-size: 5rem;
  line-height: 1;
  animation: emoji-pop 0.45s ease;
}

.loading-emoji.pop {
  animation: emoji-pop 0.45s ease;
}

.loading-text {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
  text-align: center;
}

@keyframes emoji-pop {
  0% {
    transform: scale(0.4) rotate(-12deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.15) rotate(4deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes heartbeat-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.4;
  }
  15% {
    transform: scale(1.08);
    opacity: 0.75;
  }
  30% {
    transform: scale(0.97);
    opacity: 0.5;
  }
  45% {
    transform: scale(1.12);
    opacity: 0.85;
  }
  65%,
  92% {
    transform: scale(1);
    opacity: 0.4;
  }
}

@media (prefers-reduced-motion: reduce) {
  button.cta.is-loading .disc {
    animation: none;
  }

  .loading-emoji,
  .loading-emoji.pop {
    animation: none;
  }

  .loading-overlay::before {
    animation: none;
    opacity: 0.4;
  }
}

.payment-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: color-mix(in srgb, var(--ink) 55%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.payment-modal[hidden] {
  display: none;
}

.payment-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: 24px;
  padding: 28px 24px 24px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Statyczna (bez animacji) wersja gradientu z heartbeatu na overlayu ładowania.
   Tło zawsze jasne (na sztywno, nie var(--bg-soft)) - formularz Stripe
   (domyślny motyw) renderuje szary tekst zakładający jasne tło, więc musi
   nim zostać niezależnie od jasnego/ciemnego motywu reszty strony. */
.payment-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(circle at 20% 15%, var(--accent) 0%, transparent 50%),
    radial-gradient(circle at 85% 25%, var(--accent-2) 0%, transparent 50%),
    radial-gradient(circle at 50% 95%, var(--teal) 0%, transparent 55%),
    #fff8ed;
}

.payment-card h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0;
  padding-right: 28px;
}

.payment-teaser {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-style: italic;
  font-weight: 700;
  color: #fff;
}

.payment-copy {
  margin: 0;
  color: #000;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* białe tło pod gradientową ceną - #priceLabel ma swój własny background
   (gradient wycięty w tekst przez background-clip: text z reguły em/strong),
   więc biel dajemy na osobnym, opakowującym elemencie, nie na samym strongu */
.price-pill {
  display: inline-block;
  background: #fff;
  padding: 1px 10px;
  border-radius: 999px;
  line-height: 1.5;
}

.price-pill strong {
  font-weight: 800;
}

.blik-label {
  display: block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.85rem;
  color: #000;
  margin: 4px 0 8px;
}

.blik-input {
  width: 100%;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.5em;
  text-align: center;
  text-indent: 0.5em; /* wyrównanie środka mimo letter-spacing */
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: #fff;
  color: #000;
}

.blik-input::placeholder {
  color: var(--ink-soft);
  opacity: 0.5;
}

.blik-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* licznik + przycisk akcji na pełnoekranowym loading-overlay (współdzielony
   między "miksujemy piosenkę" i "czekamy na BLIK") */
.blik-countdown {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
}

#overlayActionBtn {
  position: relative;
  z-index: 1;
  width: auto;
  min-width: 200px;
}

.payment-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  cursor: pointer;
}

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

.payment-close:hover {
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-soft));
  color: var(--accent);
}

.payment-error {
  margin: 0;
  min-height: 1.2em;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.88rem;
}

#payBtn {
  width: 100%;
  background: linear-gradient(135deg, #0f9b5f, #22c55e, #86efac);
  color: #fff;
  box-shadow: 0 14px 30px -14px rgba(15, 155, 95, 0.6);
}
