:root {
  --bg: #f6f8fb;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.84);
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --t1: #0284c7;
  --t1-soft: rgba(2, 132, 199, 0.12);
  --t2: #7c3aed;
  --t2-soft: rgba(124, 58, 237, 0.11);
  --t3: #d97706;
  --t3-soft: rgba(217, 119, 6, 0.12);
  --gold-bg: #fffbeb;
  --gold-border: #fde68a;
  --gold-text: #b45309;
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.12);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 44px -12px rgba(15, 23, 42, 0.16);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-card: #111827;
  --bg-subtle: #1e293b;
  --bg-glass: rgba(11, 17, 32, 0.84);
  --border: #1f2937;
  --border-hover: #334155;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --t1: #38bdf8;
  --t1-soft: rgba(56, 189, 248, 0.15);
  --t2: #a78bfa;
  --t2-soft: rgba(167, 139, 250, 0.15);
  --t3: #fbbf24;
  --t3-soft: rgba(251, 191, 36, 0.14);
  --gold-bg: rgba(245, 158, 11, 0.1);
  --gold-border: rgba(245, 158, 11, 0.28);
  --gold-text: #fcd34d;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 28px -6px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 50px -12px rgba(0, 0, 0, 0.65);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    radial-gradient(circle at 15% 10%, rgba(37, 99, 235, 0.08), transparent 38%),
    radial-gradient(circle at 85% 5%, rgba(14, 165, 233, 0.07), transparent 34%),
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 42px 42px, 42px 42px;
  opacity: 0.45;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 72%);
}

[data-theme="dark"] .bg-grid {
  opacity: 0.22;
}

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

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
}

.brand-text h1 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-text h1 span {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-tabs {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.view-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
}

.view-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-count {
  font-size: 0.74rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.view-tab.active .tab-count {
  background: var(--primary-soft);
  color: var(--primary);
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* Main */
.main-content {
  flex: 1;
  padding-top: 24px;
  padding-bottom: 48px;
}

/* Hero */
.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px 28px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
}

.profile-pill {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.profile-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.profile-pill .sep {
  opacity: 0.4;
}

.hero-left h2 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.hero-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.93rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-box {
  text-align: left;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.18s ease;
  color: var(--text);
}

.stat-box:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.stat-value {
  display: block;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-box.accent-t1 .stat-value { color: var(--t1); }
.stat-box.accent-sim .stat-value { color: var(--green); }
.stat-box.accent-intl .stat-value { color: var(--t2); }
.stat-box.accent-ref .stat-value { color: var(--text-muted); }

.stat-label {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* View switch */
.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* Controls */
.controls-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 0.93rem;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

#search-input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.clear-btn {
  position: absolute;
  right: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.clear-btn:hover {
  background: var(--border);
  color: var(--text);
}

.filter-rows {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.pill {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.pill:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

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

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

.filter-selects select {
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.filter-selects select:focus {
  border-color: var(--primary);
}

.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 0.86rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.reset-link {
  border: none;
  background: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.84rem;
}

.reset-link:hover {
  text-decoration: underline;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
}

.comp-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.comp-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

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

.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.73rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

.badge-t1 { background: var(--t1-soft); color: var(--t1); }
.badge-t2 { background: var(--t2-soft); color: var(--t2); }
.badge-t3 { background: var(--t3-soft); color: var(--t3); }
.badge-ref { background: rgba(100, 116, 139, 0.14); color: var(--text-secondary); }
.badge-scope { background: var(--bg-subtle); color: var(--text-secondary); font-weight: 600; }
.badge-sim { background: var(--green-soft); color: var(--green); font-weight: 600; }
.badge-heavy-cost { background: rgba(239, 68, 68, 0.12); color: #dc2626; font-weight: 600; }

[data-theme="dark"] .badge-heavy-cost {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
}

.notice-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid #f59e0b;
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}

.notice-icon {
  font-size: 1.4rem;
  line-height: 1.2;
}

.notice-banner h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.notice-banner p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.rating-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--gold-bg);
  color: var(--gold-text);
  border: 1px solid var(--gold-border);
}

.card-title-block h3 {
  margin: 0;
  font-size: 1.07rem;
  line-height: 1.38;
  font-weight: 700;
  color: var(--text);
}

.card-short {
  margin: 3px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-summary {
  margin: 0;
  font-size: 0.87rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-subtle);
  font-size: 0.81rem;
}

.meta-item {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.meta-label {
  flex-shrink: 0;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 54px;
}

.meta-value {
  color: var(--text);
}

.gold-box {
  background: var(--gold-bg);
  border: 1px solid var(--gold-border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.81rem;
  color: var(--text-secondary);
}

.gold-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  font-weight: 700;
  color: var(--gold-text);
  font-size: 0.79rem;
}

.gold-box p {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tech-tag {
  font-size: 0.74rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.card-actions {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.16s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  flex: 1;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: var(--bg-subtle);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  background: var(--bg-card);
}

/* Channels View */
.channels-header {
  margin-bottom: 18px;
}

.channels-header h3 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.channels-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.channel-group {
  margin-bottom: 26px;
}

.channel-group-title {
  margin: 0 0 12px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.channel-group-title::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 4px;
  background: var(--primary);
}

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

.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.18s ease;
  box-shadow: var(--shadow-sm);
}

.channel-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.channel-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.channel-card h4 {
  margin: 0;
  font-size: 0.98rem;
  color: var(--text);
}

.channel-card p {
  margin: 0;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.channel-link-hint {
  margin-top: auto;
  padding-top: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 660px;
  max-height: 88vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.35;
}

.modal-sub {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-close {
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.95rem;
}

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

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 0.9rem;
}

.detail-section h4 {
  margin: 0 0 6px;
  font-size: 0.84rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-section p {
  margin: 0;
  color: var(--text);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  background: var(--bg-subtle);
  padding: 14px;
  border-radius: 12px;
}

.detail-cell span {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.detail-cell strong {
  font-size: 0.86rem;
  color: var(--text);
}

.modal-footer {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

/* Empty & Footer */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.empty-state h3 {
  margin: 0 0 6px;
}

.empty-state p {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  padding: 18px 0;
  font-size: 0.81rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .hero-card {
    grid-template-columns: 1fr;
    padding: 20px;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 16px;
  }
  .topbar-actions {
    justify-content: space-between;
  }
  .cards-grid {
    grid-template-columns: 1fr;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .hero-left h2 {
    font-size: 1.32rem;
  }
}
