:root {
  --bg: #0f0f12;
  --bg-card: #1a1a1f;
  --text: #f2f2f2;
  --text-dim: #9a9aa2;
  --accent: #ff5a3c;
  --border: #2a2a30;
}

* { box-sizing: border-box; }

html {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  max-width: 100vw;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.site-title {
  display: block;
  text-decoration: none;
  font-family: "Lobster", "Playfair Display", Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.2rem, 13vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-align: center;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 0;
  background: linear-gradient(90deg, #ff3b3b, #ff9d3b, #f4ff3b, #3bff6a, #3bd1ff, #a63bff, #ff3b3b);
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 6s linear infinite;
}

@keyframes shimmer {
  to { background-position: 300% center; }
}

header {
  padding: 16px 24px 24px;
  max-width: 1100px;
  margin: 0 auto;
}

header p {
  margin: 0;
}

header p a {
  color: var(--text-dim);
  text-decoration: none;
}

header p a:hover {
  color: var(--text);
}

nav {
  display: flex;
  justify-content: center;
  gap: 36px;
  flex-wrap: wrap;
  padding: 10px 0 16px;
}

nav button {
  background: none;
  border: none;
  color: var(--text);
  padding: 4px 0;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

nav button:hover {
  color: var(--accent);
}

nav button.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.grid {
  columns: 3 260px;
  column-gap: 6px;
}

.card {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin-bottom: 6px;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.card .media {
  width: 100%;
  height: auto;
  display: block;
}

.card .meta {
  padding: 6px 2px 0;
}

.card .caption {
  font-size: 0.9rem;
  margin: 0 0 4px;
}

.card .date {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 0;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 4px;
}

.media-wrap {
  position: relative;
}

.stack-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.72rem;
  padding: 3px 7px;
  border-radius: 999px;
}

.empty {
  color: var(--text-dim);
  padding: 40px 16px;
  text-align: center;
  max-width: 100%;
  word-break: break-word;
}

.empty a {
  color: var(--accent);
}

.spinner-wrap {
  display: flex;
  justify-content: center;
  padding: 60px 0;
  column-span: all;
}

.spinner-wrap.small {
  padding: 20px 0;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.load-more-wrap {
  column-span: all;
  display: flex;
  justify-content: center;
  padding: 20px 0 10px;
}

.load-more-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 28px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.load-more-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.load-more-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  overflow: hidden;
}

.lightbox.open {
  display: flex;
}

#lightbox-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

.lightbox img,
.lightbox video {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 8px;
}

.lightbox img {
  cursor: zoom-in;
  will-change: transform;
  user-select: none;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-nav.prev { left: 0; }
.lightbox-nav.next { right: 0; }

.lightbox-counter {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
}

.lightbox .close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 24px;
}

.add-link {
  margin-left: auto;
  background: var(--accent);
  color: #fff !important;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
}

/* Upload page */
.upload-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 420px;
  margin: 0 auto 48px;
}

.upload-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.upload-form input,
.upload-form select,
.upload-form textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

.upload-form button {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 14px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.upload-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

.status {
  min-height: 20px;
  font-size: 0.9rem;
  margin: 0;
}

.status.error { color: #ff6b6b; }
.status.success { color: #4ade80; }
.status.info { color: var(--text-dim); }

.my-uploads {
  max-width: 640px;
  margin: 0 auto;
}

.my-uploads h2 {
  font-size: 1.1rem;
  color: var(--text-dim);
  font-weight: 500;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.row-caption {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-date {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.del-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.del-btn:hover {
  border-color: #ff6b6b;
  color: #ff6b6b;
}

.edit-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.edit-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.edit-panel {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.edit-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 0 4px;
}

.edit-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.edit-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
}

.edit-thumb img,
.edit-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.edit-thumb.marked-remove {
  border-color: #ff6b6b;
  opacity: 0.4;
}

.edit-single-preview {
  width: 100%;
}

.edit-single-preview video {
  width: 100%;
  border-radius: 8px;
  display: block;
}

.edit-single-preview audio {
  width: 100%;
  display: block;
}

.edit-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.edit-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.edit-label input,
.edit-label textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

.edit-actions {
  display: flex;
  gap: 8px;
}

.edit-save,
.edit-cancel {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.edit-save {
  background: var(--accent);
  border: none;
  color: #fff;
}

.edit-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.edit-status {
  min-height: 16px;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0;
}

.dim {
  color: var(--text-dim);
}

.hidden {
  display: none !important;
}

/* Отдельная страница-лента (Текст, Мерчуха) — не грид */
.feed-container {
  display: block;
}

/* Текстовые посты — отдельно от общей ленты */
.text-feed {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.text-post {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.text-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.text-body {
  font-size: 0.92rem;
  white-space: pre-wrap;
  margin: 0 0 8px;
}

/* Мерчуха — цена в мини-карточке общей ленты */
.price {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 6px;
}

.merch-buy-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.merch-buy-link:hover {
  text-decoration: underline;
}

/* Текстовая карточка в общей ленте "трешпост" — нужен визуальный якорь без картинки */
.text-card {
  background: var(--bg-card);
  border-radius: 8px;
}

.text-card .meta {
  padding: 14px;
}

.audio-card {
  background: var(--bg-card);
  border-radius: 8px;
}

.audio-card .meta {
  padding: 14px;
}

.audio-player {
  width: 100%;
  margin-top: 8px;
  display: block;
}

/* Контакт */
.contact-page {
  max-width: 420px;
  margin: 40px auto 0;
  text-align: center;
}

.contact-call-btn {
  display: block;
  width: 100%;
  background: #39ff14;
  color: #e21b1b;
  border: none;
  text-decoration: none;
  padding: 26px 14px;
  border-radius: 4px;
  font-size: 1.7rem;
  font-family: "Lobster", "Playfair Display", Georgia, serif;
  cursor: pointer;
  margin-bottom: 16px;
}

.contact-call-btn:active {
  transform: translateY(1px);
}

/* Мерч — отдельные посты друг под другом */
.merch-list {
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.merch-list-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  animation: merchBob 2.2s ease-in-out infinite;
}

.merch-list-card:hover,
.merch-list-card:active {
  animation-play-state: paused;
  transform: scale(1.05);
  transition: transform 0.2s ease;
}

.merch-list-card.poke {
  animation: merchPoke 0.5s cubic-bezier(0.36, 1.6, 0.4, 1);
}

/* Скачущая анимация карточек мерча */
@keyframes merchBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.03); }
}

@keyframes merchPoke {
  0% { transform: scale(1); }
  40% { transform: scale(1.22) rotate(-3deg); }
  70% { transform: scale(0.94) rotate(2deg); }
  100% { transform: scale(1) rotate(0); }
}

.merch-grid-media-wrap {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  margin-bottom: 10px;
}

.merch-grid-media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.merch-grid-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.merch-grid-price {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  margin: 0 0 10px;
}

.merch-learn-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.merch-learn-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Страница товара — открывается по "Узнать больше" */
.merch-detail {
  width: min(420px, 100%);
  margin: 0 auto;
  text-align: center;
}

.merch-back-btn {
  display: block;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 0 0 16px;
  cursor: pointer;
  text-align: left;
}

.merch-back-btn:hover {
  color: var(--accent);
}

.merch-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  margin: 0 auto 16px;
}

.merch-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.merch-image-count {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
}

.merch-share-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.merch-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.merch-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0 0 10px;
  white-space: pre-wrap;
}

.merch-price {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 16px;
}

/* Кнопка "Купить" — шутка про "аут оф сток" */
.merch-buy-btn {
  display: block;
  width: 100%;
  text-align: center;
  background: #39ff14;
  color: #e21b1b;
  border: none;
  padding: 22px 14px;
  border-radius: 4px;
  font-size: 1.5rem;
  font-weight: 400;
  font-family: "Lobster", "Playfair Display", Georgia, serif;
  cursor: pointer;
}

.merch-buy-btn:active {
  transform: translateY(1px);
}

.merch-buy-btn.sold-out {
  cursor: default;
  font-size: 1.25rem;
  line-height: 1.25;
}

.merch-buy-btn.loading {
  cursor: default;
  animation: merchLoading 0.7s ease-in-out infinite;
}

@keyframes merchLoading {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.merch-soldout-note {
  margin: 10px 0 0;
  color: #fff;
  font-style: italic;
  font-size: 0.85rem;
  font-family: "Lobster", "Playfair Display", Georgia, serif;
}
