:root {
  --bg: #0f1115;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #4f46e5;
  --card: #161922;
  --media-bg: #0b0d12;
}

/* Light theme */
:root.light-theme {
  --bg: #f8f9fa;
  --text: #1a1d23;
  --muted: #5f6b7a;
  --accent: #4f46e5;
  --card: #ffffff;
  --media-bg: #e9ecef;
}

* {
  box-sizing: border-box;
}
html,
body {
  /* height: 100%; */
  overflow: hidden;
}
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu,
    Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  background: transparent;
  color: var(--text);
}

/* Apply background only when theme is explicitly set */
:root.theme-set body {
  background: var(--bg);
}

#app {
  /* max-width: 1100px; */
  margin: 0 auto;
  padding: 16px;
}

.gallery {
  position: relative;
}
.status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.reconnect {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.carousel {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.viewport {
  overflow: hidden;
  width: 100%;
}
.track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  gap: 12px;
  transition: transform 300ms ease;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(44px, auto);
  cursor: pointer;
}
.media {
  position: relative;
  background: var(--media-bg);
}
.media img,
.media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  aspect-ratio: 1 / 1;
}
.caption {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.35;
  max-height: 3.2em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Simple mode - hide captions and adjust card layout */
:root.simple-mode .card {
  grid-template-rows: auto;
}

:root.simple-mode .caption {
  display: none;
}

/* Navigation */
.nav {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.6),
    rgba(118, 75, 162, 0.6)
  );
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity 150ms ease, box-shadow 150ms ease, filter 150ms ease;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  backdrop-filter: blur(8px) saturate(120%);
  opacity: 0.9;
}
.nav:hover {
  opacity: 1;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
.nav:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}
.nav:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.nav.prev {
  left: 8px;
}
.nav.next {
  right: 8px;
}

/* Responsive: show more columns on wider screens */
@media (min-width: 520px) {
  .track {
    grid-auto-columns: 50%;
  }
}
@media (min-width: 900px) {
  .track {
    grid-auto-columns: calc(33.3333% - 8px);
  }
}

/* Skeleton Loading */
@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(44px, auto);
  min-height: 0;
}

.skeleton-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(128, 128, 128, 0.15);
  position: relative;
  overflow: hidden;
}

.skeleton-media::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.08) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

.skeleton-caption {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 40px;
}

.skeleton-line {
  height: 23px;
  border-radius: 5px;
  background: rgba(128, 128, 128, 0.12);
  position: relative;
  overflow: hidden;
}

.skeleton-line::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

.skeleton-line:first-child {
  width: 85%;
}

:root.simple-mode .skeleton-card {
  grid-template-rows: auto;
}

:root.simple-mode .skeleton-caption {
  display: none;
}

/* Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
