:root {
  --bg-primary: #f4f5f7;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-modal: #ffffff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #aaaaaa;
  --border-color: #eaecf0;
  --border-light: #f0f0f0;
  --card-hover-shadow: 0 4px 14px rgba(0,0,0,0.06);
  --search-bg: #ffffff;
  --nav-hover-bg: #f5f5f5;
  --accent: #e94560;
  --accent-light: #fef0f0;
  --header-bg: #ffffff;
  --feature-card-bg: #ffffff;
  --input-bg: #ffffff;
}

[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-sidebar: #16213e;
  --bg-card: #2a2a3e;
  --bg-modal: #2a2a3e;
  --text-primary: #e0e0e0;
  --text-secondary: #aaaaaa;
  --text-muted: #777777;
  --border-color: #3a3a4e;
  --border-light: #3a3a4e;
  --card-hover-shadow: 0 4px 14px rgba(0,0,0,0.3);
  --search-bg: #2a2a3e;
  --nav-hover-bg: #2a2a3e;
  --accent-light: #2a1a2e;
  --header-bg: #16213e;
  --feature-card-bg: #2a2a3e;
  --input-bg: #3a3a4e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ═══ Top Header ═══ */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  transition: background 0.3s;
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 20px;
  gap: 24px;
}
.header-left {
  flex-shrink: 0;
}
.header-logo {
  font-size: 1.1em;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}
.header-nav {
  display: flex;
  gap: 2px;
  flex: 1;
}
.header-nav .nav-item {
  padding: 6px 14px;
  font-size: 0.82em;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}
.header-nav .nav-item:hover {
  background: var(--nav-hover-bg);
  color: var(--accent);
}
.header-nav .nav-item.active {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-light);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.header-lang-select {
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.78em;
  cursor: pointer;
  transition: border-color 0.15s;
  outline: none;
}
.header-lang-select:hover { border-color: var(--accent); }

/* ═══ App Layout: sidebar + main ═══ */
.app-layout {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  min-height: calc(100vh - 56px);
}

/* ═══ Sidebar ═══ */
.sidebar {
  width: 210px;
  min-width: 210px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  transition: background 0.3s;
}

.sidebar-section {
  padding: 12px 10px 4px;
}
.sidebar-section-title {
  font-size: 0.72em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 6px 6px;
}

.sidebar-nav { }
.nav-btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.85em;
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
  transition: all 0.12s;
  margin-bottom: 1px;
  text-decoration: none;
}
.nav-btn:hover { background: var(--nav-hover-bg); color: var(--accent); }
.nav-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-nav-item {
  display: block;
  width: 100%;
  padding: 7px 12px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.82em;
  cursor: pointer;
  border-radius: 6px;
  text-align: left;
  transition: all 0.12s;
  margin-bottom: 1px;
  text-decoration: none;
}
.sidebar-nav-item:hover { background: var(--nav-hover-bg); color: var(--accent); }

.page-link {
  padding: 6px 12px;
  font-size: 0.8em;
  color: var(--text-muted);
}
.page-link:hover { color: var(--accent); }

.sidebar-footer-links {
  padding: 0 10px 8px;
}

.submit-nav-btn { color: #4caf50; }
.submit-nav-btn:hover { background: #e8f5e9; color: #388e3c; }

.sidebar-divider {
  height: 1px;
  background: var(--border-light);
  margin: 6px 6px;
}

.sidebar-admin-link {
  display: block;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 0.82em;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.12s;
}
.sidebar-admin-link:hover { color: var(--accent); background: var(--nav-hover-bg); }

.sidebar-stats {
  padding: 12px 16px;
  margin-top: auto;
  border-top: 1px solid var(--border-light);
  font-size: 0.74em;
  color: var(--text-muted);
}
.sidebar-stats-count { font-weight: 600; color: var(--text-secondary); }

/* ═══ Main Content ═══ */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 16px 24px 0;
}

/* ═══ Search + Engine Switcher ═══ */
.search-engine-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.search-bar {
  flex: 1;
  min-width: 200px;
  max-width: 480px;
}
.search-bar input {
  width: 100%;
  padding: 9px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.85em;
  outline: none;
  transition: all 0.2s;
  background: var(--input-bg);
  color: var(--text-primary);
}
.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233,69,96,0.08);
}

.engine-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.engine-label {
  font-size: 0.74em;
  color: var(--text-muted);
  margin-right: 2px;
}
.engine-btn {
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.74em;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.engine-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.engine-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ═══ Feature Cards ═══ */
.feature-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
.feature-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--feature-card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.feature-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(233,69,96,0.08);
}
.feature-icon {
  font-size: 1.8em;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: 12px;
}
.feature-title {
  font-size: 0.88em;
  font-weight: 600;
  color: var(--text-primary);
}
.feature-desc {
  font-size: 0.74em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ═══ Promo / Ad Section ═══ */
.promo-section {
  margin-bottom: 10px;
}
.promo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--feature-card-bg);
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  padding: 10px 16px;
}
.promo-tag {
  font-size: 0.68em;
  padding: 2px 8px;
  border-radius: 4px;
  background: #ffedd5;
  color: #c2410c;
  font-weight: 500;
}
.promo-text {
  font-size: 0.82em;
  color: var(--text-muted);
}
.promo-link {
  margin-left: auto;
  font-size: 0.78em;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

/* ═══ Ad Banner ═══ */
.ad-banner {
  margin-bottom: 10px;
}
.ad-banner a {
  text-decoration: none;
  display: block;
}
.ad-banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #fbbf24;
  border-radius: 10px;
  padding: 12px 18px;
  transition: all 0.2s;
}
.ad-banner-inner:hover {
  box-shadow: 0 2px 10px rgba(251,191,36,0.3);
  transform: translateY(-1px);
}
.ad-tag {
  font-size: 0.65em;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f59e0b;
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
}
.ad-banner-inner span:not(.ad-tag) {
  flex: 1;
  font-size: 0.85em;
  color: #92400e;
  font-weight: 500;
}
.ad-arrow {
  font-size: 0.85em;
  color: #92400e;
  flex-shrink: 0;
}

[data-theme="dark"] .ad-banner-inner {
  background: linear-gradient(135deg, #422006, #78350f);
  border-color: #92400e;
}
[data-theme="dark"] .ad-banner-inner span:not(.ad-tag),
[data-theme="dark"] .ad-arrow {
  color: #fde68a;
}

/* ═══ Subcategory tabs ═══ */
.sub-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

/* ═══ Sort tabs (hot/new) ═══ */
.sort-tabs {
  display: flex; gap: 8px; margin-bottom: 10px;
}
.sort-tab {
  padding: 5px 16px; border-radius: 18px; border: 1px solid var(--border-color);
  background: var(--bg-card); color: var(--text-muted);
  font-size: 0.8em; cursor: pointer; transition: all 0.15s;
}
.sort-tab:hover { border-color: var(--accent); color: var(--accent); }
.sort-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Card external link */
.card-actions { display: flex; gap: 4px; margin-top: 2px; }
.card-ext-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-primary); font-size: 0.7em;
  text-decoration: none; transition: all 0.15s;
}
.card-ext-link:hover { background: var(--accent-light); }
.sub-tab {
  padding: 3px 10px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.75em;
  cursor: pointer;
  transition: all 0.12s;
}
.sub-tab:hover { border-color: var(--accent); color: var(--accent); }
.sub-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sub-tab .count {
  display: inline-block;
  background: var(--border-light);
  border-radius: 8px;
  padding: 0 5px;
  font-size: 0.78em;
  margin-left: 2px;
  color: var(--text-muted);
}
.sub-tab.active .count { background: rgba(255,255,255,0.25); color: #fff; }

/* Stats bar */
.stats-bar {
  padding: 0 0 8px;
  font-size: 0.72em;
  color: var(--text-muted);
}

/* Container */
.page-content { }

/* Category sections */
.category-section { margin-bottom: 20px; }
.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  margin-bottom: 8px;
}
.category-title {
  font-size: 0.95em;
  font-weight: 700;
  color: var(--text-primary);
  position: relative;
  padding-left: 12px;
}
.category-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.15em;
  bottom: 0.15em;
  width: 3px;
  border-radius: 2px;
}
.category-section[data-subcat="chatbot"] .category-title::before { background: #4FC3F7; }
.category-section[data-subcat="platform"] .category-title::before { background: #7C4DFF; }
.category-section[data-subcat="image"] .category-title::before { background: #F06292; }
.category-section[data-subcat="coding"] .category-title::before { background: #4CAF50; }
.category-section[data-subcat="writing"] .category-title::before { background: #FF8A65; }
.category-section[data-subcat="video"] .category-title::before { background: #E53935; }
.category-section[data-subcat="search"] .category-title::before { background: #26C6DA; }
.category-section[data-subcat="audio"] .category-title::before { background: #AB47BC; }
.category-section[data-subcat="learning"] .category-title::before { background: #FFB300; }
.category-section[data-subcat="office"] .category-title::before { background: #00ACC1; }
.category-section[data-subcat="agent"] .category-title::before { background: #EC407A; }
.category-section[data-subcat="prompt"] .category-title::before { background: #8D6E63; }
.category-section[data-subcat="design"] .category-title::before { background: #FF6F00; }
.category-section[data-subcat="content_detection"] .category-title::before { background: #EF5350; }

.category-more {
  font-size: 0.76em;
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 10px;
  border-radius: 4px;
  transition: all 0.12s;
}
.category-more:hover { color: var(--accent); background: var(--accent-light); }

/* Grid inside category */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

/* Card - ai-bot.cn style */
.card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  padding: 10px 13px;
  text-decoration: none;
  transition: all 0.2s;
}
.card:hover {
  border-color: #d0d0d0;
  box-shadow: var(--card-hover-shadow);
  transform: translateY(-1px);
}

.card-icon-wrap {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  flex-shrink: 0;
}
.card-icon-wrap img { width: 100%; height: 100%; object-fit: cover; }

.card-body-text {
  flex: 1;
  min-width: 0;
}
.card-name {
  font-size: 0.83em;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}
.card-company {
  font-size: 0.68em;
  color: var(--text-muted);
  line-height: 1.3;
}
.card-desc {
  font-size: 0.72em;
  color: var(--text-muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty state */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.empty-state .emoji { font-size: 3em; margin-bottom: 12px; }

/* Placeholder pages */
.placeholder-page {
  text-align: center;
  padding: 80px 20px;
}
.placeholder-icon {
  font-size: 3.5em;
  margin-bottom: 16px;
}
.placeholder-page h2 {
  font-size: 1.3em;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.placeholder-page p {
  font-size: 0.9em;
  color: var(--text-muted);
}

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-modal);
  border-radius: 14px; padding: 28px;
  max-width: 520px; width: 100%; max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.modal h2 { margin-bottom: 16px; font-size: 1.1em; color: var(--text-primary); }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.8em; color: var(--text-secondary); margin-bottom: 4px; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 8px 12px; border: 1.5px solid var(--border-color); border-radius: 6px;
  font-size: 0.88em; outline: none; transition: border-color 0.15s;
  background: var(--input-bg);
  color: var(--text-primary);
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.btn-primary {
  padding: 8px 20px; border-radius: 6px; border: none;
  font-size: 0.88em; cursor: pointer; font-weight: 500;
  background: var(--accent); color: #fff; transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-secondary {
  padding: 8px 20px; border-radius: 6px; border: 1px solid var(--border-color);
  font-size: 0.88em; cursor: pointer; font-weight: 500;
  background: var(--bg-card); color: var(--text-secondary); transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.74em;
  border-top: 1px solid var(--border-light);
  margin-top: 10px;
}

/* ═══ Hamburger Menu Button ═══ */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3em;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--text-primary);
  border-radius: 6px;
}
.menu-toggle:hover { background: var(--nav-hover-bg); }

/* ═══ Responsive ═══ */
@media (max-width: 900px) {
  .header-inner { padding: 0 10px; gap: 4px; }
  .header-nav { overflow-x: auto; gap: 0; -webkit-overflow-scrolling: touch; }
  .header-nav .nav-item { padding: 6px 8px; font-size: 0.72em; flex-shrink: 0; }
  .header-logo { font-size: 1em; }
  .feature-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Header - fix alignment for mobile */
  .header-inner { padding: 0 8px; gap: 6px; height: 50px; }
  .header-left { display: flex; align-items: center; gap: 6px; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; padding: 0; font-size: 1.3em; height: 36px; width: 36px; line-height: 1; }
  .header-logo { font-size: 0.92em; white-space: nowrap; }
  .header-nav { overflow-x: auto; flex: 0 1 auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .header-nav::-webkit-scrollbar { display: none; }
  .header-nav .nav-item { padding: 4px 6px; font-size: 0.65em; flex-shrink: 0; display: inline-flex; align-items: center; }
  .header-right { margin-left: auto; flex-shrink: 0; }
  .header-lang-select { font-size: 0.68em; padding: 2px 6px; }

  /* Layout: sidebar becomes overlay */
  .app-layout { position: relative; }
  .sidebar {
    position: fixed;
    top: 56px;
    left: -280px;
    width: 280px;
    min-width: 280px;
    height: calc(100vh - 56px);
    z-index: 150;
    border-right: 1px solid var(--border-color);
    border-bottom: none;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    transition: left 0.25s ease;
    flex-direction: column;
    padding: 0;
  }
  .sidebar.open { left: 0; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 56px; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 149;
  }
  .sidebar-backdrop.show { display: block; }

  .sidebar-section { display: block; }
  .sidebar-nav { display: block; width: auto; overflow: visible; }
  .nav-btn, .sidebar-nav-item {
    width: 100%;
    padding: 8px 14px;
    font-size: 0.82em;
    white-space: normal;
    margin-bottom: 1px;
  }
  .sidebar-nav-item { padding: 7px 14px; }
  .sidebar-divider { display: block; }
  .sidebar-admin-link { display: block; }
  .sidebar-stats { display: block; }
  .sidebar-footer-links { padding: 0 10px 8px; }
  .page-link { padding: 6px 14px; }

  .main-content { padding: 10px; }

  /* Search */
  .search-engine-row { flex-direction: column; align-items: stretch; }
  .search-bar { max-width: 100%; }
  .engine-switcher { justify-content: flex-start; flex-wrap: wrap; }
  .engine-btn { padding: 3px 8px; font-size: 0.7em; }

  /* Feature cards */
  .feature-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .feature-card { padding: 10px 12px; gap: 10px; }
  .feature-icon { width: 40px; height: 40px; font-size: 1.4em; }
  .feature-title { font-size: 0.82em; }
  .feature-desc { font-size: 0.7em; }

  /* Subcategory tabs */
  .sub-tab-bar { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .sub-tab { flex-shrink: 0; font-size: 0.72em; }

  /* Grid & Cards - larger touch targets */
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .card {
    padding: 12px 14px;
    gap: 12px;
    border-radius: 12px;
  }
  .card-icon-wrap { width: 44px; height: 44px; min-width: 44px; }
  .card-name { font-size: 0.88em; }
  .card-desc { display: none; } /* hide desc on mobile */

  /* Modal */
  .modal { padding: 20px; max-width: 100%; border-radius: 14px 14px 0 0; margin-top: auto; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .form-row { flex-direction: column; gap: 0; }

  /* Promo */
  .promo-item { flex-wrap: wrap; }
  .promo-text { font-size: 0.78em; }

  /* Placeholder pages */
  .placeholder-page { padding: 40px 16px; }
  .placeholder-icon { font-size: 2.5em; }

  footer { padding: 14px; font-size: 0.7em; }
}

@media (max-width: 480px) {
  .header-nav { gap: 0; }
  .header-nav .nav-item { padding: 5px 5px; font-size: 0.63em; }
  .feature-cards { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card { padding: 10px 12px; }
  .card-icon-wrap { width: 38px; height: 38px; min-width: 38px; }
  .card-name { font-size: 0.82em; }
  .engine-btn { font-size: 0.65em; padding: 2px 6px; }
  .engine-label { display: none; }
  .modal { padding: 16px; }
}
