/* ============================================================
   工具箱导航 · 前台样式
   主题：CSS 变量，JS 按时段切换 data-theme
   ============================================================ */

:root {
  --bg: #f4f6fa;
  --bg-soft: #eef1f6;
  --card: #ffffff;
  --card-hover: #ffffff;
  --text: #1f2329;
  --muted: #7a8190;
  --accent: #4a7cf7;
  --accent-soft: rgba(74, 124, 247, .12);
  --border: #e4e8ef;
  --shadow: 0 2px 10px rgba(20, 30, 60, .06);
  --shadow-hover: 0 8px 24px rgba(20, 30, 60, .12);
  --chip-bg: #ffffff;
  --chip-active-text: #ffffff;
  --letter-bg-1: #e8f0fe;
  --letter-bg-2: #fdeee8;
  --letter-bg-3: #e6f7ef;
  --letter-bg-4: #f4ecfd;
  --letter-bg-5: #fdf4e3;
  --header-bg: rgba(255, 255, 255, .86);
  --footer-text: #9aa1ad;
}

html[data-theme="dark"] {
  --bg: #131722;
  --bg-soft: #1a2030;
  --card: #1c2333;
  --card-hover: #212a3e;
  --text: #e8ebf2;
  --muted: #8b93a5;
  --accent: #6c9bff;
  --accent-soft: rgba(108, 155, 255, .16);
  --border: #2a3348;
  --shadow: 0 2px 10px rgba(0, 0, 0, .25);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, .4);
  --chip-bg: #1c2333;
  --letter-bg-1: #1e2c4d;
  --letter-bg-2: #4a2e22;
  --letter-bg-3: #1d3a2e;
  --letter-bg-4: #33234d;
  --letter-bg-5: #473a1e;
  --header-bg: rgba(19, 23, 34, .86);
  --footer-text: #5c6475;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .25s ease, color .25s ease;
}

/* ---------- 头部 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .5px;
}

.brand-slogan {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .2s ease, box-shadow .2s ease;
}

.theme-toggle:hover { transform: scale(1.06); box-shadow: var(--shadow); }

/* ---------- 公告 ---------- */
.notice {
  max-width: 1180px;
  margin: 14px auto 0;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 主容器 ---------- */
.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 40px;
  flex: 1;
}

/* ---------- 最近使用 ---------- */
.recent {
  margin-bottom: 22px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}

.recent-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.recent-item {
  flex-shrink: 0;
  position: relative;
  display: inline-flex;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  transition: border-color .2s ease, box-shadow .2s ease;
  user-select: none;
}

.recent-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }

.recent-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  padding-right: 30px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.recent-link:hover { color: var(--text); text-decoration: none; }

.recent-item .r-icon {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  object-fit: contain;
}

.recent-item .r-letter {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.recent-item .r-clear {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
}

.recent-item .r-clear:hover { color: #e05353; background: var(--bg-soft); }

/* ---------- 搜索 ---------- */
.toolbar { margin-bottom: 14px; }

.search-input {
  width: 100%;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

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

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

/* ---------- 分类 chips ---------- */
.cat-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.chip {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all .18s ease;
  user-select: none;
}

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

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--chip-active-text);
  font-weight: 600;
}

.chip .chip-count {
  font-size: 11px;
  opacity: .75;
  margin-left: 4px;
}

/* ---------- 工具网格 ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 14px;
}

.tool-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease;
}

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

/* 卡片主体跳转链接：绝对定位覆盖整卡，原生 target=_blank 打开 */
.card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 14px;
}

.t-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--bg-soft);
}

.t-icon.letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.t-info { flex: 1; min-width: 0; }

.t-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.t-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}

.t-tags {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.t-tag {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 6px;
}

.t-meta {
  position: absolute;
  right: 14px;
  bottom: 12px;
  font-size: 11px;
  color: var(--muted);
}

.t-actions {
  position: absolute;
  right: 12px;
  top: 12px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

.doc-btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  transition: all .18s ease;
}

.doc-btn:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 14px;
}

/* ---------- 加载中 ---------- */
.loading {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 14px;
}

/* ---------- 页脚 ---------- */
.site-footer {
  text-align: center;
  padding: 22px 16px 30px;
  color: var(--footer-text);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
  line-height: 1.8;
}

.site-footer a {
  color: var(--footer-text);
  text-decoration: none;
}

.site-footer a:hover { color: var(--accent); text-decoration: none; }

.footer-beian { margin-top: 4px; }

.beian-icon {
  height: 14px;
  width: auto;
  vertical-align: -2px;
  margin-right: 5px;
}

.beian-sep { margin: 0 8px; color: var(--footer-text); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .header-inner { padding: 12px 16px; }
  .container { padding: 16px 16px 32px; }
  .tool-grid { grid-template-columns: 1fr; }
  .brand-name { font-size: 18px; }
  .tool-card { padding: 14px; }
}
