/* ============================================================
   全天电脑维修 · 常用测试工具  | 共享样式
   设计语言：Ant Design 蓝主色 + 柔和卡片 + 响应式
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --brand: #1677ff;
  --brand-2: #4096ff;
  --brand-dk: #0958d9;
  --ink: #1f2329;
  --ink-2: #4b5563;
  --muted: #8a919f;
  --line: #e8ebf0;
  --bg: #f4f7fb;
  --card: #ffffff;
  --ok: #16a34a;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(22,119,255,.10);
  --shadow-sm: 0 2px 10px rgba(15,23,42,.06);
  --maxw: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  line-height: 1.65; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
:focus-visible { outline: 3px solid rgba(22,119,255,.35); outline-offset: 2px; }

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.82); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .bar { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); font-size: 17px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-dk)); color: #fff; font-size: 18px;
}
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
.header-link { font-size: 14px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.header-link:hover { color: var(--brand); }

/* ---------- 面包屑 ---------- */
.breadcrumb { font-size: 13px; color: var(--muted); padding: 16px 0 0; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb span.sep { margin: 0 8px; }
.breadcrumb .cur { color: var(--ink); }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 22px; margin: 18px 0 26px;
  background: linear-gradient(135deg, #1677ff 0%, #0958d9 55%, #052e8f 100%);
  color: #fff; padding: 46px 40px;
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%); border-radius: 50%;
}
.hero h1 { font-size: clamp(24px, 4vw, 34px); margin: 0 0 10px; font-weight: 800; letter-spacing: .5px; }
.hero p { margin: 0; font-size: 15px; opacity: .92; max-width: 640px; }
.hero .tags { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.hero .tags span {
  font-size: 12px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25);
  padding: 4px 11px; border-radius: 999px;
}

/* ---------- 卡片网格 ---------- */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.card {
  display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; transition: transform .16s ease, box-shadow .16s ease, border-color .16s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #c6dbff; }
.card .ic {
  width: 50px; height: 50px; border-radius: 13px; background: #eef4ff; color: var(--brand);
  display: inline-grid; place-items: center; font-size: 26px; margin-bottom: 14px;
}
.card h3 { font-size: 17px; margin: 0 0 6px; }
.card p { margin: 0; font-size: 13.5px; color: var(--muted); flex: 1; }
.card .go { margin-top: 14px; font-weight: 700; font-size: 14px; color: var(--brand); display: inline-flex; align-items: center; gap: 6px; }

/* ---------- 工具页通用 ---------- */
main { padding-bottom: 40px; }
.tool-head { margin: 20px 0 18px; }
.tool-head h1 { font-size: clamp(22px, 3.4vw, 28px); margin: 0 0 8px; }
.tool-head .lede { margin: 0; color: var(--ink-2); font-size: 15px; max-width: 760px; }
.tool-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--brand); display: inline-block; }

/* ---------- 统计 ---------- */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat { background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat .n { font-size: 22px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }

/* ---------- 电平条 / 画布 ---------- */
.meter { height: 20px; background: #eef1f6; border-radius: 999px; overflow: hidden; margin: 10px 0; }
.meter > i { display: block; height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #16a34a, #f59e0b 72%, #ef4444); transition: width .05s linear; }
canvas { width: 100%; display: block; background: #0f172a; border-radius: 12px; }

/* ---------- 按钮 ---------- */
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
button, .btn {
  font-family: inherit; font-size: 14px; cursor: pointer; border: 1px solid var(--line); background: #fff;
  color: var(--ink); padding: 10px 18px; border-radius: 10px; transition: .15s; line-height: 1;
}
button:hover, .btn:hover { border-color: var(--brand-2); color: var(--brand); }
button.primary, .btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.primary:hover, .btn.primary:hover { background: var(--brand-dk); color: #fff; }
button.stop { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
button:disabled { opacity: .5; cursor: not-allowed; }
select { font-family: inherit; font-size: 14px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.pill { font-size: 12.5px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); }
.pill.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- 拟真键盘（实物比例 / 立体键帽） ---------- */
.kbd-wrap { overflow: visible; padding: 4px 0 10px; }
.kbd {
  --ku: min(40px, calc(100cqi / 25.5));   /* 桌面封顶40px(避免超宽屏整把>容器而溢出)；窄屏按容器宽度(100cqi)自适应，整把键盘铺满视口不滚动 */
  position: relative;
  width: 100%;
  display: flex; gap: calc(var(--ku) * 0.4); align-items: flex-start;
  container-type: inline-size;
  background: linear-gradient(180deg, #f3f5f9, #e7eaf0);
  border: 1px solid #d3d8e2; border-radius: 16px;
  padding: 60px 12px 14px;          /* 顶部留白用于放置右上角 LOGO 广告位 */
  box-shadow: 0 18px 42px rgba(15, 23, 42, .14), inset 0 1px 0 #fff;
  margin: 0 auto;
}
.kbd-brand { position: absolute; top: 16px; left: 18px; font-size: 12px; color: #9aa3b2;
  font-weight: 700; letter-spacing: .4px; display: flex; align-items: center; gap: 6px; }
.kbd-brand .led { width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
  box-shadow: 0 0 8px var(--brand); display: inline-block; }
.kb-col { display: flex; flex-direction: column; gap: calc(var(--ku) * 0.1); }
.kb-col.num { display: grid; grid-template-columns: repeat(4, var(--ku)); grid-auto-rows: var(--ku); gap: calc(var(--ku) * 0.1); }
.krow { display: flex; gap: calc(var(--ku) * 0.1); }
.kkey {
  width: calc(var(--ku) * 1); height: calc(var(--ku) * 1); border-radius: calc(var(--ku) * 0.16); flex: 0 0 auto;
  background: linear-gradient(180deg, #ffffff, #eef1f6);
  border: 1px solid #d4d9e2; border-bottom: calc(var(--ku) * 0.07) solid #c2c8d4;
  box-shadow: inset 0 1px 0 #fff;
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  font-size: clamp(8px, calc(var(--ku) * 0.27), 13px); color: #2a2f3a; font-weight: 600; padding: 0 calc(var(--ku) * 0.08); line-height: 1.12; overflow: hidden; white-space: nowrap;
  user-select: none; transition: transform .06s, background .06s, border-color .06s;
}
.kkey small { display: block; font-size: calc(var(--ku) * 0.22); color: #8a919f; font-weight: 500; }
.kkey.fn { font-size: clamp(7px, calc(var(--ku) * 0.24), 11px); }
.kkey.mod { font-size: clamp(7px, calc(var(--ku) * 0.24), 11px); }
.kkey.active { background: linear-gradient(180deg, #1677ff, #0958d9); color: #fff;
  border-bottom-color: #073aa0; transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3); }
.kkey.active small { color: rgba(255, 255, 255, .85); }
.kkey.stuck { background: #ef4444; color: #fff; border-bottom-color: #b91c1c; }
.kkey.empty { visibility: hidden; border: none; background: none; box-shadow: none; }
/* 右上角 LOGO 广告位 */
.kbd-ad { position: absolute; top: 10px; right: 12px; z-index: 6; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: rgba(255, 255, 255, .96); border: 1px solid #e2e8f0; border-radius: 11px;
  padding: 6px 8px; max-width: calc(var(--ku) * 3.6); box-shadow: 0 8px 22px rgba(15, 23, 42, .20); }
.kbd-ad img { width: clamp(28px, calc(var(--ku) * 1.5), 54px); height: clamp(28px, calc(var(--ku) * 1.5), 54px); object-fit: contain; border-radius: 8px; background: #fff; }
.kbd-ad .nm { font-size: clamp(9px, calc(var(--ku) * 0.24), 11px); color: #1b2330; font-weight: 700; line-height: 1.2; text-align: center; }
.kbd-ad .tg { font-size: 9px; color: #8a93a6; }
.kbd-ad.hidden { display: none; }
@media (max-width: 720px) {
  .kbd { border-radius: 12px; padding: 52px 8px 10px; }
  .kbd-ad { padding: 5px 6px; }
}
.log { height: 120px; overflow-y: auto; background: #0f172a; color: #a5f3fc; border-radius: 10px;
  padding: 10px 12px; font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
.log div { margin-bottom: 2px; }

/* ---------- 鼠标区域 ---------- */
.track { position: relative; height: 360px; border: 2px dashed var(--line); border-radius: 12px; overflow: hidden;
  cursor: crosshair; touch-action: none;
  background:
    linear-gradient(#eef1f6 1px, transparent 1px) 0 0 / 100% 24px,
    linear-gradient(90deg, #eef1f6 1px, transparent 1px) 0 0 / 24px 100%, #fafbfc;
}
.dot { position: absolute; width: 14px; height: 14px; border-radius: 50%; transform: translate(-50%,-50%); pointer-events: none; }
.dot.l { background: rgba(22,119,255,.55); } .dot.m { background: rgba(245,158,11,.6); } .dot.r { background: rgba(239,68,68,.55); }
.readout { position: absolute; left: 10px; top: 10px; background: rgba(15,23,42,.82); color: #a5f3fc;
  font-family: Consolas, monospace; font-size: 12px; padding: 8px 10px; border-radius: 8px; pointer-events: none; }

/* ---------- 摄像头舞台 ---------- */
.stage { position: relative; background: #0f172a; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9;
  display: flex; align-items: center; justify-content: center; }
.stage video { width: 100%; height: 100%; object-fit: contain; transition: transform .15s ease; }
.stage .ph { color: #64748b; font-size: 14px; padding: 20px; text-align: center; }
.overlay { position: absolute; left: 10px; top: 10px; background: rgba(15,23,42,.82); color: #a5f3fc;
  font-family: Consolas, monospace; font-size: 12px; padding: 8px 10px; border-radius: 8px; }

/* ---------- 摄像头设置导航菜单 ---------- */
.cam-nav { display: flex; flex-wrap: wrap; gap: 14px 22px; margin-bottom: 18px;
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.cam-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cam-group-label { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .3px; }
.cam-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.cam-tab {
  display: inline-flex; align-items: center; gap: 7px; font-family: inherit; font-size: 13.5px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); padding: 9px 14px; border-radius: 10px;
  transition: .15s; line-height: 1; white-space: nowrap;
}
.cam-tab svg { width: 17px; height: 17px; flex: 0 0 auto; }
.cam-tab:hover { border-color: var(--brand-2); color: var(--brand); transform: translateY(-1px); }
.cam-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 4px 12px rgba(22,119,255,.25); }
.cam-tab.active svg { stroke: #fff; }
.stage video.cam-mirror, .overlay.cam-mirror { transform: scaleX(-1); }
@media (max-width: 480px) {
  .cam-nav { gap: 12px; }
  .cam-tab { padding: 8px 11px; font-size: 13px; }
}

/* ---------- 手柄 ---------- */
.pad { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.box { background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.gbtns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.gb { aspect-ratio: 1; border-radius: 8px; background: #fff; border: 1px solid var(--line); display: flex; align-items: center;
  justify-content: center; font-size: 11px; color: var(--muted); }
.gb.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.stick { position: relative; width: 120px; height: 120px; border-radius: 50%; background: #e2e8f0; margin: 0 auto; }
.stick .knob { position: absolute; width: 42px; height: 42px; border-radius: 50%; background: var(--brand);
  left: 39px; top: 39px; transform: translate(-50%,-50%); transition: left .03s, top .03s; }
.axes { display: flex; gap: 18px; justify-content: center; margin-top: 10px; }
.axis-info { font-family: Consolas, monospace; font-size: 12px; text-align: center; color: var(--ink-2); }
.drift-ok { color: var(--ok); font-weight: 700; } .drift-bad { color: #b45309; font-weight: 700; }

/* ---------- 说明 / SEO 文案 ---------- */
.prose { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-top: 20px; }
.prose h2 { font-size: 18px; margin: 0 0 10px; }
.prose h3 { font-size: 15px; margin: 18px 0 6px; }
.prose p, .prose li { font-size: 14px; color: var(--ink-2); }
.prose ul { padding-left: 20px; margin: 6px 0; }
.prose li { margin: 4px 0; }
.notice { background: #eef4ff; border: 1px solid #cfe0ff; color: #1d4ed8; border-radius: 12px; padding: 12px 16px; font-size: 13px; margin-bottom: 18px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 10px; }

/* ---------- 页脚 ---------- */
.site-footer { border-top: 1px solid var(--line); background: #fff; margin-top: 30px; }
.site-footer .inner { max-width: var(--maxw); margin: 0 auto; padding: 26px 20px; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; }
.site-footer .copy { font-size: 13px; color: var(--muted); }
.site-footer .links a { font-size: 13px; color: var(--ink-2); margin-left: 16px; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .hero { padding: 32px 22px; border-radius: 16px; }
  .pad { grid-template-columns: 1fr; }
  .track { height: 300px; }
  .site-footer .inner { flex-direction: column; align-items: flex-start; }
  .site-footer .links a { margin: 0 16px 0 0; }
}
@media (max-width: 480px) {
  .container { padding: 0 14px; }
  .tool-panel { padding: 14px; }
}

/* ---------- 摄像头操作按钮置顶（吸顶） ---------- */
.btns--top { margin: 0 0 18px; position: sticky; top: 68px; z-index: 20; background: var(--card); padding: 10px 0; box-shadow: 0 6px 14px rgba(15,23,42,.06); }
.btns--top .primary { font-size: 15px; padding: 11px 20px; }
@media (max-width: 560px) {
  .btns--top { position: static; padding: 0; margin: 0 0 14px; box-shadow: none; }
  .btns--top .primary { font-size: 14px; padding: 10px 16px; }
}


/* ---------- 测试工具导航菜单 ---------- */
.tools-nav { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 4px; }
.tn-item { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); border-radius: 999px; font-size: 13.5px; text-decoration: none; transition: .15s; white-space: nowrap; }
.tn-item svg { width: 16px; height: 16px; flex: 0 0 auto; }
.tn-item:hover { border-color: var(--brand-2); color: var(--brand); transform: translateY(-1px); }
.tn-item.active { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 4px 12px rgba(22,119,255,.25); }
.tn-item.active svg { stroke: #fff; }
@media (max-width: 560px) {
  .tools-nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; margin: 12px 0 2px; scrollbar-width: none; }
  .tools-nav::-webkit-scrollbar { display: none; }
  .tn-item { flex: 0 0 auto; }
}
