/* ============================================================
   Toolbox — TDesign 风格重构（顶栏 + 左侧边栏 + 移动端抽屉）
   布局：桌面 ≥768px 左侧边栏常显；移动端边栏隐藏、顶栏按钮抽屉
   ============================================================ */
:root {
  --primary: #0052d9;          /* TDesign 品牌蓝 */
  --primary-dark: #0034b5;
  --primary-light: #e8f1ff;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1a2333;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-hover: 0 8px 24px rgba(0, 82, 217, .14), 0 4px 10px rgba(0, 0, 0, .06);
  --maxw: 1200px;
  --aside-w: 232px;
  --header-h: 60px;
}

* { 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);
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ================= 顶栏 ================= */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: #fff; border-bottom: 1px solid var(--border);
  z-index: 1000; display: flex; align-items: center;
}
.header-inner { display: flex; align-items: center; gap: 14px; width: 100%; height: 100%; padding: 0 16px; min-width: 0; }
.menu-toggle { display: inline-flex; flex-shrink: 0; color: var(--text); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--primary); white-space: nowrap; flex-shrink: 0; }
.brand-logo { display: flex; align-items: center; justify-content: center; color: var(--primary); }
.header-search { flex: 1; max-width: 440px; position: relative; min-width: 0; }
.header-search form { display: flex; align-items: center; width: 100%; min-width: 0; }
.header-search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; flex-shrink: 0; }
.header-search input {
  width: 100%; min-width: 0; padding: 8px 12px 8px 36px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #f5f7fa; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.header-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,82,217,.15); background: #fff; }

/* ================= 桌面端左侧边栏 ================= */
.site-aside { display: none; }
.aside-brand {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px;
  color: var(--primary); padding: 0 20px; height: var(--header-h); border-bottom: 1px solid var(--border);
}
.aside-nav { padding: 10px 8px; overflow-y: auto; }
.side-menu { border: 0 !important; width: 100%; }
.menu-label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.menu-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.menu-count { font-style: normal; font-size: 11px; color: var(--text-muted); margin-left: auto; background: #f3f4f6; border-radius: 8px; padding: 0 7px; line-height: 18px; }
/* 强化分类菜单文字可见性（防止 TDesign 默认态颜色异常时文字隐身） */
.side-menu .t-menu__item { color: var(--text); }
.side-menu .t-menu__item:hover { color: var(--primary); background: var(--primary-light); }
.side-menu .t-menu__item.t-is-active { color: var(--primary); background: var(--primary-light); font-weight: 600; }

/* ================= 移动端抽屉 ================= */
.drawer-head {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px;
  color: var(--primary); padding: 4px 8px 14px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.drawer-title { font-size: 17px; }

/* ================= 内容区 ================= */
.site-content { padding-top: var(--header-h); min-height: 100vh; }

/* ================= Hero ================= */
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: 32px; font-weight: 800; letter-spacing: -.5px; }
.hero-sub { color: var(--text-muted); margin-top: 10px; font-size: 15px; }
.hero-search {
  max-width: 560px; margin: 22px auto 0; display: flex; gap: 8px;
  background: #fff; padding: 6px; border-radius: 10px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.hero-search input {
  flex: 1; border: none; outline: none; padding: 10px 16px; font-size: 15px; background: transparent;
}
.hero-search button {
  border: none; background: var(--primary); color: #fff;
  padding: 10px 24px; border-radius: 8px; font-size: 15px; cursor: pointer;
  transition: background .15s;
}
.hero-search button:hover { background: var(--primary-dark); }
.hero-stats { display: flex; justify-content: center; gap: 28px; margin-top: 24px; color: var(--text-muted); font-size: 14px; }
.hero-stats strong { color: var(--primary); font-size: 18px; margin-right: 4px; }

/* ================= 区块 ================= */
.section { padding: 32px 0 8px; }
.section-title { font-size: 22px; font-weight: 700; }
.section-sub { color: var(--text-muted); margin-top: 4px; font-size: 14px; }
.group-title { font-size: 17px; font-weight: 600; margin: 22px 0 12px; color: var(--text); }

/* ================= 工具卡片网格 ================= */
.grid {
  display: grid; gap: 14px; margin-top: 16px;
  grid-template-columns: repeat(4, 1fr);
}
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; gap: 12px; align-items: flex-start; min-width: 0;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: #b8d3ff; }
.tool-card .tool-body { flex: 1; min-width: 0; }
.tool-icon {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.tool-icon-lg { width: 54px; height: 54px; border-radius: 12px; }
.tool-name { font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.tool-tag {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; margin-top: 5px;
  color: var(--primary); background: var(--primary-light);
}
.tool-desc { font-size: 13px; color: var(--text-muted); margin-top: 7px; line-height: 1.5; overflow-wrap: anywhere; word-break: break-word; }

/* ================= 分页 ================= */
.pagination {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 8px; margin-top: 26px; padding: 4px 0 8px;
}
.page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font-size: 14px; transition: all .15s; user-select: none;
}
a.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.current {
  background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600;
  cursor: default;
}
.page-ellipsis { color: var(--text-muted); padding: 0 2px; }

/* ================= 回到顶部 ================= */
.back-top {
  position: fixed; right: 22px; bottom: 26px; z-index: 900;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 82, 217, .35);
  transition: background .15s, transform .15s;
}
.back-top:hover { background: var(--primary-dark); transform: translateY(-2px); }

/* ================= 分类卡片 ================= */
.cat-grid { display: grid; gap: 12px; margin-top: 16px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; transition: transform .15s, box-shadow .15s;
}
.cat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.cat-icon {
  width: 42px; height: 42px; border-radius: 10px; margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 17px; font-weight: 700;
}
.cat-name { font-weight: 600; font-size: 14px; }
.cat-count { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cat-inline { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.chip { padding: 6px 14px; border-radius: 999px; font-size: 13px; }

/* ================= 页面头 / 工具页 ================= */
.page-head { padding: 28px 0 8px; }
.page-head h1 { font-size: 26px; font-weight: 800; }
.cat-icon-lg { width: 54px; height: 54px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 24px; font-weight: 700; margin-bottom: 12px; }
.muted { color: var(--text-muted); font-size: 14px; margin-top: 6px; }

.tool-page { padding-bottom: 36px; }
.tool-head { display: flex; gap: 16px; align-items: flex-start; padding: 24px 0 18px; }
.tool-head h1 { font-size: 24px; font-weight: 800; }
.tool-breadcrumb { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.tool-breadcrumb .sep { margin: 0 6px; }
.tool-head .tool-desc { font-size: 14px; max-width: 640px; margin-top: 8px; }
.tool-body {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}

/* ================= 工具内部 UI ================= */
.tool-ui { display: flex; flex-direction: column; gap: 14px; }
.tool-ui textarea, .tool-ui input[type=text], .tool-ui input[type=number] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.tool-ui textarea:focus, .tool-ui input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,82,217,.15); }
.tool-ui textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
.tool-ui label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 9px 18px; border-radius: 8px; font-size: 14px; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--text); transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.stats-row { display: flex; gap: 18px; flex-wrap: wrap; }
.stat-box { background: var(--primary-light); border-radius: 8px; padding: 10px 16px; }
.stat-box b { display: block; font-size: 20px; color: var(--primary); }
.stat-box span { font-size: 12px; color: var(--text-muted); }
.result-box {
  background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 14px;
  font-family: ui-monospace, Menlo, monospace; font-size: 13px; white-space: pre-wrap; word-break: break-all;
  min-height: 80px; max-height: 400px; overflow: auto;
}
.result-box.err { background: #fef2f2; color: #dc2626; }

/* ================= 空状态 ================= */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state h2 { font-size: 20px; color: var(--text); margin-bottom: 8px; }
.empty-state code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: 13px; }

/* ================= 页脚 ================= */
.footer { border-top: 1px solid var(--border); margin-top: 44px; padding: 28px 0; background: #fff; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
.footer-brand p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.footer-links a { font-size: 13px; color: var(--text-muted); }
.footer-links a:hover { color: var(--primary); }
.footer-copy { text-align: center; color: #94a3b8; font-size: 12px; margin-top: 22px; }

/* ================= 响应式：桌面 ≥768px ================= */
@media (min-width: 768px) {
  .site-header { left: var(--aside-w); }
  .site-aside {
    display: block; position: fixed; top: 0; left: 0; bottom: 0; width: var(--aside-w);
    background: #fff; border-right: 1px solid var(--border); z-index: 999;
  }
  .site-content { margin-left: var(--aside-w); }
  .menu-toggle { display: none; }
}

/* ================= 响应式：窄屏 <768px ================= */
@media (max-width: 1199px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 992px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 24px; }
  .tool-head { flex-direction: column; }
  .footer-inner { flex-direction: column; }
  /* 移动端顶栏：压缩间距，搜索框撑满剩余空间，杜绝超宽 */
  .header-inner { gap: 8px; padding: 0 10px; }
  .brand { font-size: 16px; gap: 6px; }
  .header-search { max-width: none; }
  .header-search input { font-size: 13px; padding: 7px 10px 7px 32px; }
  .header-search .search-icon { left: 9px; }
  .back-top { right: 14px; bottom: 18px; width: 40px; height: 40px; }
}
