:root {
  --bg: #141514;
  --panel: #1a1b1a;
  --input: #111211;
  --line: #272927;
  --line-strong: #2c2e2c;
  --text: #f4f4f0;
  --muted: #a9aaa5;
  --soft: #d2d4ce;
  --accent-color: #9d6cff;
  --accent-surface: rgba(157, 108, 255, 0.18);
  --accent-surface-strong: rgba(157, 108, 255, 0.34);
  --pill-bg: rgba(157, 108, 255, 0.18);
  --pill-text: #ede7ff;
  --pill-strong-bg: rgba(157, 108, 255, 0.34);
  --pill-strong-text: #ffffff;
  --pill-border: rgba(157, 108, 255, 0.24);
  --code: #7aa876;
  --clay: #bd7658;
  --link: #8dbde0;
  --star: #ffd76a;
  --icon-bg: #fff;
}

body[data-theme="light"] {
  --bg: #f4efe4;
  --panel: #fffaf0;
  --input: #fffdf8;
  --line: #ddd5c8;
  --line-strong: #cfc5b6;
  --text: #1d2523;
  --muted: #6b716c;
  --soft: #323a36;
  --accent-color: #7c5cff;
  --accent-surface: rgba(124, 92, 255, 0.14);
  --accent-surface-strong: rgba(124, 92, 255, 0.24);
  --pill-bg: rgba(124, 92, 255, 0.14);
  --pill-text: #314037;
  --pill-strong-bg: rgba(124, 92, 255, 0.24);
  --pill-strong-text: #1c2621;
  --pill-border: rgba(124, 92, 255, 0.22);
  --code: #4f6f52;
  --link: #315a70;
  --star: #b47c00;
  --icon-bg: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Avenir Next, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem clamp(1rem, 3vw, 2rem) 0.55rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--clay);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  max-width: none;
  margin: 0;
  font-size: clamp(1.15rem, 1.8vw, 1.75rem);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.lede {
  max-width: 42rem;
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.stats {
  align-self: end;
  display: flex;
  gap: 0.5rem;
  min-width: 0;
}

.stats div,
.toolbar,
.detail {
  border: 1px solid var(--line);
  background: var(--panel);
}

.stats div {
  min-width: 4.6rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.7rem;
}

.stats strong {
  display: block;
  font-size: 0.86rem;
}

.stats span {
  color: var(--muted);
  font-size: 0.62rem;
}

.theme-toggle {
  min-width: 4.3rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.45rem 0.55rem;
  color: var(--text);
  background: var(--panel);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.accent-toggle {
  min-width: 4.4rem;
  border: 1px solid var(--pill-border);
  border-radius: 0.7rem;
  padding: 0.45rem 0.6rem;
  color: var(--text);
  background: linear-gradient(135deg, var(--accent-surface-strong), var(--accent-surface));
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.accent-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

main {
  max-width: 1920px;
  margin: 0 auto;
  padding: 0.55rem clamp(1rem, 3vw, 2rem) 2rem;
}

.toolbar {
  position: sticky;
  top: 0.4rem;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 0.45rem;
  border-radius: 1rem;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 0.75rem;
  padding: 0.62rem 0.75rem;
  color: var(--text);
  background: var(--input);
  font: inherit;
}

.layout {
  display: grid;
  grid-template-columns: minmax(16rem, 18rem) minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
  margin-top: 0.55rem;
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(21rem, 24rem);
  gap: 0.9rem;
  align-items: start;
  min-width: 0;
}

.filters {
  position: sticky;
  top: 3.95rem;
  z-index: 2;
  max-height: calc(100vh - 4.55rem);
  overflow: auto;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
}

.filters-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.8rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.filters-eyebrow {
  color: var(--clay);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.filter-summary {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.clear-filters {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  color: var(--muted);
  background: var(--input);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
}

.clear-filters:hover {
  color: var(--text);
  border-color: var(--pill-border);
  background: var(--accent-surface);
}

.filter-group + .filter-group {
  margin-top: 0.95rem;
}

.filter-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.filter-group-toggle {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.filter-group-toggle:hover .filter-title {
  color: var(--accent-color);
}

.filter-group-note {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.filter-group.collapsed .filter-list,
.filter-group.collapsed .expand-filters {
  display: none;
}

.filter-title {
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.filter-meta {
  color: var(--muted);
  font-size: 0.62rem;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.expand-filters {
  margin-top: 0.45rem;
  width: 100%;
  border: 1px dashed var(--line-strong);
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.expand-filters:hover {
  color: var(--text);
  border-color: var(--pill-border);
  background: var(--accent-surface);
}

.filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 0.85rem;
  padding: 0.58rem 0.75rem;
  color: var(--text);
  background: var(--input);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.filter-item:hover {
  border-color: var(--pill-border);
  background: var(--accent-surface);
}

.filter-item.active {
  border-color: var(--pill-border);
  background: var(--accent-surface);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

.filter-item-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 700;
}

.filter-item-count {
  flex: none;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18.5rem, 1fr));
  gap: 0.9rem;
  min-width: 0;
  align-content: start;
}

.card {
  position: relative;
  cursor: pointer;
  width: 100%;
  min-height: 4.7rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.65rem 0;
  color: inherit;
  text-align: left;
  background: transparent;
  transition: opacity 160ms ease;
}

.card:hover,
.card.active {
  opacity: 0.78;
}

.card.bubble-open,
.card.bubble-open:hover,
.card.bubble-open.active {
  opacity: 1;
}

.card.bubble-open {
  z-index: 4;
}

.card h2 {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
}

.card p {
  margin: 0.18rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plugin-row {
  display: grid;
  grid-template-columns: 2.85rem minmax(0, 1fr) 1.8rem;
  gap: 0.65rem;
  align-items: center;
}

.plugin-copy {
  min-width: 0;
}

.favorite-button {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 1.15rem;
  cursor: pointer;
}

.favorite-button:hover,
.favorite-button.favorited,
.detail-favorite.favorited {
  color: var(--star);
}

.detail-favorite {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  color: var(--pill-text);
  background: var(--input);
  font: inherit;
  cursor: pointer;
}

.icon {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 0.65rem;
  object-fit: contain;
  background: var(--icon-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.icon.fallback {
  display: inline-grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--icon-color), #262826);
  font-size: 1.4rem;
  font-weight: 800;
}

.pillrow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  padding: 0.3rem 0.62rem;
  border: 1px solid var(--pill-border);
  color: var(--pill-text);
  background: var(--pill-bg);
  font-size: 0.76rem;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

.card .pillrow .pill:nth-child(-n + 4) {
  color: var(--pill-strong-text);
  background: var(--pill-strong-bg);
  border-color: transparent;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.card .pillrow .pill:nth-child(n + 5) {
  opacity: 0.9;
}

.detail {
  position: sticky;
  top: 3.6rem;
  max-height: calc(100vh - 4.2rem);
  overflow: auto;
  padding: 0.9rem;
  border-radius: 1rem;
}

.detail h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  letter-spacing: -0.05em;
}

.detail p,
.detail li {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.82rem;
}

.detail .summary {
  font-size: 0.9rem;
  color: var(--soft);
}

.detail a {
  color: var(--link);
}

.detail code {
  word-break: break-all;
  color: var(--code);
}

.section-title {
  margin-top: 0.9rem;
  color: var(--text);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.empty {
  margin: 0;
}

@media (max-width: 900px) {
  .hero,
  .layout,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .content {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .detail {
    position: static;
    max-height: none;
  }

  .filters {
    position: static;
    max-height: none;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1400px) {
  .content {
    grid-template-columns: 1fr;
  }

  .detail {
    position: static;
    max-height: none;
  }
}

.detail-head {
  display: grid;
  grid-template-columns: 2.8rem minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
}

.card-bubble {
  position: absolute;
  right: 0.1rem;
  top: 3.7rem;
  z-index: 5;
  width: min(100%, 26rem);
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  padding: 0.8rem 0.85rem 0.8rem;
  background: var(--panel);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

.bubble-title {
  margin-bottom: 0.35rem;
  color: var(--text);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.bubble-full-title {
  margin-top: 0.75rem;
}

.bubble-separator {
  height: 0.7rem;
}

.card-bubble p {
  margin: 0;
  color: var(--soft);
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: normal;
}

.bubble-full {
  max-height: 15rem;
  overflow: auto;
  padding-right: 0.2rem;
}

.bubble-close {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  display: grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.bubble-close:hover {
  color: var(--text);
  background: var(--accent-surface);
}
