/* 浅色主题 / 响应式展厅样式 */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --primary-dark: #1d4ed8;
  --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.04);
  --shadow: 0 4px 6px -1px rgb(15 23 42 / 0.06), 0 2px 4px -1px rgb(15 23 42 / 0.04);
  --shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.08), 0 4px 6px -2px rgb(15 23 42 / 0.04);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex: none;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  width: 280px;
  max-width: 100%;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-box i {
  color: var(--muted);
  font-size: 18px;
}

.search-box input {
  border: 0;
  outline: 0;
  padding: 0;
  flex: 1;
  font-size: 14px;
  color: var(--text);
  background: transparent;
  min-width: 0;
}

.search-box input::placeholder {
  color: var(--muted);
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  margin-bottom: 12px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.filter-chip:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.chip-count {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  font-size: 11px;
  font-weight: 600;
}

.filter-chip.active .chip-count {
  background: rgba(255, 255, 255, 0.25);
}

/* Category section */
.category-section {
  margin: 28px 0 36px;
}

.category-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
  padding-left: 12px;
  border-left: 4px solid var(--primary);
}

.category-name {
  font-size: 18px;
  font-weight: 700;
}

.category-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* Grid */
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.site-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
}

.site-card:hover,
.site-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  outline: none;
  border-color: #cbd5e1;
}

.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #eef2f7;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s;
}

.site-card:hover .thumb-wrap img {
  transform: scale(1.03);
}

.card-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.45);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.site-card:hover .card-overlay {
  opacity: 1;
}

.card-body {
  padding: 15px;
}

.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.channel-badge,
.category-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.channel-badge.ch-blue     { color: #1e40af; background: #dbeafe; }
.channel-badge.ch-indigo   { color: #3730a3; background: #e0e7ff; }
.channel-badge.ch-gray     { color: #334155; background: #f1f5f9; }
.channel-badge.ch-orange   { color: #9a3412; background: #ffedd5; }
.channel-badge.ch-purple   { color: #6b21a8; background: #f3e8ff; }
.channel-badge.ch-teal     { color: #115e59; background: #ccfbf1; }
.channel-badge.ch-green    { color: #166534; background: #dcfce7; }
.channel-badge.ch-rose     { color: #9f1239; background: #ffe4e6; }
.channel-badge.ch-cyan     { color: #0e7490; background: #cffafe; }
.channel-badge.ch-amber    { color: #92400e; background: #fef3c7; }

.category-badge {
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--border);
}

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

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

.open-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.open-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Header actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

/* 排序切换按钮 */
.sort-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  user-select: none;
}

.sort-toggle:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.sort-toggle.active {
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  border-color: transparent;
  color: #fff;
}

.sort-toggle.active .ti {
  color: #fff;
}

/* 榜单排名徽标 */
.rank-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

/* 评分控件 */
.rating {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.rating-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 22px;
}

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

.rating-score {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.rating-score.rated {
  color: var(--primary-dark);
}

.rating-clear {
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.rating-clear:hover {
  background: #f1f5f9;
  color: #ef4444;
}

.rating-scale {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rating-btn {
  flex: 1 1 auto;
  min-width: 22px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}

.rating-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-light);
}

.rating-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* Viewer */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
}

.viewer[aria-hidden="false"] {
  display: block;
}

.viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.viewer-frame {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.viewer-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.viewer-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.viewer-info h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 999px;
  flex: none;
}

.viewer-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.icon-btn i {
  font-size: 20px;
}

/* Viewer 内评分 */
.viewer-rating {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.viewer-rating .rating {
  margin: 0;
  padding: 0;
  border: 0;
}

.viewer-rating .rating-head {
  margin-bottom: 0;
  min-height: auto;
}

.viewer-rating .rating-scale {
  flex-wrap: wrap;
  gap: 4px;
}

.viewer-rating .rating-btn {
  min-width: 20px;
  padding: 3px 0;
  font-size: 11px;
}

.viewer-rating .rating-clear {
  width: 22px;
  height: 22px;
  font-size: 14px;
}

.viewer-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #f1f5f9;
}

.viewer-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

body.viewer-open {
  overflow: hidden;
}

/* Footer */
.site-footer {
  margin-top: 40px;
  padding: 22px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Responsive */
@media (max-width: 720px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
  }

  .header-actions {
    width: 100%;
  }

  .sort-toggle {
    width: 100%;
    justify-content: center;
  }

  .search-box {
    width: 100%;
  }

  .filter-bar {
    gap: 8px;
  }

  .filter-chip {
    padding: 6px 10px;
    font-size: 12px;
  }

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

  .viewer-header {
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .viewer-info {
    width: 100%;
    order: 1;
  }

  .viewer-info h2 {
    font-size: 14px;
  }

  .viewer-controls {
    margin-left: auto;
  }
}

@media (min-width: 1200px) {
  .site-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}
