:root {
  --bg: #040404;
  --bg-soft: #0a0a0a;
  --panel: rgba(20, 20, 20, 0.7);
  --panel-strong: rgba(18, 18, 18, 0.92);
  --line: #27272a;
  --line-soft: rgba(255, 204, 51, 0.22);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #facc15;
  --accent-sub: #eab308;
  --accent-dark: #9a6f00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1200px 720px at 20% -10%, #1b1204 0%, var(--bg-soft) 35%, var(--bg) 75%),
    linear-gradient(160deg, rgba(250, 204, 21, 0.06), transparent 40%, rgba(0, 0, 0, 0.35));
  font-family: 'SF Pro Text', 'SF Pro Display', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  text-rendering: optimizeLegibility;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: rgba(6, 6, 6, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar__brand {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.11em;
  color: var(--accent);
  text-transform: uppercase;
}

.topbar__subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
}

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

.topbar__nav a {
  color: #f4f4f5;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}

.topbar__nav a.active,
.topbar__nav a:hover {
  color: #0f0f0f;
  border-color: var(--accent);
  background: var(--accent);
}

.feed-page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 16px 28px;
}

.desktop-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.rail {
  position: sticky;
  top: 70px;
}

.rail-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
}

.rail-card h2 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.rail-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  font-size: 12px;
  color: #0c0a00;
  background: var(--accent);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
}

.signal-list,
.trend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--text);
}

.signal-list li,
.trend-list li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
}

.signal-list li:last-child,
.trend-list li:last-child {
  border-bottom: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
}

.stat__value {
  color: var(--accent);
  font-weight: 800;
  font-size: 20px;
}

.stat__label {
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}

.timeline {
  min-width: 0;
}

.feed-controls {
  position: sticky;
  top: 70px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: linear-gradient(140deg, rgba(23, 22, 22, 0.75), rgba(12, 10, 10, 0.9));
  backdrop-filter: blur(8px);
}

.feed-controls h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.01em;
}

.feed-controls .meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

#refresh-btn {
  border: 1px solid #4b5563;
  background: linear-gradient(180deg, #19191f, #0f0f14);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

#refresh-btn:hover {
  border-color: var(--accent);
  color: #151105;
  background: var(--accent);
  box-shadow: 0 10px 18px rgba(250, 204, 21, 0.32);
}

.error {
  border: 1px solid #a16207;
  color: #fde68a;
  background: rgba(250, 204, 21, 0.08);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
}

.feed-root {
  display: grid;
  gap: 12px;
}

.post {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-soft);
  border-radius: 16px;
  padding: 14px;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.post:hover {
  border-color: rgba(250, 204, 21, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.post__head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.post__title {
  min-width: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: baseline;
}

.post__channel {
  font-weight: 700;
  color: #fef3c7;
}

.post__time {
  color: var(--muted);
  font-size: 12px;
}

.post__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.post__stats {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.post__body {
  white-space: pre-wrap;
  line-height: 1.45;
  margin: 8px 0 10px;
  color: #ffffff;
  font-size: 14px;
}

.post__body a,
.overlay-body a {
  color: #fef3c7;
}

.post__summary {
  margin-top: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  color: #fde68a;
  font-size: 13px;
  white-space: pre-wrap;
}

.post__reactions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reaction-pill {
  border: 1px solid rgba(250, 204, 21, 0.2);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.9);
  font-size: 12px;
}

.media-grid {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.media-grid--single {
  grid-template-columns: minmax(0, 1fr);
}

.media-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.media-grid--multi {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.media-tile {
  border-radius: 12px;
  border: 1px solid #2b2b2f;
  overflow: hidden;
  background: #000;
  display: block;
  cursor: pointer;
  position: relative;
  min-height: 120px;
  aspect-ratio: 16 / 10;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.media-tile img,
.media-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-tile--video {
  background: #09090b;
}

.media-tile--video video {
  opacity: 0.82;
}

.media-tile--audio,
.media-tile--file {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 140px;
  padding: 10px;
}

.media-tile .media-label {
  position: absolute;
  inset: 8px auto auto 8px;
  background: rgba(0,0,0,.62);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  color: #fff;
}

.media-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #93c5fd;
  font-size: 13px;
  width: 100%;
  min-height: 92px;
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 6px;
  text-align: center;
}

.media-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(250, 204, 21, 0.45);
}

.media-preview {
  position: absolute;
  inset: auto 8px 8px auto;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 16px;
  pointer-events: none;
}

.media-empty {
  color: var(--muted);
  font-size: 13px;
}

.md-body code,
.post__body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 0.92em;
}

.post__body .md-strike {
  text-decoration: line-through;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(2, 6, 23, 0.93);
  display: grid;
  place-items: center;
  padding: 24px;
}

.overlay[hidden] {
  display: none;
}

.overlay-close {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 40;
  width: 36px;
  height: 36px;
  border: 1px solid #4b5563;
  border-radius: 999px;
  color: #f9fafb;
  background: rgba(30, 41, 59, 0.95);
  cursor: pointer;
  touch-action: none;
  pointer-events: auto;
}

#overlay-content {
  max-width: min(95vw, 1200px);
  max-height: 94vh;
  width: min(100%, 1200px);
  display: grid;
  place-items: center;
  gap: 0;
}

#overlay-content .overlay-inner {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateX(0);
  transition: opacity 150ms ease, transform 180ms ease;
}

.overlay-frame {
  position: relative;
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 12px;
  align-items: start;
}

.overlay-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: 1px solid #4b5563;
  border-radius: 999px;
  color: #f9fafb;
  background: rgba(15, 23, 42, 0.9);
  cursor: pointer;
  z-index: 6;
  pointer-events: auto;
}

.overlay-nav:hover:not(:disabled) {
  border-color: var(--accent);
}

.overlay-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.overlay-nav--prev {
  left: 14px;
}

.overlay-nav--next {
  right: 14px;
}

.overlay-counter {
  font-size: 12px;
  color: var(--muted);
}

.overlay-thumbs {
  max-width: min(95vw, 860px);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  justify-content: flex-start;
  padding: 2px 4px 4px;
  scrollbar-width: thin;
}

.overlay-thumb {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1220;
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
}

.overlay-thumb:hover {
  border-color: #64748b;
}

.overlay-thumb--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.25);
}

.overlay-thumb--image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.overlay-file-link {
  color: #93c5fd;
  border: 1px solid #2f2f3a;
  border-radius: 12px;
  background: #0b1220;
  padding: 10px 14px;
  text-decoration: none;
}

.overlay-file-link:hover {
  border-color: var(--accent);
  color: #fff;
}

.overlay-media {
  max-width: 100%;
  max-height: 94vh;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
  object-fit: contain;
  user-select: none;
}

.overlay-image-error {
  width: min(95vw, 860px);
  min-height: 120px;
  border: 1px solid #334155;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.75);
  color: #f8fafc;
  padding: 24px;
  text-align: center;
}

.overlay-transition-prev {
  transform: translateX(12px);
}

.overlay-transition-next {
  transform: translateX(-12px);
}

.overlay-visible {
  opacity: 1;
  transform: translateX(0);
}

.overlay-media--video {
  width: min(95vw, 1080px);
  height: auto;
  max-height: 84vh;
}

.overlay-media--audio {
  width: min(720px, 85vw);
}

.overlay-media--image {
  width: min(95vw, 1080px);
  max-height: 84vh;
  height: auto;
  object-fit: contain;
}

.overlay-caption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.mobile-tabbar {
  display: none;
}

@media (max-width: 1100px) {
  .desktop-shell {
    grid-template-columns: 1fr;
  }

  .timeline {
    order: 1;
  }

  .rail {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .rail--left,
  .rail--right {
    order: 2;
  }
}

@media (max-width: 700px) {
  body {
    background: linear-gradient(160deg, #0f0f0f, var(--bg) 65%);
  }

  .feed-page {
    padding: 8px 8px 86px;
  }

  .topbar {
    padding: 10px 10px;
  }

  .topbar__subtitle {
    width: 100%;
    margin-left: 0;
  }

  .feed-controls {
    position: static;
    top: 0;
    flex-direction: column;
    align-items: stretch;
  }

  .feed-controls h1 {
    font-size: 23px;
  }

  .post__head {
    gap: 8px;
    flex-direction: column;
    align-items: flex-start;
  }

  .media-grid--multi,
  .media-grid--two,
  .media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rail {
    grid-template-columns: 1fr;
  }

  .rail-card {
    display: none;
  }

  .rail .stats-grid {
    display: grid;
  }

  .rail-card:first-child,
  .rail-card:last-child {
    display: none;
  }

  .mobile-tabbar {
    position: fixed;
    inset: auto 8px 8px 8px;
    z-index: 18;
    display: flex;
    background: rgba(10, 10, 10, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 8px;
    gap: 6px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .mobile-tab {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: #ddd;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 12px;
    padding: 8px 6px;
  }

  .mobile-tab:active,
  .mobile-tab:hover {
    border-color: rgba(250, 204, 21, 0.5);
    color: #fff;
    background: rgba(250, 204, 21, 0.2);
  }

  .overlay-nav {
    display: none;
  }
}

@media (max-width: 700px) and (min-width: 520px) {
  .signal-list li,
  .trend-list li {
    font-size: 14px;
  }
}

@media (hover: none), (pointer: coarse) {
  .overlay-nav {
    display: none;
  }
}

@media (min-width: 701px) {
  .overlay-close {
    width: 40px;
    height: 40px;
  }
}
