:root {
  --bg: #0a0c11;
  --bg-grid: rgba(255, 255, 255, 0.028);
  --panel: #11141c;
  --panel-2: #171b25;
  --line: #262c3b;
  --line-soft: #1c2130;
  --text: #e9ecf2;
  --muted: #8a93a8;
  --pink: #fb7299;
  --cyan: #2dd4bf;
  --yellow: #fbbf24;
  --new: #22d3ee;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 75%);
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  cursor: pointer;
  display: inline-block;
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  text-align: center;
  border-radius: 0;
  transition: border-color 0.15s, background 0.15s, filter 0.15s;
}

.btn:hover {
  border-color: #3a4256;
  background: #1c2130;
}

.btn.primary {
  background: var(--pink);
  border-color: var(--pink);
  color: #141018;
  font-weight: 700;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.accent {
  background: linear-gradient(135deg, rgba(251, 114, 153, 0.2), rgba(45, 212, 191, 0.12));
  border-color: rgba(251, 114, 153, 0.5);
  color: #ffb3c8;
}

.btn.accent:hover {
  border-color: var(--pink);
  filter: brightness(1.06);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--cyan);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  text-decoration: underline;
}

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(251, 114, 153, 0.07), transparent 75%);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 20px 22px;
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  min-width: 0;
}

.logo {
  margin: 0;
  font-family: "Consolas", "Courier New", monospace;
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 2px 2px 0 var(--pink), 4px 4px 0 rgba(0, 0, 0, 0.6);
}

.logo-mark {
  color: var(--cyan);
  text-shadow: none;
}

.tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
}

#randomBtn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.search-wrap {
  max-width: 560px;
  margin-top: 16px;
}

#search {
  width: 100%;
  padding: 11px 14px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}

#search::placeholder {
  color: #5c6478;
}

.hint {
  margin: 6px 0 0;
  color: #5c6478;
  font-size: 11px;
}

/* ---------- tags ---------- */

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 44px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-bar {
  align-items: center;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 14px 0 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-bottom: 1px solid var(--line-soft);
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.section-label {
  flex: 0 0 auto;
  margin-right: 10px;
  color: #5c6478;
  font-size: 11px;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.category-tab {
  appearance: none;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 10px 14px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.category-tab:hover {
  color: var(--text);
}

.category-tab[aria-pressed="true"] {
  color: #fff;
  border-bottom-color: var(--pink);
  font-weight: 700;
}

.category-tab-fav {
  color: #ff9ab5;
}

.category-tab-fav[aria-pressed="true"] {
  color: #fff;
}

.fav-tab-count {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  margin-left: 5px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 10px;
  font-weight: 400;
  text-align: center;
}

.tag-bar {
  display: block;
  padding: 10px 0 6px;
}

.theme-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.theme-toggle {
  appearance: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  font-family: inherit;
}

.theme-toggle:hover .section-label {
  color: var(--text);
}

.theme-caret {
  color: #5c6478;
  font-size: 11px;
}

.theme-summary {
  color: #5c6478;
  font-size: 11px;
}

.theme-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 9px;
}

.theme-tags[hidden] {
  display: none;
}

.tag {
  appearance: none;
  cursor: pointer;
  padding: 5px 10px;
  background: transparent;
  color: #7f889c;
  border: 1px solid var(--line-soft);
  border-radius: 0;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tag:hover {
  color: var(--text);
  border-color: #3a4256;
  background: var(--panel);
}

.tag[aria-pressed="true"] {
  color: var(--pink);
  border-color: rgba(251, 114, 153, 0.55);
  background: rgba(251, 114, 153, 0.08);
  font-weight: 500;
}

.tag-expand {
  appearance: none;
  cursor: pointer;
  padding: 5px 4px;
  border: 0;
  background: transparent;
  color: var(--cyan);
  font-family: inherit;
  font-size: 12px;
  white-space: nowrap;
}

.tag-expand:hover {
  text-decoration: underline;
}

.multi-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: auto;
}

.multi-btn {
  appearance: none;
  cursor: pointer;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  white-space: nowrap;
  transition: color 0.15s;
}

.multi-btn:hover {
  color: var(--text);
}

.multi-btn[aria-pressed="true"] {
  color: var(--pink);
  font-weight: 700;
}

.multi-help {
  position: absolute;
  top: -8px;
  right: -10px;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--yellow);
  color: #1a1400;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  cursor: help;
  z-index: 3;
}

.multi-pop {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: 240px;
  max-width: 80vw;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  line-height: 1.6;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}

.multi-wrap:hover .multi-pop,
.multi-wrap.open .multi-pop {
  display: block;
}

/* ---------- applied filters ---------- */

.applied-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 0 12px;
}

.applied-bar[hidden] {
  display: none;
}

.applied-label {
  color: var(--muted);
  font-size: 12px;
}

.applied-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.applied-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid rgba(251, 114, 153, 0.4);
  background: rgba(251, 114, 153, 0.08);
  color: #ffb3c8;
  font-size: 12px;
}

.applied-chip button {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

/* ---------- toolbar ---------- */

.grid-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  margin-bottom: 12px;
  background: rgba(10, 12, 17, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}

.count {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.sort-group {
  display: inline-flex;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.sort-btn {
  appearance: none;
  cursor: pointer;
  padding: 6px 12px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
}

.sort-btn + .sort-btn {
  border-left: 1px solid var(--line);
}

.sort-btn:hover {
  color: var(--text);
}

.sort-btn[aria-pressed="true"] {
  background: var(--pink);
  color: #141018;
  font-weight: 700;
}

/* ---------- grid / cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--pink);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(251, 114, 153, 0.22);
}

.card:focus-within {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #05060a;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.card-cover img,
.badges,
.card-pv {
  pointer-events: none;
}

.card-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fav-btn {
  pointer-events: auto;
}

.badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 5px;
  z-index: 1;
}

.badge {
  padding: 2px 6px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.badge.featured {
  background: var(--yellow);
  color: #1a1400;
}

.badge.new {
  background: var(--new);
  color: #04201c;
}

.fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 10%;
  min-width: 22px;
  max-width: 26px;
  aspect-ratio: 1 / 1;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.38);
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.fav-btn:hover {
  border-color: rgba(251, 114, 153, 0.45);
  background: rgba(0, 0, 0, 0.55);
}

.fav-btn.is-fav {
  border-color: rgba(251, 114, 153, 0.6);
  background: rgba(251, 114, 153, 0.12);
}

.fav-btn.is-fav:active {
  transform: scale(0.88);
}

.fav-btn .fav-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: grayscale(1) brightness(0.82);
  opacity: 0.68;
  transition: filter 0.15s, opacity 0.15s;
}

.fav-btn:hover .fav-icon {
  filter: grayscale(1) brightness(1);
  opacity: 0.92;
}

.fav-btn.is-fav .fav-icon {
  filter: drop-shadow(0 0 3px rgba(251, 114, 153, 0.55));
  opacity: 1;
}

.card-pv {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.68);
  color: var(--yellow);
  font-family: "Consolas", "Courier New", monospace;
  font-size: 11px;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  padding: 12px 13px 13px;
}

.card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.card-author {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.chip {
  padding: 0 6px;
  border: 1px solid var(--line);
  color: #9aa3b8;
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
}

.chip-cat {
  border-color: rgba(45, 212, 191, 0.32);
  color: var(--cyan);
}

.play-btn {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--pink);
  background: var(--pink);
  color: #141018;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 0.15s;
}

.play-btn:hover {
  filter: brightness(1.08);
}

/* ---------- empty / pager ---------- */

.empty {
  border: 1px dashed var(--line);
  padding: 52px 20px;
  text-align: center;
  color: var(--muted);
}

.empty p {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 16px;
}

.empty span {
  display: block;
  margin-bottom: 14px;
  font-size: 12px;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 26px;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.page-btn:hover:not(:disabled) {
  border-color: #3a4256;
  background: var(--panel-2);
}

.page-btn.active {
  background: var(--pink);
  border-color: var(--pink);
  color: #141018;
  font-weight: 700;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-ellipsis {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.modal-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  border-color: var(--pink);
}

.modal-cover {
  aspect-ratio: 16 / 9;
  background: #05060a;
  border-bottom: 1px solid var(--line);
}

.modal-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-body {
  padding: 18px;
}

.modal-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.modal-title {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.35;
}

.modal-author {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.modal-tag {
  appearance: none;
  cursor: pointer;
  padding: 3px 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: #9aa3b8;
  font-family: inherit;
  font-size: 12px;
}

.modal-tag:hover {
  border-color: var(--pink);
  color: var(--pink);
}

.modal-tag.cat {
  border-color: rgba(45, 212, 191, 0.35);
  color: var(--cyan);
}

.modal-tag.cat:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
}

.modal-meta b {
  color: var(--yellow);
  font-family: "Consolas", "Courier New", monospace;
  font-weight: 500;
}

.modal-desc {
  margin: 0 0 18px;
  color: #c7ccd8;
  font-size: 14px;
  line-height: 1.75;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-actions a.btn.primary {
  flex: 1 1 140px;
}

.modal-actions [data-modal-fav] {
  flex: 0 0 auto;
  min-width: 104px;
  text-align: center;
}

/* ---------- toast / footer ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  max-width: 90vw;
  padding: 10px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.err {
  border-color: #5a1f1f;
  color: #fca5a5;
}

.site-footer {
  border-top: 1px solid var(--line-soft);
  padding: 20px 16px;
  text-align: center;
  color: #5c6478;
  font-size: 11px;
}

.site-footer p {
  margin: 0;
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .header-inner {
    padding: 22px 14px 18px;
  }

  .header-top {
    flex-wrap: wrap;
  }

  #randomBtn {
    width: auto;
    margin-left: auto;
  }

  .container {
    padding: 0 14px 32px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }

  .category-bar {
    padding-top: 10px;
  }

  .section-label {
    margin-right: 6px;
  }

  .category-tab {
    padding: 9px 11px 11px;
    font-size: 13px;
  }

  .theme-head {
    gap: 8px;
  }

  .theme-tags {
    gap: 5px;
  }

  .grid-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .card-body {
    padding: 10px;
  }

  .card-title {
    font-size: 13px;
  }

  .modal {
    padding: 0;
  }

  .modal-box {
    max-width: none;
    max-height: 100vh;
    height: 100vh;
    border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
