:root {
  --color-primary: #4056F4;
  --color-primary-dark: #2d3fd9;
  --primary-rgb: 64, 86, 244;
  --color-primary-soft: rgba(var(--primary-rgb), 0.1);
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --bg-primary: #f7faff;
  --bg-secondary: #E8EEFF;
  --bg-card: #ffffff;
  --bg-hover: #f3f7ff;
  --text-primary: #102033;
  --text-secondary: #526070;
  --text-muted: #5f6f84;
  --border-color: #dce5f2;
  --shadow-sm: 0 12px 32px rgba(15, 35, 68, 0.08);
  --shadow-md: 0 24px 70px rgba(15, 35, 68, 0.12);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 24px;
  --space-lg: 32px;
  --space-xl: 48px;
  --sidebar-width: 240px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 600px at 15% -5%, rgba(var(--primary-rgb), 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(var(--primary-rgb), 0.06), transparent 55%),
    linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  background-attachment: fixed;
  color: var(--text-primary);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.text-link {
  color: var(--color-primary);
  font-weight: 700;
}

.text-link:hover {
  color: var(--color-primary-dark);
}

/* ---------- 整体布局 ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- 左侧分类导航 ---------- */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid rgba(15, 35, 68, 0.08);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  overflow-y: auto;
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  box-shadow: 0 14px 32px rgba(var(--primary-rgb), 0.24);
}

.cat-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 0;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 15px;
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.cat-item:hover {
  color: var(--color-primary-dark);
  background: var(--bg-hover);
}

.cat-item.is-active {
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  box-shadow: 0 10px 24px rgba(var(--primary-rgb), 0.24);
}

.cat-item__icon {
  width: 22px;
  text-align: center;
}

.cat-item__count {
  margin-left: auto;
  font-size: 12px;
  opacity: 0.7;
}

.app-sidebar__chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  color: var(--color-primary-dark);
  font-weight: 700;
  background: var(--color-primary-soft);
  border: 1px solid rgba(var(--primary-rgb), 0.16);
  transition: transform 0.2s ease;
}

.app-sidebar__chat:hover {
  transform: translateY(-2px);
}

/* ---------- 右侧主区 ---------- */
.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 0 clamp(16px, 4vw, 40px);
  border-bottom: 1px solid rgba(15, 35, 68, 0.08);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
}

.app-topbar__menu {
  display: none;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  background: #fff;
  cursor: pointer;
}

.app-topbar__brand {
  display: none;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* 登录态区（顶部右侧） */
.nav__auth {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.nav__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  color: #fff;
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  box-shadow: 0 14px 32px rgba(var(--primary-rgb), 0.2);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.nav__cta:hover {
  transform: translateY(-2px);
}

.nav__user {
  max-width: 140px;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nav__ghost {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
}

.nav__ghost:hover {
  color: var(--color-primary-dark);
}

.nav__logout {
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-secondary);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.nav__logout:hover {
  color: var(--color-danger);
  border-color: rgba(220, 38, 38, 0.4);
}

.app-content {
  width: min(1120px, calc(100% - clamp(32px, 8vw, 80px)));
  margin: 0 auto;
  padding: 40px 0 24px;
}

/* ---------- 搜索区 ---------- */
.search-hero {
  text-align: center;
  padding: 24px 0 40px;
}

.search-hero h1 {
  margin: 0 0 28px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(680px, 100%);
  margin: 0 auto;
  padding: 6px 6px 6px 20px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus-within {
  border-color: rgba(var(--primary-rgb), 0.58);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.1);
}

.search-box input {
  flex: 1;
  min-width: 0;
  height: 46px;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  background: transparent;
}

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

.search-box__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
  border-right: 1px solid var(--border-color);
}

.search-box__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 17px;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.search-box__icon:hover {
  color: var(--color-primary-dark);
  background: rgba(var(--primary-rgb), 0.08);
  transform: scale(1.05);
}

.search-box__btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-size: 18px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  cursor: pointer;
  transition: transform 0.2s ease;
}

.search-box__btn:hover {
  transform: scale(1.05);
}

.engine-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.engine-tab {
  padding: 7px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.engine-tab:hover {
  color: var(--color-primary-dark);
}

.engine-tab.is-active {
  color: var(--color-primary-dark);
  font-weight: 700;
  background: var(--color-primary-soft);
  border-color: rgba(var(--primary-rgb), 0.2);
}

/* ---------- 工具区 ---------- */
.tools-section {
  padding: 12px 0 40px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -0.03em;
}

.section-heading__meta {
  margin: 0;
  color: var(--text-muted);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.tool-card {
  position: relative;
  min-height: 160px;
  padding: 22px;
  border: 1px solid rgba(15, 35, 68, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.tool-card:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--primary-rgb), 0.34);
  background: #f8fbff;
}

.tool-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.tool-card__icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  color: var(--color-primary-dark);
  font-weight: 800;
  background: var(--color-primary-soft);
  border: 1px solid rgba(var(--primary-rgb), 0.16);
}

.tool-card__badge {
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  background: var(--color-success);
}

.tool-card h3 {
  margin: 0 0 8px;
  font-size: 19px;
}

.tool-card p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.7;
}

.empty-state {
  padding: var(--space-xl);
  text-align: center;
  border: 1px solid rgba(15, 35, 68, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
}

.empty-state__icon {
  margin-bottom: 12px;
  font-size: 42px;
}

/* ---------- 关于 ---------- */
.about {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  padding: 24px 0 40px;
}

.about__card {
  padding: var(--space-lg);
  border: 1px solid rgba(15, 35, 68, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}

.about__card p {
  color: var(--text-secondary);
  line-height: 1.8;
}

.about__card--accent {
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.14), rgba(var(--primary-rgb), 0.05));
}

/* ---------- 页脚 ---------- */
.app-footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 24px 0;
  border-top: 1px solid rgba(15, 35, 68, 0.08);
  color: var(--text-muted);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: min(360px, calc(100% - 32px));
  padding: 14px 16px;
  border-radius: 14px;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  border-color: rgba(220, 38, 38, 0.48);
}

.toast.is-success {
  border-color: rgba(22, 163, 74, 0.48);
}

/* ---------- 遮罩（移动端抽屉） ---------- */
.app-mask {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(2px);
}

/* ---------- AI 精选导航 ---------- */
.ainav-section {
  padding: 12px 0 40px;
}

.nav-group {
  margin-bottom: 32px;
}

.nav-group__title {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.ai-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.ai-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(15, 35, 68, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.ai-card:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--primary-rgb), 0.34);
  background: #f8fbff;
}

.ai-card__icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
}

.ai-card__icon--fallback {
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
}

.ai-card__body {
  min-width: 0;
}

.ai-card__body h4 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-card__body p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .tool-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .ai-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 860px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    box-shadow: var(--shadow-md);
  }

  .app-sidebar.is-open {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
  }

  .app-topbar__menu {
    display: inline-flex;
  }

  .app-topbar__brand {
    display: inline-block;
  }

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

  .ai-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .app-content {
    width: calc(100% - 32px);
    padding-top: 28px;
  }

  .search-hero {
    padding: 8px 0 28px;
  }

  .nav__user {
    display: none;
  }

  .nav__auth {
    gap: 8px;
  }

  .nav__cta {
    padding: 0 14px;
    font-size: 14px;
  }

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

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

  .section-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .app-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==========================================================
   兼容 login.html / chat.html 复用的公共类
   （这些页面仍使用顶部导航与通用按钮，勿删）
   ========================================================== */
.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(15, 35, 68, 0.08);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  gap: var(--space-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 24px;
  color: var(--text-secondary);
  font-size: 15px;
}

.nav__links a:hover {
  color: var(--color-primary-dark);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  box-shadow: 0 14px 32px rgba(var(--primary-rgb), 0.2);
}

.btn--ghost {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.78);
  border-color: var(--border-color);
}

.btn:hover {
  transform: translateY(-2px);
}

@media (max-width: 620px) {
  .nav {
    flex-wrap: wrap;
    padding: 14px 0;
  }

  .nav__links {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
  }
}

/* ---------- 主题切换器 ---------- */
.theme-switch {
  position: relative;
}
.theme-switch__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.theme-switch__btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.theme-switch__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06) inset;
}
.theme-switch__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  min-width: 168px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 3px;
  transform-origin: top right;
  animation: theme-menu-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.theme-switch__menu[hidden] {
  display: none;
}
@keyframes theme-menu-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.theme-switch__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}
.theme-switch__item:hover {
  background: var(--bg-hover);
  transform: translateX(2px);
}
.theme-switch__item.is-active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}

/* ===== 暗夜护眼主题：修正各处发白的半透明卡片背景 ===== */
[data-theme="night-care"] .app-sidebar,
[data-theme="night-care"] .app-topbar,
[data-theme="night-care"] .tool-card,
[data-theme="night-care"] .empty-state,
[data-theme="night-care"] .about__card,
[data-theme="night-care"] .ai-card,
[data-theme="night-care"] .site-header,
[data-theme="night-care"] .btn--ghost {
  background: rgba(37, 43, 54, 0.82);
}
[data-theme="night-care"] .toast {
  background: rgba(45, 52, 65, 0.96);
}
[data-theme="night-care"] .theme-switch__menu {
  background: rgba(37, 43, 54, 0.78);
  border-color: rgba(255, 255, 255, 0.12);
}
[data-theme="night-care"] .tool-card:hover,
[data-theme="night-care"] .ai-card:hover {
  background: rgba(45, 52, 65, 0.92);
}
