:root {
  --bg: #0e0e10;
  --surface: #18181c;
  --surface-2: #222229;
  --border: #2e2e38;
  --text: #f0eee8;
  --muted: #9894a0;
  --accent: #c084fc;
  --accent-ink: #14051f;
  --ok: #4ade80;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #ecebe5;
  --border: #dddbd3;
  --text: #1a1a1e;
  --muted: #6c6974;
  --accent: #8b3fd9;
  --accent-ink: #ffffff;
  --ok: #18a050;
  --shadow: 0 10px 30px rgba(30, 20, 50, .15);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }

/* Cabecera */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand img { border-radius: 10px; flex: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand strong { font: 800 1.35rem Syne, sans-serif; letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.links a { text-decoration: none; color: var(--muted); font-weight: 500; }
.links a:hover { color: var(--accent); }
.pill {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 4px 11px; cursor: pointer; font-weight: 600; font-size: .85rem;
}
.pill:hover { border-color: var(--accent); }

main { flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; padding: 22px clamp(16px, 4vw, 40px) 40px; }

/* Controles */
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.search {
  flex: 1 1 280px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 12px;
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; padding: 11px 0; min-width: 0; }
select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; min-height: 44px; cursor: pointer;
}
.cats { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 6px; }
.cat {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: .86rem; display: inline-flex; gap: 6px; align-items: center;
}
.cat b { color: var(--muted); font-weight: 600; font-size: .78rem; }
.cat:hover { border-color: var(--accent); }
.cat[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cat[aria-pressed="true"] b { color: inherit; opacity: .75; }
.tipos { display: flex; gap: 6px; margin: 16px 0 0; }
.tipos[hidden] { display: none; }
.tipo {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 7px 16px; cursor: pointer; font-weight: 600; display: inline-flex; gap: 8px; align-items: center;
}
.tipo b { color: var(--muted); font-weight: 600; font-size: .78rem; }
.tipo:hover { border-color: var(--accent); }
.tipo[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tipo[aria-pressed="true"] b { color: inherit; opacity: .75; }
.tipos + .cats { margin-top: 12px; }
.card.gif::after {
  content: "GIF"; position: absolute; top: 8px; right: 8px; font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; pointer-events: none;
}
.status { color: var(--muted); font-size: .88rem; margin: 10px 0 14px; min-height: 1.3em; }

/* Rejilla */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  position: relative; display: block; padding: 0; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; background: var(--surface-2); cursor: zoom-in; aspect-ratio: 3 / 2;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.card:hover, .card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); outline: none; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.card img.ok { opacity: 1; }
.card .cap {
  position: absolute; inset: auto 0 0 0; padding: 22px 10px 8px; text-align: left;
  font-size: .8rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.78));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .15s;
}
.card:hover .cap, .card:focus-visible .cap { opacity: 1; }
@media (hover: none) { .card .cap { opacity: 1; } }
.more { height: 1px; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 60px 0; }

/* Visor */
.viewer {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #08080a; color: #f0eee8;
  display: none; flex-direction: column;
}
.viewer[open] { display: flex; }
.viewer::backdrop { background: transparent; }
.v-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.v-title { font: 700 1.05rem Syne, sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-meta { color: #9894a0; font-size: .82rem; white-space: nowrap; margin-right: auto; }
.icon { background: transparent; border: 0; font-size: 1.3rem; cursor: pointer; color: inherit; padding: 4px 8px; }
.v-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 0 56px; }
.v-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px;
  border: 0; border-radius: 10px; background: rgba(255,255,255,.08); color: #fff; font-size: 2rem; cursor: pointer;
}
.nav:hover { background: rgba(255,255,255,.18); }
.prev { left: 6px; } .next { right: 6px; }
.v-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 12px 16px 18px; }
.btn {
  border: 1px solid #3a3a46; background: #1d1d23; color: #f0eee8; border-radius: 10px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; font-weight: 500; font-size: .9rem;
}
.btn:hover { border-color: #c084fc; }
.btn.primary { background: #c084fc; border-color: #c084fc; color: #14051f; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 100;
  background: var(--ok); color: #06140b; padding: 9px 16px; border-radius: 10px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 18px 16px 26px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); text-align: center;
}
.foot img { border-radius: 6px; }
.foot code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }

@media (max-width: 640px) {
  .brand small { display: none; }
  .links { gap: 8px; flex-wrap: nowrap; }
  .links a { display: none; }
  .pill { padding: 4px 9px; }
  .cats { flex-wrap: nowrap; overflow-x: auto; margin: 14px -16px 4px; padding: 0 16px 6px; scrollbar-width: none; }
  .cats::-webkit-scrollbar { display: none; }
  .cat { flex: none; }
  .top { padding-top: 10px; padding-bottom: 10px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card { border-radius: 10px; }
  .v-stage { padding: 0 6px; }
  .nav { width: 36px; height: 52px; font-size: 1.6rem; background: rgba(0,0,0,.45); }
}
