/* pay-per-view-v1 — self-contained per prototype principle. */

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ============ APP SHELL ============ */
.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 680px) 320px;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ============ SIDEBAR ============ */
.sidebar { position: sticky; top: 24px; height: calc(100vh - 48px); display: flex; flex-direction: column; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 32px; font-weight: 800; margin-bottom: 36px; color: var(--text); }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar nav a {
  padding: 14px 18px; color: var(--text-soft); border-radius: 999px; font-weight: 600; font-size: 16px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.sidebar nav a.active, .sidebar nav a:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.new-post { border-radius: 999px; background: var(--cta-bg); color: var(--cta-text); font-weight: 700; padding: 14px 22px; font-size: 16px; }

/* ============ MAIN ============ */
.main { min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; min-height: 44px;
}
.topbar h1 { font-size: 28px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.topbar-brand { display: none; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.topbar-brand img { width: 24px; height: 24px; object-fit: contain; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }

/* ============ CREATOR BANNER ============ */
.creator-card {
  display: flex; align-items: center; gap: 14px;
  padding: 18px;
  margin-bottom: 18px;
}
.creator-card .who { flex: 1; min-width: 0; }
.creator-card .who b { display: block; font-weight: 800; font-size: 16px; }
.creator-card .who small { display: block; color: var(--text-soft); font-size: 13px; margin-top: 2px; }
.creator-card .mbti {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700; font-size: 11px;
  padding: 2px 8px; border-radius: 999px;
  margin-left: 6px;
}
.creator-card .visit {
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s;
}
.creator-card .visit:hover { background: var(--surface-soft); }

/* ============ SECTION TITLE ============ */
.section-h {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.section-h h2 { font-size: 20px; font-weight: 700; margin: 0; }
.section-h .count { color: var(--text-soft); font-size: 13px; }

/* ============ GALLERY GRID ============ */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: end start;
  padding: 12px;
  color: white;
  cursor: pointer;
  border: 1px solid var(--line);
  transition: transform 0.15s;
}
.tile:hover { transform: translateY(-2px); }
.tile .title {
  position: relative;
  z-index: 2;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.tile .price-chip {
  position: absolute;
  top: 10px; right: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700; font-size: 12px;
  padding: 4px 10px; border-radius: 999px;
  z-index: 3;
  font-variant-numeric: tabular-nums;
}
.tile.locked::before {
  content: "";
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
}
.tile.locked .lock {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 26px;
  z-index: 2;
}
.tile.unlocked .check {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 3;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 800;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ============ HOW IT WORKS ============ */
.how {
  padding: 20px;
  background: linear-gradient(180deg, var(--surface), var(--primary-soft));
}
.how h2 { margin: 0 0 10px; font-size: 18px; font-weight: 700; }
.how ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.how li {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 14px; line-height: 1.55;
  color: var(--text);
}
.how li .n {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 800; font-size: 12px;
  display: grid; place-items: center;
}

/* ============ RIGHT PANEL ============ */
.right-panel { display: flex; flex-direction: column; gap: 18px; }
.right-panel .card { padding: 20px; }
.right-panel h2 { font-size: 16px; margin: 0 0 12px; font-weight: 700; }

/* Wallet snapshot — small indigo gradient */
.wallet-snap {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}
.wallet-snap h2 { color: rgba(255,255,255,0.85); margin-bottom: 8px; }
.wallet-snap .bal {
  font-size: 22px; font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.wallet-snap .bal small { font-size: 12px; font-weight: 700; opacity: 0.85; margin-left: 4px; }
.wallet-snap .usd { color: rgba(255,255,255,0.78); font-size: 12px; margin-top: 4px; }
.wallet-snap .top-up {
  margin-top: 14px;
  width: 100%;
  padding: 10px; border-radius: 999px;
  background: rgba(255,255,255,0.18);
  color: white;
  font-weight: 700; font-size: 13px;
  transition: background 0.15s;
}
.wallet-snap .top-up:hover { background: rgba(255,255,255,0.28); }

/* Library mini-list */
.lib-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.lib-list li { display: flex; align-items: center; gap: 12px; }
.lib-list .thumb {
  width: 48px; height: 48px;
  border-radius: 10px;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.lib-list .meta { flex: 1; min-width: 0; }
.lib-list .meta b { display: block; font-weight: 700; font-size: 13px; }
.lib-list .meta small { display: block; color: var(--text-soft); font-size: 12px; margin-top: 2px; }

/* Creator profile mini */
.creator-mini { text-align: center; padding-bottom: 8px; }
.creator-mini .avatar { width: 60px; height: 60px; font-size: 24px; margin: 0 auto 10px; }
.creator-mini h3 { margin: 0; font-size: 16px; font-weight: 800; }
.creator-mini p { color: var(--text-soft); font-size: 13px; margin: 4px 0 14px; line-height: 1.5; }
.creator-mini .row { display: flex; gap: 8px; }
.creator-mini .row button {
  flex: 1; padding: 9px 12px; border-radius: 999px;
  font-weight: 700; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.creator-mini .row button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border-color: transparent;
}

/* ============ AVATAR ============ */
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: white; font-weight: 800; flex-shrink: 0; user-select: none; }
.avatar.g1 { background: linear-gradient(135deg, var(--primary), var(--ai)); }
.avatar.g2 { background: linear-gradient(135deg, var(--ai), var(--info)); }
.avatar.g3 { background: linear-gradient(135deg, var(--success), var(--ai)); }
.avatar.g4 { background: linear-gradient(135deg, var(--accent), var(--accent-warm)); }
.avatar.g5 { background: linear-gradient(135deg, var(--primary), var(--accent)); }

/* ============ UNLOCK MODAL ============ */
.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 16px;
}
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: 22px;
  width: 100%;
  max-width: 380px;
  overflow: hidden;
  box-shadow: var(--shadow-float);
  animation: modalIn 0.18s ease-out;
}
@keyframes modalIn { from { transform: translateY(8px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 4;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  color: white;
  display: grid; place-items: center;
  font-size: 14px;
  backdrop-filter: blur(8px);
}
.modal-close:hover { background: rgba(255,255,255,0.28); }

.modal-preview {
  position: relative;
  height: 220px;
  display: grid; place-items: center;
  color: white;
  font-weight: 700;
}
.modal-preview.locked { filter: blur(10px) brightness(0.7); }
.modal-preview .ptitle {
  position: absolute;
  bottom: 14px; left: 18px;
  z-index: 2;
  font-size: 16px;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}
.modal-success {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(16,185,129,0.92);
  color: white;
  font-size: 48px;
  opacity: 0;
  transition: opacity 0.22s;
  pointer-events: none;
}
.modal-success.show { opacity: 1; }

.modal-body { padding: 22px; }
.modal-body h3 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.modal-body .by { color: var(--text-soft); font-size: 13px; margin: 0 0 16px; }
.modal-price {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 4px;
}
.modal-price .num {
  font-size: 32px; font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.modal-price .unit { font-weight: 700; color: var(--text-soft); font-size: 14px; }
.modal-body .usd { color: var(--text-soft); font-size: 12px; margin-bottom: 18px; }

.balance-row {
  display: flex; justify-content: space-between;
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface-soft);
  margin-bottom: 18px;
  font-size: 13px;
}
.balance-row .k { color: var(--text-soft); }
.balance-row .v { font-weight: 700; font-variant-numeric: tabular-nums; }

.modal-confirm {
  width: 100%; padding: 13px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 800; font-size: 15px;
  margin-bottom: 8px;
}
.modal-confirm:disabled { opacity: 0.6; cursor: default; }
.modal-cancel {
  width: 100%; padding: 11px;
  color: var(--text-soft);
  font-weight: 600; font-size: 14px;
}

/* ============ MOBILE NAV ============ */
.mobile-nav { display: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
    padding-bottom: 96px;
    gap: 12px;
  }
  .sidebar, .right-panel { display: none; }

  .topbar {
    position: sticky; top: 0; z-index: 10;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 12px 4px;
    margin: 0 0 12px;
  }
  .topbar h1 { display: none; }
  .topbar-brand { display: inline-flex; }

  .gallery { grid-template-columns: repeat(2, 1fr); }

  .mobile-nav {
    position: fixed;
    left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    padding: 10px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 20;
  }
  .mobile-nav a { text-align: center; font-size: 12px; color: var(--text-soft); padding: 8px 4px; }
  .mobile-nav a.active { color: var(--text); font-weight: 600; }
  .mobile-nav .compose-btn {
    width: 46px; height: 46px;
    margin: auto; padding: 0;
    border-radius: 50%;
    background: var(--cta-bg); color: var(--cta-text);
    display: grid; place-items: center; line-height: 1;
  }
}
