/* 古法编程 · 开发者工具 — 现代极简工具风 */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e7ec;
  --border-strong: #d4dae2;
  --text: #1a1f29;
  --text-2: #4a5462;
  --text-3: #8a94a3;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --mono: "JetBrains Mono", "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 32px rgba(16,24,40,.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body > main { flex: 1 0 auto; width: 100%; }
body > .site-footer { flex-shrink: 0; width: 100%; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------- 顶栏 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  height: 58px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: .2px;
}
.nav-brand .logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: grid; place-items: center;
  color: #fff; font-size: 15px; font-weight: 800;
}
.nav-brand small {
  font-weight: 500;
  color: var(--text-3);
  font-size: 12px;
  border-left: 1px solid var(--border-strong);
  padding-left: 10px;
  margin-left: 2px;
}
.nav-links {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}
.nav-links a {
  font-size: 13.5px;
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); }
.nav-links a.primary {
  background: var(--accent);
  color: #fff;
}
.nav-links a.primary:hover { background: var(--accent-hover); }

/* ---------- 容器 ---------- */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 面包屑 ---------- */
.crumb {
  font-size: 12.5px;
  color: var(--text-3);
  padding: 14px 0 0;
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
}
.crumb a { color: var(--text-3); }
.crumb a:hover { color: var(--accent); }
.crumb .sep { opacity: .5; }

/* ---------- 工具中心主页 Hero ---------- */
.hero {
  text-align: center;
  padding: 52px 0 36px;
}
.hero h1 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(120deg, var(--text), #4338ca);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  margin-top: 12px;
  color: var(--text-2);
  font-size: 16px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
.hero .search {
  margin: 26px auto 0;
  max-width: 480px;
  position: relative;
}
.hero .search input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 42px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 15px;
  font-family: var(--sans);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.hero .search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.hero .search svg {
  position: absolute;
  left: 15px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-3);
}

/* ---------- 工具分组 ---------- */
.tool-group { margin: 36px 0; }
.tool-group h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tool-group h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- 工具卡片网格 ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 15px;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}
.tool-card .ic {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
}
.tool-card .ic svg { width: 20px; height: 20px; }
.tool-card .tc-body { min-width: 0; }
.tool-card h3 {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 3px;
}
.tool-card p {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.5;
}

/* ---------- 工具页头（紧凑，让位给工具区） ---------- */
.tool-head {
  padding: 12px 0 16px;
  margin-bottom: 18px;
}
.tool-head h1 {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: 11px;
}
.tool-head h1 .ic {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
}
.tool-head h1 .ic svg { width: 20px; height: 20px; }
.tool-head p {
  margin-top: 7px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.55;
  max-width: 760px;
}

/* ---------- 工作区 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 28px;
  box-shadow: var(--shadow-lg);
}
@media (max-width: 600px) {
  .panel { padding: 18px 16px; border-radius: 12px; }
}
.workbench {
  display: grid;
  gap: 20px;
}
.workbench.split {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 760px) {
  .workbench.split { grid-template-columns: 1fr; }
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 7px;
}

textarea, input[type=text], input[type=number], select {
  width: 100%;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}
textarea { min-height: 300px; line-height: 1.6; }
textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.out, .out-box {
  background: var(--surface-2);
}
select { font-family: var(--sans); cursor: pointer; }

/* ---------- 按钮 ---------- */
.btn-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.btn {
  appearance: none;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn svg { width: 15px; height: 15px; }

/* ---------- 提示/状态 ---------- */
.hint {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 8px;
}
.status {
  font-size: 13px;
  font-weight: 600;
  padding: 3px 0;
  min-height: 20px;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 行内结果表 */
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  font-size: 13.5px;
}
.kv dt { color: var(--text-3); font-weight: 600; }
.kv dd { font-family: var(--mono); word-break: break-all; }

/* 颜色预览 */
.swatch {
  width: 100%;
  height: 88px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* 说明区 */
.note {
  margin-top: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.65;
}
.note b { color: var(--text-2); }

/* 说明收纳：把 .note 收进右下角浮动 i 按钮的弹层，让出工具区空间 */
.info-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  font-family: var(--mono);
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: grid; place-items: center;
  z-index: 80;
  transition: transform .15s, background .15s, color .15s;
}
.info-fab:hover { transform: scale(1.08); background: var(--accent); color: #fff; }
.info-fab:active { transform: scale(.96); }
.note.as-pop {
  position: fixed;
  right: 22px;
  bottom: 74px;
  max-width: 420px;
  width: calc(100vw - 44px);
  margin-top: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-lg);
  z-index: 81;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.note.as-pop.show { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* 相关工具 */
.related { margin: 36px 0 10px; }
.related h2 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: 56px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.site-footer .container {
  padding-top: 28px;
  padding-bottom: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  align-items: center;
  font-size: 13px;
  color: var(--text-3);
}
.site-footer a { color: var(--text-2); }
.site-footer .grow { flex: 1; }

/* QR canvas */
#qr-out { display: grid; place-items: center; min-height: 220px; }
#qr-out canvas, #qr-out img { border-radius: 8px; }

/* diff 输出 */
.diff-out {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}
.diff-out ins { background: #d4f4dd; text-decoration: none; }
.diff-out del { background: #ffd7d7; text-decoration: line-through; }
