
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat-cell {
  background: var(--bg);
  padding: 11px 14px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -0.02em;
}

.stat-value.accent-blue { color: var(--blue); }
.stat-value.accent-green { color: var(--green); }
.stat-value.accent-orange { color: var(--orange); }

.toolbar {
  position: sticky;
  top: 60px;
  z-index: 90;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-box .input {
  padding-left: 36px;
  height: 38px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 1.6px solid var(--text-muted);
  border-radius: 50%;
  pointer-events: none;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: 6px;
  height: 1.6px;
  background: var(--text-muted);
  transform: rotate(45deg);
}

.filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.filter-row .select {
  width: auto;
  min-width: 132px;
  height: 34px;
  padding: 0 30px 0 10px;
  font-size: 13px;
}

.toggle-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.toggle-group button {
  padding: 0 12px;
  height: 34px;
  border: 0;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  border-right: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}

.toggle-group button:last-child {
  border-right: 0;
}

.toggle-group button:hover {
  background: var(--bg-hover);
}

.toggle-group button.active {
  background: var(--accent);
  color: #ffffff;
  font-weight: 500;
}

.category-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}

.category-bar::-webkit-scrollbar {
  height: 4px;
}

.category-bar::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 500;
}

.chip-count {
  font-size: 11px;
  font-family: var(--mono);
  opacity: 0.7;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 12px;
}

.filter-pill button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  font-size: 14px;
}

.filter-pill button:hover {
  color: var(--red);
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 18px 0 12px;
  flex-wrap: wrap;
}

.result-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.result-count strong {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 700;
}

.repo-list {
  border-top: 1px solid var(--border);
}

.web-section {
  margin-top: 34px;
  padding-top: 24px;
  border-top: 2px solid var(--border-strong);
}

.web-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.web-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.web-list {
  display: flex;
  flex-direction: column;
}

.web-item {
  display: block;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.web-item:hover {
  background: var(--bg-subtle);
}

.web-item-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.btn-detail-strong {
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.22);
}

.btn-detail-strong:hover {
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.ai-panel {
  border: 1px solid #e3e8ef;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  padding: 16px 18px;
}

.ai-panel-head {
  margin-bottom: 12px;
}

.ai-panel-title {
  font-size: 14.5px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
}

.ai-panel-desc {
  font-size: 12.5px;
  color: #6b7280;
  line-height: 1.6;
}

.ai-panel-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ai-modal .modal-body {
  max-height: 68vh;
  overflow: auto;
}

.ai-field-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 10px;
}

.ai-model-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.ai-model-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s;
}

.ai-model-item:hover {
  border-color: #b9c6d8;
}

.ai-model-item.active {
  border-color: var(--accent);
  background: #f5f9ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09);
}

.ai-model-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  word-break: break-word;
}

.ai-model-cost {
  flex: none;
  font-size: 12px;
  color: #2563eb;
  background: #eef4ff;
  border: 1px solid #d6e4ff;
  border-radius: 999px;
  padding: 3px 10px;
}

.ai-cost-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #4b5563;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f7f9fc;
}

.ai-cost-row strong {
  color: #111827;
}

.ai-note {
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.6;
  margin-top: 12px;
}

.ai-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 18px;
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  background: #fafbfd;
}

.ai-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid #eef1f5;
}

.ai-result-model {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.ai-result-meta {
  font-size: 12.5px;
  color: #6b7280;
}

.ai-answer {
  border: 1px solid #e8ebf0;
  border-radius: 10px;
  background: #fbfcfd;
  padding: 16px 18px;
  font-size: 13.5px;
  line-height: 1.85;
  color: #1f2937;
  word-break: break-word;
}

.ai-answer h2 {
  font-size: 14.5px;
  margin: 18px 0 8px;
  padding-left: 9px;
  border-left: 3px solid var(--accent);
  color: #111827;
}

.ai-answer h2:first-child {
  margin-top: 0;
}

.ai-answer h3 {
  font-size: 13.5px;
  margin: 14px 0 6px;
  color: #111827;
}

.ai-answer p {
  margin: 0 0 10px;
}

.ai-answer ul,
.ai-answer ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.ai-answer li {
  margin-bottom: 5px;
}

.ai-answer strong {
  color: #111827;
}

.web-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.web-item-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--accent);
  word-break: break-word;
}

.web-item-host {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.web-item-snippet {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 0;
  word-break: break-word;
}

.web-item-url {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
  word-break: break-all;
}

.web-empty {
  padding: 22px 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.web-section .pagination {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.repo-card {
  display: flex;
  gap: 16px;
  padding: 18px 4px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.repo-card:hover {
  background: var(--bg-subtle);
}

.repo-main {
  flex: 1;
  min-width: 0;
}

.repo-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.repo-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--blue);
  word-break: break-all;
}

.repo-title:hover {
  text-decoration: underline;
}

.repo-owner {
  color: var(--text-muted);
  font-weight: 400;
}

.repo-desc {
  color: var(--text-secondary);
  font-size: 13.5px;
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.repo-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-muted);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.meta-num {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text-secondary);
}

.lang-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}

.repo-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  min-width: 104px;
  flex-shrink: 0;
}

.repo-rank {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.repo-tags {
  margin-top: 10px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-hover);
  color: var(--text-muted);
}

.rank-badge.top1 { background: #111111; color: #ffffff; }
.rank-badge.top2 { background: #525252; color: #ffffff; }
.rank-badge.top3 { background: #8a8a8a; color: #ffffff; }

.load-bar {
  height: 2px;
  background: transparent;
  overflow: hidden;
  position: relative;
}

.load-bar.active::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  animation: loading 1.1s ease-in-out infinite;
  transform-origin: left center;
}

@keyframes loading {
  0% { transform: translateX(-100%) scaleX(0.3); }
  50% { transform: translateX(0) scaleX(0.5); }
  100% { transform: translateX(100%) scaleX(0.3); }
}

main.container {
  padding-bottom: 40px;
}

.menu-toggle {
  display: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  padding: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
}

.menu-toggle span {
  display: block;
  width: 15px;
  height: 1.6px;
  background: var(--text);
  border-radius: 1px;
}

.m-sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 8989;
}

.m-sidebar-mask.open {
  display: block;
}

.console-btn {
  white-space: nowrap;
}

.site-header .brand-logo {
  width: auto;
  height: 34px;
  max-width: 260px;
  border-radius: 6px;
}

.site-header .brand-logo img {
  width: auto;
  height: 100%;
  max-width: 260px;
  object-fit: contain;
}

.m-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(282px, 84vw);
  height: 100%;
  background: var(--bg);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.14);
  z-index: 8990;
  transform: translateX(-102%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.m-sidebar.open {
  transform: translateX(0);
}

.m-sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.m-sidebar-head .brand-text {
  min-width: 0;
}

.m-sidebar-head .brand-logo img {
  max-height: 30px;
}

.m-sidebar-close {
  margin-left: auto;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
}

.m-sidebar-nav {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.m-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.m-sidebar-nav a:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.m-sidebar-nav a.active {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.m-nav-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ic-fire {
  border: 1.6px solid currentColor;
  border-radius: 50% 50% 50% 0;
  width: 12px;
  height: 12px;
  transform: rotate(-45deg);
}

.ic-fire::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: currentColor;
}

.ic-user::before,
.ic-user::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.ic-user::before {
  top: 0;
  width: 6px;
  height: 6px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.ic-user::after {
  bottom: 0;
  width: 13px;
  height: 6px;
  border: 1.5px solid currentColor;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
}

.ic-grid::before,
.ic-grid::after {
  content: "";
  position: absolute;
  width: 5.5px;
  height: 5.5px;
  border: 1.4px solid currentColor;
  border-radius: 1px;
  box-sizing: border-box;
}

.ic-grid::before {
  top: 0;
  left: 0;
  box-shadow: 7.5px 0 0 -1.4px currentColor, 0 7.5px 0 -1.4px currentColor,
              7.5px 7.5px 0 -1.4px currentColor;
}

.ic-grid::after {
  display: none;
}

.m-sidebar-section {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

.m-sidebar-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.m-sidebar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.m-sidebar-chips .chip {
  padding: 5px 11px;
  font-size: 12.5px;
}

@media (max-width: 900px) {
  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }

  .repo-side {
    min-width: 92px;
  }
}

@media (max-width: 720px) {

  .site-header .nav {
    display: none;
  }

  .site-header .inner {
    height: 56px;
    min-height: 56px;
    flex-wrap: nowrap;
    padding: 0 14px;
    gap: 12px;
  }

  .menu-toggle {
    display: flex;
  }

  .site-header .console-btn {
    display: none;
  }

  .site-header .brand-logo {
    height: 28px;
    max-width: 190px;
  }

  .site-header .brand-logo img {
    max-width: 190px;
  }

  .stat-cell { padding: 10px 11px; }

  .stat-value { font-size: 16px; }

  .stat-label { font-size: 11px; }

  .repo-card {
    flex-direction: column;
    gap: 10px;
    padding: 15px 2px;
  }

  .repo-side {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    gap: 8px;
  }

  .repo-side .btn { flex: 1 1 auto; }

  .repo-title { font-size: 14.5px; }

  .repo-meta {
    gap: 10px 14px;
    font-size: 12px;
  }

  .toolbar {
    position: static;
    padding: 12px 0;
  }

  .search-row { flex-wrap: wrap; }

  .search-box { min-width: 100%; order: -1; }

  .search-row .btn { flex: 1 1 auto; }

  .filter-row { gap: 8px; }

  .filter-row .select {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  .toggle-group {
    flex: 1 1 auto;
  }

  .toggle-group button {
    flex: 1;
    padding: 0 8px;
    font-size: 12.5px;
  }

  .result-head { padding: 14px 0 10px; }

  .result-count { font-size: 12.5px; }

  .pagination button {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font-size: 12.5px;
  }

  .pagination .muted { display: none; }

  .drawer-body .metric-grid,
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .container { padding: 0 12px; }

  .site-header .inner { padding: 0 12px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  .chip { padding: 4px 10px; font-size: 12.5px; }

  .repo-side { flex-wrap: wrap; }
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  margin-top: 40px;
  padding: 22px 0;
}

.footer-line {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.footer-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.footer-meta span:empty {
  display: none;
}

.announce-modal {
  max-width: 480px;
}

.announce-content {
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 720px) {
  .site-footer { margin-top: 28px; padding: 18px 0; }

  .announce-modal { width: calc(100% - 32px); }
}
