/* =========================================================
 * Web Utils - 全局样式
 * 风格:简洁、现代、信息密度适中、纯前端工具箱
 * ========================================================= */

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

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.08), 0 4px 10px rgba(0,0,0,.04);
  --radius: 10px;
  --radius-sm: 6px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
code, pre, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* =========================================================
 * 顶栏
 * ========================================================= */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
}
.nav {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}
.nav a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: all .15s;
}
.nav a:hover { color: var(--primary); background: var(--primary-light); }
.nav a.active { color: var(--primary); background: var(--primary-light); }

.search-box {
  position: relative;
}
.search-box input {
  width: 220px;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  outline: none;
  transition: all .15s;
}
.search-box input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-light);
}
.search-box::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: .5;
}

.menu-toggle { display: none; }

/* =========================================================
 * 容器
 * ========================================================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}
.container-narrow {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* =========================================================
 * Hero
 * ========================================================= */
.hero {
  text-align: center;
  padding: 48px 24px 40px;
  background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);
}
.hero h1 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.hero-search {
  max-width: 540px;
  margin: 0 auto;
  position: relative;
}
.hero-search input {
  width: 100%;
  padding: 14px 18px 14px 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  outline: none;
  font-size: 15px;
}
.hero-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}
.hero-search::before {
  content: "🔍";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: .5;
}

/* =========================================================
 * 卡片网格
 * ========================================================= */
.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title .more {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.section-title .more:hover { color: var(--primary); }

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.category-tabs a {
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  transition: all .15s;
}
.category-tabs a:hover, .category-tabs a.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: all .2s;
  position: relative;
  cursor: pointer;
  display: block;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}
.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
.card p {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.card .fav {
  position: absolute;
  top: 12px;
  right: 12px;
  color: #cbd5e1;
  font-size: 16px;
  padding: 4px;
  cursor: pointer;
  transition: color .15s;
}
.card .fav:hover { color: var(--warning); }
.card .fav.active { color: var(--warning); }

/* =========================================================
 * 特性(底部)
 * ========================================================= */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 40px 0;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.feature .icon { font-size: 28px; margin-bottom: 8px; }
.feature h4 { font-size: 14px; margin-bottom: 4px; }
.feature p { font-size: 12.5px; color: var(--text-muted); }

/* =========================================================
 * 工具页 (layout)
 * ========================================================= */
.tool-header {
  margin-bottom: 24px;
}
.tool-header h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}
.tool-header p {
  color: var(--text-muted);
  font-size: 14px;
}
.tool-header .crumbs {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.tool-header .crumbs a:hover { color: var(--primary); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.panel-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* =========================================================
 * 表单
 * ========================================================= */
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.form-row label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 80px;
}
textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: all .15s;
}
textarea {
  resize: vertical;
  min-height: 160px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}
textarea:focus, input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* =========================================================
 * 复选框组
 * ========================================================= */
.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.checkbox-list label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  min-width: 0;
  color: var(--text);
  transition: all .15s;
}
.checkbox-list label:hover { border-color: var(--primary); }
.checkbox-list input { accent-color: var(--primary); }
.checkbox-list label.checked {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--primary); }
.slider-row .val {
  min-width: 50px;
  text-align: right;
  font-family: ui-monospace, monospace;
  font-weight: 600;
  color: var(--primary);
}

/* =========================================================
 * 输出区
 * ========================================================= */
.output {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-all;
  min-height: 80px;
  white-space: pre-wrap;
  max-height: 400px;
  overflow: auto;
}
.output.light {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.output.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* =========================================================
 * 标签/Tab
 * ========================================================= */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  gap: 4px;
}
.tab {
  padding: 10px 18px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all .15s;
  font-size: 13px;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* =========================================================
 * 信息提示
 * ========================================================= */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}

/* =========================================================
 * 二维码
 * ========================================================= */
.qr-display {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.qr-display canvas, .qr-display img {
  max-width: 280px;
  height: auto;
}

/* =========================================================
 * 颜色预览
 * ========================================================= */
.color-preview {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

/* =========================================================
 * 统计数字
 * ========================================================= */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.stat .v {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  font-family: ui-monospace, monospace;
}
.stat .l {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* =========================================================
 * 复制反馈
 * ========================================================= */
.copy-feedback {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
}
.copy-feedback.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

/* =========================================================
 * Footer
 * ========================================================= */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px;
  margin-top: 60px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.footer a:hover { color: var(--primary); }

/* =========================================================
 * 响应式
 * ========================================================= */
@media (max-width: 768px) {
  .topbar-inner { padding: 12px 16px; gap: 12px; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0;
         background: var(--surface); flex-direction: column; padding: 8px;
         border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .nav a { padding: 10px 12px; }
  .menu-toggle { display: block; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
  .search-box input { width: 140px; }
  .container, .container-narrow { padding: 20px 16px; }
  .hero { padding: 32px 16px 24px; }
  .hero h1 { font-size: 26px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card { padding: 14px; }
  .card h3 { font-size: 14px; }
  .card p { font-size: 12px; }
  .form-row { flex-direction: column; align-items: stretch; }
  .form-row label { min-width: 0; }
}

/* =========================================================
 * 工具页 - 字符统计网格
 * ========================================================= */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.stat-row .stat { padding: 10px; }
.stat-row .v { font-size: 18px; }