/* ============================================================
   工具箱 ToolBox — 全新视觉系统 (v2)
   设计语言：玻璃顶栏 / 渐变 Hero / 卡片悬浮 / 深色模式
   纯静态、无构建步骤，全站共享此文件。
   ============================================================ */

:root {
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-soft: #eef2ff;
  --accent: #ec4899;
  --bg: #f6f7fb;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #eef2ff 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 10%, #faf0ff 0%, transparent 55%),
             #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fbfcff;
  --text: #0f172a;
  --text-strong: #020617;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e9ebf3;
  --border-strong: #d8dce8;
  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 10px 30px -12px rgba(15,23,42,.12);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-lg: 0 20px 50px -20px rgba(79,70,229,.35);
  --green: #16a34a;
  --red: #e11d48;
  --amber: #d97706;
  --maxw: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

html[data-theme="dark"] {
  --primary: #818cf8;
  --primary-2: #a78bfa;
  --primary-soft: #1e2030;
  --accent: #f472b6;
  --bg: #080b14;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #1a1d33 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 10%, #241a33 0%, transparent 55%),
             #080b14;
  --surface: #10141f;
  --surface-2: #141925;
  --text: #e7ebf4;
  --text-strong: #f8fafc;
  --muted: #9aa6bd;
  --muted-2: #6b7689;
  --border: #222a3c;
  --border-strong: #2c3548;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 40px -16px rgba(0,0,0,.6);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 20px 50px -20px rgba(129,140,248,.4);
}

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

body {
  font-family: var(--font);
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background-color .3s, color .3s;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏（玻璃） ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 11px 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--text-strong); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-size: 18px; box-shadow: var(--shadow-lg);
}
.main-nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.main-nav a {
  color: var(--muted); padding: 8px 13px; border-radius: 9px;
  font-size: 14px; font-weight: 600; transition: background .15s, color .15s;
}
.main-nav a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.main-nav a.active { color: var(--primary); background: var(--primary-soft); }
.header-tools { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 17px;
  display: grid; place-items: center; transition: .15s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 9px; padding: 7px 11px; font-size: 18px; cursor: pointer; color: var(--text); }

/* ---------- 容器 ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 30px 20px 80px; }
.tool-main { max-width: var(--maxw); margin: 0 auto; padding: 26px 20px 80px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.back-link:hover { color: var(--primary); text-decoration: none; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 46px 16px 10px; }
.hero .eyebrow {
  display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: .5px;
  color: var(--primary); background: var(--primary-soft); padding: 5px 14px; border-radius: 999px; margin-bottom: 16px;
}
.hero h1 {
  font-size: clamp(30px, 5vw, 46px); margin: 0 0 14px; letter-spacing: -1px; line-height: 1.15;
  background: linear-gradient(120deg, var(--text-strong), var(--primary) 55%, var(--primary-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p { color: var(--muted); font-size: 17px; max-width: 660px; margin: 0 auto 22px; }
.hero-search {
  position: relative; display: flex; align-items: center;
  max-width: 560px; margin: 0 auto; padding: 0 14px 0 18px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px;
  box-shadow: var(--shadow); transition: border-color .18s, box-shadow .18s;
}
.hero-search:focus-within { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.hero-search .s-icon { flex: 0 0 auto; margin-right: 10px; font-size: 16px; color: var(--muted-2); pointer-events: none; }
div.hero-search input {
  flex: 1 1 auto; width: 100%; border: none; outline: none; background: transparent;
  padding: 15px 8px; font-size: 16px; color: var(--text); box-shadow: none;
}
div.hero-search input:focus { box-shadow: none; }
.hero-search .s-clear { flex: 0 0 auto; border: none; background: none; color: var(--muted-2); cursor: pointer; font-size: 18px; padding: 0 4px; display: none; }
.hero-badges { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.badge { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--muted); box-shadow: var(--shadow-sm); }
.no-result { text-align: center; color: var(--muted); padding: 40px; display: none; }

/* ---------- 分类 / 卡片 ---------- */
.section-title { margin: 40px 0 16px; font-size: 21px; display: flex; align-items: center; gap: 11px; color: var(--text-strong); }
.section-title .bar { width: 5px; height: 22px; border-radius: 3px; background: linear-gradient(var(--primary), var(--primary-2)); }
.section-title .count { font-size: 13px; color: var(--muted-2); font-weight: 600; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 16px; }
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 11px;
  transition: transform .18s, box-shadow .18s, border-color .18s; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.tool-card::after { content: "→"; position: absolute; right: 16px; top: 16px; color: var(--muted-2); opacity: 0; transform: translateX(-4px); transition: .18s; font-weight: 700; }
.tool-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--border-strong); text-decoration: none; }
.tool-card:hover::after { opacity: 1; transform: translateX(0); color: var(--primary); }
.tool-card .icon {
  font-size: 24px; width: 50px; height: 50px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--primary-2) 18%, var(--surface)));
  border-radius: 13px; color: var(--primary);
}
.tool-card h3 { margin: 0; font-size: 16.5px; color: var(--text-strong); }
.tool-card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.tool-card .tag { align-self: flex-start; font-size: 12px; color: var(--primary); background: var(--primary-soft); padding: 3px 10px; border-radius: 999px; font-weight: 600; }

/* ---------- 面板 / 表单 ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.panel h2 { margin: 0 0 14px; font-size: 18px; color: var(--text-strong); }
.panel h3 { margin: 18px 0 10px; font-size: 14.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.tool-header { margin-bottom: 20px; }
.tool-header .crumb { font-size: 13px; color: var(--muted-2); margin-bottom: 8px; }
.tool-header .crumb a { color: var(--muted); }
.tool-header h1 { margin: 0 0 7px; font-size: 27px; color: var(--text-strong); letter-spacing: -.4px; }
.tool-header p { margin: 0; color: var(--muted); font-size: 15px; max-width: 720px; }

.two-col { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 22px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 7px; color: var(--text); }
.label-row { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 7px; }
.label-row label { margin: 0; }
.field-hint { font-size: 12.5px; color: var(--muted-2); margin-top: 5px; }

input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"],
textarea, select {
  width: 100%; font-family: var(--font); font-size: 14px; padding: 11px 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
textarea { font-family: var(--mono); resize: vertical; min-height: 170px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; border: none; border-radius: var(--radius-sm); padding: 11px 18px; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: filter .15s, transform .05s, box-shadow .15s; box-shadow: var(--shadow-lg);
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { background: var(--surface-2); filter: none; }
.btn.ghost { background: transparent; color: var(--primary); padding: 9px 12px; box-shadow: none; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: none; background: none; color: var(--muted); padding: 7px 13px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: .15s; }
.seg button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.seg button:hover:not(.active) { color: var(--text); }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 8px 0; cursor: pointer; }
.check-row input { width: auto; }

.hint { font-size: 13px; color: var(--muted); }
.ok { color: var(--green); font-weight: 600; }
.warn { color: var(--amber); font-weight: 600; }
.err { color: var(--red); font-weight: 600; }

/* ---------- 结果 ---------- */
.result {
  margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #0f172a; color: #e2e8f0; padding: 15px 17px;
  font-family: var(--mono); font-size: 13px; white-space: pre-wrap; word-break: break-word;
  max-height: 480px; overflow: auto; line-height: 1.55;
}
html[data-theme="dark"] .result { background: #060912; color: #cbd5e1; border-color: #1c2740; }
.result:empty { display: none; }
.result .k { color: #7dd3fc; } .result .s { color: #86efac; } .result .n { color: #fca5a5; } .result .b { color: #fcd34d; } .result .c { color: #c4b5fd; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 13px; margin-top: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .v { font-size: 23px; font-weight: 800; color: var(--text-strong); letter-spacing: -.5px; }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 3px; }
.stat.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border: none; }
.stat.primary .v, .stat.primary .l { color: #fff; }
.stat.amber { background: #fff7ed; border-color: #fed7aa; } .stat.amber .v { color: var(--amber); }
html[data-theme="dark"] .stat.amber { background: #2a1d0e; border-color: #5a3d17; }
.stat.green { background: #f0fdf4; border-color: #bbf7d0; } .stat.green .v { color: var(--green); }
html[data-theme="dark"] .stat.green { background: #0e2417; border-color: #175c39; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 14px; }
table.tbl th, table.tbl td { border: 1px solid var(--border); padding: 8px 11px; text-align: right; }
table.tbl th { background: var(--surface-2); font-weight: 700; color: var(--text); }
table.tbl td:first-child, table.tbl th:first-child { text-align: center; }
.tbl-wrap { overflow: auto; max-height: 380px; border-radius: 10px; border: 1px solid var(--border); }

/* ---------- 广告位 ---------- */
.ad-slot { margin: 20px 0; }
.ad-slot.flex { display: flex; justify-content: center; }
.ad-placeholder {
  width: 100%; min-height: 100px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted-2);
  background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 12px, var(--surface-2) 12px, var(--surface-2) 24px);
  font-size: 13px;
}
.ad-placeholder .ad-label { font-weight: 800; letter-spacing: 2px; color: var(--muted); }
.ad-placeholder small { opacity: .8; font-size: 11px; }
.ad-placeholder.banner { min-height: 110px; }
.ad-placeholder.rectangle { min-height: 280px; max-width: 336px; margin: 0 auto; }
.ad-placeholder.native { min-height: 130px; }

/* ---------- 页脚 ---------- */
.site-footer { border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 70%, transparent); margin-top: 50px; backdrop-filter: blur(10px); }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 26px 20px; color: var(--muted); font-size: 13.5px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.footer-inner a { color: var(--muted); margin-right: 14px; }
.footer-inner a:hover { color: var(--primary); }

/* ---------- 游戏 ---------- */
.game-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.game-board { background: linear-gradient(135deg, #bbada0, #a89683); padding: 11px; border-radius: 12px; touch-action: none; user-select: none; box-shadow: var(--shadow); }
.game-board .cell { background: rgba(255,255,255,.18); border-radius: 7px; }
.canvas-host { background: #0b0f1a; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); line-height: 0; }
.score-line { display: flex; gap: 12px; align-items: center; font-size: 14px; color: var(--text); }
.score-pill { background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 5px 16px; font-weight: 800; }
.controls-hint { font-size: 13px; color: var(--muted); }

/* ---------- 字帖 ---------- */
.copybook-stage { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; overflow: auto; max-width: 100%; box-shadow: var(--shadow-sm); }
.copybook-stage canvas { display: block; }
html[data-theme="dark"] .copybook-stage { background: #fff; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: all .25s; z-index: 200; }
html[data-theme="dark"] .toast { background: #1e2638; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .main-nav { display: none; }
  .main-nav.open { display: flex; flex-direction: column; width: 100%; gap: 4px; }
  .menu-toggle { display: block; }
  .header-inner { flex-wrap: wrap; }
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
