/* =====================================================
 * style.css — 多功能工具箱 · 仿 runoob（菜鸟教程）风格 + 优化
 * 基底：白底顶栏 / 绿色品牌 / 左侧可折叠分类树 / 浅灰页面 + 白色内容卡
 * 优化：浅·深两态、平滑过渡、焦点环、移动端抽屉、减少动效适配
 * 类名与 app.js 渲染函数保持一致，已逐项核对。
 * ===================================================== */
* { box-sizing: border-box; }

/* ---------- 设计令牌：浅色（runoob 基底） ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace;
  /* logo 专用：圆体优先，自带柔和设计感；Windows 回退到现代中文黑体 */
  --font-logo: "Yuanti SC", "YuanTi SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Heiti SC", sans-serif;

  --bg: #f5f6f8;            /* 页面浅灰底 */
  --bg-tint: rgba(76, 175, 80, 0.05);

  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f3;
  --surface-hover: #f0f7f1; /* 悬停：极淡绿 */

  --border: #e6e8ec;
  --border-strong: #d8dbe0;

  --text: #2b2f36;
  --text-2: #4a515c;
  --muted: #8a929e;

  --primary: #4caf50;      /* 菜鸟绿 */
  --primary-d: #43a047;
  --primary-soft: rgba(76, 175, 80, 0.12);
  --primary-ring: rgba(76, 175, 80, 0.30);
  --accent: #2f9e44;
  --grad: linear-gradient(135deg, #4caf50 0%, #43a047 100%);
  --grad-soft: linear-gradient(135deg, rgba(76,175,80,.08), rgba(67,160,71,.06));

  --ok: #4caf50;
  --warn: #f59e0b;
  --danger: #e53935;

  --shadow-xs: 0 1px 2px rgba(20, 24, 40, 0.05);
  --shadow-sm: 0 1px 4px rgba(20, 24, 40, 0.07);
  --shadow-md: 0 10px 26px -10px rgba(20, 24, 40, 0.14);
  --shadow-lg: 0 20px 44px -16px rgba(20, 24, 40, 0.22);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --code-bg: #2b303b;
  --code-fg: #e6edf3;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- 设计令牌：深色（优化项） ---------- */
[data-theme="dark"] {
  --bg: #0f1115;
  --bg-tint: rgba(76, 175, 80, 0.06);

  --surface: #181b21;
  --surface-2: #1f232b;
  --surface-3: #272c35;
  --surface-hover: #1e2a22;

  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #e8ebf0;
  --text-2: #c2c8d2;
  --muted: #8b94a3;

  --primary: #5cc46a;
  --primary-d: #7ad988;
  --primary-soft: rgba(92, 196, 106, 0.16);
  --primary-ring: rgba(92, 196, 106, 0.34);
  --accent: #69db7c;
  --grad: linear-gradient(135deg, #5cc46a 0%, #43a047 100%);
  --grad-soft: linear-gradient(135deg, rgba(92,196,106,.14), rgba(67,160,71,.10));

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 5px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 12px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 22px 48px -16px rgba(0, 0, 0, 0.72);

  --code-bg: #0c0f15;
  --code-fg: #d6e2f0;
}

/* ---------- 基础 ---------- */
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  font-size: 14px; line-height: 1.65;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .3s ease, color .3s ease;
  overflow: hidden;
}
#app { display: flex; flex-direction: column; height: 100vh; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* ---------- 顶栏（白底，runoob 风） ---------- */
header.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  position: sticky; top: 0; z-index: 30;
}
.menu-btn {
  display: none; width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 17px; cursor: pointer; align-items: center; justify-content: center;
}
/* 居中分组：logo + 顶部导航 作为一个整体居中 */
.topgroup { display: flex; align-items: center; gap: 18px; flex: 1 1 auto; justify-content: center; min-width: 0; }
.topright { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

/* 文字 logo：纯绿字体 + 圆体（设计感强），整体干净利落 */
header.topbar .logo { display: inline-flex; align-items: center; cursor: pointer; user-select: none; }
.logo-word {
  font-family: var(--font-logo);
  font-size: 21px; font-weight: 800; letter-spacing: 1.5px; line-height: 1;
  color: var(--accent); white-space: nowrap;
  text-shadow: 0 1px 0 rgba(47, 158, 68, .12);
}

header.topbar .search { position: relative; flex: 0 1 340px; max-width: 340px; }
header.topbar .search input {
  width: 100%; padding: 9px 14px 9px 38px; border: 1px solid var(--border);
  border-radius: var(--radius-pill); font-size: 14px; background: var(--surface-2); color: var(--text);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s;
}
header.topbar .search input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--primary-soft); }
header.topbar .search::before { content: "🔍"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); opacity: .55; font-size: 13px; }
header.topbar .count { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* 主题切换器 */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 3px; gap: 2px; box-shadow: var(--shadow-xs); }
.seg button {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  width: 32px; height: 28px; border-radius: var(--radius-pill); font-size: 13px; line-height: 1;
  transition: background .2s var(--ease), color .2s var(--ease), transform .15s var(--ease);
}
.seg button:hover { color: var(--text); transform: translateY(-1px); }
.seg button.on { background: var(--surface); color: var(--primary-d); box-shadow: var(--shadow-sm); }

/* ---------- 主体布局 ---------- */
.body {
  display: flex; flex: 1; min-height: 0; position: relative;
  max-width: 1200px; margin: 0 auto; width: 100%; gap: 28px; align-items: flex-start;
  padding: 22px 28px 60px; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; scroll-behavior: smooth; background: var(--bg);
}
/* 全局隐藏页面/左栏滚动条（仅靠滚轮或触控板滚动，更干净） */
.body::-webkit-scrollbar, #sidebar::-webkit-scrollbar, #main::-webkit-scrollbar { display: none; width: 0; height: 0; }
#sidebar {
  flex: 0 0 230px; width: 230px; align-self: flex-start; position: sticky; top: 0;
  max-height: calc(100vh - 120px); overflow-y: auto; scrollbar-width: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 8px 14px;
}
/* 首页等不需要左菜单时隐藏 */
#sidebar.is-hidden { display: none !important; }
/* 侧边栏：仿 runoob 左侧分类树（仅工具详情页显示，内容为当前大分类的二级分类） */
#sidebar .tree-title {
  display: block; padding: 14px 16px 12px; margin: 0 10px 10px;
  font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: .3px;
  border-bottom: 1px solid var(--border); text-decoration: none;
  transition: color .15s var(--ease);
}
#sidebar .tree-title:hover { color: var(--primary-d); }
/* 工具页左栏：手风琴分类树（点击分类展开其工具，再点其他收起前一个） */
.tree-group { margin: 2px 8px; }
.tree-group-head {
  display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px; font-weight: 600;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.tree-group-head:hover { background: var(--surface-hover); color: var(--text); }
.tree-group-head .tg-caret { width: 14px; font-size: 11px; color: var(--muted); transition: transform .2s var(--ease); }
.tree-group.open .tg-caret { transform: rotate(90deg); }
.tree-group-head .tg-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-group-head .tg-count { font-size: 11px; color: var(--muted); background: var(--surface-3); padding: 1px 8px; border-radius: var(--radius-pill); }
.tree-group-body { display: none; padding: 2px 0 6px; }
.tree-group.open .tree-group-body { display: block; }
.tree-sub {
  display: block; padding: 7px 12px 7px 34px; margin: 1px 0;
  color: var(--text-2); font-size: 13px; text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.tree-sub:hover { background: var(--surface-hover); color: var(--text); }
.tree-sub.active { background: var(--primary-soft); color: var(--primary-d); font-weight: 600; border-left-color: var(--primary); }

/* 移动端遮罩 */
.scrim { display: none; position: fixed; inset: 0; background: rgba(15, 17, 21, 0.45); z-index: 25; opacity: 0; transition: opacity .25s var(--ease); }

/* ---------- 主区 ---------- */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
#main > * { width: 100%; max-width: 1200px; }
/* 工具页白色内容卡（runoob 风） */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px 26px; max-width: 1200px; box-shadow: var(--shadow-sm);
  animation: fadeIn .35s var(--ease) both;
}
.toolhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolhead h2 { margin: 0; font-size: 22px; letter-spacing: .2px; }
.catbadge { background: var(--primary-soft); color: var(--primary-d); padding: 4px 13px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; }
.star { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--border-strong); transition: transform .18s var(--ease), color .2s; line-height: 1; }
.star:hover { transform: scale(1.2) rotate(8deg); }
.star.on { color: var(--warn); }
.desc { color: var(--muted); margin: 10px 0 18px; max-width: 760px; }
.form, .guide, .tablewrap, .widget { margin-top: 10px; }
.field { margin-bottom: 16px; max-width: 720px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; font-weight: 600; }

/* ---------- 通用控件 ---------- */
.btn {
  background: var(--grad); color: #fff; border: none; padding: 9px 20px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px; margin: 4px 8px 4px 0; font-weight: 600; font-family: inherit;
  box-shadow: var(--shadow-sm); transition: transform .16s var(--ease), box-shadow .2s var(--ease), filter .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); filter: brightness(1.04); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.inp, .ta, textarea, input[type=text], input[type=number], input[type=password], select {
  width: 100%; max-width: 720px; padding: 10px 13px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.inp:focus, .ta:focus, textarea:focus, select:focus, input[type=text]:focus, input[type=number]:focus, input[type=password]:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft);
}
.ta, textarea { resize: vertical; line-height: 1.6; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 12px 0; line-height: 1.7; }
.unsupported, .note {
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--warn) 42%, var(--border));
  color: var(--text); padding: 13px 15px; border-radius: var(--radius-sm); margin-top: 10px; font-size: 13px; line-height: 1.7;
}
.out {
  background: var(--code-bg); color: var(--code-fg); padding: 16px 18px; border-radius: var(--radius-sm); margin-top: 14px;
  white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); font-size: 13px; line-height: 1.7;
  max-height: 480px; overflow: auto; border: 1px solid var(--border);
}
pre.out { margin: 14px 0 0; }
.guide .out { background: var(--code-bg); }

/* 结果复制 / 导出 工具条 —— 悬浮于结果模块，鼠标移入结果区时显示，移出隐藏 */
.resultwrap { position: relative; }
.widget { position: relative; }
.resultbar {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  display: flex; gap: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .18s var(--ease), transform .18s var(--ease), visibility .18s var(--ease);
  pointer-events: none;
}
.resultwrap:hover .resultbar,
.widget:hover .resultbar,
.tablewrap:hover .resultbar { opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto; }
.rbtn {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 6px 14px; box-shadow: var(--shadow-sm);
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), transform .15s var(--ease);
}
.rbtn:hover { color: var(--primary-d); border-color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }
.rbtn:active { transform: translateY(0); }
/* 触摸设备无 hover：常驻可见，且改为静态定位避免遮挡结果内容 */
@media (hover: none) {
  .resultbar { opacity: 1; visibility: visible; transform: none; position: static; justify-content: flex-end; margin: 10px 2px 0; width: auto; pointer-events: auto; }
}

/* ---------- 表格（ref 类） ---------- */
.tablewrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--border); padding: 9px 14px; text-align: left; }
.tbl th { background: var(--surface-2); position: sticky; top: 0; font-weight: 700; color: var(--muted); letter-spacing: .3px; }
.tbl tr:hover td { background: var(--surface-hover); }
.tbl tbody tr:last-child td { border-bottom: none; }

/* =====================================================
 * 首页 / 分类视图（紧凑高效）
 * ===================================================== */
.hero {
  position: relative; overflow: hidden; text-align: center; padding: 36px 30px 32px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); margin-bottom: 20px;
  box-shadow: var(--shadow-sm); animation: fadeIn .4s var(--ease) both;
}
.hero::before { content: ""; position: absolute; top: -120px; left: 50%; transform: translateX(-50%); width: 420px; height: 220px; border-radius: 50%; background: radial-gradient(ellipse, var(--bg-tint), transparent 70%); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero-title { margin: 0 0 8px; font-size: 30px; letter-spacing: .3px; color: var(--text); }
.hero-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.hero-input {
  width: min(560px, 100%); margin: 0 auto; display: block; padding: 13px 20px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 15px; font-family: inherit;
  box-shadow: var(--shadow-sm); transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.hero-input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 5px var(--primary-soft); transform: translateY(-1px); }

/* 首页分区 */
.homesec { margin-bottom: 22px; animation: fadeIn .4s var(--ease) both; }
.homesec-h { font-size: 15px; font-weight: 700; color: var(--text-2); margin: 0 0 12px; padding-left: 2px; }
.homesec-h::before { content: ""; display: inline-block; width: 4px; height: 14px; background: var(--grad); border-radius: 2px; margin-right: 8px; vertical-align: -2px; }

/* 常用工具 chips */
.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  cursor: pointer; padding: 8px 15px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-xs);
  transition: transform .16s var(--ease), box-shadow .2s var(--ease), border-color .2s, color .2s, background .2s;
}
.chip:hover { transform: translateY(-2px); border-color: var(--primary); color: var(--primary-d); background: var(--surface-hover); box-shadow: var(--shadow-sm); }

/* 全部分类索引（紧凑网格） */
.catindex { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.catrow {
  display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none;
  padding: 10px 13px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-xs);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: transform .16s var(--ease), box-shadow .2s var(--ease), border-color .2s, color .2s, background .2s;
}
.catrow:hover { transform: translateY(-2px); border-color: var(--primary); color: var(--text); background: var(--surface-hover); box-shadow: var(--shadow-sm); }
.catrow .ci { font-size: 17px; width: 20px; text-align: center; }
.catrow .cn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catrow .cc { font-size: 11px; color: var(--muted); background: var(--surface-3); padding: 2px 9px; border-radius: var(--radius-pill); }

/* 分类视图头部 */
.cathead { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.backbtn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 8px 15px; border-radius: var(--radius-pill); cursor: pointer; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-xs); transition: background .2s var(--ease), transform .16s var(--ease), box-shadow .2s var(--ease);
}
.backbtn:hover { background: var(--surface-hover); transform: translateX(-3px); box-shadow: var(--shadow-sm); }
.cathead-title { margin: 0; font-size: 22px; }
.cathead-count { color: var(--muted); font-size: 13px; }
.cathead-emoji { font-size: 26px; margin-right: 2px; }

/* 面包屑（分类页：首页 / 分类名称） */
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 18px; flex-wrap: wrap; }
.crumb-item { color: var(--primary-d); text-decoration: none; font-weight: 600; cursor: pointer; }
.crumb-item:hover { text-decoration: underline; }
.crumb-sep { color: var(--border-strong); }
.crumb-cur { color: var(--text); font-weight: 600; }

/* ---------- 顶部大分类菜单（位于顶栏内、搜索框左侧、文字居中） ---------- */
.topnav {
  display: flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0; max-width: 100%;
  justify-content: flex-start; overflow-x: auto; overflow-y: hidden;
  white-space: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.topnav::-webkit-scrollbar { height: 6px; }
.topnav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
.tnav-item {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 7px 13px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 600; text-decoration: none;
  cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease);
}
.tnav-item:hover { background: var(--surface-hover); color: var(--text); }
.tnav-item.active { background: var(--primary-soft); color: var(--primary-d); }

/* ---------- 大分类 / 二级分类卡片（首页与 mega 页共用 .megagrid） ---------- */
.megagrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 13px; }
.megacard {
  display: flex; align-items: center; gap: 14px; padding: 18px 20px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
  animation: cardIn .45s var(--ease) both;
}
.megacard::after { content: ""; position: absolute; left: 0; top: 0; height: 3px; width: 100%; background: var(--grad); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease); }
.megacard:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.megacard:hover::after { transform: scaleX(1); }
.megacard-emoji { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: var(--surface-3); flex: none; }
.megacard-info { min-width: 0; }
.megacard-name { font-size: 16px; font-weight: 700; }
.megacard-count { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* 工具列表（舒适网格，铺满右侧，一行约 4 个） */
.toolgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.toolgrid.dense { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.toolcard {
  position: relative; overflow: hidden; padding: 18px 20px; cursor: pointer; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
  animation: cardIn .4s var(--ease) both;
}
.toolcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--grad); transform: scaleY(0); transform-origin: top; transition: transform .25s var(--ease); }
.toolcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.toolcard:hover::before { transform: scaleY(1); }
.toolcard.mini { padding: 16px 18px; }
.toolcard-name { font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.toolcard.mini .toolcard-name { font-size: 15px; }
.toolcard-desc { font-size: 13px; color: var(--muted); margin-bottom: 14px; min-height: 40px; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.toolcard.mini .toolcard-desc { margin-bottom: 12px; min-height: 38px; }
.toolcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.toolcard-type { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--primary-soft); color: var(--primary-d); }
.toolcard-go { font-size: 13px; color: var(--muted); transition: transform .18s var(--ease), color .18s; }
.toolcard:hover .toolcard-go { color: var(--primary-d); transform: translateX(3px); }

/* 大分类页：按二级分类分段铺满展示全部工具 */
.megasec { margin-bottom: 26px; animation: fadeIn .4s var(--ease) both; }
.megasec-h { display: flex; align-items: center; margin: 0 0 12px; padding-left: 2px; }
.megasec-h::before { content: ""; display: inline-block; width: 4px; height: 16px; background: var(--grad); border-radius: 2px; margin-right: 8px; vertical-align: -2px; }
.megasec-link { font-size: 16px; font-weight: 700; color: var(--text-2); text-decoration: none; transition: color .15s var(--ease); }
.megasec-link:hover { color: var(--primary-d); }

/* ---------- 入场动画 ---------- */
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 计时 / 时钟 ---------- */
.big { font-size: 38px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 12px 0; letter-spacing: 1px; font-family: var(--font-mono); }
.clocklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 14px; }
.clockrow { display: flex; justify-content: space-between; background: var(--surface); border: 1px solid var(--border); padding: 11px 15px; border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); }
.laps { margin-top: 10px; }
.laps div { padding: 4px 0; color: var(--muted); font-family: var(--font-mono); }

/* ---------- 日历 ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 400px; margin-top: 14px; }
.calh { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; font-weight: 700; }
.cald { text-align: center; padding: 10px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; transition: transform .15s var(--ease); }
.cald:hover { transform: scale(1.05); }
.cald.today { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }

/* ---------- 文本 / 编辑 ---------- */
.sample { background: var(--surface); border: 1px solid var(--border); padding: 16px; border-radius: var(--radius-sm); line-height: 2; box-shadow: var(--shadow-xs); }
.preview { background: var(--surface); border: 1px solid var(--border); padding: 16px; border-radius: var(--radius-sm); margin-top: 12px; box-shadow: var(--shadow-xs); }
.frame { width: 100%; height: 300px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 12px; background: var(--surface); box-shadow: var(--shadow-xs); }
.q { font-weight: 600; margin: 14px 0 10px; }
.quiz button, .card button { display: block; width: 100%; max-width: 400px; margin: 8px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; text-align: center; cursor: pointer; max-width: 400px; margin: 14px 0; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.cardface { font-size: 22px; font-weight: 700; min-height: 46px; }

/* ---------- 颜色 ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 16px; }
.swatch { width: 74px; height: 46px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 11px; cursor: pointer; border: 1px solid var(--border-strong); transition: transform .16s var(--ease), box-shadow .2s var(--ease); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.swatch:hover { transform: scale(1.08); box-shadow: var(--shadow-md); }
.swatch-lg { width: 140px; height: 140px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 12px 0; box-shadow: var(--shadow-sm); }
.grad { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 12px; box-shadow: var(--shadow-xs); }

/* ---------- 键值表 ---------- */
.kv { display: grid; gap: 8px; margin-top: 12px; }
.krow { display: flex; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--border); padding: 11px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); }
.krow.hi { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------- 投票 / 条形 ---------- */
.bars { margin-top: 14px; }
.barrow { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.barfill { flex: 1; height: 22px; background: var(--grad); border-radius: var(--radius-pill); transition: width .4s var(--ease); min-width: 3px; box-shadow: var(--shadow-xs); }
.barrow span:last-child { width: 48px; text-align: right; color: var(--muted); font-family: var(--font-mono); }

/* ---------- 键盘测试 ---------- */
.keys { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.key { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 15px; min-width: 40px; text-align: center; font-family: var(--font-mono); box-shadow: var(--shadow-xs); transition: background .12s var(--ease), transform .12s var(--ease); }
.key.on { background: var(--grad); color: #fff; transform: scale(1.08); border-color: transparent; box-shadow: var(--shadow-sm); }

/* ---------- CSV 编辑器 ---------- */
.csvgrid { display: table; border-collapse: collapse; margin-top: 14px; }
.csvr { display: table-row; }
.csvc { display: table-cell; border: 1px solid var(--border); padding: 0; }
.csvc.h { background: var(--surface-2); font-weight: 700; padding: 8px 10px; }
.csvc input { border: none; padding: 8px 10px; width: 150px; background: transparent; color: var(--text); font-family: inherit; }

/* ---------- 画布类 ---------- */
.cv, canvas { max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-top: 12px; display: block; box-shadow: var(--shadow-xs); }
.printbox .thumb, .thumb { max-width: 100px; margin: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); }
.printbox { display: flex; flex-wrap: wrap; }

/* ---------- 像素画 ---------- */
.pixgrid { display: grid; grid-template-columns: repeat(16, 18px); gap: 1px; background: var(--border-strong); border: 1px solid var(--border); width: max-content; margin-top: 12px; border-radius: 6px; overflow: hidden; }
.pix { width: 18px; height: 18px; background: var(--surface); cursor: pointer; transition: transform .08s; }
.pix:hover { transform: scale(1.12); }

/* ---------- 热力图 ---------- */
.heat { margin-top: 14px; }
.heatrow { display: flex; }
.heatcell { width: 56px; height: 42px; display: flex; align-items: center; justify-content: center; color: #111; font-size: 12px; border: 1px solid #fff; }

/* ---------- 列表 / 习惯 ---------- */
.list { margin-top: 14px; display: grid; gap: 8px; }
.listrow { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); padding: 11px 15px; border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); transition: transform .15s var(--ease); }
.listrow:hover { transform: translateX(3px); }
.listrow span, .listrow a { flex: 1; }

/* ---------- CPS 点击区 ---------- */
.cps { width: 100%; height: 200px; background: var(--surface-2); border: 2px dashed var(--border-strong); border-radius: var(--radius); margin-top: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 18px; font-weight: 600; transition: background .2s var(--ease), border-color .2s var(--ease); }
.cps:active { background: var(--primary-soft); border-color: var(--primary); }

/* ---------- 滚动条美化（仅内容区保留滚动条） ---------- */
.out::-webkit-scrollbar, .tablewrap::-webkit-scrollbar { width: 9px; height: 9px; }
.out::-webkit-scrollbar-thumb, .tablewrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9px; }
.out::-webkit-scrollbar-track, .tablewrap::-webkit-scrollbar-track { background: transparent; }

/* ---------- 页脚（常驻全宽，仅居中版权声明） ---------- */
.foot { flex: none; background: var(--surface); border-top: 1px solid var(--border); }
.foot-inner { max-width: 1200px; margin: 0 auto; padding: 20px 28px; text-align: center; }
.foot-copy { color: var(--muted); font-size: 12.5px; letter-spacing: .3px; }

/* ---------- 响应式 ---------- */
/* 平板 / 手机：顶栏重排为两行（行1 菜单+logo+搜索+主题，行2 大分类横向滚动），网格收窄 */
@media (max-width: 900px) {
  header.topbar { flex-wrap: wrap; row-gap: 8px; }
  .topgroup { display: contents; }                 /* 让 logo / topnav 直接参与顶栏 flex 布局，便于换行 */
  .menu-btn { display: inline-flex; order: 0; }
  .logo { order: 1; flex: 0 0 auto; }
  .topright { order: 2; margin-left: auto; }
  .topnav { order: 3; flex: 1 1 100%; margin-top: 2px; }
  .topnav .tnav-item { padding: 7px 11px; font-size: 13px; }

  #sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 26; width: 268px;
    transform: translateX(-100%); transition: transform .3s var(--ease); box-shadow: var(--shadow-lg);
    border-radius: 0; border: none; border-right: 1px solid var(--border); max-height: none;
  }
  body.nav-open #sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; opacity: 1; }
  header.topbar .search { flex-basis: 200px; max-width: 200px; }
  header.topbar .count { display: none; }
  .body { padding: 16px 16px 50px; max-width: none; }
  .hero-title { font-size: 26px; }
  .megagrid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .toolgrid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* 自定义组件通用适配：防止内部固定宽度元素（图片/画布/表格/输入框）撑破移动端布局 */
.widget img, .widget video, .widget canvas, .widget iframe, .widget svg, .widget object,
.panel img, .panel video, .panel iframe { max-width: 100%; height: auto; }
.widget pre { max-width: 100%; overflow: auto; }
.widget table { width: 100%; }
.widget input, .widget select, .widget textarea, .widget button { max-width: 100%; }
.widget { font-size: 14px; }

/* 手机：较宽的专属组件允许横向滚动，避免溢出 */
@media (max-width: 600px) {
  .heatrow { overflow-x: auto; }
  .heatcell { width: 46px; height: 36px; font-size: 11px; }
  .pixgrid { max-width: 100%; overflow-x: auto; }
  .csvgrid { max-width: 100%; overflow-x: auto; }
  .csvc input { width: 110px; }
  .cal { max-width: 100%; }
  .cald { padding: 8px 0; font-size: 12px; }
  .swatch-lg { width: 110px; height: 110px; }
  .clocklist { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  header.topbar { padding: 9px 12px; gap: 8px; }
  .logo-word { font-size: 17px; letter-spacing: 1px; }
  header.topbar .search { flex-basis: 130px; max-width: 130px; }
  #theme-seg button { width: 30px; height: 26px; font-size: 12px; }
  .topright { gap: 8px; }
  .body { padding: 12px 12px 44px; }
  .panel { padding: 16px 15px 20px; }
  .toolhead h2 { font-size: 19px; }
  .megagrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .toolgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .toolcard { padding: 15px 16px; }
  .toolcard-desc { min-height: 36px; }
  .megacard { padding: 15px 16px; gap: 11px; }
  .megacard-emoji { width: 42px; height: 42px; font-size: 21px; }
  .big { font-size: 30px; }
  .field { max-width: 100%; }
  .inp, .ta, textarea, input[type=text], input[type=number], input[type=password], select { max-width: 100%; }
  .desc { font-size: 13px; }
  .krow { flex-wrap: wrap; }
}

/* ---------- 尊重减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
