/* ==================== CSS Variables ==================== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-hover: #1e40af;
  --secondary: #6366f1;
  --accent: #f59e0b;
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --bg-footer: #1e293b;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-light: #cbd5e1;
  --border: #e2e8f0;
  --border-dark: #cbd5e1;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px 0 rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-sm: 4px;
  --header-height: 60px;
  --max-width: 1200px;
  --transition: all 0.2s ease;
}

/* Category colors */
.cat-1 { --cat-color: #3b82f6; --cat-bg: #eff6ff; } /* 字符 - blue */
.cat-2 { --cat-color: #8b5cf6; --cat-bg: #f5f3ff; } /* 转换 - violet */
.cat-3 { --cat-color: #ef4444; --cat-bg: #fef2f2; } /* 加密 - red */
.cat-4 { --cat-color: #10b981; --cat-bg: #ecfdf5; } /* 网络 - green */
.cat-7 { --cat-color: #f59e0b; --cat-bg: #fffbeb; } /* 数学 - amber */
.cat-8 { --cat-color: #06b6d4; --cat-bg: #ecfeff; } /* 坐标 - cyan */

/* ==================== Reset ==================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}
a:hover { color: var(--primary-hover); }

img { max-width: 100%; height: auto; }

ul, ol { list-style: none; }

/* ==================== Header ==================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}
.logo:hover { color: var(--primary-hover); }
.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
}

.header-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}
.header-search input {
  width: 100%;
  height: 36px;
  padding: 0 36px 0 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  font-size: 13px;
  background: var(--bg-body);
  outline: none;
  transition: var(--transition);
}
.header-search input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-light);
}
.header-search .search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}
.search-results.active { display: block; }
.search-result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.search-result-item:hover { background: var(--primary-light); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item .sr-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}
.search-result-item .sr-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-item .sr-cat {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
}

.header-nav {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.header-nav a {
  padding: 6px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: var(--transition);
}
.header-nav a:hover {
  color: var(--primary);
  background: var(--primary-light);
}
.header-nav a.active {
  color: var(--primary);
  font-weight: 600;
}

.mobile-menu-btn {
  display: none;
  font-size: 22px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
}

/* ==================== Main ==================== */
.site-main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
  padding: 24px 20px;
}

/* ==================== Hero Section ==================== */
.hero {
  text-align: center;
  padding: 40px 20px 32px;
}
.hero h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.hero h1 .highlight {
  color: var(--primary);
}
.hero .stats {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.hero .stats .num {
  font-weight: 600;
  color: var(--primary);
}

.hero-search {
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}
.hero-search input {
  width: 100%;
  height: 44px;
  padding: 0 100px 0 18px;
  border: 1px solid var(--border-dark);
  border-radius: 22px;
  font-size: 15px;
  outline: none;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.hero-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.hero-search button {
  position: absolute;
  right: 5px;
  top: 5px;
  height: 34px;
  padding: 0 20px;
  border: none;
  border-radius: 17px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.hero-search button:hover { background: var(--primary-hover); }

.hero-tags {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.hero-tags a {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.hero-tags a:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* ==================== Category Grid ==================== */
.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title .bar {
  width: 4px;
  height: 18px;
  background: var(--primary);
  border-radius: 2px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.category-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}
.category-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--cat-color, var(--primary));
}
.category-card .cat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--cat-bg, var(--primary-light));
  color: var(--cat-color, var(--primary));
  flex-shrink: 0;
}
.category-card .cat-info h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}
.category-card .cat-info p {
  font-size: 12px;
  color: var(--text-secondary);
}
.category-card .cat-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==================== Tool Cards ==================== */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
  height: 100%;
}
.tool-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--primary);
}
.tool-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-card .tool-icon {
  font-size: 18px;
}
.tool-card .tool-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  margin-bottom: 12px;
}
.tool-card .tool-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tool-card .tool-cat-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--cat-bg, var(--primary-light));
  color: var(--cat-color, var(--primary));
  font-weight: 500;
}
.tool-card .tool-link {
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
}

/* ==================== Breadcrumb ==================== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--text-muted); }

/* ==================== Category Page ==================== */
.category-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}
.category-header .cat-icon-lg {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: var(--cat-bg, var(--primary-light));
  color: var(--cat-color, var(--primary));
}
.category-header h1 {
  font-size: 22px;
  font-weight: 700;
}
.category-header p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ==================== Tool Page ==================== */
.tool-page {
  max-width: 900px;
  margin: 0 auto;
}
.tool-page-header {
  margin-bottom: 24px;
}
.tool-page-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}
.tool-page-header .tool-breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.tool-page-header .tool-breadcrumb a {
  color: var(--text-secondary);
}
.tool-page-header .tool-breadcrumb a:hover {
  color: var(--primary);
}
.tool-page-header .tool-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.tool-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.tool-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  transition: var(--transition);
}
.tool-back:hover { color: var(--primary); }

/* Form elements */
.form-group {
  margin-bottom: 16px;
}
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.form-group .label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.form-group .hint {
  font-size: 12px;
  color: var(--text-muted);
}

textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  background: #fff;
}
textarea:focus, input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
textarea {
  resize: vertical;
  min-height: 120px;
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
  line-height: 1.5;
}

.input-group {
  display: flex;
  gap: 8px;
}
.input-group > * { flex: 1; }

.radio-group, .checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.radio-group label, .checkbox-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 400;
  margin-bottom: 0;
  cursor: pointer;
  font-size: 13px;
}
.radio-group input, .checkbox-group input {
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  background: #fff;
  color: var(--text-primary);
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-block { width: 100%; }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.output-box {
  position: relative;
}
.output-box .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
}

.result-area {
  margin-top: 16px;
}
.result-area .result-label {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-primary);
}
.result-area .result-content {
  padding: 12px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  min-height: 40px;
  white-space: pre-wrap;
}
.result-area .result-content.empty {
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==================== Footer ==================== */
.site-footer {
  background: var(--bg-footer);
  color: var(--text-light);
  padding: 32px 0 20px;
  margin-top: auto;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 24px;
}
.footer-col h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #fff;
}
.footer-col p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-light);
}
.footer-col ul li {
  margin-bottom: 6px;
}
.footer-col ul a {
  font-size: 13px;
  color: var(--text-light);
}
.footer-col ul a:hover { color: var(--primary); }
.footer-bottom {
  text-align: center;
  padding-top: 16px;
  border-top: 1px solid #334155;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==================== Responsive ==================== */
@media (max-width: 900px) {
  .category-grid, .tool-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
  .header-nav {
    display: none;
  }
}

@media (max-width: 600px) {
  .category-grid, .tool-grid {
    grid-template-columns: 1fr;
  }
  .footer-grid {
    grid-template-columns: 1fr;
  }
  .header-inner {
    gap: 12px;
    padding: 0 12px;
  }
  .header-search { display: none; }
  .mobile-menu-btn { display: block; }
  .hero h1 { font-size: 22px; }
  .site-main { padding: 16px 12px; }
  .tool-panel { padding: 16px; }
  .category-header { padding: 16px; flex-direction: column; text-align: center; }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
