body { padding: 16px; color: var(--text-dim); }
.count { font-size: 12px; color: var(--text-faint); }
/* Items are distributed into columns by JS in row order (1: left,
   2: middle, 3: right, 4: left, …) instead of CSS columns, which
   would fill top-to-bottom per column. */
.masonry { display: flex; gap: 10px; margin-top: 14px; align-items: flex-start; }
.masonry-col { flex: 1; min-width: 0; }
.item { background: var(--panel); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; border: 2px solid var(--border); }
.item-name { padding: 6px 10px; font-size: 11px; }
.item-name a { color: var(--text-faint-2); text-decoration: none; }
.item-name a:hover { color: #aaa; }
.media-wrap { aspect-ratio: 4/3; background: var(--panel); position: relative; overflow: hidden; }
.media-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 25%, #252525 50%, transparent 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.media-wrap.loaded { aspect-ratio: unset; }
.media-wrap.loaded::after { display: none; }
.media-wrap img, .media-wrap video { width: 100%; display: block; opacity: 0; transition: opacity .25s; }
.media-wrap.loaded img, .media-wrap.loaded video { opacity: 1; }
.tag-filter { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.tag-filter select {
  background: transparent; color: var(--text-dim); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; padding: 5px 10px; font-size: 13px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.tag-filter select:focus { outline: none; border-color: rgba(255,255,255,0.3); }
.tag-clear { color: var(--text-faint); font-size: 12px; text-decoration: none; }
.tag-clear:hover { color: #aaa; }
.search { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.search input {
  background: transparent; color: var(--text-dim); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; padding: 5px 10px; font-size: 13px; width: 240px;
  outline: none;
}
.search input:focus { border-color: rgba(255,255,255,0.3); }
.search button {
  background: transparent; color: #aaa; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; padding: 5px 10px; font-size: 13px; cursor: pointer;
}
.search button:hover { color: var(--text-dim); border-color: rgba(255,255,255,0.3); }
.empty-msg { color: var(--text-faint); margin-top: 40px; }
.audio-player { width: 100%; padding: 8px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox.hidden { display: none; }
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}
.lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(1000px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.lightbox-close:hover { background: rgba(0, 0, 0, 0.75); }
/* Fixed stage: every file gets the same box, independent of its own
   dimensions. The media is contained inside it. */
.lightbox-main {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 62vh;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  overflow: hidden;
}
.lightbox-main img,
.lightbox-main video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.lightbox-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 4px;
}
.lightbox-name {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  word-break: break-all;
}
.lightbox-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
}
.lightbox-copy:hover { color: var(--text-dim); border-color: rgba(255, 255, 255, 0.3); }
.lightbox-copy.copied { color: #6c6; border-color: #6c6; }
/* Tags read as inline #hashtags rather than pills. */
.lightbox-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  margin-bottom: 18px;
}
.tag-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--text-faint);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
}
.tag-chip::before { content: '#'; opacity: 0.45; }
.tag-chip:hover { color: #ccc; border-bottom-color: rgba(255, 255, 255, 0.3); }
.lightbox-no-tags {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-faint);
}
.lightbox-similar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.similar-thumb { position: relative; cursor: pointer; }
.similar-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid transparent;
  display: block;
}
.similar-thumb:hover img { border-color: var(--border-hover); }
.lightbox-similar-empty { grid-column: 1 / -1; color: var(--text-faint); font-size: 12px; }

/* Play badge on video thumbnails (masonry + similar grid) */
.play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  pointer-events: none;
}
.play-badge svg { margin-left: 2px; }
.similar-thumb .play-badge { width: 30px; height: 30px; }
.video-thumb a { display: block; position: relative; }

/* NSFW — Schleier über allem, was den Tag trägt.
   scale(1.06) gegen die durchsichtigen Ränder, die ein Blur sonst am Bildrand
   hinterlässt; overflow:hidden am .media-wrap schneidet den Überstand ab. */
.media-wrap.nsfw img,
.media-wrap.nsfw video,
.lightbox-main.nsfw img,
.lightbox-main.nsfw video,
.similar-thumb.nsfw img {
  filter: blur(22px);
  transform: scale(1.06);
}
.similar-thumb.nsfw img { filter: blur(10px); }
.media-wrap.nsfw .play-badge { display: none; }
.nsfw-veil {
  position: absolute;
  inset: 0;
  z-index: 3;                      /* über dem <a> und dem Play-Badge */
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  cursor: pointer;
}
.nsfw-veil:hover { background: rgba(0, 0, 0, 0.2); }
.lightbox-main { position: relative; }
.lightbox-main .nsfw-veil { font-size: 14px; border-radius: 8px; }

@media (max-width: 640px) {
  .lightbox-main { height: 48vh; }
}
