:root {
  color-scheme: light dark;
  --bg: #fff;
  --fg: #111;
  --muted: #666;
  --tile-bg: #f2f2f2;
  --accent: #0d6efd;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111;
    --fg: #eee;
    --muted: #aaa;
    --tile-bg: #1c1c1c;
  }
}

/* Grotto by Vladimir Nikolic: https://www.1001fonts.com/grotto-font.html */
@font-face {
  font-family: "Grotto";
  src: url("/fonts/Grotto.ttf");
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

/* Firefox: gradients aren't supported here, so approximate with a flat
   color from the title gradient. scrollbar-color is inherited, so
   setting it on html covers the whole page. */
html {
  scrollbar-color: #e6683c var(--tile-bg);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--tile-bg);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  border-radius: 6px;
  border: 2px solid var(--tile-bg);
}

::-webkit-scrollbar-thumb:hover {
  background: #cc2366;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(128, 128, 128, 0.25);
}

.site-header h1 {
  margin: 0;
  flex: 1;
}

/* Sized to fit the text itself (not the full flexed h1 width) so the
   gradient's stops land across the visible letters instead of mostly
   spilling out to the right of them, past the end of the short title. */
.brand-title {
  display: inline-block;
  font-family: "Grotto", system-ui, sans-serif;
  font-size: 3rem;
  line-height: 1.1;
  padding: 0.5rem 0;
  background: linear-gradient(to right, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

#sync-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: linear-gradient(to left, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

#sync-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

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

main {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

h2 {
  display: inline-block;
  font-family: "Grotto", system-ui, sans-serif;
  font-size: 2.1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 0.75rem;
  padding-bottom: 0.75rem;
}

/* Colors pulled from the title gradient's stops: reposts = start (M),
   images = middle, reels = end (a). */
#reposts-heading {
  color: #f09433;
}

#comments-heading {
  color: #e6683c;
}

#images-heading {
  color: #dc2743;
}

#reels-heading {
  color: #bc1888;
}

.tile-row {
  display: grid;
  gap: 0.75rem;
}

.tile-row--reels {
  grid-auto-flow: column;
  grid-auto-columns: min(45vw, 260px);
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.tile-row--images {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.tile {
  display: block;
  width: 100%;
  background: var(--tile-bg);
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: inherit;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.tile--reel {
  aspect-ratio: 9 / 16;
}

.tile--image {
  aspect-ratio: 1 / 1;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.carousel-dots {
  position: absolute;
  left: 50%;
  bottom: 0.5rem;
  transform: translateX(-50%);
  display: flex;
  gap: 0.3rem;
  pointer-events: none;
}

.carousel-dots i {
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.tile--link {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.75rem;
  text-decoration: none;
  color: var(--fg);
}

.tile-caption {
  font-size: 0.85rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

.tile-cta {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.lightbox[hidden] {
  display: none;
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: min(92vw, 720px);
  max-height: 90vh;
  background: var(--tile-bg);
  border-radius: 12px;
  overflow: hidden;
}

.lightbox-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 0;
}

.lightbox-media img,
.lightbox-media video {
  display: block;
  max-width: 100%;
  max-height: 75vh;
}

.lightbox-media a {
  display: flex;
  cursor: pointer;
}

.lightbox-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
}

.lightbox-play-btn[hidden] {
  display: none;
}

.lightbox-namecard {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--fg);
  border-top: 1px solid rgba(128, 128, 128, 0.25);
}

.lightbox-namecard:hover {
  background: rgba(128, 128, 128, 0.08);
}

.lightbox-account {
  font-weight: 700;
  font-size: 0.9rem;
}

.lightbox-caption {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: pre-wrap;
}

.site-footer {
  padding: 1rem 1.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid rgba(128, 128, 128, 0.25);
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: inherit;
}

.site-footer a:hover {
  color: var(--fg);
}

.tile--see-more {
  display: flex;
  align-items: center;
  justify-content: center;
}

.see-more-pill {
  padding: 0.6rem 1.25rem;
  border: none;
  background: linear-gradient(to left, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  color: #fff;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.see-more-pill:hover {
  background: linear-gradient(to right, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

.repost-controls {
  display: flex;
  gap: 0.75rem;
  margin: 0 0 1.5rem;
}

.repost-sort-btn {
  padding: 0.4rem 1.1rem;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.repost-sort-btn.is-active {
  border-color: transparent;
  background: linear-gradient(to right, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  color: #fff;
}

.repost-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.repost-grid.repost-grid--channels {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.repost-grid.repost-grid--batches {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.repost-batch-header {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--fg);
}

.repost-batch-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.repost-channel-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.repost-channel-label {
  flex: 0 0 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  color: inherit;
  text-decoration: none;
}

.repost-channel-label:hover .repost-channel-name {
  text-decoration: underline;
}

.repost-channel-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.repost-channel-name {
  font-size: 0.95rem;
  font-weight: 600;
  max-width: 96px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.repost-channel-scroll {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(38vw, 150px);
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
}

/* Channels with few posts (<= COMPACT_THRESHOLD in app.js) get a compact
   block instead of a full-width row, sized to just their own posts so
   several sit side by side on one line. */
.repost-compact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
}

.repost-compact-block {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.repost-compact-cards {
  display: flex;
  gap: 0.6rem;
}

.repost-compact-cards .repost-card {
  width: min(38vw, 150px);
  flex-shrink: 0;
}

.repost-card {
  display: block;
  aspect-ratio: 1 / 1;
  background: var(--tile-bg);
  border-radius: 8px;
  overflow: hidden;
}

.repost-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.repost-card--see-more {
  display: flex;
  align-items: center;
  justify-content: center;
}

.repost-channel-see-more-row {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}

.repost-card--link {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem;
  text-decoration: none;
  color: var(--fg);
}

.repost-channel {
  font-weight: 700;
  font-size: 0.85rem;
}

.repost-caption {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.repost-cta {
  margin-top: auto;
  font-size: 0.75rem;
  color: #f09433;
  font-weight: 600;
}

.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 640px;
}

.comment-card {
  display: flex;
  gap: 0.75rem;
}

.comment-avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.comment-body {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--tile-bg);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
}

.comment-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.comment-username {
  font-weight: 700;
  font-size: 0.9rem;
  color: inherit;
  text-decoration: none;
}

.comment-username:hover {
  text-decoration: underline;
}

.comment-date {
  font-size: 0.75rem;
  color: var(--muted);
}

.comment-text {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: var(--fg);
  overflow-wrap: break-word;
  word-break: break-word;
}

.comment-see-more-row {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}
