:root {
  --bg: #101010;
  --surface: #1a1a1a;
  --surface-light: #242424;
  --text: #f2f2f2;
  --muted: #b9b9b9;
  --border: rgba(255, 255, 255, 0.11);
  --header-bg: rgba(16, 16, 16, 0.86);
  --radius: 16px;
  --gap: 16px;
  --header-height: 58px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(var(--header-height) + 16px);
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-title {
  flex: 0 0 auto;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.site-nav,
.sort-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.site-nav {
  flex: 1 1 auto;
}

.sort-controls {
  flex: 0 0 auto;
}

.nav-button {
  min-height: 38px;
  padding: 7px 11px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.nav-button:hover,
.nav-button:focus-visible,
.nav-button.active {
  background: var(--surface-light);
}

.intro {
  max-width: 1400px;
  margin: 0 auto;
  padding: 38px 16px 16px;
}

.intro h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 5vw, 4.75rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.intro p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.mosaic {
  columns: 4 260px;
  column-gap: var(--gap);
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

.tile {
  position: relative;
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 var(--gap);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
}

.tile-media {
  position: relative;
  background: #080808;
}

.tile img,
.tile video,
.tile iframe {
  display: block;
  width: 100%;
  border: 0;
}

/* Images use their natural proportions. */
.image-tile img {
  height: auto;
}

/* YouTube stays fixed at 16:9. */
.youtube-tile .tile-media {
  aspect-ratio: 16 / 9;
}

/*
  Uploaded video aspect ratios are set dynamically in script.js.

  script.js should apply:
    media.style.aspectRatio = item.aspectRatio;

  If no poster/aspectRatio exists, script.js falls back to 16 / 9.
*/
.video-tile .tile-media {
  background: #050505;
}

/* Audio defaults to square unless script.js sets a cover-specific ratio. */
.audio-tile .tile-media {
  aspect-ratio: 1 / 1;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050505;
}

.youtube-tile iframe {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Placeholder background text appears behind unloaded videos/embeds. */
.video-tile .tile-media::before,
.youtube-tile .tile-media::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  background: linear-gradient(135deg, #181818, #050505);
}

.video-tile .tile-media::before {
  content: "Video";
}

.youtube-tile .tile-media::before {
  content: "YouTube";
}

.video-tile video,
.youtube-tile iframe,
.youtube-preview {
  position: relative;
  z-index: 1;
}

.tile-caption {
  display: grid;
  gap: 4px;
  padding: 11px 12px 13px;
}

.tile-title {
  font-weight: 700;
  line-height: 1.25;
}

.tile-meta {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.play-button {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  text-align: left;
}

.play-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.play-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  transform: translate(-50%, -50%);
  color: white;
  background: rgba(0, 0, 0, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  font-size: 1.35rem;
  line-height: 1;
  pointer-events: none;
}

.audio-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.audio-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.55);
  background: linear-gradient(135deg, #222, #080808);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.audio-player-wrap {
  padding: 12px;
}

.audio-player-wrap audio {
  width: 100%;
}

.loading-message,
.error-message,
.empty-message,
.noscript-message {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
  color: var(--muted);
}

.error-message {
  color: #ffb3b3;
}

@media (max-width: 900px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .site-nav,
  .sort-controls {
    width: 100%;
  }

  .mosaic {
    columns: 2 220px;
  }
}

@media (max-width: 600px) {
  :root {
    --gap: 14px;
    --radius: 14px;
  }

  .site-header {
    padding: 8px 12px;
  }

  .nav-button {
    min-height: 42px;
    padding: 8px 12px;
  }

  .intro {
    padding: 28px 12px 12px;
  }

  .mosaic {
    columns: 1;
    padding: 12px;
  }
}