/* ============ 全局 ============ */
:root {
  --primary: #0a7dff;
  --primary-light: #e8f2ff;
  --primary-dark: #0866d6;
  --bg: #f4f6fa;
  --card-bg: #fff;
  --text: #1a1a2e;
  --text-sub: #6b7280;
  --border: #e6e8ee;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(20, 40, 90, 0.06);
  --shadow-hover: 0 10px 28px rgba(20, 40, 90, 0.12);
  --danger: #ff4d4f;
  --success: #22c55e;
  --warning: #f59e0b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ============ 顶部导航 ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(20,40,90,0.04);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), #5aa9ff);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(10,125,255,0.3);
}
.logo-text { font-size: 22px; font-weight: 800; color: var(--primary); }
.logo-sub { font-size: 12px; color: var(--text-sub); margin-left: 2px; }

.header-right { display: flex; align-items: center; gap: 16px; }
.icon-btn {
  width: 36px; height: 36px;
  border: none; background: var(--primary-light);
  border-radius: 9px; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.icon-btn:hover { background: #d6e7ff; transform: scale(1.05); }

/* ============ 语言选择器 ============ */
.lang-wrap { position: relative; display: inline-block; }
.lang-btn {
  /* 覆盖 .icon-btn 的固定 36x36 方形 —— 按钮现在要装「旗帜 + 语言名」，
     改为宽度自适应，并加 min-width 容纳最短语言名（如 "中文"） */
  width: auto;
  height: auto;
  min-width: 96px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* 显式隐藏 emoji 字体可能造成的奇怪上下偏移 */
  line-height: 1;
}
.lang-btn .lang-flag {
  font-size: 16px;
  line-height: 1;
  /* 旗帜 emoji 在部分平台是双宽度，固定行高避免按钮高度跳变 */
  display: inline-block;
}
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 200;
  display: none;
  width: max-content;
  min-width: 220px;
  max-width: 320px;
  max-height: 420px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(20,40,90,0.14);
  padding: 6px;
  /* 强制纵向排列：每项独占一行，绝不横向 */
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}
.lang-menu.open { display: flex; }
.lang-menu::-webkit-scrollbar { width: 6px; }
.lang-menu::-webkit-scrollbar-thumb { background: #d0d9e6; border-radius: 3px; }
.lang-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s;
}
.lang-item:hover { background: var(--primary-light); }
.lang-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }


.nav-link { font-size: 14px; color: var(--text-sub); transition: color .2s; }
.nav-link:hover { color: var(--primary); }
.login-btn {
  padding: 7px 20px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 20px;
  font-size: 14px; font-weight: 600;
  transition: all .2s;
}
.login-btn:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(10,125,255,0.3); }

.search-box { display: none; }
.search-box.active { display: block; }
.search-box input {
  padding: 8px 16px; border: 2px solid var(--primary);
  border-radius: 20px; font-size: 14px; width: 240px;
  outline: none;
}

/* 分类导航 */
.cat-nav {
  border-top: 1px solid var(--border);
  background: #fff;
}
.cat-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cat-nav-inner::-webkit-scrollbar { display: none; }
.cat-item {
  flex-shrink: 0;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-sub);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all .2s;
  display: flex; align-items: center; gap: 6px;
}
.cat-item:hover { color: var(--primary); }
.cat-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.cat-item .cat-icon { font-size: 16px; }

.header-placeholder { height: 0; }

/* ============ Hero ============ */
.hero {
  background: linear-gradient(135deg, #eaf2ff 0%, #d5e8ff 50%, #eaf4ff 100%);
  padding: 60px 24px 50px;
  text-align: center;
}
.hero h1 { font-size: 40px; font-weight: 800; letter-spacing: 1px; color: #123a6b; margin-bottom: 12px; }
.hero p { font-size: 17px; color: #41618c; }
.hero p .count-up { color: var(--primary); }
.hero-search {
  margin-top: 26px;
  display: flex; justify-content: center;
}
.hero-search input {
  width: 480px; max-width: 80vw;
  padding: 14px 22px;
  border: 2px solid var(--primary);
  border-radius: 30px 0 0 30px;
  font-size: 15px;
  outline: none;
  background: #fff;
}
.hero-search button {
  padding: 14px 32px;
  background: var(--primary); color: #fff;
  border: 2px solid var(--primary);
  border-radius: 0 30px 30px 0;
  font-size: 15px; font-weight: 600;
  transition: background .2s;
}
.hero-search button:hover { background: var(--primary-dark); }

/* ============ 工具区 ============ */
.main { max-width: 1280px; margin: 0 auto; padding: 30px 24px 60px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.section-head h2 { font-size: 24px; font-weight: 800; color: #123a6b; position: relative; padding-left: 14px; }
.section-head h2::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 5px; background: var(--primary); border-radius: 3px;
}
.section-count { font-size: 13px; color: var(--text-sub); }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.tool-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  cursor: pointer;
  transition: all .25s;
  position: relative;
  display: flex; flex-direction: column;
}
.tool-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
  border-color: #b8d6ff;
}
.tool-card .t-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  margin-bottom: 12px;
}
.tool-card .t-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.tool-card .t-desc {
  font-size: 12.5px; color: var(--text-sub);
  line-height: 1.5;
  flex: 1;
}
.tool-card .t-tags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  font-weight: 600;
}
.tag.hot { background: #ffe8e6; color: #ff4d4f; }
.tag.new { background: #e8f7ee; color: #16a34a; }
.tag.limit { background: #fef3e2; color: #d97706; }
.tag.offline { background: #e8e8f8; color: #6366f1; }

.tool-card.disabled { opacity: .5; cursor: not-allowed; }
.tool-card.disabled:hover { transform: none; box-shadow: none; border-color: var(--border); }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 0;
  color: var(--text-sub);
  font-size: 16px;
}
.empty-state .emoji { font-size: 50px; display: block; margin-bottom: 16px; }

/* ============ 页脚 ============ */
.site-footer {
  background: #123a6b;
  color: #b9cbe2;
  padding: 50px 24px;
  text-align: center;
}
.footer-slogan { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 16px; }
.footer-links { font-size: 13px; margin-bottom: 14px; }
.footer-links a { color: #9db8d8; margin: 0 8px; transition: color .2s; }
.footer-links a:hover { color: #fff; }
.footer-links span { color: #3d5d85; }
.footer-copy { font-size: 12px; color: #6c88aa; margin-bottom: 8px; }
.footer-note { font-size: 12px; color: #6c88aa; }

.back-top {
  position: fixed; right: 24px; bottom: 24px;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--primary); color: #fff;
  border: none; font-size: 20px;
  box-shadow: 0 6px 16px rgba(10,125,255,0.35);
  opacity: 0; pointer-events: none;
  transition: all .3s;
  z-index: 99;
}
.back-top.show { opacity: 1; pointer-events: auto; }
.back-top:hover { background: var(--primary-dark); transform: translateY(-3px); }

/* ============ 工具弹窗 ============ */
.tool-modal-mask {
  position: fixed; inset: 0;
  background: rgba(15,25,50,0.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.tool-modal-mask.active { display: flex; }
.tool-modal {
  background: #fff;
  border-radius: 18px;
  width: 640px; max-width: 100%;
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: modalIn .3s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(30px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border: none; background: #f0f2f7;
  border-radius: 8px;
  font-size: 14px;
  transition: background .2s;
}
.modal-close:hover { background: #e0e4ec; }
.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* 政策文档样式 */
.doc-wrap { max-width: 720px; }
.doc-updated {
  font-size: 13px; color: var(--text-sub);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.doc-section { margin-bottom: 20px; }
.doc-section:last-child { margin-bottom: 0; }
.doc-section h4 {
  font-size: 15px; font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}
.doc-section p {
  font-size: 14px; line-height: 1.9;
  color: var(--text);
  text-align: justify;
}

/* 工具通用控件 */
.tool-section { margin-bottom: 20px; }
.tool-section:last-child { margin-bottom: 0; }
.tool-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; color: #3a4a6a; }
.tool-input, .tool-textarea, .tool-select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  background: #fff;
}
.tool-input:focus, .tool-textarea:focus, .tool-select:focus { border-color: var(--primary); }
.tool-textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.tool-btn {
  padding: 11px 24px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  transition: all .2s;
  margin-right: 10px;
  margin-bottom: 8px;
}
.tool-btn:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(10,125,255,0.3); }
.tool-btn.secondary { background: #f0f2f7; color: var(--text); }
.tool-btn.secondary:hover { background: #e0e4ec; box-shadow: none; }
.tool-btn.green { background: var(--success); }
.tool-btn.green:hover { background: #1aa64e; box-shadow: 0 4px 12px rgba(34,197,94,0.3); }
.tool-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.tool-result {
  margin-top: 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  word-break: break-all;
  display: none;
}
.tool-result.show { display: block; }
.tool-result pre {
  white-space: pre-wrap; word-break: break-all;
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 12.5px;
}

/* 上传区 */
.upload-zone {
  border: 2px dashed #c5d6ee;
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  color: var(--text-sub);
  cursor: pointer;
  transition: all .2s;
  background: #fbfdff;
}
.upload-zone:hover { border-color: var(--primary); background: #f0f7ff; }
.upload-zone .u-icon { font-size: 34px; display: block; margin-bottom: 8px; }
.upload-zone .u-text { font-size: 14px; }
.upload-zone .u-hint { font-size: 12px; color: #9aa3b2; margin-top: 4px; }
.upload-preview {
  margin-top: 14px; display: none;
  text-align: center;
}
.upload-preview.show { display: block; }
.upload-preview img {
  max-width: 100%; max-height: 260px;
  border-radius: 10px; border: 1px solid var(--border);
}

/* 参数行 */
.param-row { display: flex; gap: 12px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.param-row .tool-label { margin-bottom: 0; min-width: 80px; }
.param-row input[type=range] { flex: 1; accent-color: var(--primary); }
.param-val { font-size: 13px; color: var(--primary); font-weight: 700; min-width: 36px; text-align: center; }

/* 结果下载链接 */
.download-link {
  display: inline-block;
  margin-top: 10px;
  padding: 9px 20px;
  background: var(--success); color: #fff;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  transition: all .2s;
}
.download-link:hover { background: #1aa64e; }

/* 双栏结果 */
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.result-grid .item { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.result-grid .item-label { font-size: 12px; color: var(--text-sub); margin-bottom: 6px; }
.result-grid .item-val { font-size: 13px; word-break: break-all; }

/* 灯箱 LED */
.led-stage {
  width: 100%; height: 140px;
  background: #111;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.led-text {
  color: #f43f5e;
  font-size: 40px;
  font-weight: 900;
  white-space: nowrap;
  text-shadow: 0 0 10px #f43f5e, 0 0 30px #f43f5e;
  letter-spacing: 4px;
  font-family: "Courier New", monospace;
}
.led-controls { display: flex; gap: 10px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.led-controls .tool-input { flex: 1; min-width: 120px; }

/* 单词卡片等 */
.periodic-table { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.periodic-table .elm {
  padding: 4px 2px; text-align: center; border-radius: 5px;
  font-size: 11px; cursor: pointer;
  color: #fff; min-height: 44px;
  display: flex; flex-direction: column; justify-content: center;
  transition: transform .15s;
}
.periodic-table .elm:hover { transform: scale(1.12); }
.periodic-table .elm .sym { font-weight: 800; font-size: 13px; }
.periodic-table .elm .num { font-size: 9px; opacity: .85; }

/* 提示消息 */
.toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: #123a6b; color: #fff;
  padding: 12px 26px;
  border-radius: 30px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transition: transform .4s ease;
  z-index: 300;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* 滚动条 */
.modal-body::-webkit-scrollbar, .tool-textarea::-webkit-scrollbar, .tool-result::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-thumb, .tool-textarea::-webkit-scrollbar-thumb, .tool-result::-webkit-scrollbar-thumb {
  background: #cfd6e4; border-radius: 4px;
}

/* 响应式 */
@media (max-width: 768px) {
  .hero h1 { font-size: 28px; }
  .logo-sub { display: none; }
  .nav-link { display: none; }
  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .header-inner { padding: 12px 16px; }
  .hero { padding: 40px 16px; }
  .main { padding: 20px 16px 40px; }
  .result-grid { grid-template-columns: 1fr; }
}

/* ============ SEO 内容区 ============ */
.seo-content {
  padding: 40px 20px 48px;
  background: linear-gradient(180deg, #fff, #f4f6fa);
  border-top: 1px solid var(--border);
}
.seo-inner {
  max-width: 1080px; margin: 0 auto;
}
.seo-inner h2 {
  font-size: 22px; color: var(--text);
  margin-bottom: 14px;
}
.seo-inner h3 {
  font-size: 16px; color: var(--primary);
  margin: 22px 0 8px;
}
.seo-inner p {
  font-size: 14px; line-height: 1.9; color: #3a4a6a;
  text-align: justify;
}
.seo-inner a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dashed rgba(10,125,255,.4);
}
.seo-inner a:hover { color: var(--primary-dark); }
/* 静态工具列表：保留 DOM 供爬虫读取，视觉隐藏 */
.seo-tools {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============ 工具详情页（/detail/{num}） ============ */
.detail-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}
.detail-inner { max-width: 920px; margin: 0 auto; }
/* 面包屑 */
.crumb-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 20px;
}
.crumb-nav a { color: var(--primary); }
.crumb-nav a:hover { color: var(--primary-dark); text-decoration: underline; }
.crumb-sep { color: #c3c9d6; }
.crumb-cur { color: var(--text); font-weight: 600; }
/* 返回按钮 */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  transition: all .2s;
  box-shadow: var(--shadow);
}
.back-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateX(-2px); }
/* 详情头部 */
.detail-title {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 26px 28px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.detail-title .t-icon {
  width: 64px; height: 64px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
}
.detail-title h1 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.detail-title p { font-size: 14px; color: var(--text-sub); }
.detail-tags { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
/* 工具主体运行区 */
.detail-body {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  min-height: 260px;
}
/* 相关工具 */
.related-wrap { margin-top: 28px; }
.related-wrap h3 { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.related-grid { gap: 16px; }
.related-grid .tool-card { margin-bottom: 0; }

/* 详情页头部容器（面包屑/返回按钮）整体样式 */
.detail-head { display: flex; flex-direction: column; }
.detail-crumb { margin-bottom: 4px; }

/* 响应式 */
@media (max-width: 640px) {
  .detail-page { padding: 18px 14px 40px; }
  .detail-title { padding: 20px; flex-direction: column; }
  .detail-title .t-icon { width: 52px; height: 52px; font-size: 26px; }
  .detail-title h1 { font-size: 20px; }
  .detail-body { padding: 16px; }
}
