/* 本地工具箱 · 首页样式
   纯静态、无依赖；浅色/深色跟随系统，可手动切换 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --text: #101828;
  --muted: #667085;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --accent-soft: #eef4ff;
  --star: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 8px 24px -12px rgba(16, 24, 40, .22);
  --radius: 12px;
  --max: 1180px;
}

html[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1a212b;
  --line: #262d38;
  --line-strong: #333c49;
  --text: #e6edf3;
  --muted: #97a3b4;
  --accent: #60a5fa;
  --accent-ink: #93c5fd;
  --accent-soft: #17253d;
  --star: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 28px -14px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 24px; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--surface); color: var(--text); padding: 10px 16px; border-radius: 8px;
}
.skip:focus { left: 16px; top: 12px; }

/* ---------- 顶栏 ---------- */
.head {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.head-inner { display: flex; align-items: center; gap: 18px; height: 62px; }
.brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 17px; font-weight: 700; text-decoration: none; letter-spacing: -.01em;
  white-space: nowrap;
}
.brand .mark {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-ink));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.brand .mark svg { width: 15px; height: 15px; }
.brand small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.head-nav { display: flex; gap: 4px; margin-left: 6px; }
.head-nav a { padding: 6px 11px; border-radius: 8px; text-decoration: none; font-size: 14px; color: var(--muted); }
.head-nav a:hover { background: var(--accent-soft); color: var(--accent-ink); }
.head-nav a[aria-current="page"] { color: var(--text); font-weight: 600; background: var(--accent-soft); }

.head-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box > svg { position: absolute; left: 10px; color: var(--muted); pointer-events: none; width: 15px; height: 15px; }
#q {
  width: 210px; padding: 8px 34px 8px 32px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface-2); color: var(--text); font-size: 14px;
  font-family: inherit;
  transition: width .18s ease, border-color .18s ease, background .18s ease;
}
#q::placeholder { color: var(--muted); }
#q:focus { width: 264px; outline: none; border-color: var(--accent); background: var(--surface); }
#q::-webkit-search-cancel-button { -webkit-appearance: none; }
.kbd {
  position: absolute; right: 8px; font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; line-height: 16px;
  font-family: ui-monospace, Menlo, monospace; pointer-events: none; background: var(--surface);
}
#q:focus ~ .kbd, #q:not(:placeholder-shown) ~ .kbd { display: none; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- 首屏 ---------- */
.hero { padding: 52px 0 30px; }
.hero h1 {
  margin: 0 0 14px; font-size: clamp(27px, 4.2vw, 42px); line-height: 1.22;
  letter-spacing: -.025em; font-weight: 750;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent), #7c3aed 88%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { margin: 0; max-width: 64ch; color: var(--muted); font-size: clamp(14px, 1.6vw, 16px); }
.hero-points { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.point {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; box-shadow: var(--shadow-sm);
}
.point i { font-style: normal; color: var(--accent); font-weight: 700; }

/* ---------- 分类筛选 ---------- */
.filters {
  position: sticky; top: 62px; z-index: 15;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-size: 14px; font-family: inherit; transition: .15s ease;
}
.chip b { font-weight: 600; font-size: 12px; color: var(--muted); }
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip[aria-pressed="true"] b { color: inherit; opacity: .6; }

/* ---------- 分类区块 ---------- */
main { flex: 1; padding-bottom: 48px; }
.cat { padding-top: 34px; }
.cat-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.cat-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.cat-head .num { font-size: 12px; color: var(--muted); }
.cat-note { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; max-width: 74ch; }

.grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
}
.grid li { position: relative; }
.card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 38px 14px 14px; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-md); }
.card .ico {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
  border: 1px solid var(--accent-soft);
}
.card .ico svg {
  width: 19px; height: 19px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.card .copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.card .name { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.card .desc {
  font-size: 12.8px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.star {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; border-radius: 7px; background: transparent; color: var(--line-strong);
  cursor: pointer; opacity: 0; transition: opacity .15s ease, color .15s ease, background .15s ease;
}
li:hover > .star, .star:hover, .star:focus-visible, .star[aria-pressed="true"] { opacity: 1; }
.star:hover { background: var(--accent-soft); color: var(--star); }
.star[aria-pressed="true"] { color: var(--star); }
.star svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round;
}
.star[aria-pressed="true"] svg { fill: currentColor; }

/* 主题按钮：浅色显示太阳，深色显示月亮 */
#theme .moon { display: none; }
html[data-theme="dark"] #theme .sun { display: none; }
html[data-theme="dark"] #theme .moon { display: block; }

.is-hidden { display: none !important; }

.empty { display: none; text-align: center; padding: 64px 20px; color: var(--muted); }
.empty.show { display: block; }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty button {
  margin-top: 14px; padding: 8px 16px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-family: inherit;
}
.empty button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 说明区 ---------- */
.about {
  margin-top: 46px; border-top: 1px solid var(--line); padding-top: 28px;
  display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.about h3 { margin: 0 0 6px; font-size: 14.5px; }
.about p { margin: 0; color: var(--muted); font-size: 13.5px; }
.about a { color: var(--accent); text-decoration: none; }
.about a:hover { text-decoration: underline; }

/* ---------- 页脚 ---------- */
.foot {
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 22px 0; color: var(--muted); font-size: 13px;
}
.foot-inner { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--accent); }
.foot .spacer { margin-left: auto; }

@media (max-width: 780px) {
  .wrap { padding: 0 16px; }
  .head-inner { height: auto; padding: 10px 0; flex-wrap: wrap; gap: 10px; }
  .head-nav { order: 3; width: 100%; margin-left: -4px; }
  .head-tools { order: 2; }
  .search-box { flex: 1; }
  #q, #q:focus { width: 100%; }
  .hero { padding: 32px 0 20px; }
  .filters { position: static; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
  .card { padding: 12px 30px 12px 12px; gap: 10px; }
  .card .desc { -webkit-line-clamp: 3; }
  .brand small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .card:hover { transform: none; }
}
