
.cat-filters {
  position: sticky; top: var(--nav-h); z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--divider);
  padding: 12px 0 11px; margin-bottom: 4px;
}
.cat-filters-in { display: flex; align-items: center; gap: 12px; }
.cat-tags-scroll {
  flex: 1; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; -ms-overflow-style: none;

  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}
.cat-tags-scroll::-webkit-scrollbar { display: none; }
.cat-tags { display: flex; gap: 8px; width: max-content; padding: 2px 30px 2px 2px; }

.tag {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 7px 15px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  background: var(--surface); color: var(--ink); border: 1px solid var(--divider);
  font-size: .88rem; font-weight: 500; line-height: 1.35;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.tag:hover { border-color: var(--brand); color: var(--link); }
.tag.active {
  background: var(--brand); color: #fff; border-color: var(--brand);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 40%, transparent);
}


.cat-count { font-size: .86rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .cat-filters-in > .cat-count { display: none; } }

.cat-sort { position: relative; flex-shrink: 0; }
.cat-filter-btn { position: relative; gap: 9px; padding: 8px 16px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.cat-filter-btn svg { width: 15px; height: 15px; fill: currentColor; }
.cat-filter-btn[aria-expanded='true'] { background: var(--brand); color: #fff; border-color: var(--brand); }

.cat-filter-n {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.cat-filter-btn[aria-expanded='true'] .cat-filter-n { background: #fff; color: var(--brand); }
.cat-filter-n[hidden] { display: none; }

.cat-drop {
  position: absolute; right: 0; top: calc(100% + 10px); width: min(400px, 92vw);
  background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-lg);
  box-shadow: 0 18px 44px var(--shadow); padding: 6px 0 0;
  max-height: min(70vh, 560px); overflow-y: auto; overscroll-behavior: contain;
}
.cat-drop[hidden] { display: none; }


.cat-group { border-bottom: 1px solid var(--divider); }
.cat-group:last-of-type { border-bottom: 0; }
.cat-group summary {
  list-style: none; cursor: pointer; padding: 13px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-weight: 600; font-size: .95rem;
}
.cat-group summary::-webkit-details-marker { display: none; }
.cat-group summary::after {
  content: ''; width: 8px; height: 8px; flex: 0 0 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s ease;
}
.cat-group[open] summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.cat-group summary:hover { color: var(--link); }
.cat-group-tags { display: flex; flex-wrap: wrap; gap: 7px; padding: 2px 18px 16px; }
.cat-group-tags .tag { font-size: .82rem; padding: 6px 12px; }

.cat-drop-foot {
  position: sticky; bottom: 0; background: var(--surface);
  border-top: 1px solid var(--divider); padding: 12px 18px 14px;
}
.cat-chosen { font-size: .82rem; color: var(--muted); margin-bottom: 10px; }
.cat-chosen b { color: var(--ink); font-weight: 600; }
.cat-drop-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cat-drop-actions .btn { padding: 7px 14px; font-size: .87rem; }

/* Grid */
.cat-grid {
  display: grid; gap: 20px; padding: 22px 0 10px;
  --cols: var(--cols-max, 4);
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}
@media (max-width: 1100px) { .cat-grid { --cols: var(--cols-mid, 3); gap: 16px; } }
@media (max-width: 760px) { .cat-grid { --cols: var(--cols-min, 2); gap: 12px; } }

.card { display: flex; flex-direction: column; }
.card-media {
  position: relative; width: 100%; aspect-ratio: var(--ratio, 1 / 1);
  background: var(--surface); border-radius: var(--radius-lg); overflow: hidden;
  cursor: zoom-in; border: 1px solid var(--divider);
  box-shadow: 0 1px 3px var(--shadow-soft);
  transition: transform .28s ease, box-shadow .28s ease, border-color .2s ease;
}
.card-media::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, .06), transparent 45%);
  opacity: 0; transition: opacity .28s ease;
}
.card-media:hover { transform: translateY(-4px); box-shadow: 0 12px 26px var(--shadow); border-color: var(--brand); }
.card-media:hover::after { opacity: 1; }
.card-media img {
  width: 100%; height: 100%; object-fit: contain;
  opacity: 0; transition: opacity .28s ease;
}
.card-media img.ready { opacity: 1; }
.card-badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  background: var(--danger); color: var(--badge-ink);
  font-size: .7rem; font-weight: 600; letter-spacing: .02em;
  padding: 3px 10px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.card-cap {
  margin-top: 9px; font-size: .86rem; color: var(--muted); text-align: center;
  transition: color .2s ease;
}
.card:hover .card-cap { color: var(--ink); }

.cat-empty { padding: 70px 20px; text-align: center; color: var(--muted); grid-column: 1 / -1; }
.cat-empty .btn { margin-top: 16px; }

/* Lightbox */
.lb {
  position: fixed; inset: 0; z-index: 200;
  display: grid; grid-template-rows: auto 1fr auto;
  background: rgba(8, 10, 14, .93);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.lb[hidden] { display: none; }


.lb-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 10px 16px; padding: 14px 64px; color: #fff;
}
.lb-bar[hidden] { display: none; }
.lb-msg { font-size: clamp(.95rem, 2vw, 1.3rem); font-weight: 600; }
.lb-bar .btn { padding: 8px 18px; }

.lb-close {
  position: fixed; top: 12px; right: 14px; z-index: 3;
  background: rgba(255, 255, 255, .12); color: #fff;
  border: 1px solid rgba(255, 255, 255, .3); width: 40px; height: 40px; border-radius: 50%;
  cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s;
}
.lb-close:hover { background: var(--danger); border-color: var(--danger); transform: rotate(90deg); }

.lb-stage { position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 16px; }
.lb-img {
  max-width: min(94vw, 1100px); max-height: 100%; width: auto; height: auto;
  object-fit: contain; border-radius: 10px; background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid rgba(255, 255, 255, .28);
  width: 48px; height: 48px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem; line-height: 1;
  transition: background .15s, border-color .15s;
}
.lb-nav:hover { background: var(--brand); border-color: var(--brand); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
@media (max-width: 600px) { .lb-nav { width: 38px; height: 38px; font-size: 1.2rem; } .lb-prev { left: 6px; } .lb-next { right: 6px; } }

.lb-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 6px 18px; padding: 14px 20px 18px; color: #fff; text-align: center;
}
.lb-title { font-size: 1.05rem; font-weight: 600; }
.lb-counter { color: rgba(255, 255, 255, .7); font-size: .85rem; font-variant-numeric: tabular-nums; }
.lb-size { color: #7ec2ff; font-size: .92rem; width: 100%; }
.lb-size:hover { color: var(--accent); }
.lb-size[hidden] { display: none; }
