/* ══════════════════════════════════════════════════════════════════════════════
   USER PROFILE SCREEN — full page, dark premium, mobile-first.
   Matches the surface language used across generator.css / index.html.
   ══════════════════════════════════════════════════════════════════════════════ */

/* Scroll wrapper inside #screen-user-profile (sibling to .app-header).
   Safe-area-top is handled by .app-header itself — we only manage vertical
   scroll here, mirroring the pattern used by .explore-scroll etc. */
:root {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.user-profile-screen {
  padding: 8px 12px 24px;
  color: #fff;
  background: transparent;
}

.ups__container {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ups__loading,
.ups__error {
  padding: 40px 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: 14px;
}

.ups-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 16px;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.ups-header {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
}

.ups-header__avatar {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  overflow: hidden;
}

.ups-header__avatar img { width: 100%; height: 100%; object-fit: cover; }

.ups-header__avatar.is-vip {
  box-shadow: 0 0 0 2px rgba(243, 214, 164, 0.4), 0 0 32px rgba(255, 166, 190, 0.16);
}

.ups-header__info { min-width: 0; }

.ups-header__name {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ups-header__username {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

.ups-header__vip-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(243, 214, 164, 0.22), rgba(255, 166, 190, 0.18));
  border: 1px solid rgba(243, 214, 164, 0.35);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f3d6a4;
}

.ups-header__edit {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}

.ups-header__edit:hover { background: rgba(255, 255, 255, 0.1); }
.ups-header__edit:active { transform: scale(0.97); }

/* ── Balance ─────────────────────────────────────────────────────────────────── */
.ups-balance__label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.ups-balance__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ups-balance__coins {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.ups-balance__coin-icon {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(125, 211, 252, 0.35));
}
.ups-balance__coin-value {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, #7dd3fc, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ups-quota {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}
.ups-quota__text { color: rgba(255, 255, 255, 0.7); font-weight: 500; }
.ups-quota__value {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ── VIP promo ───────────────────────────────────────────────────────────────── */
.ups-vip-card {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(236, 72, 153, 0.15));
  border: 1px solid rgba(168, 85, 247, 0.35);
  position: relative;
  overflow: hidden;
}

.ups-vip-card::before {
  content: '';
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.08), transparent 45%);
  pointer-events: none;
}

.ups-vip-card__badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f3d6a4, #ffa6be);
  color: #1a1a2e;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.ups-vip-card__title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.ups-vip-card__desc {
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 14px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.ups-btn {
  appearance: none;
  border: none;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ups-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.ups-btn:active:not(:disabled) { transform: scale(0.97); }

.ups-btn--primary {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.25);
}
.ups-btn--primary:hover:not(:disabled) { filter: brightness(1.1); }

.ups-btn--vip {
  background: linear-gradient(135deg, #f3d6a4, #ffa6be);
  color: #1a1a2e;
  box-shadow: 0 8px 24px rgba(243, 214, 164, 0.25);
  padding: 12px 22px;
}

.ups-btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.ups-btn--ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }

/* ── Media section ──────────────────────────────────────────────────────────── */
.ups-media {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ups-media__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 2px;
}

.ups-media__title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.ups-media__tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  padding: 3px;
}

.ups-media__tab {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}

.ups-media__tab.active {
  background: #fff;
  color: #1a1a2e;
}

.ups-media__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

@media (min-width: 560px) {
  .ups-media__grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
}

.ups-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ups-tile:active { transform: scale(0.97); }
.ups-tile:hover  { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }

.ups-tile__media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ups-tile__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.45), rgba(0,0,0,0.08) 60%);
  pointer-events: none;
}

.ups-tile__play svg {
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
  opacity: 0.95;
}

.ups-tile__meta {
  position: absolute;
  left: 6px;
  bottom: 6px;
  right: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.ups-tile__kind { font-size: 12px; }
.ups-tile__date { opacity: 0.85; }

.ups-media__empty,
.ups-media__loading,
.ups-media__error {
  padding: 36px 16px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.ups-media__footer { display: flex; justify-content: center; padding: 4px 0 0; }

/* ── Edit modal ─────────────────────────────────────────────────────────────── */
.ups-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 0 12px env(safe-area-inset-bottom);
}

.ups-modal-overlay.visible { opacity: 1; }

.ups-modal {
  background: #121215;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.45);
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.ups-modal-overlay.visible .ups-modal { transform: translateY(0); }

@media (min-width: 620px) {
  .ups-modal-overlay { align-items: center; }
  .ups-modal { border-radius: 20px; }
}

.ups-modal__title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.ups-modal__avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.ups-modal__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 28px;
  font-weight: 700;
  opacity: 0.75;
}
.ups-modal__avatar img { width: 100%; height: 100%; object-fit: cover; }

.ups-modal__avatar-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  max-width: 220px;
}

.ups-field { display: block; margin-bottom: 12px; }
.ups-field__label {
  display: block;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.ups-field__input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}
.ups-field__input:focus { border-color: rgba(168, 85, 247, 0.5); }

.ups-modal__error {
  min-height: 16px;
  color: #ff6b7a;
  font-size: 12px;
  margin: 4px 0 8px;
}

.ups-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.ups-modal__actions .ups-btn { flex: 1 1 0; }

/* ── Media viewer ───────────────────────────────────────────────────────────── */
.ups-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2100;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 16px;
}
.ups-viewer-overlay.visible { opacity: 1; }

/* Back button in profile header (task 6) — 40×40 ghost button before the
   "Профиль" title, inline with the existing app-header layout. */
.ups-header-bar { gap: 8px; }
.ups-header-bar__title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  flex: 1;
  text-align: left;
}
.ups-back-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.ups-back-btn:hover { background: rgba(255, 255, 255, 0.10); }
.ups-back-btn:active { transform: scale(0.93); }
.ups-back-btn svg { width: 22px; height: 22px; }

/* Scroll wrapper inside #screen-user-profile (sibling to .app-header). */
.ups-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.ups-viewer {
  position: relative;
  max-width: 100%;
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 42px;
}

.ups-viewer__close {
  position: absolute;
  top: calc(80px + env(safe-area-inset-top, 0));
  right: 16px;
  z-index: 10002;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ups-viewer__stage {
  position: relative;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ups-viewer__img,
.ups-viewer__video {
  width: 100%;
  max-height: 70vh;
  display: block;
  object-fit: contain;
  background: #000;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Media viewer icon cluster + copy-prompt row + privacy toggle (task 1)
   ═══════════════════════════════════════════════════════════════════════════ */
.ups-viewer__icon-bar {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  gap: 8px;
  z-index: 3;
}
.ups-viewer__icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 15, 22, 0.58);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  backdrop-filter: blur(10px) saturate(160%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.ups-viewer__icon-btn:hover {
  background: rgba(35, 35, 48, 0.78);
  border-color: rgba(255, 255, 255, 0.28);
}
.ups-viewer__icon-btn:active { transform: scale(0.92); }
.ups-viewer__icon-btn--danger { color: #fca5a5; }
.ups-viewer__icon-btn--danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

/* "Create video" FAB — pink→purple pill matching the generator UI. */
.ups-viewer__video-fab {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(15, 15, 22, 0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.ups-viewer__video-fab svg { color: #c084fc; flex-shrink: 0; }
.ups-viewer__video-fab:hover {
  background: rgba(168, 85, 247, 0.85);
  border-color: rgba(255, 255, 255, 0.35);
}
.ups-viewer__video-fab:hover svg { color: #fff; }
.ups-viewer__video-fab:active { transform: scale(0.96); }

@media (max-width: 380px) {
  .ups-viewer__icon-bar { left: 8px; bottom: 8px; gap: 6px; }
  .ups-viewer__icon-btn { width: 34px; height: 34px; }
  .ups-viewer__video-fab { right: 8px; bottom: 8px; padding: 8px 12px 8px 10px; font-size: 12px; }
}

/* Prompt + copy-button row. The prompt grows to fill the row, the copy button
   sits compact on the right (task 1). */
.ups-viewer__prompt-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 4px 2px 0;
}
.ups-viewer__prompt {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.5;
  max-height: 96px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.ups-viewer__prompt-copy {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.75);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.ups-viewer__prompt-copy:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.ups-viewer__prompt-copy:active { transform: scale(0.92); }

/* Privacy toggle row. The track and thumb are styled from scratch so we
   don't inherit browser checkbox UA. */
.ups-viewer__privacy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ups-viewer__privacy-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ups-viewer__privacy-label {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.ups-viewer__privacy-hint {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.5);
}

/* Locked switch (non-VIP trying to use VIP-only feature) */
.ups-switch--locked {
  cursor: not-allowed;
}
.ups-switch--locked .ups-switch__track {
  background: rgba(255, 255, 255, 0.15);
}
.ups-switch--locked input {
  pointer-events: none;
}

/* VIP badge on privacy toggle (non-VIP users) */
.ups-switch--with-vip-badge {
  position: relative;
}
.ups-switch__vip-badge {
  position: absolute;
  top: -8px;
  right: -10px;
  background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  cursor: pointer;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 14px;
}

/* Reusable switch. Input is visually-hidden; we toggle via :checked sibling. */
.ups-switch {
  position: relative;
  flex-shrink: 0;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.ups-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.ups-switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.2s ease;
}
.ups-switch__track::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, background 0.2s ease;
}
.ups-switch input:checked ~ .ups-switch__track {
  background: linear-gradient(135deg, #a855f7, #ec4899);
}
.ups-switch input:checked ~ .ups-switch__track::before {
  transform: translateX(20px);
}
.ups-switch input:disabled ~ .ups-switch__track { opacity: 0.5; }

/* Local fallback toast if global #toast is missing */
.ups-toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(20, 20, 28, 0.95);
  color: #fff;
  font-size: 13px;
  z-index: 10000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: upsToastIn 0.2s ease;
}
@keyframes upsToastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Small screens fine-tuning ──────────────────────────────────────────────── */
@media (max-width: 380px) {
  .ups-header { grid-template-columns: 64px 1fr auto; gap: 10px; padding: 14px; }
  .ups-header__avatar { width: 64px; height: 64px; font-size: 24px; }
  .ups-header__name { font-size: 16px; }
  .ups-balance__coin-value { font-size: 22px; }
  .ups-media__grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .ups-tile__meta { font-size: 9px; }
}
