/* ==========================================================================
   胡同学助手 - 全局样式
   视觉参数严格遵循《V3.0 全量开发需求文档》3.1 节，禁止自由发挥
   ========================================================================== */

/* ---------- 1. 设计变量 ---------- */
:root {
  /* 品牌色 */
  --c-primary: #1677ff;
  --c-primary-hover: #4096ff;
  --c-primary-active: #0958d9;
  --c-primary-bg: #e8f3ff;
  --c-accent: #ff7d00;

  /* 中性色 */
  --c-bg: #f7f8fa;
  --c-surface: #ffffff;
  --c-border: #e5e6eb;
  --c-text: #1d2129;
  --c-text-sub: #4e5969;
  --c-text-placeholder: #86909c;

  /* 功能色 */
  --c-success: #00b42a;
  --c-error: #f53f3f;
  --c-info: #1677ff;
  --c-warn: #ff7d00;

  /* 圆角 */
  --r-control: 8px;   /* 按钮 / 输入框 */
  --r-card: 12px;     /* 卡片 / 上传区域 */

  /* 阴影 */
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-card-hover: 0 8px 20px rgba(0, 0, 0, 0.12);
  --shadow-focus: 0 0 0 2px rgba(22, 119, 255, 0.15);

  /* 间距 */
  --gap-block: 24px;  /* 区块之间 */
  --gap-card: 20px;   /* 卡片内边距 */
  --gap-label: 8px;   /* 表单标签与输入框 */

  /* 层级 */
  --z-nav: 100;
  --z-modal: 200;
  --z-toast: 300;

  /* 布局 */
  --layout-max: 1200px;
  --nav-h: 60px;
}

/* ---------- 2. 深色模式（纯 CSS 跟随系统，不做手动切换按钮） ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #17171a;
    --c-surface: #232324;
    --c-border: #373739;
    --c-text: #e5e6eb;
    --c-text-sub: #a9aeb8;
    --c-text-placeholder: #6b6e76;
    --c-primary-bg: #12305c;
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-card-hover: 0 8px 20px rgba(0, 0, 0, 0.55);
  }
}

/* ---------- 3. 基础重置 ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  /* 移动端视口高度修正 */
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* 焦点样式统一为主色边框，禁止浏览器默认粗黑 outline */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: var(--r-control);
}

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

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.35; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

/* ---------- 4. 布局容器 ---------- */
.wrap {
  width: 100%;
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 0 16px;
}

.block { margin-top: var(--gap-block); }
.block:first-child { margin-top: var(--gap-block); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 { font-size: 20px; }
.section-head .more {
  font-size: 13px;
  color: var(--c-text-sub);
}

/* ---------- 5. 导航栏 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  height: var(--nav-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--c-text);
  flex-shrink: 0;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--r-control);
  background: var(--c-primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.nav-links a {
  padding: 6px 10px;
  border-radius: var(--r-control);
  color: var(--c-text-sub);
  font-size: 14px;
  white-space: nowrap;
}
.nav-links a:hover {
  background: var(--c-primary-bg);
  color: var(--c-primary);
  text-decoration: none;
}
.nav-links a.is-active {
  color: var(--c-primary);
  font-weight: 600;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  /* 关键：移动端 .nav-links 会变成 position:fixed 脱离文档流，其 flex:1 随之失效，
     若无此规则，搜索按钮与汉堡菜单会紧贴 logo 而不是靠右 */
  margin-left: auto;
}

/* 搜索唤起按钮 */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-control);
  background: var(--c-bg);
  color: var(--c-text-placeholder);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-trigger:hover {
  border-color: var(--c-primary);
}
.search-trigger .kbd {
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  font-size: 11px;
}

/* 汉堡菜单（移动端） */
.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-control);
  background: var(--c-surface);
  cursor: pointer;
  padding: 0;
}
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 3px auto;
  background: var(--c-text);
  border-radius: 2px;
}

/* ---------- 6. 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-control);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn:active { transform: translateY(1px); }
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--c-primary-hover);
  border-color: var(--c-primary-hover);
  color: #fff;
}
.btn-primary:active { background: var(--c-primary-active); }

.btn-accent {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}
.btn-accent:hover { filter: brightness(1.06); color: #fff; }

.btn-sm { min-height: 30px; padding: 0 12px; font-size: 13px; }
.btn-ghost { background: transparent; }

/* ---------- 7. 卡片 ---------- */
.card {
  padding: var(--gap-card);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s, transform 0.2s;
}
.card-hover:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

/* 工具卡片网格 */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.tool-card {
  position: relative;
  display: block;
  padding: var(--gap-card);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  color: var(--c-text);
  transition: box-shadow 0.2s, transform 0.2s;
}
.tool-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  text-decoration: none;
}
/* 工具图标：语义化 emoji + 分类主题色底，让 97 个图标既个性分明又有分类归属感 */
.tool-card .tc-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-control);
  display: grid;
  place-items: center;
  font-size: 21px;
  line-height: 1;
  background: var(--tint-bg, var(--c-primary-bg));
  margin-bottom: 10px;
}
/* 分类主题色底（浅色） */
.tool-card[data-cat="doc"]    { --tint-bg: #e8f3ff; }
.tool-card[data-cat="image"]  { --tint-bg: #f5e8ff; }
.tool-card[data-cat="calc"]   { --tint-bg: #ffe8f3; }
.tool-card[data-cat="text"]   { --tint-bg: #e6fffb; }
.tool-card[data-cat="dev"]    { --tint-bg: #f0ffe6; }
.tool-card[data-cat="office"] { --tint-bg: #fff4e6; }
.tool-card[data-cat="life"]   { --tint-bg: #ffece8; }
/* 深色模式下改用低饱和深底，保证 emoji 与文字对比度 */
@media (prefers-color-scheme: dark) {
  .tool-card[data-cat="doc"]    { --tint-bg: #12305c; }
  .tool-card[data-cat="image"]  { --tint-bg: #2a1a4d; }
  .tool-card[data-cat="calc"]   { --tint-bg: #4d1a38; }
  .tool-card[data-cat="text"]   { --tint-bg: #0d3d3a; }
  .tool-card[data-cat="dev"]    { --tint-bg: #1f3d12; }
  .tool-card[data-cat="office"] { --tint-bg: #4d3212; }
  .tool-card[data-cat="life"]   { --tint-bg: #4d1a18; }
}
.tool-card .tc-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.tool-card .tc-desc {
  font-size: 13px;
  color: var(--c-text-sub);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 42px;
}
.tool-card .tc-soon {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--c-border);
  color: var(--c-text-sub);
  font-size: 11px;
}
/* 未上线工具不可点击态 */
.tool-card.is-disabled {
  opacity: 0.72;
  cursor: not-allowed;
}
.tool-card.is-disabled:hover {
  transform: none;
  box-shadow: var(--shadow-card);
}

/* 分类卡片 */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.cat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px var(--gap-card);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  color: var(--c-text);
  transition: box-shadow 0.2s, transform 0.2s;
}
.cat-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  text-decoration: none;
}
.cat-card .cc-icon { font-size: 22px; }
.cat-card .cc-name { font-weight: 600; font-size: 14px; }
.cat-card .cc-count { font-size: 12px; color: var(--c-text-placeholder); }

/* ---------- 8. 表单控件 ---------- */
.field { margin-bottom: 16px; }
.field > label {
  display: block;
  margin-bottom: var(--gap-label);
  font-size: 13px;
  color: var(--c-text-sub);
  font-weight: 500;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-control);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;              /* 禁止粗黑 outline */
  border-color: var(--c-primary);
  box-shadow: var(--shadow-focus);
}
.input::placeholder,
.textarea::placeholder { color: var(--c-text-placeholder); }

.field-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.field-row > .field { flex: 1 1 200px; margin-bottom: 0; }

.hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--c-text-placeholder);
}

/* 单选组（分段控件） */
.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-control);
  background: var(--c-bg);
  gap: 2px;
  flex-wrap: wrap;
}
.segmented button {
  min-height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--c-text-sub);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.segmented button[aria-pressed="true"] {
  background: var(--c-primary);
  color: #fff;
}

/* ---------- 9. 上传区域 ---------- */
.uploader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  padding: var(--gap-card);
  border: 1px dashed var(--c-border);
  border-radius: var(--r-card);
  background: var(--c-surface);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.uploader:hover { border-color: var(--c-primary); }
.uploader.is-dragover {
  border-color: var(--c-primary);
  background: var(--c-primary-bg);
}
.uploader.is-dragover .up-main { color: var(--c-primary); }
.uploader .up-icon { font-size: 32px; line-height: 1; }
.uploader .up-main { font-size: 14px; font-weight: 600; }
.uploader .up-sub { font-size: 12px; color: var(--c-text-placeholder); }

/* ---------- 10.5 显式计算（参数变更 → 点击计算） ---------- */
/* 按钮上的待计算脉冲点 */
.btn .run-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-accent);
  flex-shrink: 0;
  animation: run-pulse 1.4s ease-in-out infinite;
}
@keyframes run-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.75); }
}

/* 结果区上方的「参数已变更」提示条 */
.dirty-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: var(--r-control);
  background: #fff7e8;
  border: 1px solid #ffd591;
  color: #ad4e00;
  font-size: 13px;
}
.dirty-bar[hidden] { display: none; }
@media (prefers-color-scheme: dark) {
  .dirty-bar { background: #3a2a10; border-color: #6b4a16; color: #ffd591; }
}

/* 结果区在参数变更后置灰，提示当前结果已过期 */
.result-stale {
  opacity: 0.55;
  filter: saturate(0.6);
  transition: opacity 0.2s, filter 0.2s;
}

/* ---------- 10. 结果区 / 对比 ---------- */
.result-box {
  padding: var(--gap-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  background: var(--c-surface);
}
.result-empty {
  padding: 32px var(--gap-card);
  text-align: center;
  color: var(--c-text-placeholder);
  font-size: 13px;
}

.compare {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 14px;
}
.compare .cmp-item { text-align: center; }
.compare .cmp-num { font-size: 20px; font-weight: 700; }
.compare .cmp-label { font-size: 12px; color: var(--c-text-sub); }
.compare .cmp-arrow { color: var(--c-primary); font-size: 18px; }
.compare .cmp-save { color: var(--c-success); font-weight: 600; }

.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.file-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-control);
  background: var(--c-surface);
  font-size: 13px;
}
.file-list .fl-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-list .fl-size { color: var(--c-text-placeholder); flex-shrink: 0; }

/* 进度条 */
.progress {
  height: 6px;
  border-radius: 3px;
  background: var(--c-border);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--c-primary);
  border-radius: 3px;
  transition: width 0.2s;
}

/* ---------- 11. 提示条 / 合规 ---------- */
.alert {
  padding: 10px 14px;
  border-radius: var(--r-control);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid transparent;
}
.alert-danger {
  background: #ffece8;
  border-color: #fbaca3;
  color: #cb2634;
}
.alert-info {
  background: var(--c-primary-bg);
  border-color: #b6d4ff;
  color: var(--c-primary-active);
}
@media (prefers-color-scheme: dark) {
  .alert-danger { background: #3d1416; border-color: #7a2b2f; color: #ffcdcb; }
  .alert-info { background: #12305c; border-color: #1e4f96; color: #a6d0ff; }
}

.disclaimer {
  margin-top: 12px;
  font-size: 12px;
  color: var(--c-text-placeholder);
}

/* ---------- 12. Toast ---------- */
.toast-layer {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  min-width: 200px;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: var(--r-control);
  background: var(--c-surface);
  border-left: 3px solid var(--c-info);
  box-shadow: var(--shadow-card-hover);
  font-size: 13px;
  color: var(--c-text);
  animation: toast-in 0.2s ease-out;
}
.toast.is-out { animation: toast-out 0.2s ease-in forwards; }
.toast-success { border-left-color: var(--c-success); }
.toast-error { border-left-color: var(--c-error); }
.toast-info { border-left-color: var(--c-info); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* ---------- 13. 搜索弹层 ---------- */
.search-mask {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(0, 0, 0, 0.45);
  display: none;
  padding: 10vh 16px 16px;
}
.search-mask.is-open { display: block; }
.search-panel {
  max-width: 640px;
  margin: 0 auto;
  background: var(--c-surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card-hover);
  overflow: hidden;
}
.search-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--c-border);
  background: transparent;
  color: var(--c-text);
  font-size: 16px;
  font-family: inherit;
}
.search-input:focus { outline: none; }
.search-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 8px;
  margin: 0;
  list-style: none;
}
.search-results li {
  padding: 8px 12px;
  border-radius: var(--r-control);
  cursor: pointer;
}
.search-results li[aria-selected="true"] { background: var(--c-primary-bg); }
.search-results .sr-name { font-size: 14px; font-weight: 600; }
.search-results .sr-cat {
  margin-left: 8px;
  font-size: 11px;
  color: var(--c-text-placeholder);
  font-weight: 400;
}
.search-results .sr-desc {
  font-size: 12px;
  color: var(--c-text-sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--c-text-placeholder);
  font-size: 13px;
}

/* ---------- 14. 收藏星标 ---------- */
.fav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-control);
  background: var(--c-surface);
  color: var(--c-text-sub);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.fav-btn:hover { border-color: var(--c-accent); color: var(--c-accent); }
.fav-btn.is-fav {
  border-color: var(--c-primary);
  color: var(--c-primary);
}
.fav-btn .star { font-size: 16px; line-height: 1; }

/* ---------- 15. 回到顶部 ---------- */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--z-nav);
  width: 44px;
  height: 44px;
  border: 1px solid var(--c-border);
  border-radius: 50%;
  background: var(--c-surface);
  box-shadow: var(--shadow-card);
  color: var(--c-text-sub);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s, box-shadow 0.2s;
}
.back-to-top.is-show { opacity: 1; visibility: visible; }
.back-to-top:hover {
  color: var(--c-primary);
  box-shadow: var(--shadow-card-hover);
}

/* ---------- 16. 面包屑 ---------- */
.breadcrumb {
  padding: 12px 0;
  font-size: 13px;
  color: var(--c-text-placeholder);
}
.breadcrumb a { color: var(--c-text-sub); }
.breadcrumb .sep { margin: 0 6px; }

/* ---------- 17. 工具页布局 ---------- */
.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: var(--gap-block);
  align-items: start;
}
.tool-main { min-width: 0; }
.tool-side { display: flex; flex-direction: column; gap: 16px; }
.side-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}
.side-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-list a {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--c-text-sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-list a:hover {
  background: var(--c-primary-bg);
  color: var(--c-primary);
  text-decoration: none;
}

.tool-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tool-head h1 { font-size: 24px; margin-bottom: 4px; }
.tool-head .th-desc { font-size: 13px; color: var(--c-text-sub); }
/* 工具页头部右侧：收藏按钮 + 该工具的版本与上线时间 */
.tool-head .th-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: none;
}
.tool-head .th-meta {
  font-size: 12px;
  line-height: 1.4;
  color: var(--c-text-placeholder);
  white-space: nowrap;
}
/* 工具页头部：大号语义图标 + 分类主题色底 */
.tool-head .th-wrap {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}
.tool-head .th-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: var(--r-card);
  display: grid;
  place-items: center;
  font-size: 27px;
  line-height: 1;
  background: var(--tint-bg, var(--c-primary-bg));
}
[data-cat="doc"]    { --tint-bg: #e8f3ff; }
[data-cat="image"]  { --tint-bg: #f5e8ff; }
[data-cat="calc"]   { --tint-bg: #ffe8f3; }
[data-cat="text"]   { --tint-bg: #e6fffb; }
[data-cat="dev"]    { --tint-bg: #f0ffe6; }
[data-cat="office"] { --tint-bg: #fff4e6; }
[data-cat="life"]   { --tint-bg: #ffece8; }
@media (prefers-color-scheme: dark) {
  [data-cat="doc"]    { --tint-bg: #12305c; }
  [data-cat="image"]  { --tint-bg: #2a1a4d; }
  [data-cat="calc"]   { --tint-bg: #4d1a38; }
  [data-cat="text"]   { --tint-bg: #0d3d3a; }
  [data-cat="dev"]    { --tint-bg: #1f3d12; }
  [data-cat="office"] { --tint-bg: #4d3212; }
  [data-cat="life"]   { --tint-bg: #4d1a18; }
}
/* 分类卡图标同样使用主题色底 */
.cat-card .cc-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-control);
  display: grid;
  place-items: center;
  font-size: 21px;
  line-height: 1;
  background: var(--tint-bg, var(--c-primary-bg));
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .tool-head .th-icon { width: 44px; height: 44px; font-size: 23px; }
}

.action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* ---------- 17.5 工具页「左输入 / 右结果」分栏 ----------
   适用规则（需求文档 V3.1 新增）：输入项 ≤ 6 个、且结果为单一固定尺寸可视化
   （二维码、转盘、Canvas、单一对比卡片）时使用左右分栏，保证桌面端一屏操作完成。
   批量处理类（文件列表可能很长）与多结果列表类（如单位换算全量表）仍用上下结构。 */
.tool-split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: var(--gap-block);
  align-items: start;
}
/* 右栏结果区吸顶，长输入时结果始终可见 */
.tool-split .split-result {
  position: sticky;
  top: calc(var(--nav-h) + 16px);
}
.tool-split .split-input > .field:last-of-type { margin-bottom: 0; }

/* 转盘/二维码等固定尺寸画布在右栏居中 */
.tool-split .split-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 200px;
  justify-content: center;
}

@media (max-width: 1024px) {
  .tool-split { grid-template-columns: minmax(0, 1fr); }
  .tool-split .split-result { position: static; }
}

/* ---------- 18. 首页 Hero ---------- */
.hero {
  padding: 48px 0 32px;
  text-align: center;
}
.hero h1 { font-size: 34px; margin-bottom: 12px; }
.hero .hero-sub {
  font-size: 15px;
  color: var(--c-text-sub);
  margin-bottom: 24px;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.hero-stats .hs-num { font-size: 22px; font-weight: 700; color: var(--c-primary); }
.hero-stats .hs-label { font-size: 12px; color: var(--c-text-sub); }

/* 内联首页搜索 */
.hero-search {
  display: flex;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}
.hero-search .input { flex: 1; min-height: 44px; font-size: 15px; }

/* ---------- 19. 页脚 ---------- */
.footer {
  margin-top: 48px;
  padding: 32px 0 24px;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 24px;
}
.footer h4 { font-size: 14px; margin-bottom: 10px; }
.footer ul { margin: 0; padding: 0; list-style: none; }
.footer li { margin-bottom: 6px; font-size: 13px; }
.footer li a { color: var(--c-text-sub); }
.footer-bottom {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
  text-align: center;
  font-size: 12px;
  color: var(--c-text-placeholder);
}
.footer-bottom a { color: var(--c-text-placeholder); }

/* ---------- 20. 响应式断点 ---------- */
/* 平板：<=1024px —— 工具页侧边栏移到下方 */
@media (max-width: 1024px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr); }
  .tool-side { order: 2; }
  .nav-links { gap: 0; }
  .nav-links a { padding: 6px 8px; font-size: 13px; }
  .search-trigger { min-width: 140px; }
}

/* 移动端：<=768px —— 汉堡菜单折叠导航 */
@media (max-width: 768px) {
  body { font-size: 14px; }
  h1 { font-size: 22px; }
  .hero { padding: 32px 0 24px; }
  .hero h1 { font-size: 26px; }
  .hero-stats { gap: 20px; }

  .hamburger { display: block; }
  .search-trigger .kbd { display: none; }
  .search-trigger { min-width: 40px; padding: 0 10px; }
  .search-trigger .st-text { display: none; }
  /* 收紧导航间距，保证 320px 窄屏下 logo + 搜索 + 汉堡不换行 */
  .nav-inner { gap: 10px; }
  .logo { font-size: 16px; }
  .logo-mark { width: 26px; height: 26px; font-size: 14px; }

  /* 折叠后的导航抽屉 */
  .nav-links {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    z-index: var(--z-nav);
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px 16px 16px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow-card);
    max-height: calc(100dvh - var(--nav-h));
    overflow-y: auto;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a {
    padding: 12px 10px;          /* 触控区域 >= 44px */
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: 15px;
  }

  .tool-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .card { padding: 16px; }

  /* 移动端按钮触控区域 >= 44px */
  .btn { min-height: 44px; padding: 0 18px; }
  .btn-sm { min-height: 40px; }
  .segmented button { min-height: 40px; padding: 0 16px; }
  .input, .select { min-height: 44px; font-size: 16px; }  /* 16px 防 iOS 自动缩放 */
  .back-to-top { right: 16px; bottom: 16px; width: 48px; height: 48px; }
  .toast-layer { left: 16px; right: 16px; top: 12px; }
  .toast { max-width: none; }
  .search-trigger { min-height: 40px; }
}

@media (max-width: 480px) {
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .tool-card .tc-desc { display: none; }
  .tool-card .tc-icon { width: 34px; height: 34px; font-size: 17px; }
}

/* ---------- 21. 打印（隐藏导航/按钮/侧边栏） ---------- */
@media print {
  .nav, .footer, .back-to-top, .tool-side, .action-bar,
  .breadcrumb, .uploader, .toast-layer, .search-mask { display: none !important; }
  body { background: #fff; }
  .card, .tool-card, .result-box { box-shadow: none; border-color: #ccc; }
}

/* ---------- 22. 工具类 ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-center { text-align: center; }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* 尊重用户的减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 23. 右侧栏增强（试点：build.py PILOT_CATS） ----------
   结构：我的收藏（JS）+ 随机推荐（JS 换一批）+ 同类推荐/数据来源（静态）。
   sticky 跟随：整体吸顶；不做 max-height 截断与栏内滚动，
   视口装不下时随主内容滚到底自然释放，底部卡片滚到底即可见。
   图标色底 --tint-bg 由 body[data-cat] 提供（见第 20 节），自动继承分类主题色。 */
.side-rich {
  position: sticky;
  top: calc(var(--nav-h) + 16px);
}
.side-card { padding: 14px 16px; }
/* 窄屏侧栏下沉到主内容之后，取消吸顶 */
@media (max-width: 1024px) {
  .side-rich { position: static; }
}

/* 工具列表（收藏 / 随机推荐共用）：图标 chip + 名称 */
.side-tools { gap: 2px; }
.side-tools a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  white-space: normal;
}
.side-tools .tc-icon {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1;
  margin-bottom: 0;
  background: var(--tint-bg, var(--c-primary-bg));
}
.side-tool-name { font-size: 13px; }

/* 我的收藏：JS 渐进增强，空态保留构建期静态提示；
   min-height 让空态卡片与相邻卡片视觉协调（分类页/工具页共用） */
.side-mine-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 108px;
}
.side-mine-sec .side-sub {
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--c-text-sub);
}
.side-empty {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--c-text-sub);
}

/* 侧栏通用按钮（换一批 / 反馈与报错） */
.side-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 7px 0;
  border: 1px solid var(--c-border);
  border-radius: var(--r-control, 8px);
  background: var(--c-surface);
  color: var(--c-text-sub);
  font-size: 12px;
  cursor: pointer;
}
.side-btn:hover {
  color: var(--c-primary);
  border-color: var(--c-primary);
  background: var(--c-primary-bg);
}
.side-btn:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 1px;
}

/* 数据来源：权威外链，名称 + 说明两行 */
.side-src { gap: 4px; }
.side-src a {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 8px;
  white-space: normal;
}
.side-src b { font-size: 13px; font-weight: 500; }
.side-src b::after {
  content: " ↗";
  font-size: 11px;
  font-weight: 400;
  color: var(--c-text-sub);
}
.side-src span { font-size: 11px; color: var(--c-text-sub); }

/* 报错反馈（由页脚迁移至工具页侧栏，分类页无此卡） */
.side-feedback p {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--c-text-sub);
}
.side-feedback-mail { word-break: break-all; }
.side-feedback-mail a { color: var(--c-primary); }
.side-feedback-note { font-size: 11px; margin-bottom: 0; }
