:root {
  --brand: #0ea5e9;
  --brand-strong: #0284c7;
  --brand-soft: #e0f2fe;
  --bg: #ffffff;
  --bg-alt: #f4f6f8;
  --surface: #ffffff;
  --text: #0f172a;
  --text-2: #64748b;
  --border: #e5e7eb;
  --danger: #ef4444;
  --twitch: #9146ff;
  --shadow: 0 10px 40px rgba(15, 23, 42, .18);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #38bdf8;
    --brand-strong: #0ea5e9;
    --brand-soft: #0c2a3d;
    --bg: #0b0f14;
    --bg-alt: #121821;
    --surface: #141a22;
    --text: #e6edf3;
    --text-2: #8b98a8;
    --border: #232c37;
    --shadow: 0 10px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #38bdf8;
  --brand-strong: #0ea5e9;
  --brand-soft: #0c2a3d;
  --bg: #0b0f14;
  --bg-alt: #121821;
  --surface: #141a22;
  --text: #e6edf3;
  --text-2: #8b98a8;
  --border: #232c37;
  --shadow: 0 10px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
.muted { color: var(--text-2); }
.i { width: 22px; height: 22px; flex: none; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 230px minmax(0, 620px) 340px;
  justify-content: center;
  min-height: 100vh;
}
.sidenav, .rightcol { position: sticky; top: 0; height: 100vh; }

/* ---------- Left nav ---------- */
.sidenav {
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 16px;
}
.logo { display: flex; align-items: center; gap: 8px; padding: 6px 10px 18px; color: var(--text); text-decoration: none !important; }
.logo-mark { font-size: 26px; transform: rotate(-12deg); }
.logo-text { font-size: 23px; letter-spacing: -.5px; color: var(--brand); }
.logo-text b { color: var(--text); font-weight: 800; }
.sidenav nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 16px;
  padding: 11px 12px; border-radius: 999px;
  font-size: 17px; color: var(--text); text-align: left; position: relative;
}
.nav-item:hover { background: var(--bg-alt); }
.nav-item.active { font-weight: 700; color: var(--brand); }
.badge {
  font-style: normal; font-size: 11px; font-weight: 700;
  background: var(--danger); color: #fff; border-radius: 999px;
  padding: 1px 6px; margin-left: auto;
}
.new-post {
  margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; font-size: 14px;
  padding: 13px 16px; border-radius: 999px;
}
.new-post:hover { background: var(--brand-strong); }

/* ---------- Profile column ---------- */
.profile {
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-width: 0;
  padding-bottom: 40px;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-name { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 4px; }
.topbar-stats { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; }
.icon-btn:hover { background: var(--bg-alt); }
.verified { width: 18px; height: 18px; color: var(--brand); flex: none; }

.banner {
  position: relative; height: 190px; overflow: hidden;
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 55%, #a855f7 100%);
}
.banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.banner-art {
  position: absolute; inset: -20px;
  display: grid; grid-template-columns: repeat(4, 1fr); place-items: center;
  font-size: 54px; opacity: .25; transform: rotate(-10deg);
}
.banner-art span:nth-child(even) { transform: scaleX(-1); }

.identity { padding: 0 16px 8px; }
.avatar-row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: -48px; position: relative; z-index: 2; }
.avatar {
  position: relative; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #fff; font-weight: 800; display: grid; place-items: center;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar-lg { width: 104px; height: 104px; font-size: 34px; border: 4px solid var(--bg); }
.avatar-sm { width: 44px; height: 44px; font-size: 15px; }
.live-dot {
  position: absolute; right: 6px; bottom: 6px; width: 18px; height: 18px; border-radius: 50%;
  background: #22c55e; border: 3px solid var(--bg); z-index: 2;
}
.profile-actions { display: flex; gap: 8px; padding-bottom: 6px; }
.pill-btn, .circle-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--brand); font-weight: 600;
}
.pill-btn { padding: 8px 14px; border-radius: 999px; font-size: 14px; }
.circle-btn { width: 40px; height: 40px; border-radius: 50%; justify-content: center; }
.pill-btn:hover, .circle-btn:hover { background: var(--brand-soft); }
.pill-btn .i, .circle-btn .i { width: 20px; height: 20px; }

.name { font-size: 22px; margin: 12px 0 0; display: flex; align-items: center; gap: 6px; }
.verified { vertical-align: middle; }
.name .verified { width: 22px; height: 22px; }
.handle { color: var(--text-2); font-size: 14px; }
.status { color: #16a34a; font-weight: 600; }
.bio { margin: 12px 0; }
.meta { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-2); font-size: 14px; }
.meta li { display: flex; align-items: center; gap: 6px; }
.meta .i { width: 17px; height: 17px; }

/* ---------- Subscription ---------- */
.subscription { padding: 4px 16px 16px; border-bottom: 1px solid var(--border); }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--text-2); margin: 16px 0 8px; }
.sub-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--brand); color: #fff; border-radius: 999px; padding: 13px 22px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .4px; font-size: 14px;
}
.sub-btn:hover { background: var(--brand-strong); }
.sub-btn.subscribed { background: var(--surface); color: var(--brand); border: 1px solid var(--brand); }
.sub-price { text-transform: none; font-weight: 600; opacity: .95; text-align: right; }

.tiers { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tier {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; font-size: 13.5px;
}
.tier p { margin: 0; color: var(--text-2); }
.tier .fine { font-size: 11.5px; font-style: italic; }
.tier.featured { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tier-flag {
  position: absolute; top: -10px; left: 12px; background: var(--brand); color: #fff;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 2px 8px; border-radius: 999px;
}
.tier-head { display: flex; gap: 10px; align-items: center; }
.tier-emoji { font-size: 26px; }
.tier h3 { margin: 0; font-size: 15px; }
.tier-head .tier-price { color: var(--brand); font-weight: 700; font-size: 13px; }
.tier-btn {
  margin-top: auto; text-align: center; border-radius: 999px; padding: 8px 10px;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 13px; text-decoration: none !important;
}
.tier-btn.ghost { background: transparent; color: var(--twitch); border: 1px solid var(--twitch); }
.tier-btn:disabled { background: var(--bg-alt); color: var(--text-2); cursor: not-allowed; }
.sold-out { opacity: .75; }

/* ---------- Tabs ---------- */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--border); position: sticky; top: 57px; z-index: 10; background: var(--bg); }
.tab {
  padding: 14px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tab b { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.tab:hover { background: var(--bg-alt); }

/* ---------- Posts ---------- */
.post { border-bottom: 1px solid var(--border); padding: 14px 16px 6px; }
.post-head { display: flex; gap: 10px; align-items: center; }
.post-who { flex: 1; min-width: 0; }
.post-name { font-weight: 700; display: flex; align-items: center; gap: 4px; }
.post-name .verified { width: 16px; height: 16px; }
.post-handle { color: var(--text-2); font-size: 13.5px; }
.post-time { color: var(--text-2); font-size: 13.5px; }
.pinned { font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.post-text { margin: 10px 0 12px; white-space: pre-line; }

.media {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-alt); aspect-ratio: 400 / 260;
}
.media .art { display: block; width: 100%; height: 100%; object-fit: cover; }
.media.locked .art { filter: blur(26px) saturate(1.3); transform: scale(1.2); }
.lock-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(15, 23, 42, .35); color: #fff; text-align: center; padding: 16px;
}
.lock-overlay .lock-icon { width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; }
.lock-overlay .lock-icon .i { width: 28px; height: 28px; }
.lock-overlay .lock-meta { font-size: 13px; opacity: .9; display: flex; gap: 12px; }
.unlock-btn {
  background: var(--brand); color: #fff; font-weight: 700; padding: 11px 22px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .4px; font-size: 13.5px; width: min(100%, 360px);
}
.unlock-btn:hover { background: var(--brand-strong); }
.reveal-caption { margin: 10px 0 0; font-size: 13.5px; color: var(--text-2); font-style: italic; }
.media.just-unlocked .art { animation: unblur 1.1s ease-out; }
@keyframes unblur { from { filter: blur(26px); transform: scale(1.2); } to { filter: none; transform: none; } }

.post-actions { display: flex; gap: 4px; align-items: center; margin-top: 8px; }
.act { display: inline-flex; align-items: center; gap: 6px; padding: 8px; border-radius: 999px; color: var(--text-2); font-size: 14px; }
.act:hover { background: var(--bg-alt); color: var(--text); }
.act.liked { color: var(--danger); }
.act.tip { color: var(--text-2); }
.act.bookmark { margin-left: auto; }
.post-likes { font-size: 13.5px; font-weight: 600; padding: 0 8px 8px; }

/* Media grid */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; }
.media-grid .media { border-radius: 4px; aspect-ratio: 1; cursor: pointer; }
.media-grid .lock-overlay { gap: 6px; }
.media-grid .lock-overlay .lock-icon { width: 36px; height: 36px; }
.media-grid .lock-overlay .lock-icon .i { width: 20px; height: 20px; }
.media-grid .grid-price { font-size: 12px; font-weight: 700; }

/* Reviews */
.review { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; }
.review .avatar-sm { font-size: 18px; }
.review-body { flex: 1; min-width: 0; }
.review-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.review-name { font-weight: 700; }
.review-stars { color: #f59e0b; letter-spacing: 1px; }
.review p { margin: 4px 0 0; }

/* ---------- Right column ---------- */
.rightcol { padding: 16px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface); }
.card-title { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--text-2); }
.poll-q { font-weight: 700; font-size: 17px; margin: 0 0 10px; }
.poll { display: flex; flex-direction: column; gap: 8px; }
.poll-opt {
  position: relative; overflow: hidden; text-align: left; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; display: flex; justify-content: space-between; gap: 8px; font-size: 14px;
}
.poll-opt:hover:not(:disabled) { border-color: var(--brand); }
.poll-opt:disabled { cursor: default; }
.poll-bar { position: absolute; inset: 0 auto 0 0; background: var(--brand-soft); transition: width .8s ease; z-index: 0; }
.poll-opt > span:not(.poll-bar) { position: relative; z-index: 1; }
.poll-opt.mine { border-color: var(--brand); font-weight: 600; }
.poll-pct { font-weight: 700; }
.poll-foot { font-size: 12.5px; color: var(--text-2); margin: 10px 0 0; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 14px; }
.stats div { background: var(--bg-alt); border-radius: 10px; padding: 10px; }
.stats dt { font-size: 12px; color: var(--text-2); }
.stats dd { margin: 2px 0 0; font-size: 22px; font-weight: 800; }
.stats sup { font-size: 12px; color: var(--text-2); }
.twitch-cta {
  display: flex; align-items: center; gap: 10px; justify-content: center; text-align: center;
  background: var(--twitch); color: #fff; font-weight: 700; padding: 11px 14px; border-radius: 999px; font-size: 14px;
  text-decoration: none !important;
}
.twitch-cta:hover { filter: brightness(1.1); }
.twitch-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff4d4d; flex: none; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.site-footer { font-size: 12.5px; color: var(--text-2); padding: 0 4px 24px; }
.site-footer p { margin: 0 0 8px; }

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav { display: none; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(2, 6, 23, .6);
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative; width: min(440px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; animation: pop .18s ease;
}
.modal-close { position: absolute; top: 10px; right: 10px; }
.modal h2 { margin: 0 34px 6px 0; font-size: 20px; }
.modal p { margin: 0 0 14px; color: var(--text-2); }
.modal-creator { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.pay-list { display: flex; flex-direction: column; gap: 8px; }
.pay-opt {
  display: flex; gap: 12px; align-items: center; text-align: left;
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
}
.pay-opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.pay-opt .pay-emoji { font-size: 24px; width: 32px; text-align: center; }
.pay-opt b { display: block; }
.pay-opt small { color: var(--text-2); }
.processing { text-align: center; padding: 18px 0 6px; }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%;
  border: 4px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .8s linear infinite;
}
.processing-msg { font-weight: 600; min-height: 1.5em; }
.success { text-align: center; }
.success .big { font-size: 56px; line-height: 1; margin: 6px 0 10px; }
.modal .primary {
  width: 100%; background: var(--brand); color: #fff; font-weight: 700; border-radius: 999px; padding: 12px; margin-top: 6px;
  text-transform: uppercase; letter-spacing: .4px; font-size: 14px;
}
.modal .primary:hover { background: var(--brand-strong); }
.modal .fineprint { font-size: 11.5px; margin: 12px 0 0; text-align: center; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 120; transform: translate(-50%, 30px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 110; overflow: hidden; }
.confetti span { position: absolute; top: -60px; font-size: 30px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(calc(100vh + 120px)) rotate(var(--rot, 540deg)); } }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: 88px minmax(0, 620px); }
  .sidenav { align-items: center; grid-row: 1 / span 2; }
  .rightcol { grid-column: 2; position: static; height: auto; overflow: visible; border-left: 1px solid var(--border); border-right: 1px solid var(--border); padding-bottom: 24px; }
  .logo-text, .nav-item span, .new-post span { display: none; }
  .nav-item { padding: 12px; }
  .badge { position: absolute; top: 4px; right: 2px; }
  .new-post { width: 52px; height: 52px; padding: 0; }
}
@media (max-width: 700px) {
  body { padding-bottom: 64px; }
  .app { display: block; }
  .sidenav { display: none; }
  .profile, .rightcol { border: 0; }
  .tiers { grid-template-columns: 1fr; }
  .tier-flag { top: -9px; }
  .banner { height: 140px; }
  .avatar-lg { width: 88px; height: 88px; font-size: 28px; }
  .avatar-row { margin-top: -40px; }
  .pill-btn span { display: none; }
  .pill-btn { padding: 0; width: 40px; height: 40px; justify-content: center; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    justify-content: space-around; align-items: center; height: 60px;
    background: var(--bg); border-top: 1px solid var(--border);
  }
  .bottomnav button { width: 48px; height: 48px; display: grid; place-items: center; color: var(--text-2); border-radius: 50%; }
  .bottomnav button.active { color: var(--brand); }
  .bottomnav .bottom-plus { background: var(--brand); color: #fff; }
  .toast { bottom: 80px; }
  .media-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.share-input {
  width: 100%; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-alt); color: var(--text); font: inherit; font-size: 13.5px;
}
.share-input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
