:root {
  --bg: #0b0f17;
  --bg-soft: #121826;
  --card: #151c2c;
  --card-hover: #1a2338;
  --border: #232c40;
  --text: #eef2fb;
  --muted: #97a2bd;
  --accent: #22c55e;
  --accent-2: #38bdf8;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #16203a 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Header */
.site-header {
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px 28px 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.chip {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

/* Feed */
main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 8px 28px 60px;
}

.feed-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 4px 14px;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--bg) 70%, transparent);
  z-index: 5;
}

.status {
  font-size: 0.82rem;
  color: var(--muted);
}

.refresh {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.refresh:hover {
  background: var(--card-hover);
}

.refresh:active {
  transform: scale(0.97);
}

/* Pinterest-style masonry via CSS columns. Column count scales with width;
   cards keep their natural height so square and landscape media both sit
   flush without cropping. */
.feed {
  column-count: 4;
  column-gap: 18px;
}

@media (max-width: 1400px) {
  .feed { column-count: 3; }
}
@media (max-width: 980px) {
  .feed { column-count: 2; }
}
@media (max-width: 620px) {
  .feed { column-count: 1; }
}

/* Card */
.card {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  margin: 0 0 18px;
  /* Clear the sticky feed header when a shared card is scrolled into view. */
  scroll-margin-top: 90px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  animation: rise 0.4s ease both;
  transition: border-color 0.2s, transform 0.2s;
}

.card:hover {
  border-color: #2f3b57;
  transform: translateY(-2px);
}

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

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #04121a;
  flex-shrink: 0;
}

.avatar.romano {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.avatar.ornstein {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
}

.who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.author {
  font-weight: 700;
  font-size: 0.95rem;
}

.handle {
  color: var(--muted);
  font-size: 0.8rem;
}

.time {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.card-text {
  margin: 0 0 14px;
  font-size: 1.02rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.card-media {
  display: block;
  margin: 0 0 14px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.card-media img {
  display: block;
  width: 100%;
  height: auto;
  /* No fixed height / cropping — respect each image's real aspect ratio
     (square, portrait, or landscape). */
}

.card-media[hidden] {
  display: none;
}

.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  color: #04121a;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  padding: 10px 18px;
  border-radius: 999px;
  transition: filter 0.15s, transform 0.1s;
}

.view-btn:hover {
  filter: brightness(1.08);
}

.view-btn:active {
  transform: scale(0.97);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 9px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, color 0.15s, border-color 0.15s;
}

.share-btn:hover {
  background: var(--card-hover);
}

.share-btn:active {
  transform: scale(0.97);
}

.share-btn.copied {
  color: #04121a;
  background: var(--accent-2);
  border-color: transparent;
}

/* Deep-linked (shared) card */
.card.highlight {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px var(--accent-2), 0 14px 40px rgba(56, 189, 248, 0.25);
  animation: highlightPulse 1.6s ease 1;
}

@keyframes highlightPulse {
  0% {
    box-shadow: 0 0 0 2px var(--accent-2), 0 0 0 12px rgba(56, 189, 248, 0.35);
  }
  100% {
    box-shadow: 0 0 0 2px var(--accent-2), 0 14px 40px rgba(56, 189, 248, 0.25);
  }
}

/* States */
.state {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}

.skeleton {
  height: 150px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--card) 30%, var(--card-hover) 50%, var(--card) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* Footer */
.site-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 50px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 480px) {
  .brand h1 {
    font-size: 1.45rem;
  }
  .card {
    padding: 16px;
  }
}
