/* ============================================================
   猫工具站 共享设计系统 (V2.2)
   双层导航：顶部胶囊 + 左侧全局导航 + 固定宽度首页
   工具卡片每排最多 5 个，禁用横向滚动
   ============================================================ */

:root {
  --bg: #ffffff;
  --surface: rgba(0, 0, 0, 0.025);
  --surface-hover: rgba(0, 0, 0, 0.055);
  --surface-active: rgba(0, 0, 0, 0.08);
  --border: rgba(0, 0, 0, 0.09);
  --border-hover: rgba(0, 0, 0, 0.18);
  --text: #111827;
  --text-soft: rgba(17, 24, 39, 0.66);
  --text-mute: rgba(17, 24, 39, 0.60);
  --text-faint: rgba(17, 24, 39, 0.25);
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-bg: rgba(37, 99, 235, 0.08);
  --radius: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pill-h: 54px;
  --sidebar-w: 180px;
}

html.dark-mode {
  --bg: #0a0a0a;
  --surface: rgba(255, 255, 255, 0.07);
  --surface-hover: rgba(255, 255, 255, 0.11);
  --surface-active: rgba(255, 255, 255, 0.15);
  --border: rgba(255, 255, 255, 0.10);
  --border-hover: rgba(255, 255, 255, 0.20);
  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.62);
  --text-mute: rgba(255, 255, 255, 0.46);
  --text-faint: rgba(255, 255, 255, 0.18);
  --accent: #6ea8fe;
  --accent-strong: #3b82f6;
  --accent-bg: rgba(110, 168, 254, 0.1);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}
body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ============================================================
   胶囊导航（原版风格）
   ============================================================ */
.pillnav {
  position: fixed; top: 14px; left: calc(50vw + 90px); transform: translateX(-50%);
  z-index: 60; display: flex; align-items: center; gap: 4px;
  padding: 6px 8px; min-height: var(--pill-h);
  width: fit-content;
  max-width: calc(100% - 24px);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border); border-radius: 999px;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.4);
}
html.dark-mode .pillnav { background: rgba(20, 20, 20, 0.76); }

.pillnav .brand {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0; text-decoration: none;
  padding: 0 8px 0 4px; font-weight: 800; letter-spacing: -0.02em;
}
.pillnav .brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  object-fit: cover;
}
.pillnav .brand .brand-name { font-size: 14px; white-space: nowrap; }
@media (max-width: 640px) {
  .pillnav .brand .brand-name { display: none; }
}

.pillnav-scroll {
  display: flex; align-items: center; gap: 2px;
  flex: 1; overflow-x: auto; white-space: nowrap;
  scrollbar-width: none; -ms-overflow-style: none;
}
.pillnav-scroll::-webkit-scrollbar { display: none; }

.pill-nav-link {
  padding: 6px 12px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; color: var(--text);
  letter-spacing: -0.02em;
  cursor: pointer; transition: all 0.2s var(--ease);
  flex-shrink: 0; white-space: nowrap;
}
.pill-nav-link:hover { color: var(--text); background: var(--surface-hover); }
.pill-nav-link.active {
  color: var(--accent); background: var(--accent-bg);
  font-weight: 700;
}

/* 图标导航：紧凑圆点样式 */
.pill-icon-only {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; font-size: 18px;
  border-radius: 50%;
  position: relative;
}
.pill-icon-only:hover::after {
  content: attr(title);
  position: absolute; top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--surface); color: var(--text);
  padding: 4px 10px; border-radius: 6px; font-size: 12px;
  white-space: nowrap; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  pointer-events: none;
}

/* 分类图标折叠容器 */
.pillnav-icons {
  display: inline-flex; align-items: center; gap: 2px;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.pillnav-icons.collapsed {
  display: none;
}
.pillnav-icons.expanded {
  display: inline-flex; align-items: center; gap: 2px;
}

/* 全部工具折叠按钮 */
.pill-toggle {
  cursor: pointer; user-select: none;
}
.pill-toggle:hover {
  color: var(--text); background: var(--surface-hover);
}

/* 顶部导航栏右侧 AI 按钮 */
.pillnav-right {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.pillnav-page {
  padding: 5px 10px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; color: var(--text);
  letter-spacing: -0.02em;
  transition: all 0.2s var(--ease); white-space: nowrap;
}
.pillnav-page:hover { color: var(--text); background: var(--surface-hover); }
.pillnav-ai {
  padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  transition: all 0.2s var(--ease); white-space: nowrap;
  text-decoration: none;
  box-shadow: 0 1px 8px rgba(37,99,235,0.2);
}
.pillnav-ai:hover { opacity: 0.9; transform: translateY(-1px); }
html.dark-mode .pillnav-ai {
  box-shadow: 0 1px 8px rgba(110,168,254,0.15);
}
.pillnav .theme-btn {
  width: 34px; height: 34px; border: none; cursor: pointer;
  background: transparent; border-radius: 999px; color: var(--text-soft);
  font-size: 15px; transition: all 0.2s var(--ease);
}
.pillnav .theme-btn:hover { background: var(--surface-hover); color: var(--text); }

.sidebar-toggle { display: none; }
@media (max-width: 768px) {
  .sidebar-toggle {
    display: inline-flex; width: 34px; height: 34px; border: none; cursor: pointer;
    background: transparent; border-radius: 999px; color: var(--text-soft);
    font-size: 17px; align-items: center; justify-content: center;
    transition: all 0.2s var(--ease);
  }
  .sidebar-toggle:hover { background: var(--surface-hover); color: var(--text); }
}

/* ============================================================
   双栏布局（自适应宽度，禁止横向滚动）
   ============================================================ */
.layout {
  display: flex;
  max-width: 100%;
  margin: 0 auto;
  padding: 100px 0 0;
  min-height: 100vh;
  overflow: hidden;
}

/* 左侧导航栏（固定不动） */
.sidebar {
  position: fixed; left: 0; top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  padding: 20px 6px 20px 24px;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
  background: var(--bg);
  z-index: 50;
  transform: translateX(0);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), background 0.35s var(--ease);
}
html.dark-mode .sidebar { background: rgba(255, 255, 255, 0.025); }
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* 侧栏分组容器 */
.sidebar-group { margin-bottom: 2px; }

/* 侧栏分类标题（可折叠） */
.sidebar-cat {
  display: flex; align-items: center; gap: 6px;
  padding: 17px 8px 17px; margin-top: 4px;
  font-size: 13.5px; font-weight: 500; color: var(--text);
  text-decoration: none; border-radius: 8px;
  cursor: pointer;
  letter-spacing: -0.02em;
  transition: all 0.15s var(--ease);
  border-bottom: 1px solid var(--border);
}
.sidebar-cat:hover { color: var(--accent); }
.sidebar-cat.active { color: var(--accent); }
.sidebar-cat-icon { width: 20px; text-align: center; font-size: 12px; flex-shrink: 0; }
.sidebar-cat-name { flex: 1; min-width: 0; }
/* 折叠箭头 */
.sidebar-cat-toggle {
  flex-shrink: 0; width: 18px; height: 18px;
  display: grid; place-items: center;
  font-size: 8px; color: var(--text-faint);
  transition: transform 0.25s var(--ease);
  border-radius: 4px; user-select: none;
}
.sidebar-cat-toggle:hover { background: var(--surface-hover); color: var(--text-mute); }
.sidebar-group.collapsed .sidebar-cat-toggle { transform: rotate(-90deg); }

/* 侧栏子工具（可折叠动画 - 改进版） */
.sidebar-sub {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.sidebar-group.collapsed .sidebar-sub {
  max-height: 0;
  transition: max-height 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-link {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 24px; border-radius: 8px;
  font-size: 13px; font-weight: 400; color: var(--text-soft);
  letter-spacing: -0.01em;
  transition: all 0.2s var(--ease); text-decoration: none;
  margin-bottom: 1px;
}
.sidebar-link:hover { color: var(--text); background: var(--surface-hover); }
.sidebar-link .sidebar-icon {
  width: 18px; text-align: center; font-size: 11px; flex-shrink: 0;
}
.sidebar-empty {
  padding: 16px 8px; font-size: 12px; color: var(--text-faint);
  text-align: center;
}

/* ============================================================
   侧边栏 AI 工具箱入口（紧凑型）
   ============================================================ */
.sidebar-ai-entry {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin: 0 4px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none; cursor: pointer;
  font-size: 13.5px; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em;
  transition: all 0.2s var(--ease);
}
.sidebar-ai-entry:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}
.sidebar-ai-entry .ai-icon {
  width: 22px; text-align: center; font-size: 13px; flex-shrink: 0;
  display: grid; place-items: center;
}
.sidebar-ai-entry .ai-label { flex: 1; }
.sidebar-ai-entry .ai-arrow {
  font-size: 10px; color: var(--text-mute);
  transition: transform 0.2s var(--ease);
}
.sidebar-ai-entry:hover .ai-arrow { transform: translateX(3px); }
.sidebar-divider { height: 1px; background: var(--border); margin: 0 8px 8px; }

/* 右侧内容区 */
.content {
  flex: 1; min-width: 0;
  margin-left: calc(var(--sidebar-w) + 1px);
  padding: 24px 24px 60px;
}

/* Regex Tester 专属外壳（复用标准 .layout/.content，仅补充其内部样式） */
.tool-container { max-width: 960px; margin: 0 auto; }
.tool-container .tool-header { display: flex; align-items: center; gap: 14px; margin: 4px 0 22px; }
.tool-container .tool-icon { font-size: 34px; line-height: 1; }
.tool-container .tool-title { font-size: 1.5rem; font-weight: 800; margin: 0; letter-spacing: -0.02em; }
.tool-container .tool-desc { color: var(--text-soft); font-size: 13px; margin: 4px 0 0; }
.tool-container .breadcrumb { font-size: 12px; color: var(--text-mute); margin-bottom: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tool-container .breadcrumb a { color: var(--accent); text-decoration: none; }
.tool-container .breadcrumb a:hover { text-decoration: underline; }
.tool-container .breadcrumb .sep { color: var(--text-mute); }

/* ============================================================
   Hero
   ============================================================ */
.hero { text-align: center; padding: 20px 0 20px; }
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 850;
  letter-spacing: -0.05em;
  line-height: 1.04;
  margin: 0 0 10px;
  color: var(--text);
}
.hero-domain {
  display: inline-block;
  font-size: 0.45em; font-weight: 400; color: var(--text-mute);
  letter-spacing: 0; vertical-align: middle;
  margin-left: 4px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.hero p { color: var(--text-soft); font-size: 14px; max-width: 560px; margin: 0 auto 16px; line-height: 1.6; }
.hero .kicker {
  display: inline-flex; gap: 7px; align-items: center; margin-bottom: 14px;
  padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-mute); font-size: 10px; font-weight: 750; letter-spacing: 0.14em; text-transform: uppercase;
  background: var(--surface);
}

/* 搜索 */
.search-wrap {
  display: flex; align-items: center; max-width: 440px; margin: 0 auto;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px;
  padding: 0 4px 0 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease), background 0.3s var(--ease);
}
.search-wrap:hover {
  border-color: var(--border-hover);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.search-wrap:focus-within {
  border-color: var(--accent); background: var(--bg);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1), 0 2px 8px rgba(0,0,0,0.06);
}
.search-wrap .ph {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin: 3px;
  color: var(--text-mute); font-size: 15px;
  border-radius: 10px; flex-shrink: 0;
  transition: background 0.25s var(--ease);
}
.search-wrap:focus-within .ph {
  background: var(--accent-bg); color: var(--accent);
}
.search-wrap input {
  flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  padding: 10px 8px 10px 0; font-size: 14px; color: var(--text);
}
.search-wrap input::placeholder { color: var(--text-faint); }
.search-wrap .search-clear {
  display: none; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin-right: 4px;
  border: none; background: transparent; border-radius: 8px;
  color: var(--text-faint); font-size: 14px; cursor: pointer; flex-shrink: 0;
  transition: all 0.2s var(--ease);
}
.search-wrap .search-clear:hover { background: var(--surface-hover); color: var(--text-mute); }
.search-wrap.has-text .search-clear { display: flex; }

/* 首页双入口 */
.hero-dual {
  display: flex; gap: 12px; justify-content: center;
  margin-top: 16px; flex-wrap: wrap;
}
.hero-entry {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
  text-decoration: none; transition: all 0.25s var(--ease);
  min-width: 200px;
}
.hero-entry:hover {
  background: var(--surface-hover); border-color: var(--border-hover);
  transform: translateY(-2px);
}
.hero-entry.active {
  background: var(--accent-bg); border-color: var(--accent);
}
.hero-entry .he-icon {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--surface-hover); border-radius: 10px;
  flex-shrink: 0;
}
.hero-entry .he-icon img { border-radius: 6px; }
.hero-entry.active .he-icon { background: var(--accent-bg); }
.hero-entry .he-body { text-align: left; }
.hero-entry .he-label {
  font-size: 14px; font-weight: 750; color: var(--text);
  display: block; letter-spacing: -0.02em;
}
.hero-entry .he-desc {
  font-size: 11px; color: var(--text-mute);
  display: block; margin-top: 1px;
}
.hero-entry .he-arrow {
  font-size: 14px; color: var(--text-mute);
  transition: transform 0.25s var(--ease);
}
.hero-entry:hover .he-arrow { transform: translateX(4px); }

/* ============================================================
   分类分区
   ============================================================ */
.cat-section { padding-top: 0; }
.cat-section + .cat-section { margin-top: 10px; }
.cat-heading {
  font-size: 16px; font-weight: 800; letter-spacing: -0.03em;
  margin: 0 0 12px; padding: 0 0 8px;
  border-bottom: 2px solid var(--accent-bg);
  scroll-margin-top: 100px;
}
.cat-empty {
  text-align: center; color: var(--text-mute); padding: 32px 0;
  font-size: 13px; background: var(--surface); border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* ============================================================
   工具卡片网格（每排最多 5 个）
   ============================================================ */
.cat-section .grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.card {
  display: flex; align-items: center; gap: 12px; padding: 14px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--text);
  transition: transform 0.35s var(--ease), background 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.35s var(--ease);
}
html.dark-mode .card { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04); }
.card:hover { transform: translateY(-4px); background: var(--surface-hover); border-color: var(--border-hover); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.32); }
.card .icon {
  flex-shrink: 0; width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--surface-hover); border: 1px solid var(--border); border-radius: 10px;
  font-size: 18px; transition: all 0.35s var(--ease);
}
.card:hover .icon { color: var(--accent); border-color: var(--border-hover); }
.card h4 { margin: 0 0 2px; font-size: 13px; font-weight: 700; letter-spacing: -0.01em; }
.card p { margin: 0; font-size: 11px; color: var(--text-mute); line-height: 1.4; display: none; }
.card:hover p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* 卡片足够宽时显示描述 */
@media (min-width: 768px) {
  .card p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
.empty { text-align: center; color: var(--text-mute); padding: 50px 0; font-size: 13px; }

/* ============================================================
   广告位
   ============================================================ */
.ad-slot { margin: 20px auto; text-align: center; min-height: 1px; }
.ad-slot .ad-label { font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 6px; }
.ad-placeholder {
  border: 1px dashed var(--border); border-radius: 12px; color: var(--text-faint);
  font-size: 11px; padding: 20px 16px;
}

/* ============================================================
   工具页通用
   ============================================================ */
.tool-head { text-align: center; margin-bottom: 16px; }
.tool-head h1 { font-size: clamp(1.3rem, 3vw, 2rem); font-weight: 800; letter-spacing: -0.04em; margin: 0 0 6px; }
.tool-head p { color: var(--text-soft); font-size: 13px; margin: 0 auto; max-width: 520px; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin: 0 auto 18px; max-width: 720px;
}
.input-row { display: flex; gap: 10px; }
.input-row input {
  flex: 1; min-width: 0; height: 40px; padding: 0 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 13px; outline: none; transition: border-color 0.25s var(--ease);
}
.input-row input:focus { border-color: var(--accent); }
.btn {
  height: 40px; padding: 0 18px; border: none; border-radius: 10px; cursor: pointer;
  background: var(--accent-strong); color: #fff; font-weight: 700; font-size: 13px;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
video.player { width: 100%; min-height: 260px; background: #000; border-radius: 12px; margin-top: 14px; display: block; }
.note { color: var(--text-mute); font-size: 12.5px; line-height: 1.7; }
.note code { background: var(--surface-hover); padding: 1px 6px; border-radius: 6px; }
pre.note { background: var(--surface-hover); padding: 12px; border-radius: 10px; overflow-x: auto; font-size: 12px; }

/* ============================================================
   页脚
   ============================================================ */
footer {
  border-top: 1px solid var(--border); background: var(--bg);
  padding: 32px 0 24px; color: var(--text-mute); font-size: 12px;
}
footer .fwrap { max-width: 100%; margin: 0 auto; padding: 0 24px 0 205px; }
footer .fcols { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 20px; }
footer h3 { font-size: 11px; color: var(--text); margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.05em; }
footer .flink { display: block; color: var(--text-mute); text-decoration: none; padding: 3px 0; transition: color 0.2s; }
footer .flink:hover { color: var(--text); }
footer .fmeta { padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: space-between; }

/* 页脚品牌列 */
.fcol-brand {
  grid-column: span 2; display: flex; align-items: flex-start; gap: 12px;
}
.fcol-logo { width: 40px; height: 40px; flex-shrink: 0; border-radius: 6px; }
.fcol-tip { margin: 0; line-height: 1.6; color: var(--text-mute); font-size: 12px; }

/* ============================================================
   移动端适配
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 90; width: 220px; padding-top: 80px;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open::after {
    content: ''; position: fixed; inset: 0; z-index: 89;
    background: rgba(0,0,0,0.3);
  }
  .content { margin-left: 0; padding: 20px 16px 40px; }
  .pillnav { padding: 6px; gap: 2px; left: 50%; }
  .pillnav-page { display: none; }
  .layout { padding-top: 90px; }
  /* 手机端每排 2 个 */
  .cat-section .grid {
    grid-template-columns: repeat(2, 1fr);
  }
  /* 页脚移动端适配 */
  footer .fwrap { padding: 0 16px; }
  .fcol-brand { grid-column: span 1; flex-direction: column; gap: 8px; }
}
/* ===== 无障碍：跳转主内容 ===== */
.skip-link{position:absolute;left:-9999px;top:auto;z-index:9999;background:#ec4899;color:#fff;padding:10px 18px;border-radius:0 0 8px 0;}
.skip-link:focus{left:0;top:0;}
