/* ===== 基础重置 & 变量 ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* 暗色主题（默认） */
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-hover: #1a1a1a;
  --border: #262626;
  --text: #e5e5e5;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.1);
  --green: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
  --header-bg: rgba(10, 10, 10, 0.85);
}

/* 浅色主题 */
[data-theme="light"] {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-hover: #f1f3f5;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-muted: #888888;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --green: #16a34a;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --header-bg: rgba(248, 249, 250, 0.85);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===== 主题切换按钮 ===== */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

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

/* ===== 首页 ===== */
.home {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.home-content {
  width: 100%;
  max-width: 600px;
  text-align: center;
}

.logo {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 40px;
  color: var(--text);
}

.logo span {
  color: var(--accent);
}

/* ===== 搜索框 ===== */
.search-box {
  position: relative;
  width: 100%;
}

.search-box input {
  width: 100%;
  padding: 16px 56px 16px 24px;
  font-size: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.search-box button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.search-box button:hover {
  background: var(--accent-hover);
}

/* ===== 搜索建议 ===== */
.suggestions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.suggestion-tag {
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
}

.suggestion-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== 结果页头部 ===== */
.results-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.logo-sm {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.logo-sm span {
  color: var(--accent);
}

.header-search {
  flex: 1;
  max-width: 600px;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: 10px 44px 10px 16px;
  font-size: 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.header-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.header-search button {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.header-search button:hover {
  background: var(--accent-hover);
}

/* ===== 加载状态 ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== 错误 ===== */
.error {
  text-align: center;
  padding: 40px 20px;
  color: #ef4444;
  font-size: 0.95rem;
}

/* ===== 主内容 ===== */
.results-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== AI 摘要 ===== */
.ai-answer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.ai-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 50px;
  margin-bottom: 12px;
}

#aiAnswerText {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ===== 图片区域 ===== */
.images-section {
  margin-bottom: 24px;
}

.images-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.images-grid img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}

.images-grid img:hover {
  transform: scale(1.03);
  border-color: var(--accent);
}

/* ===== 搜索结果卡片 ===== */
.search-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
  text-decoration: none;
  display: block;
}

.result-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.result-url {
  font-size: 0.8rem;
  color: var(--green);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-url .favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}

.result-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.result-card:hover .result-title {
  color: var(--accent);
}

.result-snippet {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== 相关问题 ===== */
.related-questions {
  margin-top: 32px;
}

.related-questions h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.question-item:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.question-item .q-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .logo { font-size: 2rem; margin-bottom: 30px; }

  .results-header {
    flex-direction: column;
    gap: 8px;
    padding: 10px 16px;
  }

  .header-search { max-width: 100%; }

  .results-main { padding: 16px; }

  .images-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .images-grid img { height: 80px; }
}
