*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100dvh;
  background: #0a0a0a;
  color: #f0f0f0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body:has(.feed-container) {
  overflow: hidden;
}

/* Sticky header bar */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 16px;
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
}

.site-logo {
  font-size: 20px;
  font-weight: 700;
  color: #f0f0f0;
  letter-spacing: -0.5px;
  user-select: none;
}

.site-logo-u {
  color: #14b8a6;
}

.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  -webkit-tap-highlight-color: transparent;
}

.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: #ccc;
  border-radius: 1px;
  transition: transform 0.3s, opacity 0.3s;
}

.hamburger-btn.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger-btn.open span:nth-child(2) {
  opacity: 0;
}

.hamburger-btn.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Slide-out menu */
.slide-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 260px;
  height: 100dvh;
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 999;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  padding-top: calc(48px + env(safe-area-inset-top, 0px) + 16px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.slide-menu.open {
  transform: translateX(0);
}

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.menu-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.menu-items {
  display: flex;
  flex-direction: column;
  padding: 0 12px;
}

.menu-item {
  background: none;
  border: none;
  color: #bbb;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  padding: 14px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f0f0f0;
}

.menu-item.active {
  background: rgba(20, 184, 166, 0.12);
  color: #14b8a6;
  font-weight: 600;
}

.menu-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 8px 16px;
}

.menu-random {
  color: #14b8a6;
}

/* Feed container — snap scroll viewport */
.feed-container {
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-top: calc(48px + env(safe-area-inset-top, 0px));
  scroll-padding-top: calc(48px + env(safe-area-inset-top, 0px));
}

.feed-container::-webkit-scrollbar {
  display: none;
}

/* Individual card */
.card {
  height: calc(100dvh - 48px - env(safe-area-inset-top, 0px));
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 16px;
  overflow: hidden;
  background: #0a0a0a;
}

.card:nth-child(even) {
  background: #111;
}

/* Top bar: type pill + source + timestamp */
.card-top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-bottom: 8px;
}

/* Type badge */
.card-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #ccc;
  flex-shrink: 0;
}

.card-type-youtube { background: rgba(255, 0, 0, 0.15); color: #ff4444; }
.card-type-twitter { background: rgba(29, 155, 240, 0.15); color: #1d9bf0; }
.card-type-reddit { background: rgba(255, 69, 0, 0.15); color: #ff6533; }
.card-type-image { background: rgba(20, 184, 166, 0.15); color: #14b8a6; }
.card-type-link { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }
.card-type-audio { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.card-type-video { background: rgba(236, 72, 153, 0.15); color: #ec4899; }

/* Source text */
.card-source {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Timestamp */
.card-time {
  font-size: 12px;
  color: #888;
  margin-left: auto;
  flex-shrink: 0;
}

/* Content area */
.card-content {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
}

/* YouTube embed */
.embed-youtube {
  width: 100%;
  max-width: 600px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
}

.embed-youtube iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* YouTube Shorts embed (portrait) */
.embed-youtube-short {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 9 / 16;
  max-height: 85dvh;
  border-radius: 12px;
  overflow: hidden;
}

.embed-youtube-short iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Twitter embed */
.embed-twitter {
  width: 100%;
  max-width: 550px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}

.embed-twitter::-webkit-scrollbar {
  display: none;
}

/* Reddit embed */
.embed-reddit {
  width: 100%;
  max-width: 550px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}

.embed-reddit::-webkit-scrollbar {
  display: none;
}

/* Reddit native video embed */
.embed-reddit-video {
  width: 100%;
  max-width: 600px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.embed-reddit-video video {
  width: 100%;
  display: block;
}

/* Twitter native video embed */
.embed-twitter-video {
  width: 100%;
  max-width: 600px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.embed-twitter-video video {
  width: 100%;
  display: block;
}

/* Image embed */
.embed-image {
  width: 100%;
  max-width: 600px;
  max-height: 75dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.embed-image img {
  max-width: 100%;
  max-height: 75dvh;
  object-fit: contain;
  border-radius: 12px;
}

/* Video embed */
.embed-video {
  width: 100%;
  max-width: 600px;
  max-height: 75dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.embed-video video {
  max-width: 100%;
  max-height: 75dvh;
  border-radius: 12px;
}

/* Audio embed */
.embed-audio {
  width: 100%;
  max-width: 500px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.embed-audio .audio-icon {
  font-size: 48px;
  opacity: 0.6;
}

.embed-audio .audio-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
}

.embed-audio .audio-desc {
  font-size: 14px;
  color: #999;
  text-align: center;
  line-height: 1.4;
}

.embed-audio audio {
  width: 100%;
  max-width: 400px;
  height: 40px;
}

/* OG link preview card */
.embed-link {
  width: 100%;
  max-width: 500px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: background 0.2s;
}

.embed-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.embed-link-thumb {
  width: 100%;
  aspect-ratio: 1.91 / 1;
  object-fit: cover;
  display: block;
}

.embed-link-body {
  padding: 20px;
}

.embed-link-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.embed-link-desc {
  font-size: 14px;
  color: #999;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

.embed-link-domain {
  font-size: 12px;
  color: #666;
}

.embed-link-visit {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #ddd;
}

/* Card caption (admin's words, between embed and metadata) */
.card-caption {
  width: 100%;
  max-width: 600px;
  margin-top: 12px;
  padding-left: 12px;
  border-left: 2px solid #14b8a6;
  font-size: 15px;
  line-height: 1.4;
  color: #f0f0f0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Card metadata (title/description/subtitle below embeds) */
.card-meta {
  width: 100%;
  max-width: 600px;
  margin-top: 12px;
  text-align: left;
}

.card-meta-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta-desc {
  font-size: 13px;
  color: #888;
  margin-top: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* Voting panel — right side on mobile, bottom center on desktop */
.vote-panel {
  position: absolute;
  bottom: 80px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 3;
}

.vote-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 50%;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.vote-btn:active {
  transform: scale(0.9);
}

.vote-btn svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: #aaa;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s, fill 0.2s;
}

.vote-btn.active-like svg {
  stroke: #4ade80;
  fill: #4ade80;
}

.vote-btn.active-dislike svg {
  stroke: #f87171;
  fill: #f87171;
}

.vote-count {
  font-size: 13px;
  font-weight: 600;
  color: #aaa;
  min-width: 20px;
  text-align: center;
}

.vote-btn.active-like .vote-count {
  color: #4ade80;
}

.vote-btn.active-dislike .vote-count {
  color: #f87171;
}

/* Empty state */
.empty-state {
  height: calc(100dvh - 48px - env(safe-area-inset-top, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #666;
  gap: 12px;
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 18px;
}

/* Loading indicator */
.loading {
  padding: 40px;
  text-align: center;
  color: #666;
  font-size: 14px;
}

/* Desktop: move vote panel to bottom center, cap embed heights */
@media (min-width: 768px) {
  .embed-twitter,
  .embed-reddit {
    flex: none;
    max-height: 85dvh;
  }

  .vote-panel {
    bottom: 32px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    gap: 24px;
  }

  .vote-btn svg {
    width: 28px;
    height: 28px;
  }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .vote-panel {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }

  @media (min-width: 768px) {
    .vote-panel {
      bottom: calc(32px + env(safe-area-inset-bottom));
    }
  }
}

/* ==========================================================================
   Admin page
   ========================================================================== */

.admin-container {
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  overflow-y: auto;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 24px;
}

.admin-logo {
  font-size: 22px;
  font-weight: 700;
  color: #f0f0f0;
  text-decoration: none;
  letter-spacing: -0.5px;
}

.admin-logout {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #aaa;
  font-size: 13px;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
}

.admin-logout:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #f0f0f0;
}

.admin-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60dvh;
  gap: 20px;
}

.admin-login[hidden] {
  display: none;
}

.admin-login h2 {
  font-size: 20px;
  font-weight: 600;
  color: #ccc;
}

.admin-login form {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 360px;
}

.admin-login input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #f0f0f0;
  font-size: 15px;
  outline: none;
}

.admin-login input:focus {
  border-color: rgba(255, 255, 255, 0.25);
}

.admin-login button {
  padding: 10px 20px;
  background: #fff;
  color: #0a0a0a;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.admin-login button:hover {
  background: #e0e0e0;
}

.admin-error {
  color: #f87171;
  font-size: 13px;
  text-align: center;
}

.admin-section {
  margin-bottom: 32px;
}

.admin-section h3 {
  font-size: 15px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.admin-url-input {
  display: flex;
  gap: 8px;
}

.admin-url-input input {
  flex: 1;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #f0f0f0;
  font-size: 15px;
  outline: none;
}

.admin-url-input input:focus {
  border-color: rgba(255, 255, 255, 0.25);
}

.admin-url-input button {
  padding: 12px 24px;
  background: #4ade80;
  color: #0a0a0a;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.admin-url-input button:hover:not(:disabled) {
  background: #22c55e;
}

.admin-url-input button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.upload-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: #14b8a6;
  background: rgba(20, 184, 166, 0.05);
}

.upload-zone-text {
  color: #666;
  font-size: 14px;
}

.upload-preview {
  margin-top: 12px;
}

.upload-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  display: block;
}

.upload-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.upload-cancel {
  flex: 1;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #f0f0f0;
  font-size: 14px;
  cursor: pointer;
}

.upload-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
}

.upload-submit {
  flex: 1;
  padding: 12px;
  background: #14b8a6;
  color: #0a0a0a;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.upload-submit:hover:not(:disabled) {
  background: #0d9488;
}

.upload-submit:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.admin-preview {
  margin-top: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
}

.preview-badge {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #4ade80;
  background: rgba(74, 222, 128, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.preview-card {
  padding: 16px;
}

.preview-loading {
  color: #666;
  font-size: 13px;
  text-align: center;
  padding: 12px;
}

.preview-youtube {
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.preview-youtube img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.preview-thumb {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 12px;
  max-height: 200px;
  object-fit: cover;
}

.preview-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-desc {
  font-size: 13px;
  color: #999;
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-domain {
  font-size: 12px;
  color: #555;
}

.admin-post-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
}

.post-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.post-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.post-type-badge {
  display: inline-block;
  width: fit-content;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 6px;
}

.post-title {
  font-size: 14px;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-meta {
  font-size: 12px;
  color: #555;
}

.post-delete {
  background: none;
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: #f87171;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.post-delete:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.4);
}

.admin-empty {
  text-align: center;
  color: #555;
  font-size: 14px;
  padding: 32px;
}

.admin-caption {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #f0f0f0;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  overflow: hidden;
  box-sizing: border-box;
}

.admin-caption:focus {
  outline: none;
  border-color: #14b8a6;
}

.admin-caption::placeholder {
  color: #555;
}

.post-caption {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2px solid #14b8a6;
  padding-left: 6px;
  margin-top: 2px;
}
