/* ===== 不学网工具箱 公共样式 ===== */

:root {
  /* 文字 / 链接 */
  --fgColor-default: #0f172a;
  --fgColor-secondary: #55627a;
  --fgColor-link: #0e7490;
  --fgColor-link-hover: #06b6d4;
  /* 表面（卡片、输入框等实体元素） */
  --bgColor-default: #ffffff;
  --bgColor-secondary: #eef2f7;
  --borderColor-default: #dfe6ef;
  /* 页面底色与氛围 */
  --page-bg: #f3f5fa;
  --glow-1: rgba(34, 211, 238, .16);
  --glow-2: rgba(99, 102, 241, .13);
  --grid-line: rgba(15, 23, 42, .045);
  /* 品牌渐变 */
  --accent-a: #0891b2;
  --accent-b: #6366f1;
  --accent-glow: rgba(8, 145, 178, .28);
  --surface-glass: rgba(255, 255, 255, .78);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --code-font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fgColor-default: #e6edf7;
    --fgColor-secondary: #93a0b5;
    --fgColor-link: #38bdf8;
    --fgColor-link-hover: #7dd3fc;
    --bgColor-default: #101725;
    --bgColor-secondary: #1a2333;
    --borderColor-default: #263248;
    --page-bg: #0a0f1a;
    --glow-1: rgba(34, 211, 238, .09);
    --glow-2: rgba(129, 91, 245, .10);
    --grid-line: rgba(148, 163, 184, .05);
    --accent-a: #22d3ee;
    --accent-b: #818cf8;
    --accent-glow: rgba(34, 211, 238, .22);
    --surface-glass: rgba(16, 23, 37, .72);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 32px -16px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
/* 防止组件自身的 display 规则盖过 hidden 属性 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--fgColor-default);
  background: var(--page-bg);
  min-height: 100vh;
}
/* 网格 + 光晕氛围层 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(52rem 30rem at 82% -8%, var(--glow-1), transparent 60%),
    radial-gradient(46rem 28rem at -12% 32%, var(--glow-2), transparent 62%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, 34px 34px, 34px 34px;
}

a { color: var(--fgColor-link); text-decoration: none; transition: color .15s; }
a:hover { color: var(--fgColor-link-hover); }
code, pre { font-family: var(--code-font-family); }
::selection { background: var(--accent-glow); }

:is(button, input, select, textarea, a, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-a);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ===== 页头 / 页脚 ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 1.1rem;
  background: var(--surface-glass);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--borderColor-default);
}
/* 顶部霓虹细线 */
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-a), var(--accent-b), transparent);
  opacity: .85;
}
.site-header .brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .01em;
  color: var(--fgColor-default);
}
.site-header .brand:hover { color: var(--fgColor-default); }
.site-nav { display: flex; align-items: center; gap: .45rem; flex: none; }
.site-header .blog-link {
  font-size: .82rem;
  white-space: nowrap;
  padding: .3rem .8rem;
  border: 1px solid var(--borderColor-default);
  border-radius: 999px;
  transition: border-color .15s, color .15s, box-shadow .15s;
}
.site-header .blog-link:hover {
  border-color: var(--accent-a);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

main {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.4rem 1rem 3rem;
}
main > h1 {
  margin: .6rem 0 .2rem;
  font-size: 1.65rem;
  line-height: 1.35;
  letter-spacing: -.01em;
  background: linear-gradient(120deg, var(--fgColor-default) 55%, var(--accent-a));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  width: fit-content;
}
.subtitle { margin: 0 0 1.2rem; color: var(--fgColor-secondary); font-size: .95rem; }
.crumb { font-size: .82rem; margin: .2rem 0 0; }
.crumb a { color: var(--fgColor-secondary); }
.crumb a:hover { color: var(--fgColor-link); }

.site-footer {
  padding: 2rem 1rem 2.5rem;
  text-align: center;
  font-size: .82rem;
  color: var(--fgColor-secondary);
  border-top: 1px solid var(--borderColor-default);
}

/* ===== 用法说明区 ===== */
.usage { margin-top: 2.4rem; font-size: .92rem; }
.usage h2 {
  position: relative;
  margin: 1.9rem 0 .7rem;
  padding-left: .75rem;
  font-size: 1.08rem;
  line-height: 1.5;
}
.usage h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: .25em;
  bottom: .25em;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent-a), var(--accent-b));
}
.usage table { width: 100%; border-collapse: collapse; font-size: .88rem; display: block; overflow-x: auto; border-radius: 10px; }
.usage th, .usage td { padding: .5rem .75rem; border: 1px solid var(--borderColor-default); text-align: left; }
.usage th { background: var(--bgColor-secondary); font-weight: 600; }
.usage code {
  padding: .1rem .35rem;
  font-size: .85em;
  background: var(--bgColor-secondary);
  border: 1px solid var(--borderColor-default);
  border-radius: 6px;
  overflow-wrap: anywhere;
}
.usage pre {
  padding: .9rem 1rem;
  background: var(--bgColor-secondary);
  border: 1px solid var(--borderColor-default);
  border-radius: 12px;
  overflow-x: auto;
  font-size: .82rem;
  line-height: 1.65;
}
.usage pre code { padding: 0; background: none; border: none; }
.usage ul, .usage ol { padding-left: 1.4rem; }
.usage li { margin: .3rem 0; }
.note {
  padding: .85rem 1rem;
  margin: 1rem 0;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .08);
  font-size: .88rem;
}
.note.info { border-color: rgba(56, 189, 248, .35); background: rgba(56, 189, 248, .08); }
.note strong:first-child { display: block; margin-bottom: .25rem; }

/* ===== 首页宫格 ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.6rem, 1fr));
  gap: 1rem .6rem;
  margin: 1.5rem 0 2.2rem;
}
.tools-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  padding: .8rem .3rem .7rem;
  border-radius: 16px;
  border: 1px solid transparent;
  text-decoration: none !important;
  transition: background .18s, transform .15s, border-color .18s, box-shadow .18s;
  -webkit-tap-highlight-color: transparent;
}
.tools-tile:hover {
  background: var(--bgColor-default);
  border-color: var(--borderColor-default);
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}
.tools-tile:active { transform: scale(.96); }
.tools-tile-icon svg {
  width: 1.65rem;
  height: 1.65rem;
  filter: drop-shadow(0 1px 2px hsl(var(--h) 70% 25% / .45));
}
.tools-tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1;
  color: #fff;
  border-radius: 18px;
  background: linear-gradient(135deg, hsl(var(--h) 70% 56%), hsl(calc(var(--h) + 40) 72% 42%));
  box-shadow:
    inset 0 1px 0 hsl(var(--h) 80% 75% / .6),
    0 4px 14px -4px hsl(var(--h) 70% 45% / .55);
  text-shadow: 0 1px 3px hsl(var(--h) 70% 25% / .4);
  transition: transform .15s, box-shadow .18s;
}
.tools-tile:hover .tools-tile-icon svg {
  width: 1.65rem;
  height: 1.65rem;
  filter: drop-shadow(0 1px 2px hsl(var(--h) 70% 25% / .45));
}
.tools-tile-icon {
  transform: scale(1.06);
  box-shadow:
    inset 0 1px 0 hsl(var(--h) 80% 75% / .6),
    0 6px 20px -4px hsl(var(--h) 70% 50% / .7);
}
.tools-tile-name {
  font-size: .8rem;
  line-height: 1.35;
  text-align: center;
  color: var(--fgColor-default);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  word-break: break-word;
}
@media only screen and (max-width: 680px) {
  .tools-grid { grid-template-columns: repeat(4, 1fr); gap: .85rem .2rem; }
  .tools-tile { padding: .55rem .15rem .5rem; gap: .45rem; }
  .tools-tile-icon svg {
  width: 1.65rem;
  height: 1.65rem;
  filter: drop-shadow(0 1px 2px hsl(var(--h) 70% 25% / .45));
}
.tools-tile-icon { width: 3.1rem; height: 3.1rem; border-radius: 16px; }
  .tools-tile-icon svg { width: 1.45rem; height: 1.45rem; }
  .tools-tile-name { font-size: .74rem; }
}
@media only screen and (max-width: 360px) {
  .tools-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== 工具通用组件（tk-*） ===== */
.tk { margin: 1rem 0 0; font-size: .92rem; line-height: 1.7; }

.tk-card {
  padding: 1.1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--borderColor-default);
  border-radius: 16px;
  background: var(--bgColor-default);
  box-shadow: var(--shadow-card);
}
.tk-card > :first-child { margin-top: 0; }
.tk-card > :last-child { margin-bottom: 0; }

.tk-h {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0 0 .85rem;
  font-size: .95rem;
  font-weight: 700;
  color: var(--fgColor-default);
}
.tk-h::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 0 8px var(--accent-glow);
  flex: none;
}
.tk-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.tk-row-tight { gap: .4rem; }
.tk-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.tk-spacer { flex: 1 1 auto; }

.tk-field { display: block; margin-bottom: .85rem; }
.tk-field:last-child { margin-bottom: 0; }
.tk-label {
  display: block;
  margin-bottom: .35rem;
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--fgColor-secondary);
}
.tk-hint { margin: .35rem 0 0; font-size: .76rem; color: var(--fgColor-secondary); }

.tk-input, .tk-textarea, .tk-select {
  width: 100%;
  padding: .55rem .75rem;
  /* 16px：低于 16px 时 iOS Safari 聚焦会自动放大页面 */
  font-size: 16px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--fgColor-default);
  background: var(--bgColor-secondary);
  border: 1px solid var(--borderColor-default);
  border-radius: 10px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.tk-select { background-image: none; padding-right: .75rem; }
.tk-input:focus, .tk-textarea:focus, .tk-select:focus {
  border-color: var(--accent-a);
  background: var(--bgColor-default);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.tk-textarea { min-height: 7rem; font-family: var(--code-font-family); font-size: 14px; resize: vertical; }
.tk-input-mono { font-family: var(--code-font-family); }
.tk-input-sm { width: auto; min-width: 5rem; }

.tk-btn {
  padding: .5rem 1.1rem;
  font-size: .85rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 10px -2px var(--accent-glow);
  transition: transform .12s, box-shadow .15s, filter .15s;
}
.tk-btn:hover { filter: brightness(1.08); box-shadow: 0 4px 16px -2px var(--accent-glow); }
.tk-btn:active { transform: scale(.97); }
.tk-btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; box-shadow: none; }
.tk-btn.ghost {
  color: var(--fgColor-default);
  background: var(--bgColor-secondary);
  border-color: var(--borderColor-default);
  box-shadow: none;
}
.tk-btn.ghost:hover { border-color: var(--accent-a); filter: none; }
.tk-btn.sm { padding: .32rem .75rem; font-size: .78rem; }

.tk-check {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .84rem;
  color: var(--fgColor-default);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.tk-check input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent-a); }

.tk-range { width: 100%; accent-color: var(--accent-a); }

.tk-seg { display: flex; flex-wrap: wrap; gap: .35rem; }
.tk-seg button {
  padding: .35rem .85rem;
  font-size: .8rem;
  font-family: inherit;
  color: var(--fgColor-secondary);
  background: var(--bgColor-secondary);
  border: 1px solid var(--borderColor-default);
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, box-shadow .15s;
}
.tk-seg button:hover { border-color: var(--accent-a); color: var(--fgColor-default); }
.tk-seg button.on {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border-color: transparent;
  box-shadow: 0 2px 8px -2px var(--accent-glow);
}

.tk-out {
  padding: .75rem .85rem;
  font-family: var(--code-font-family);
  font-size: 13px;
  line-height: 1.65;
  color: var(--fgColor-default);
  background: var(--bgColor-secondary);
  border: 1px solid var(--borderColor-default);
  border-radius: 10px;
  overflow-x: auto;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  -webkit-user-select: all;
  user-select: all;
}
.tk-out.big { font-size: 15px; letter-spacing: .02em; }
.tk-out.empty { color: var(--fgColor-secondary); -webkit-user-select: none; user-select: none; }

.tk-kv { display: grid; grid-template-columns: 7.5rem 1fr; gap: .5rem .8rem; font-size: .86rem; margin: 0; }
.tk-kv dt { color: var(--fgColor-secondary); }
.tk-kv dd { margin: 0; color: var(--fgColor-default); overflow-wrap: anywhere; -webkit-user-select: all; user-select: all; }

.tk-badge:empty { display: none; }
.tk-badge {
  display: inline-block;
  padding: .12rem .55rem;
  font-size: .74rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--bgColor-secondary);
  border: 1px solid var(--borderColor-default);
  color: var(--fgColor-secondary);
}
.tk-badge.ok { background: rgba(52, 211, 153, .12); border-color: rgba(52, 211, 153, .35); color: #059669; }
.tk-badge.warn { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .35); color: #b45309; }
.tk-badge.bad { background: rgba(244, 63, 94, .12); border-color: rgba(244, 63, 94, .35); color: #be123c; }
@media (prefers-color-scheme: dark) {
  .tk-badge.ok { color: #34d399; }
  .tk-badge.warn { color: #fbbf24; }
  .tk-badge.bad { color: #fb7185; }
}

.tk-tip {
  padding: .8rem .95rem;
  margin-bottom: 1rem;
  font-size: .84rem;
  line-height: 1.7;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .08);
  color: var(--fgColor-default);
}

.tk-toast {
  position: fixed;
  left: 50%;
  bottom: 2.2rem;
  z-index: 320;
  padding: .55rem 1.1rem;
  font-size: .84rem;
  color: #fff;
  background: rgba(10, 15, 26, .88);
  border: 1px solid rgba(148, 163, 184, .25);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  transform: translate(-50%, 1rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .5);
}
.tk-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ===== 首页意见箱 ===== */
.fb-card {
  padding: 1.1rem 1.2rem;
  margin: 1rem 0;
  border: 1px solid var(--borderColor-default);
  border-radius: 16px;
  background: var(--bgColor-default);
  box-shadow: var(--shadow-card);
}
.fb-card h2 { margin: 0 0 .4rem; font-size: 1.02rem; }
.fb-card p { margin: 0 0 .6rem; font-size: .88rem; color: var(--fgColor-secondary); }
.fb-card p:last-child { margin-bottom: 0; }
.fb-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.fb-btn {
  padding: .5rem 1.1rem;
  font-size: .85rem;
  font-weight: 600;
  color: #fff !important;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border-radius: 10px;
  box-shadow: 0 2px 10px -2px var(--accent-glow);
  transition: filter .15s, box-shadow .15s;
}
.fb-btn:hover { filter: brightness(1.08); box-shadow: 0 4px 16px -2px var(--accent-glow); }
.fb-btn.ghost {
  color: var(--fgColor-default) !important;
  background: var(--bgColor-secondary);
  border: 1px solid var(--borderColor-default);
  box-shadow: none;
}
.fb-btn.ghost:hover { border-color: var(--accent-a); filter: none; }
@media only screen and (max-width: 680px) {
  .fb-actions .fb-btn { flex: 1 1 auto; text-align: center; }
}

/* ===== 手机端 ===== */
@media only screen and (max-width: 680px) {
  .tk { font-size: .88rem; }
  .tk-card { padding: .9rem; border-radius: 14px; }
  .tk-grid2 { grid-template-columns: 1fr; }
  .tk-kv { grid-template-columns: 5.6rem 1fr; font-size: .82rem; }
  .tk-btn { padding: .55rem 1rem; }
  .tk-row > .tk-btn { flex: 1 1 auto; }
  .tk-out { font-size: 12.5px; }
  main > h1 { font-size: 1.4rem; }
}

/* 尊重系统的减少动效设置 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
