/* ==============================================
   AI 导航 - Apple 风格 CSS（兼容主流浏览器）
   ============================================== */
:root {
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-glass-hover: rgba(255, 255, 255, 0.88);
  --bg-card: #ffffff;
  --bg-card-hover: #f5f5f7;
  --bg-input: #f5f5f7;
  --bg-badge: #f0f0f5;

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --text-inverse: #ffffff;

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-light: #e8f0fe;
  --success: #34c759;
  --warning: #ff9f0a;
  --danger: #ff3b30;
  --star: #ff9500;

  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.14);
  --border-color: rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  --header-height: 56px;
  --content-max: 1200px;
}

[data-theme="dark"] {
  --bg-primary: #1c1c1e;
  --bg-secondary: #2c2c2e;
  --bg-glass: rgba(28, 28, 30, 0.85);
  --bg-glass-hover: rgba(44, 44, 46, 0.95);
  --bg-card: #2c2c2e;
  --bg-card-hover: #3a3a3c;
  --bg-input: #3a3a3c;
  --bg-badge: #3a3a3c;

  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #86868b;

  --accent: #2997ff;
  --accent-hover: #40a9ff;
  --accent-light: rgba(41, 151, 255, 0.15);

  --border: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.18);
  --border-color: rgba(255, 255, 255, 0.08);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }

/* ===== HEADER ===== */
.nav-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-height);
  background: var(--bg-glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
          backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 24px;
}
.nav-header .logo { height: 32px; display: flex; align-items: center; }
.nav-header .logo img { height: 100%; max-height: 32px; }

.nav-links {
  flex: 1;
  display: flex; gap: 4px; overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  padding: 6px 12px;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}
.nav-links a:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.nav-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  width: 36px; height: 36px;
  background: transparent; border: none; cursor: pointer;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition-fast);
}
.theme-toggle:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* ===== 响应式 utility ===== */
.nav-mobile-only { display: none !important; }
.nav-desktop-only { display: inline-flex; }
.nav-header .logo.nav-desktop-only { display: flex; }
.nav-header .nav-links.nav-desktop-only { display: flex; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 16px; height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 14px; font-weight: 500;
  font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: var(--transition-fast);
}
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--bg-card); border-color: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.btn-ghost { background: transparent; color: var(--text-primary); }
.btn-ghost:hover { background: var(--bg-card-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ff5249; }

/* ===== HERO ===== */
.hero-section {
  padding: calc(var(--header-height) + 60px) 24px 40px;
  text-align: center;
  max-width: 800px; margin: 0 auto;
}
.hero-section h1 {
  font-size: 48px; font-weight: 700; letter-spacing: -0.03em;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-section p {
  font-size: 18px; color: var(--text-secondary); margin-bottom: 32px;
}

.search-container {
  position: relative; max-width: 560px; margin: 0 auto;
}
.search-container input {
  width: 100%; height: 52px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0 24px 0 52px;
  font-size: 15px; font-family: inherit;
  color: var(--text-primary);
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}
.search-container input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}
.search-icon {
  position: absolute; top: 50%; left: 20px;
  transform: translateY(-50%);
  color: var(--text-tertiary); display: flex;
}

.filter-chips {
  display: flex; gap: 6px; flex-wrap: wrap;
  justify-content: center;
  margin-top: 24px;
}
.filter-chip {
  display: inline-block;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13px; color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}
.filter-chip:hover {
  background: var(--accent-light); color: var(--accent);
  border-color: var(--accent);
}

/* ===== SORT BAR ===== */
.sort-bar {
  max-width: var(--content-max); margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.sort-label { font-size: 13px; color: var(--text-tertiary); }
#sort-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 12px;
  font-size: 13px; color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2386868b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* ===== SECTION TITLE ===== */
.section-title {
  max-width: var(--content-max); margin: 32px auto 16px;
  padding: 0 24px;
  font-size: 20px; font-weight: 600;
  letter-spacing: -0.01em;
}

/* ===== CARD GRID ===== */
.card-grid {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.site-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition-base);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.site-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.badge-featured {
  position: absolute; top: 12px; right: 12px;
  background: linear-gradient(135deg, #ff9500, #ff6b00);
  color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.btn-visit {
  position: absolute; bottom: 16px; right: 16px;
  width: 28px; height: 28px;
  background: var(--bg-input);
  border: none; border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  opacity: 1; transition: var(--transition-fast);
}
.btn-visit:hover { background: var(--accent); color: #fff; }

.card-header { display: flex; gap: 12px; margin-bottom: 12px; }
.card-icon {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.card-icon img { width: 100%; height: 100%; object-fit: contain; }
.card-info { min-width: 0; flex: 1; }
.card-title {
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-desc {
  font-size: 12px; color: var(--text-tertiary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}
.card-rating {
  display: none; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-secondary);
}
.card-rating svg { color: var(--star); }
.card-rating .count { color: var(--text-tertiary); }

/* Card models */
.card-models { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.model-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.model-tag-views {
  background: var(--bg-input);
  color: var(--text-tertiary);
}

/* "全部" chip hidden on desktop */
.filter-chip[data-cat-id="all"] { display: none; }
.filter-chip.active {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: var(--text-primary);
}

/* ===== FOOTER ===== */
.site-footer {
  margin-top: 64px;
  padding: 32px 24px;
  text-align: center;
  border-top: 1px solid var(--border-color);
}
.friend-links {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}
.friend-links .friend-label {
  color: var(--text-secondary); font-weight: 500; margin-right: 8px;
}
.friend-links .sep { margin: 0 8px; color: var(--text-tertiary); }
.friend-links a { color: var(--text-secondary); }
.friend-links a:hover { color: var(--accent); }
.copyright { color: var(--text-tertiary); font-size: 13px; }
.copyright a { color: var(--text-secondary); }

/* ===== ADS ===== */
.ad-container { max-width: var(--content-max); margin: 0 auto; padding: 24px; }

/* ===== FORM / CONTAINER ===== */
.container-narrow {
  max-width: 720px; margin: 0 auto;
  padding: calc(var(--header-height) + 48px) 24px 60px;
}
.page-title { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 24px; }

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 500; font-size: 14px; margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  transition: var(--transition-fast);
}
.form-group input,
.form-group select { height: 42px; }
.form-group textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-ok { background: #e7f7ec; color: #2a8849; border: 1px solid #b8e6c5; }
.alert-err { background: #ffeeed; color: #d92020; border: 1px solid #ffcecb; }

.content-md { line-height: 1.8; font-size: 15px; color: var(--text-primary); }
.content-md h1, .content-md h2, .content-md h3 { margin: 24px 0 12px; font-weight: 600; letter-spacing: -0.01em; }
.content-md h1 { font-size: 24px; }
.content-md h2 { font-size: 20px; }
.content-md h3 { font-size: 17px; }
.content-md p { margin-bottom: 12px; }
.content-md a { color: var(--accent); }
.content-md code {
  background: var(--bg-input);
  padding: 2px 6px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 13px;
}
.content-md ul, .content-md ol { margin: 12px 0 12px 24px; }

/* ===== ERROR PAGE ===== */
.error-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  text-align: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  /* 移动端：导航栏跟随滚动（不固定），且重新分配显隐 */
  .nav-header {
    position: static;
    padding: 0 12px;
    gap: 8px;
    background: var(--bg-primary);
    -webkit-backdrop-filter: none;
            backdrop-filter: none;
  }
  /* 移动端显隐切换 */
  .nav-desktop-only { display: none !important; }
  .nav-mobile-only { display: inline-flex !important; }
  /* 左侧的订阅按钮顶左，右侧按钮组靠右 */
  .nav-header > .js-subscribe-btn.nav-mobile-only { margin-right: auto; }
  .nav-actions { margin-left: 0; gap: 6px; }
  .nav-actions .btn { padding: 0 10px; font-size: 12px; height: 30px; }

  /* 移动端 Hero：隐藏搜索框，显示分类筛选 */
  .hero-section {
    padding: 24px 16px 12px;
  }
  .hero-section h1 { font-size: 28px; margin-bottom: 6px; }
  .hero-section p { font-size: 14px; margin-bottom: 0; }

  .search-container { display: none; }

  .filter-chips {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
    padding: 2px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-chips::-webkit-scrollbar { display: none; }
  .filter-chip[data-cat-id="all"] { display: inline-block; }
  .filter-chip { flex-shrink: 0; }

  .section-title { display: none; }

  /* 排序条紧贴搜索框 */
  .sort-bar {
    padding: 8px 16px 4px;
    margin-top: 0;
  }

  /* 卡片网格：移动端单列 */
  .card-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 8px 16px 0;
  }
  .card-grid + .card-grid { margin-top: 10px; }

  /* 移动端：卡片底栏显示模型，隐藏评分，访问按钮常显 */
  .card-models { display: flex; }
  .card-rating { display: none; }
  .btn-visit { opacity: 1; }

  /* 广告位移动端缩小 padding */
  .ad-container { padding: 12px 16px; }

  /* 其他子页面（关于/投稿/404 等）：去掉为固定 header 预留的顶部空间 */
  .container-narrow { padding: 24px 16px 40px; }
  .page-title { font-size: 24px; }
  .form-card { padding: 18px; }
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  -webkit-backdrop-filter: blur(2px);
          backdrop-filter: blur(2px);
}
.modal-overlay.is-open { display: flex; animation: modal-fade .18s ease-out; }
@keyframes modal-fade {
  from { opacity: 0; } to { opacity: 1; }
}

.modal-panel {
  width: min(460px, calc(100% - 32px));
  max-height: 85vh;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-slide .22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modal-slide {
  from { transform: translateY(12px); opacity: 0.4; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.modal-close {
  background: none;
  border: 0;
  font-size: 22px;
  line-height: 1;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0 4px;
  transition: var(--transition-fast);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body {
  padding: 18px 20px 20px;
  overflow-y: auto;
}

.modal-hint {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.75;
  margin: 0 0 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  box-sizing: border-box;
  outline: none;
  transition: var(--transition-fast);
}
.modal-body textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.6;
}
.modal-body input:focus,
.modal-body textarea:focus {
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.modal-submit {
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.modal-submit:hover:not(:disabled) { background: var(--accent-hover); }
.modal-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.modal-status {
  margin-top: 10px;
  font-size: 13px;
  text-align: center;
  min-height: 18px;
  line-height: 1.5;
}
.modal-status.success { color: #15803d; }
.modal-status.error { color: var(--danger); }

/* 更新日志列表 */
.changelog-day {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
}
.changelog-day:last-child { border-bottom: 0; padding-bottom: 0; }
.changelog-day:first-child { padding-top: 0; }
.changelog-date {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}
.changelog-item {
  margin-bottom: 10px;
}
.changelog-item:last-child { margin-bottom: 0; }
.changelog-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.changelog-item-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
