/* ==========================================================================
   轻工具站 - 公共样式
   纯静态、零依赖、移动端优先
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f8f9;
  --bg-code: #f4f5f7;
  --border: #e3e5e8;
  --border-strong: #d0d4d9;
  --text: #1f2328;
  --text-soft: #656d76;
  --text-faint: #8b949e;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

/* ---------- 布局 ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 860px; margin: 0 auto; padding: 0 20px; }

/* ---------- 顶栏 ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .92);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(8px);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.01em;
}
.logo-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex: none;
}
.nav-links { display: flex; gap: 20px; }
.nav-links a {
  color: var(--text-soft);
  text-decoration: none;
  font-size: 14px;
}
.nav-links a:hover { color: var(--accent); }

/* ---------- 首页 Hero ---------- */
.hero { padding: 56px 0 36px; text-align: center; }
.hero h1 {
  font-size: 34px;
  line-height: 1.3;
  margin: 0 0 14px;
  letter-spacing: -.02em;
  font-weight: 700;
}
.hero .lead {
  font-size: 16px;
  color: var(--text-soft);
  margin: 0 auto;
  max-width: 620px;
}
.badges {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-soft);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 13px;
}
.badge svg { flex: none; }

/* ---------- 工具网格 ---------- */
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: none;
  margin: 8px 0 16px;
  letter-spacing: .01em;
}
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 48px;
}
.tool-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tool-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(37, 99, 235, .09);
  transform: translateY(-1px);
}
.tool-card .icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 13px;
}
.tool-card h3 {
  margin: 0 0 5px;
  font-size: 16px;
  font-weight: 600;
}
.tool-card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.6;
}
.tool-card .tag {
  display: inline-block;
  margin-top: 11px;
  font-size: 12px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 5px;
  padding: 2px 8px;
}

/* ---------- 分类筛选 ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.filter-btn {
  font: inherit;
  font-size: 13.5px;
  color: var(--text-soft);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 15px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.filter-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.filter-btn.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.tool-card[hidden] { display: none; }
.empty-hint {
  color: var(--text-faint);
  font-size: 14px;
  padding: 24px 0 40px;
  text-align: center;
}

/* ---------- 工具页 ---------- */
.tool-head { padding: 34px 0 22px; border-bottom: 1px solid var(--border); margin-bottom: 26px; }
.breadcrumb { font-size: 13px; color: var(--text-faint); margin-bottom: 14px; }
.breadcrumb a { color: var(--text-soft); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.tool-head h1 { font-size: 27px; margin: 0 0 9px; letter-spacing: -.02em; font-weight: 700; }
.tool-head .desc { color: var(--text-soft); margin: 0; font-size: 15px; }

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 18px;
  background: var(--bg);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.panel-head label,
.panel-head .label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
}

/* ---------- 表单元素 ---------- */
textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 13px;
  resize: vertical;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus, input[type="text"]:focus, input[type="number"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg);
}
textarea { min-height: 170px; }
select, input[type="number"] { font-family: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text-faint); background: var(--bg-soft); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- 输出区 ---------- */
.output {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
  margin: 0;
}
.output.placeholder { color: var(--text-faint); }

.status {
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 7px;
  margin-top: 11px;
  display: none;
}
.status.show { display: block; }
.status.ok { background: var(--green-soft); color: var(--green); }
.status.err { background: var(--red-soft); color: var(--red); }

/* ---------- 统计数字 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 11px; }
.stat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  text-align: center;
  background: var(--bg-soft);
}
.stat .num {
  font-size: 23px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1.2;
  word-break: break-all;
}
.stat .lbl { font-size: 12.5px; color: var(--text-soft); margin-top: 3px; }

/* ---------- 正则高亮 ---------- */
.hl-box {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.8;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}
.hl-box mark {
  background: #fde68a;
  color: #78350f;
  border-radius: 3px;
  padding: 1px 2px;
  font-weight: 600;
}
.hl-box mark.grp { background: #bbf7d0; color: #14532d; }
.match-list {
  font-family: var(--mono);
  font-size: 12.5px;
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
}
.match-list .row {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
}
.match-list .row:last-child { border-bottom: none; }
.match-list .idx { color: var(--text-faint); flex: none; min-width: 34px; }
.match-list .val { color: var(--text); word-break: break-all; }

/* ---------- 提示块 ---------- */
.tip {
  display: flex;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.65;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 18px;
}
.tip.info { background: var(--accent-soft); color: #1e40af; }
.tip.safe { background: var(--green-soft); color: #166534; }
.tip.warn { background: var(--amber-soft); color: #92400e; }
.tip svg { flex: none; margin-top: 2px; }

/* ---------- SEO 内容区 ---------- */
.content {
  border-top: 1px solid var(--border);
  margin-top: 44px;
  padding-top: 30px;
  padding-bottom: 60px;
}
.content h2 {
  font-size: 19px;
  margin: 0 0 12px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.content h3 {
  font-size: 15.5px;
  margin: 26px 0 9px;
  font-weight: 600;
}
.content p { color: var(--text-soft); margin: 0 0 13px; font-size: 14.5px; }
.content ul { color: var(--text-soft); padding-left: 22px; margin: 0 0 15px; font-size: 14.5px; }
.content li { margin-bottom: 6px; }
.content strong { color: var(--text); font-weight: 600; }
.content code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.faq { border-top: 1px solid var(--border); margin-top: 26px; padding-top: 8px; }
.faq details { border-bottom: 1px solid var(--border); padding: 13px 0; }
.faq summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 14.5px;
  color: var(--text);
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "＋ "; color: var(--accent); }
.faq details[open] summary::before { content: "－ "; }
.faq details p { margin: 9px 0 0; font-size: 14px; }

/* ---------- 相关工具 ---------- */
.related { display: flex; gap: 9px; flex-wrap: wrap; }
.related a {
  font-size: 13.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 7px;
  padding: 7px 13px;
  text-decoration: none;
  transition: background .15s;
}
.related a:hover { background: #dbe7ff; }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 26px 0;
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}
.site-footer a { color: var(--text-soft); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .hero { padding: 36px 0 26px; }
  .hero h1 { font-size: 25px; }
  .hero .lead { font-size: 15px; }
  .tool-head h1 { font-size: 22px; }
  .tool-grid { grid-template-columns: 1fr; }
  .nav-links { gap: 14px; }
  .panel { padding: 16px; }
  .stat .num { font-size: 20px; }
}

/* ---------- 文本对比 ---------- */
.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  min-width: 640px;
}
.diff-table td {
  padding: 2px 8px;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-word;
  border-bottom: 1px solid var(--border);
}
.diff-table td.ln {
  width: 46px;
  min-width: 46px;
  text-align: right;
  color: var(--text-faint);
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  user-select: none;
  font-size: 11.5px;
  padding-right: 9px;
}
.diff-table td.code { width: calc(50% - 46px); }
.diff-table tr.equal td.code { color: var(--text-soft); }
.diff-table tr.insert td.code { background: #dcfce7; }
.diff-table tr.insert td.ln { background: #bbf7d0; color: #166534; }
.diff-table tr.delete td.code { background: #fee2e2; }
.diff-table tr.delete td.ln { background: #fecaca; color: #991b1b; }
.diff-table tr.change td.code { background: #fef3c7; }
.diff-table tr.change td.ln { background: #fde68a; color: #92400e; }
.diff-table del {
  background: #fca5a5;
  color: #7f1d1d;
  text-decoration: line-through;
  border-radius: 3px;
  padding: 0 1px;
}
.diff-table ins {
  background: #86efac;
  color: #14532d;
  text-decoration: none;
  border-radius: 3px;
  padding: 0 1px;
}
