/* ============================================================
   前端开发工具箱 · 全局样式与主题变量
   设计规范见 SKILL.md 第 8 章：
   - 主色 #165DFF / 成功 #00B42A / 错误 #F53F3F / 警告 #FF7D00
   - 深浅主题切换，默认跟随系统
   ============================================================ */

/* ---------- 主题变量（浅色为默认，深色覆盖） ---------- */
/* ============================================================
   主题变量（浅色为默认，深色覆盖）
   设计基调：深蓝科技感 + 柔和渐变 + 精致阴影
   ============================================================ */
:root {
  --primary: #165DFF;
  --primary-hover: #3B7FFF;
  --primary-active: #0E42D2;
  --primary-bg: rgba(22, 93, 255, 0.08);
  --success: #00B42A;
  --danger: #F53F3F;
  --warning: #FF7D00;

  /* 渐变品牌色（顶栏 / 强调元素） */
  --brand-gradient: linear-gradient(135deg, #165DFF 0%, #7B5CFF 100%);
  --brand-gradient-hover: linear-gradient(135deg, #3B7FFF 0%, #9B7FFF 100%);

  /* 表面 */
  --bg: #f0f2f7;
  --bg-container: #ffffff;
  --bg-secondary: #f2f3f8;
  --bg-elevated: #ffffff;
  --bg-input: #ffffff;

  /* 文字 */
  --text-1: #17181c;
  --text-2: #4e5969;
  --text-3: #8a94a6;
  --text-on-primary: #ffffff;

  /* 边框 */
  --border: #e5e6eb;
  --border-strong: #c9cdd4;

  /* 代码区 */
  --code-bg: #f7f8fa;
  --code-text: #1d2129;
  --code-border: #e5e6eb;

  /* diff 高亮 */
  --diff-add-bg: #e8ffea;
  --diff-add-text: #006622;
  --diff-del-bg: #ffece8;
  --diff-del-text: #b42318;

  /* 阴影（更有层次） */
  --shadow-1: 0 1px 2px rgba(28, 41, 90, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-2: 0 8px 24px rgba(29, 33, 41, 0.12);
  --shadow-primary: 0 4px 14px rgba(22, 93, 255, 0.28);

  /* 布局 */
  --sidebar-width: 232px;
  --header-height: 56px;
  --radius: 8px;
  --radius-lg: 12px;

  color-scheme: light;
}

:root.dark {
  --primary: #4d7fff;
  --primary-hover: #6aa1ff;
  --primary-active: #165DFF;
  --primary-bg: rgba(77, 127, 255, 0.12);
  --success: #23c343;
  --danger: #f76560;
  --warning: #ffa940;

  --brand-gradient: linear-gradient(135deg, #3B7FFF 0%, #9B6CFF 100%);
  --brand-gradient-hover: linear-gradient(135deg, #6aa1ff, #b18cff);

  --bg: #0d0e12;
  --bg-container: #17181c;
  --bg-secondary: #23242a;
  --bg-elevated: #26272c;
  --bg-input: #232428;

  --text-1: #f4f5f7;
  --text-2: #c2c7d0;
  --text-3: #7e8899;
  --text-on-primary: #ffffff;

  --border: #31333a;
  --border-strong: #45484f;

  --code-bg: #1b1c21;
  --code-text: #e8eaed;
  --code-border: #2c2e35;

  --diff-add-bg: rgba(35, 195, 67, 0.14);
  --diff-add-text: #7ee88b;
  --diff-del-bg: rgba(247, 101, 96, 0.16);
  --diff-del-text: #ff9d98;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 6px 20px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

/* ---------- 基础重置 ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-1);
  background: var(--bg);
  transition: background-color 0.25s, color 0.25s;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
textarea, input, select { font-family: inherit; color: var(--text-1); }

::selection { background: var(--primary); color: #fff; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 图标 ---------- */
.icon { flex-shrink: 0; vertical-align: -2px; }

/* ============================================================
   布局：顶栏 + 侧边栏 + 内容区
   ============================================================ */

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg-container) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  z-index: 100;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--text-1);
}
.app-logo .icon {
  color: #fff;
  background: var(--brand-gradient);
  padding: 4px;
  border-radius: 7px;
  box-shadow: var(--shadow-primary);
}

.tool-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: 6px; }

/* 侧边栏 */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--bg-container);
  border-right: 1px solid var(--border);
  z-index: 90;
  transition: transform 0.25s;
}

.sidebar-search { padding: 10px 12px; border-bottom: 1px solid var(--border); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 24px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  border-radius: var(--radius);
  text-transform: uppercase;
}
.nav-group-header:hover { background: var(--bg-secondary); }
.nav-group-header span:first-of-type { flex: 1; text-align: left; }

.nav-list { display: block; }

/* 搜索结果分组（搜索态侧边栏） */
.search-group { margin-bottom: 6px; }
.search-group .nav-group-header { pointer-events: none; text-transform: none; font-size: 11.5px; color: var(--text-3); }

/* 一级目录（分类）条目：更大更醒目 */
.nav-item.nav-cat {
  padding: 11px 13px;
  margin: 3px 0;
  font-size: 14px;
  font-weight: 600;
  position: relative;
  transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-item.nav-cat.active {
  background: var(--primary-bg);
  color: var(--primary);
}
.nav-item.nav-cat.active::before {
  /* 左侧渐变指示条 */
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 3px;
  background: var(--brand-gradient);
}
.nav-cat-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg-secondary);
  border-radius: 999px;
  padding: 1px 8px;
  line-height: 18px;
  transition: all 0.15s;
}
.nav-item.nav-cat.active .nav-cat-count {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 14px;
  margin: 1px 0;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-secondary); color: var(--text-1); }
.nav-item.active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.hidden { display: none; }

/* 遮罩（移动端抽屉） */
.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 80;
}

/* 内容区 */
.tool-main {
  margin: var(--header-height) 0 0 var(--sidebar-width);
  min-height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
}
#tool-container { flex: 1; }

/* ============================================================
   二级目录：内容区顶部的横向工具标签条
   ============================================================ */

.cat-tabs {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  position: sticky;
  top: var(--header-height);
  z-index: 70;
  padding: 9px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}

.cat-tabs-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  padding: 3px 10px 3px 8px;
  border-radius: 8px;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-primary);
}

.cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-container);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-1);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.cat-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(22, 93, 255, 0.16);
}
.cat-tab.active {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-primary);
}
.cat-tab.active:hover { transform: none; }

@media (max-width: 768px) {
  .cat-tabs { padding: 6px 12px; gap: 5px; }
  .cat-tabs-label { display: none; } /* 移动端省空间：顶部已有工具标题 */
  .cat-tab { padding: 4px 11px; font-size: 12px; }
}

/* 工具页容器：多页并存，切换显示 */
.tool-page { display: none; }
.tool-page.tool-active {
  display: block;
  padding: 16px;
  animation: tool-in 0.2s ease;
}

@keyframes tool-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- SEO 首页目录（卡片网格；路由启动后由 JS 清空） ---------- */
.seo-home {
  padding: 28px 32px 48px;
  max-width: 1080px;
  margin: 0 auto;
}
.seo-home h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 8px;
  letter-spacing: 0.2px;
}
.seo-desc {
  font-size: 14.5px;
  color: var(--text-2);
  line-height: 1.8;
  margin: 0 0 10px;
}
/* 分类分组 */
.seo-group { margin: 22px 0 0; }
.seo-group-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 3px solid var(--primary);
}
.seo-group-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}
/* 卡片网格 */
.seo-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.seo-links li { display: flex; }
.seo-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-container);
  box-shadow: var(--shadow-1);
  text-decoration: none;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.seo-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(22, 93, 255, 0.14);
}
.seo-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.4;
}
.seo-card:hover .seo-card-title { color: var(--primary); }
.seo-card-desc {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- SEO 静态工具页（<id>.html，由 scripts/gen-seo-pages.mjs 生成） ----------
   真实 URL + 内嵌可用工具 + 可抓取正文，无跳转；复用工具页组件样式 */
body.seo-static { background: var(--bg); }
body.seo-static .tool-main { margin: 0; min-height: 100vh; }

.seo-header {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  height: 52px;
  background: color-mix(in srgb, var(--bg-container) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.seo-logo {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-1);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seo-logo strong {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.seo-all-link {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-3);
  text-decoration: none;
}
.seo-all-link:hover { color: var(--primary); }

.seo-h1 {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
}

.seo-noscript {
  margin: 12px 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--primary-bg);
  color: var(--text-2);
  font-size: 13.5px;
}

.seo-article {
  max-width: 860px;
  margin: 0 auto;
  padding: 6px 28px 36px;
}
.seo-article h2 {
  font-size: 16.5px;
  font-weight: 600;
  color: var(--text-1);
  margin: 28px 0 10px;
}
.seo-intro {
  font-size: 14.5px;
  color: var(--text-2);
  line-height: 1.9;
  margin: 0;
}
.seo-steps {
  margin: 0;
  padding-left: 22px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 2;
}
.seo-related {
  margin: 0;
  padding-left: 20px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 2.1;
}
.seo-related a { color: var(--primary); }
.seo-privacy {
  margin-top: 30px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--primary-bg);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 768px) {
  .seo-h1 { font-size: 17px; padding-top: 14px; }
  .seo-article { padding: 6px 18px 28px; }
  .seo-header { padding: 0 14px; }
  .seo-logo { font-size: 14px; }
  .seo-home { padding: 18px 16px 36px; }
  .seo-links { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; }
  .seo-card { padding: 11px 12px; }
  .seo-card-title { font-size: 13.5px; }
  .seo-card-desc { -webkit-line-clamp: 2; font-size: 12px; }
  .seo-group-title { font-size: 14px; margin-bottom: 10px; }
}

/* ---------- 移动端布局 ---------- */
#menu-btn { display: none; }

@media (max-width: 768px) {
  #menu-btn { display: inline-flex; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-2);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-mask { display: block; }

  .tool-main { margin-left: 0; }
  .tool-page.tool-active { padding: 12px; }
}

/* 页脚：ICP 备案号 */
.app-footer {
  padding: 14px 16px 26px;
  text-align: center;
}
.app-footer .icp {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-3);
}
.app-footer .icp a {
  color: var(--text-3);
  text-decoration: none;
}
.app-footer .icp a:hover {
  color: var(--text-2);
  text-decoration: underline;
}
/* 公安备案（启用后与 ICP 号同行排列，点号「·」分隔） */
.app-footer .icp a.police {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
}
.app-footer .icp a.police::before {
  content: "·";
  margin-right: 6px;
  color: var(--text-3);
}

/* ============================================================
   通用组件
   ============================================================ */

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-container);
  color: var(--text-1);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}
.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(22, 93, 255, 0.14);
}
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-gradient);
  border-color: transparent;
  color: var(--text-on-primary);
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
  background: var(--brand-gradient-hover);
  border-color: transparent;
  color: #fff;
  transform: translateY(-1px);
}
.btn-sm { padding: 4px 10px; font-size: 12.5px; }

/* 图标按钮（顶栏） */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
}
.icon-btn:hover { background: var(--bg-secondary); color: var(--text-1); }

/* 输入控件 */
.input, .select, .textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  font-size: 13.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent);
}

.textarea {
  min-height: 90px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.field-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }

.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }

/* 代码区（输入/输出通用） */
.code-area {
  width: 100%;
  min-height: 220px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  tab-size: 2;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.code-area:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}
.code-area[readonly] { background: var(--code-bg); cursor: default; }

/* 工具页内布局 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--bg-container);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.toolbar-spacer { flex: 1; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
}

.pane {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.pane-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

/* 底部状态栏 */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-3);
  font-size: 12.5px;
  min-height: 34px;
}
.status-bar.status-ok { color: var(--success); }
.status-bar.status-error { color: var(--danger); }
.status-bar.status-warn { color: var(--warning); }

/* 卡片 / 面板 */
.card {
  background: var(--bg-container);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-1);
  margin-bottom: 14px;
}
.card-title {
  font-size: 13.5px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--text-1);
}

/* 标签 / 徽章 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-secondary);
  color: var(--text-2);
}
.tag-primary { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.tag-success { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.tag-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tag-warning { background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); }

/* 表格 */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.table th { color: var(--text-2); font-weight: 600; background: var(--bg-secondary); }
.table tr:hover td { background: var(--bg-secondary); }

/* 键值信息行 */
.kv { display: flex; gap: 8px; font-size: 13px; }
.kv-key { color: var(--text-3); }
.kv-val { color: var(--text-1); word-break: break-all; }

/* ============================================================
   Toast 提示
   ============================================================ */

.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 12px);
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  max-width: 360px;
  padding: 11px 15px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: auto;
}
.toast-show { opacity: 1; transform: none; }
.toast-hide { opacity: 0; transform: translateX(24px); }

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--primary); }
.toast-msg { flex: 1; color: var(--text-1); }

.toast-close {
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 15px;
  padding: 0 2px;
  line-height: 1;
}
.toast-close:hover { color: var(--text-1); }

/* ============================================================
   工具页错误兜底
   ============================================================ */

.tool-error {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-2);
}
.tool-error-detail {
  margin: 8px 0 16px;
  color: var(--text-3);
  font-size: 12.5px;
  word-break: break-all;
}

/* ============================================================
   工具页内可复用的小组件
   ============================================================ */

/* 实时时钟卡片（时间戳工具页顶部） */
.ts-live-card {
  background: var(--bg-container);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.ts-live-card .stat-item {
  background: color-mix(in srgb, var(--primary) 5%, var(--bg-secondary));
}
/* 实时钟 5 项均分一行 */
.ts-live-card .stat-grid {
  grid-template-columns: repeat(5, 1fr);
}
@media (max-width: 900px) {
  .ts-live-card .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .ts-live-card .stat-grid { grid-template-columns: 1fr; }
}

/* 二维结果面板（diff 等） */
.diff-view {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--code-bg);
  min-height: 220px;
  max-height: 60vh;
  overflow: auto;
}
.diff-add { background: var(--diff-add-bg); color: var(--diff-add-text); }
.diff-del { background: var(--diff-del-bg); color: var(--diff-del-text); text-decoration: line-through; }

/* 匹配高亮 */
.mark-hit {
  background: color-mix(in srgb, var(--warning) 35%, transparent);
  border-radius: 2px;
  padding: 0 1px;
}

/* 键值统计网格 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.stat-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-secondary);
  text-align: center;
}
.stat-value { font-size: 20px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* 隐私提示条 */
.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-3);
  font-size: 12px;
}

/* ============================================================
   拖拽上传区（文件哈希等）
   ============================================================ */

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  transition: border-color 0.2s, background 0.2s;
}
.dropzone-over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-secondary));
}

.progress {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.15s;
}

/* Markdown 预览区内容样式 */
.md-preview h1, .md-preview h2, .md-preview h3,
.md-preview h4, .md-preview h5, .md-preview h6 {
  margin: 0.8em 0 0.4em;
  line-height: 1.35;
}
.md-preview h1 { font-size: 1.7em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.md-preview h2 { font-size: 1.4em; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
.md-preview h3 { font-size: 1.2em; }
.md-preview p { margin: 0.5em 0; }
.md-preview ul, .md-preview ol { padding-left: 1.6em; margin: 0.5em 0; }
.md-preview li { margin: 0.2em 0; }
.md-preview blockquote {
  margin: 0.6em 0;
  padding: 0.3em 1em;
  border-left: 4px solid var(--border-strong);
  color: var(--text-2);
  background: var(--bg-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.md-preview code {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: ui-monospace, Consolas, monospace;
}
.md-preview pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 10px 12px;
  border-radius: var(--radius);
  overflow: auto;
  line-height: 1.5;
}
.md-preview pre code {
  background: none;
  border: none;
  padding: 0;
}
.md-preview table { border-collapse: collapse; margin: 0.6em 0; width: 100%; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 5px 10px; }
.md-preview th { background: var(--bg-secondary); }
.md-preview img { max-width: 100%; }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md-preview a { color: var(--primary); }

/* 行内代码输入框字体 */
.code-inline { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

/* 单选组 */
.radio { cursor: pointer; }

/* ============================================================
   打赏（二维码弹层）
   ============================================================ */

/* 顶栏入口按钮 */
.donate-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--warning);
  border-radius: 999px;
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--warning);
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.15s;
}
.donate-btn:hover {
  background: var(--warning);
  color: #fff;
}

/* 遮罩 */
.donate-mask {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.donate-mask.show { display: flex; }

/* 弹窗卡片 */
.donate-dialog {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 22px 22px 18px;
  width: min(400px, calc(100vw - 40px));
  text-align: center;
  animation: tool-in 0.22s ease;
}
.donate-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.donate-sub { font-size: 12.5px; color: var(--text-3); margin: 0 0 16px; }

.donate-qr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 420px) {
  .donate-qr-grid { grid-template-columns: 1fr; }
}

.donate-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-container);
}
.donate-qr {
  width: 150px;
  height: 150px;
  display: block;
  border-radius: 6px;
  image-rendering: pixelated;
  background: #fff;
  cursor: zoom-in;
  transition: transform 0.15s;
}
.donate-qr:hover { transform: scale(1.03); }
.donate-label { font-size: 13px; font-weight: 600; }
.donate-alipay .donate-title-tag { color: #1677FF; }
.donate-wechat { color: #07C160; }

.donate-close {
  margin-top: 14px;
  width: 100%;
}

/* 放大查看 */
.donate-qr.zoomed {
  position: fixed;
  z-index: 1100;
  width: min(70vw, 320px);
  height: min(70vw, 340px);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow-2);
  background: #fff;
  padding: 6px;
}
