:root {
  --bg: #0f1115;
  --bg-deep: #0a0c10;
  --ink: #f4f6fa;
  --muted: #9aa3b2;
  --line: #2a303c;
  --card: #171b22;
  --accent: #ff4d1a;
  --accent-ink: #fff7f2;
  --pin: #e60023;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --header-h: 68px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  overscroll-behavior-y: auto;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 8% -5%, rgba(255, 77, 26, 0.18) 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(64, 140, 255, 0.12) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  font-family: "Figtree", system-ui, sans-serif;
}

/* Post pages: allow vertical scroll only — horizontal swipe = next/prev */
.post-page,
.post-stage,
.post-media,
.post-image {
  touch-action: pan-y;
  overscroll-behavior-x: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.site-main {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 4rem;
  flex: 1;
}

body {
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  background: rgba(15, 17, 21, 0.88);
  border-bottom: 1px solid rgba(42, 48, 60, 0.9);
}

.header-inner {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.plus-btn {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(228, 87, 46, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.plus-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 14px 28px rgba(228, 87, 46, 0.42);
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}

.text-btn:hover {
  color: var(--ink);
}

/* Pages */
.page h1,
.home-hero h1 {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 0.2rem 0 0.6rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.lede {
  margin: 0;
  max-width: 36rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.home-hero {
  margin-bottom: 1.75rem;
  animation: rise 0.5s ease both;
}

.narrow-page {
  width: min(480px, 100%);
  margin: 0 auto;
}

/* Feed */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

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

.meme-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateY(8px);
  opacity: 0;
  animation: rise 0.45s ease forwards;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.meme-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 22px 44px rgba(23, 20, 15, 0.12);
}

.meme-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #0a0c10;
}

.meme-card-title {
  display: block;
  padding: 0.85rem 0.95rem 1rem;
  font-weight: 650;
  font-size: 0.95rem;
  line-height: 1.3;
}

.feed-sentinel {
  height: 1px;
}

.feed-status,
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}

.empty-state h2 {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

/* Post page */
.post-page {
  width: min(1200px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.post-title {
  text-align: center;
  width: 100%;
  margin-bottom: 1rem;
}

.post-page .ad-wrap,
.post-page .ad-placeholder {
  width: min(728px, 100%);
}

.post-stage {
  position: relative;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: start;
  justify-items: center;
  gap: 0.65rem;
  width: 100%;
  margin: 0.75rem 0 1rem;
}

.post-media {
  position: relative;
  width: 100%;
  min-width: 0;
  border-radius: calc(var(--radius) + 4px);
  overflow: visible;
  background: #0a0c10;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  justify-self: stretch;
}

.post-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
  object-position: top center;
  image-rendering: auto;
  background: #0a0c10;
  cursor: zoom-in;
}

.pin-wrap {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 5;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.92);
  overscroll-behavior: contain;
}

.lightbox[hidden] {
  display: none !important;
}

.lightbox-image {
  max-width: min(100vw, 1200px);
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-close {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1001;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 700px) {
  .site-main {
    width: 100%;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }

  .post-page {
    width: 100%;
  }

  .post-stage {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 0.2rem;
    width: 100%;
  }

  .post-nav {
    width: 48px;
    min-height: 72px;
    padding: 0.35rem 0.1rem;
    border-radius: 10px;
  }

  .post-nav em {
    display: block;
    font-size: 0.62rem;
  }

  .post-nav span {
    font-size: 1.45rem;
  }

  .post-media {
    border-radius: 10px;
  }

  .post-image {
    max-height: none;
    width: 100%;
  }

  .pin-wrap {
    top: 0.5rem;
    left: 0.5rem;
  }

  .pinterest-btn {
    padding: 0.45rem 0.7rem;
    font-size: 0.8rem;
  }

  .feed-grid {
    gap: 0.65rem;
  }

  .meme-card-title {
    padding: 0.65rem 0.7rem 0.75rem;
    font-size: 0.88rem;
  }

  .lightbox {
    padding: 0;
  }

  .lightbox-image {
    max-width: 100vw;
    max-height: 100vh;
    width: 100%;
    border-radius: 0;
  }

  .lightbox-close {
    top: 0.5rem;
    right: 0.5rem;
    width: 44px;
    height: 44px;
  }
}

.pinterest-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: var(--pin);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(230, 0, 35, 0.35);
  transition: transform 0.15s ease;
}

.pinterest-btn:hover {
  transform: scale(1.04);
}

.post-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  width: 64px;
  min-height: 96px;
  padding: 0.5rem 0.25rem;
  border-radius: 16px;
  background: rgba(23, 27, 34, 0.95);
  border: 1px solid var(--line);
  transition: background 0.15s ease;
  position: sticky;
  top: calc(50vh - 48px);
  z-index: 6;
}

.post-nav span {
  font-size: 1.8rem;
  line-height: 1;
}

.post-nav em {
  font-style: normal;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.post-nav:hover:not(.is-disabled) {
  background: #1f2530;
}

.post-nav.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.post-meta {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  width: 100%;
}

/* Ads */
.ad-wrap,
.ad-placeholder {
  margin: 0.85rem 0;
  min-height: 90px;
  border-radius: 14px;
  overflow: hidden;
}

.ad-placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  background: rgba(23, 27, 34, 0.7);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem;
}

/* Forms */
.auth-form,
.upload-form {
  margin-top: 1.5rem;
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-form label,
.upload-form label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.auth-form input,
.upload-form input[type="text"],
.upload-form input:not([type="file"]) {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  background: #0f131a;
  color: var(--ink);
}

.upload-form input[type="file"] {
  font: inherit;
}

.upload-preview {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 12px;
  background: #111;
}

.primary-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.2rem;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

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

.primary-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.form-error {
  margin: 0;
  color: #b42318;
  font-size: 0.9rem;
}

.site-footer {
  border-top: 1px solid rgba(42, 48, 60, 0.9);
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
