:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f3f4f6;
  --primary: #000000;
  --primary-dark: #1f2937;
  --primary-pale: #f3f4f6;
  --accent: #dc2626;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  width: 1em;
  height: 1em;
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  backdrop-filter: none;
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
}

.brand-mark,
.modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: #000;
  color: #fff;
  box-shadow: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
}

.brand-name {
  font-size: 17px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  position: relative;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  fill: none;
  stroke: #9ca3af;
  stroke-width: 2;
}

.search-box input {
  width: 192px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #f3f4f6;
  padding: 0 12px 0 38px;
  color: var(--text);
  outline: 0;
}

.search-box input:focus {
  border-color: transparent;
  background: #fff;
  box-shadow: 0 0 0 2px #d1d5db;
}

.icon-button {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #f3f4f6;
  color: #4b5563;
  transition: background 0.18s ease;
}

.icon-button:hover {
  background: #e5e7eb;
}

.icon-button.primary {
  background: #000;
  color: #fff;
}

.icon-button.primary:hover {
  background: #1f2937;
}

.icon-button svg,
.modal-close svg,
.nav-chip svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.primary svg {
  fill: currentColor;
  stroke: 0;
}

.category-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  border-top: 0;
  background: #f9fafb;
  padding: 8px;
}

.category-scroll {
  display: flex;
  flex: 1;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.nav-chip {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #fff;
  color: #374151;
  padding: 7px 16px;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.nav-chip svg {
  width: 16px;
  height: 16px;
}

.nav-chip:hover,
.nav-chip.active {
  border-color: #000;
  background: #000;
  color: #fff;
}

.nav-divider {
  width: 1px;
  height: 22px;
  flex: 0 0 auto;
  background: #d1d5db;
}

.content {
  width: 100%;
  padding: 112px 8px 48px;
}

.welcome-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  border: 0;
  border-radius: 5px;
  background: linear-gradient(90deg, #111827, #000);
  color: #fff;
  padding: 18px 16px;
  box-shadow: none;
}

.welcome-banner p {
  margin: 0 0 4px;
  font-weight: 800;
}

.welcome-banner span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.star-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.star-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.view-stack {
  display: grid;
  gap: 20px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 24px;
  font-size: 18px;
}

.rank-list {
  display: grid;
  gap: 12px;
}

.rank-item,
.bar-row,
.category-stat {
  display: flex;
  align-items: center;
  gap: 16px;
}

.rank-item {
  width: 100%;
  border: 0;
  border-radius: 5px;
  background: transparent;
  padding: 12px;
  color: inherit;
  text-align: left;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.rank-item:hover {
  background: #f9fafb;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
  transform: scale(1.01);
}

.rank-num {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: #e5e7eb;
  color: #4b5563;
  font-weight: 800;
}

.rank-item:nth-child(1) .rank-num {
  background: #000;
  color: #fff;
}

.rank-item:nth-child(2) .rank-num {
  background: #374151;
  color: #fff;
}

.rank-item:nth-child(3) .rank-num {
  background: #6b7280;
  color: #fff;
}

.rank-copy {
  min-width: 0;
  flex: 1;
}

.rank-copy h3,
.plugin-card h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.rank-copy p,
.plugin-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.rank-copy p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-count {
  min-width: 78px;
  color: var(--accent);
  text-align: right;
  font-weight: 800;
}

.download-count small {
  display: block;
  color: #8ca2ba;
  font-size: 12px;
  font-weight: 400;
}

.bar-list {
  display: grid;
  gap: 16px;
}

.bar-label {
  width: 78px;
  flex: 0 0 auto;
  color: #46607d;
}

.bar-track {
  display: block;
  height: 32px;
  flex: 1;
  overflow: hidden;
  border-radius: 5px;
  background: #f3f4f6;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: #000;
}

.category-stat {
  width: 100%;
  border: 0;
  border-radius: 5px;
  background: transparent;
  padding: 8px;
  color: inherit;
  text-align: left;
}

.category-stat:hover {
  background: #f9fafb;
}

.bar-row strong,
.category-stat strong {
  width: 86px;
  text-align: right;
}

.plugin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.plugin-card {
  display: flex;
  min-height: 212px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  padding: 20px;
  box-shadow: none;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.plugin-card:hover {
  border-color: #9ca3af;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.1);
  transform: translateY(-3px);
}

.plugin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.tag,
.detail-tag {
  display: inline-flex;
  border-radius: 5px;
  background: #f3f4f6;
  color: #4b5563;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.plugin-card p {
  display: -webkit-box;
  min-height: 46px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.plugin-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: auto 0 16px;
  color: var(--muted);
  font-size: 12px;
}

.plugin-meta .hot {
  color: var(--accent);
  font-weight: 800;
}

.card-action,
.plugin-detail a {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 5px;
  background: #000;
  color: #fff;
  font-weight: 700;
}

.card-action:hover,
.plugin-detail a:hover {
  background: #1f2937;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 72px 16px;
  color: #8ca2ba;
  text-align: center;
}

.modal[hidden],
[hidden] {
  display: none !important;
}

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

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

.modal-card {
  position: relative;
  width: min(390px, 100%);
  border: 0;
  border-radius: 5px;
  background: #fff;
  padding: 26px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: #9ca3af;
}

.modal-icon {
  width: 50px;
  height: 50px;
  margin: 0 auto 16px;
  font-size: 20px;
  font-weight: 800;
}

.modal-card h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.modal-card p {
  margin: 0 0 8px;
  color: var(--muted);
}

.modal-card strong {
  display: block;
  color: #111827;
  font-size: 18px;
}

.plugin-detail {
  text-align: left;
}

.plugin-detail .detail-tag {
  margin-bottom: 12px;
}

.install-guide {
  margin: 16px 0;
  border-radius: 5px;
  background: #f3f4f6;
  padding: 12px;
}

.install-guide span {
  display: block;
  margin-bottom: 6px;
  color: #6b7280;
  font-size: 12px;
}

.install-guide p {
  margin: 0;
  color: #111827;
  font-weight: 600;
}

.detail-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.plugin-detail a {
  width: 100%;
}

mark {
  border-radius: 3px;
  background: #fff4bf;
  color: var(--text);
  padding: 0 2px;
}

@media (max-width: 1100px) {
  .plugin-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .plugin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .brand-name {
    display: none;
  }

  .search-box input {
    width: min(48vw, 176px);
  }

  .content {
    padding-top: 118px;
  }

  .panel {
    padding: 18px;
  }

  .rank-item,
  .bar-row,
  .category-stat {
    gap: 10px;
  }

  .bar-label {
    width: 68px;
  }

  .bar-row strong,
  .category-stat strong {
    width: 60px;
  }

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