/* Custom pieces that Tailwind CDN doesn't cover well */

.noise {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.5rem;
  padding: 0 1rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.btn-primary {
  background: #6B3BCF;
  color: #ffffff;
  box-shadow: none;
}

.btn-primary:hover {
  background: #5B2DB5;
}

.btn-primary:active {
  background: #4B2499;
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(107, 59, 207, 0.35);
}

.btn-ghost {
  background: #fff;
  color: #1A1A1A;
  border-color: rgba(26, 26, 26, 0.12);
  box-shadow: none;
}

.btn-ghost:hover {
  background: #F7F7F9;
  border-color: rgba(26, 26, 26, 0.18);
}

.btn-ghost:active {
  background: #F0EEF5;
}

.btn-ghost:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(107, 59, 207, 0.15);
}

.btn-primary:disabled,
.btn-ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Compact header / inline actions */
.btn-sm {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
  border-radius: 0.375rem;
}

/* Full-width CTAs in tool / forms */
.btn-lg {
  height: 2.75rem;
  padding: 0 1.25rem;
  font-size: 0.9375rem;
  border-radius: 0.625rem;
}

.field {
  margin-top: 0.35rem;
  display: block;
  width: 100%;
  border-radius: 0.85rem;
  border: 1px solid rgba(18, 26, 22, 0.12);
  background: #fff;
  padding: 0.8rem 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field:focus {
  border-color: rgba(107, 59, 207, 0.55);
  box-shadow: 0 0 0 4px rgba(107, 59, 207, 0.12);
}

.qty-btn {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 9999px;
  border: none;
  background: #fff;
  color: #121a16;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(18, 26, 22, 0.06);
}

.qty-btn:hover {
  background: rgba(107, 59, 207, 0.08);
}

.qty-input {
  width: 2.75rem;
  border: none;
  background: transparent;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  outline: none;
  -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pay-chip {
  border-radius: 0.85rem;
  border: 1px solid rgba(18, 26, 22, 0.1);
  background: rgba(255, 255, 255, 0.75);
  padding: 0.65rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(18, 26, 22, 0.55);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pay-chip.is-active {
  border-color: rgba(107, 59, 207, 0.45);
  background: rgba(107, 59, 207, 0.1);
  color: #4b2a9a;
}

.pay-chip.is-flash {
  border-color: rgba(45, 122, 78, 0.45);
  box-shadow: inset 0 0 0 1px rgba(45, 122, 78, 0.12);
}

.pay-chip.is-flash.is-active {
  border-color: rgba(45, 122, 78, 0.55);
  background: rgba(45, 122, 78, 0.12);
  color: #1f5c3a;
}

.pay-flash {
  border-radius: 1rem;
  border: 1px solid rgba(45, 122, 78, 0.22);
  background: linear-gradient(135deg, rgba(45, 122, 78, 0.08), rgba(255, 255, 255, 0.7));
  padding: 0.75rem 0.9rem;
}

.pay-flash-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1f5c3a;
  line-height: 1.3;
}

.pay-flash-timer {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(18, 26, 22, 0.55);
  font-variant-numeric: tabular-nums;
}

/* ——— Hero free offer ——— */
.hero-free {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.hero-free-num {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.35rem, 4.5vw, 1.85rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #5b2db5;
}

.hero-free-hint {
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(26, 26, 26, 0.55);
}

@media (min-width: 640px) {
  .hero-free-hint {
    font-size: 0.9375rem;
  }
}

/* ——— Pricing block ——— */
.pricing-free {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1.25rem 1.2rem 1.2rem;
  border-radius: 1.35rem;
  background:
    linear-gradient(135deg, rgba(167, 139, 250, 0.18), rgba(107, 59, 207, 0.08) 45%, #fff 100%),
    #fff;
  box-shadow: 0 10px 30px -22px rgba(26, 26, 26, 0.28);
  border: 1px solid rgba(107, 59, 207, 0.16);
}

@media (min-width: 720px) {
  .pricing-free {
    grid-template-columns: 1.4fr auto auto;
    align-items: center;
    gap: 1.25rem 1.5rem;
    padding: 1.35rem 1.5rem;
  }
}

.pricing-free-offer {
  min-width: 7rem;
}

.pricing-free-offer .pricing-price {
  color: #5b2db5;
}

.pricing-free-cta {
  justify-self: stretch;
  text-align: center;
}

@media (min-width: 720px) {
  .pricing-free-cta {
    justify-self: end;
    min-width: 11.5rem;
  }
}

.pricing-grid {
  display: grid;
  gap: 1rem;
  align-items: stretch;
}

.pricing-kicker {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(18, 26, 22, 0.4);
}

.pricing-heading {
  margin: 0.35rem 0 0;
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #121a16;
}

.pricing-lead {
  margin: 0.45rem 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: rgba(18, 26, 22, 0.55);
  max-width: 36rem;
}

.pricing-price {
  margin: 0;
  font-size: clamp(2.35rem, 4vw, 2.85rem);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: #121a16;
}

.pricing-price-note {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: rgba(18, 26, 22, 0.48);
}

.pricing-packs {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 100%;
}

.pricing-packs-head {
  padding: 0 0.15rem 0.15rem;
}

.pricing-packs-grid {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .pricing-packs-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }
}

.pricing-pack {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1.15rem 1.2rem 1.15rem;
  border-radius: 1.15rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(18, 26, 22, 0.08);
}

.pricing-pack .btn-primary {
  margin-top: 1rem;
}

.pricing-pack-featured {
  background: linear-gradient(180deg, rgba(107, 59, 207, 0.12) 0%, rgba(255, 255, 255, 0.92) 72%);
  border-color: rgba(107, 59, 207, 0.22);
}

.pricing-pack-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.pricing-pack-name {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5a2fb8;
}

.pricing-pack-name.is-muted {
  color: rgba(18, 26, 22, 0.45);
}

.pricing-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.28rem 0.55rem;
  background: #5a2fb8;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.35rem;
  border-radius: 9999px;
  background: rgba(240, 238, 245, 0.9);
}

.chip {
  cursor: pointer;
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip span {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.65rem 0.95rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(18, 26, 22, 0.55);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.chip input:checked + span {
  background: #fff;
  color: #1A1A1A;
  box-shadow: 0 8px 20px -12px rgba(26, 26, 26, 0.35);
}

.chip:hover span {
  color: #1A1A1A;
}

.dropzone.is-dragover {
  border-color: #6B3BCF !important;
  background: rgba(107, 59, 207, 0.08) !important;
}

/* После выбора файлов dropzone остаётся полной ширины и по центру (добавить ещё) */
.dropzone.has-file {
  min-height: 160px;
  max-height: none;
  width: 100%;
  aspect-ratio: auto;
  margin-inline: 0;
  justify-content: center;
  align-items: center;
}

.dropzone.has-file .dropzone-inner {
  opacity: 1;
  width: 100%;
  max-width: 22rem;
  margin-inline: auto;
}

.dropzone.has-file .dropzone-inner strong {
  font-size: 1rem;
}

.dropzone.has-file .dropzone-inner .btn-primary {
  margin-top: 0.85rem;
  height: 2.35rem;
  font-size: 0.8125rem;
}

#toolOptions[hidden],
#fileQueueWrap[hidden],
#processRemainingBtn[hidden],
#dropzone[hidden],
#creditsPill[hidden],
#logoutBtn[hidden],
#loginForm[hidden],
#registerForm[hidden],
#forgotForm[hidden],
#authTabs[hidden],
#registerSuccess[hidden],
#forgotSuccess[hidden],
#forgotError[hidden],
#forgotDevLink[hidden],
.modal[hidden],
#toast[hidden],
#payError[hidden],
#paySuccess[hidden],
#fileLightbox[hidden] {
  display: none !important;
}

#loginForm:not([hidden]),
#registerForm:not([hidden]),
#forgotForm:not([hidden]),
#registerSuccess:not([hidden]) {
  display: block !important;
}

#creditsPill:not([hidden]) {
  display: inline-flex !important;
}

#logoutBtn:not([hidden]),
#authBtn:not([hidden]),
#processRemainingBtn:not([hidden]) {
  display: inline-flex !important;
}

#toolOptions:not([hidden]),
#fileQueueWrap:not([hidden]) {
  display: block !important;
}

.site-header.is-open .mobile-nav {
  display: block;
}

.tab.is-active {
  background: #fff;
  color: #1A1A1A;
  box-shadow: 0 8px 18px -12px rgba(26, 26, 26, 0.35);
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (max-width: 640px) {
  .segmented {
    border-radius: 1.25rem;
  }
}

/* ——— Batch file queue (TinyJPG-style) ——— */
.file-queue {
  list-style: none;
  margin: 0;
  max-height: min(52vh, 420px);
  overflow-y: auto;
}

.file-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0.55rem;
  border-radius: 0.85rem;
}

.file-row:hover {
  background: rgba(240, 238, 245, 0.55);
}

.file-thumb {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 0.65rem;
  object-fit: cover;
  background: #f0eef5;
  box-shadow: inset 0 0 0 1px rgba(18, 26, 22, 0.08);
  display: block;
}

button.file-thumb-btn {
  padding: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
  border-radius: 0.65rem;
  overflow: hidden;
  flex-shrink: 0;
}

button.file-thumb-btn:focus-visible {
  outline: 2px solid rgba(107, 59, 207, 0.55);
  outline-offset: 2px;
}

.file-thumbs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: auto;
  height: 3.25rem;
}

.file-thumbs .file-thumb {
  width: 3.25rem;
  height: 3.25rem;
  box-shadow: 0 0 0 1px rgba(18, 26, 22, 0.1);
}

.file-lightbox {
  z-index: 90;
  padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right))
    max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
  align-items: center;
  justify-items: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.file-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(96vw, 880px);
  max-height: min(92dvh, 92vh);
  margin: auto;
  padding: 0.65rem;
  padding-top: 2.4rem;
  border-radius: 1.15rem;
  background: #fff;
  box-shadow: 0 24px 60px -24px rgba(26, 26, 26, 0.45);
  overflow: auto;
  overscroll-behavior: contain;
}

.file-lightbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  align-items: start;
}

.file-lightbox-grid.is-single {
  grid-template-columns: 1fr;
}

.file-lightbox-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #f0eef5;
  min-height: 0;
}

.file-lightbox-card img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  /* Stories 9:16: два кадра рядом должны влезать по высоте экрана */
  max-height: min(78dvh, 78vh, 680px);
  object-fit: contain;
  background: #f7f5fb;
}

.file-lightbox-grid.is-single .file-lightbox-card img {
  max-height: min(82dvh, 82vh, 760px);
}

.file-lightbox-card span {
  position: absolute;
  left: 0.45rem;
  top: 0.45rem;
  z-index: 1;
  border-radius: 0.4rem;
  padding: 0.2rem 0.45rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
}

.file-lightbox-card span.is-before {
  background: rgba(18, 26, 22, 0.75);
}

.file-lightbox-card span.is-after {
  background: #6b3bcf;
}

@media (max-width: 420px) {
  .file-lightbox-panel {
    width: 100%;
    max-height: min(94dvh, 94vh);
    padding: 0.45rem;
    padding-top: 2.25rem;
    border-radius: 1rem;
  }

  .file-lightbox-grid {
    gap: 0.35rem;
  }

  .file-lightbox-card img {
    max-height: min(72dvh, 72vh);
  }
}

.file-meta {
  min-width: 0;
}

.file-name {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #121a16;
}

.file-sub {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: rgba(18, 26, 22, 0.45);
}

.file-error {
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
  color: #b42318;
}

.file-progress {
  margin-top: 0.4rem;
  height: 0.35rem;
  overflow: hidden;
  border-radius: 9999px;
  background: #efeaf8;
}

.file-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: #6b3bcf;
  transition: width 0.25s ease;
}

.file-pct {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #5a2fb8;
  font-variant-numeric: tabular-nums;
}

.file-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.file-action {
  border: none;
  background: transparent;
  color: #5a2fb8;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  text-decoration: none;
  white-space: nowrap;
}

.file-action:hover {
  text-decoration: underline;
}

.file-action-buy {
  border-radius: 0.5rem;
  background: rgba(107, 59, 207, 0.1);
  padding: 0.4rem 0.65rem;
}

.file-action-buy:hover {
  background: rgba(107, 59, 207, 0.16);
  text-decoration: none;
}

.file-row.is-done .file-status {
  color: #1a7f4b;
  font-weight: 600;
}

.file-row.is-need_credits .file-status,
.file-row.is-error .file-status {
  color: #b42318;
  font-weight: 600;
}

@media (max-width: 480px) {
  .file-row {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }

  .file-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-end;
  }
}
