/* 主题：默认深色；html[data-theme="light"] 切浅色 */
:root {
  --bg: #0e1217;
  --panel: #161b22;
  --surface: #11161c;
  --surface2: #1a212a;
  --hover: #202934;
  --chip: #1b2b3a;
  --chip-line: #2b4256;
  --step: #2a2440;
  --step-ink: #b0a0e8;
  --step-line: #3d3560;
  --faint: #3a4553;
  --scroll: #333d4a;
  --stage: #0b0f14;
  --line: #252d38;
  --line2: #1e252e;
  --ink: #e7edf5;
  --ink2: #a3b0c0;
  --ink3: #6c7889;
  --acc: #4f9ed8;
  --acc-d: #3d86bd;
  --warn: #d9a93c;
  --err: #e0685a;
  --ok: #4ab984;
  --shadow: 0 10px 34px rgba(0,0,0,.55);
  --fig-shell: #24303d;
  --fig-shell-s: #3e5164;
  --fig-cav: #0d1218;
  --fig-cav-s: #4a657d;
  --fig-jaw: #8ba3bb;
  --fig-dim: #e2703f;
  --fig-ink: #dfe7f0;
  --fig-ink2: #93a2b4;
}

html[data-theme="light"] {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --surface: #ffffff;
  --surface2: #fafbfd;
  --hover: #f5f9fd;
  --chip: #eaf2f8;
  --chip-line: #dbe7f2;
  --step: #f2f0fb;
  --step-ink: #5b4ba8;
  --step-line: #e0dcf5;
  --faint: #c0c9d6;
  --scroll: #cfd8e3;
  --stage: #ffffff;
  --line: #e2e8f0;
  --line2: #eef2f7;
  --ink: #1f2937;
  --ink2: #5b6878;
  --ink3: #93a1b2;
  --acc: #2f6f9e;
  --acc-d: #245a80;
  --warn: #b8860b;
  --err: #c0392b;
  --ok: #2f8f5b;
  --shadow: 0 10px 34px rgba(31,41,55,.18);
  --fig-shell: #dbe6f4;
  --fig-shell-s: #a8bdd6;
  --fig-cav: #ffffff;
  --fig-cav-s: #7f9ab8;
  --fig-jaw: #37475c;
  --fig-dim: #d9592b;
  --fig-ink: #1f2937;
  --fig-ink2: #5b6878;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  font: 13px/1.45 "Microsoft YaHei", "PingFang SC", "Segoe UI", "Hiragino Sans",
        "Yu Gothic UI", "Malgun Gothic", "Noto Sans", "Noto Sans Arabic", system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- header */
header {
  flex: 0 0 54px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.brand b { font-size: 14.5px; letter-spacing: .2px; }
.brand .sub { display: block; font-size: 11px; color: var(--ink3); margin-top: 1px; }

.tabs { display: flex; gap: 2px; margin-left: 8px; background: var(--line2); padding: 3px; border-radius: 7px; }
.tabs button {
  border: 0; background: transparent; padding: 5px 13px; border-radius: 5px;
  font: inherit; font-size: 12.5px; color: var(--ink2); cursor: pointer;
}
.tabs button:hover { color: var(--acc); }
.tabs button.on { background: var(--panel); color: var(--acc); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.acts { margin-left: auto; display: flex; align-items: center; gap: 8px; }
select, input, button { font: inherit; }
select {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 6px 8px; border-radius: 6px; height: 30px; max-width: 190px;
}
header button {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink2);
  padding: 6px 12px; border-radius: 6px; height: 30px; cursor: pointer;
}
header button:hover { border-color: var(--acc); color: var(--acc); }
header button.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
header button.primary:hover { background: var(--acc-d); }

/* ---------------------------------------------------------------- layout */
main { flex: 1 1 auto; display: flex; min-height: 0; min-width: 0; overflow: hidden; }

aside { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; min-height: 0; flex: 0 0 316px; }
#holes { border-right: 0; border-left: 1px solid var(--line); flex: 0 0 336px; }

aside::-webkit-scrollbar { width: 9px; }
aside::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 5px; }
aside::-webkit-scrollbar-track { background: transparent; }

.ph {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px; font-size: 12px; font-weight: 700; color: var(--ink2);
  background: var(--surface2); border-bottom: 1px solid var(--line);
  letter-spacing: .3px;
}
.ph small { font-weight: 400; color: var(--ink3); }
.ph2 { padding: 9px 13px; font-size: 11px; color: var(--ink3); line-height: 1.6; }

/* ---------------------------------------------------------------- groups */
details.grp { border-bottom: 1px solid var(--line2); }
details.grp > summary {
  list-style: none; cursor: pointer;
  padding: 9px 13px; font-size: 12.5px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; gap: 7px;
  user-select: none;
}
details.grp > summary::-webkit-details-marker { display: none; }
details.grp > summary::before {
  content: "▸"; color: var(--ink3); font-size: 10px; transition: transform .15s;
}
details.grp[open] > summary::before { transform: rotate(90deg); }
details.grp > summary:hover { background: var(--surface2); }
details.grp .ico { color: var(--acc); font-size: 12px; }

.row {
  display: grid; grid-template-columns: 1fr 84px;
  align-items: center; gap: 8px;
  padding: 4px 13px 4px 26px;
}
.row label { font-size: 12px; color: var(--ink2); }
.row input[type=number] {
  width: 100%; height: 26px; padding: 2px 6px; text-align: right;
  border: 1px solid var(--line); border-radius: 5px; background: var(--surface);
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.row input[type=number]:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 2px rgba(47,111,158,.12); }
.row select { width: 100%; height: 26px; padding: 1px 4px; font-size: 12px; }
.row .hint { grid-column: 1 / -1; font-size: 10.5px; color: var(--ink3); margin: -2px 0 3px; line-height: 1.45; }
.row.chk { grid-template-columns: 1fr 26px; }
.row.chk input { width: 15px; height: 15px; accent-color: var(--acc); }

/* ---------------------------------------------------------------- stage */
#stage { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; background: var(--surface); overflow: hidden; }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; }

#hud {
  position: absolute; left: 14px; top: 12px;
  font-size: 11.5px; color: var(--ink3); line-height: 1.7;
  pointer-events: none;
}
#hud b { color: var(--ink2); font-weight: 600; }
#hud .big { font-size: 15px; color: var(--ink); font-weight: 600; }

#hint {
  position: absolute; right: 14px; bottom: 10px;
  font-size: 11px; color: var(--faint); user-select: none;
}

/* ---------------------------------------------------------------- holes */
.hcard {
  margin: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); overflow: hidden;
}
.hcard.muted { opacity: .55; }
.hhead {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 9px; background: var(--surface2); border-bottom: 1px solid var(--line2);
  cursor: pointer; user-select: none;
}
.hhead .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--acc); flex: 0 0 auto; }
.hhead input.nm {
  flex: 1; min-width: 0; border: 0; background: transparent; font-weight: 600;
  font-size: 12.5px; color: var(--ink); padding: 2px 0;
}
.hhead input.nm:focus { outline: none; border-bottom: 1px solid var(--acc); }
.hhead .face { font-size: 10.5px; color: var(--acc); background: var(--chip); padding: 1px 6px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.hhead .del {
  border: 0; background: transparent; color: var(--faint); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 2px;
}
.hhead .del:hover { color: var(--err); }

.hbody { padding: 6px 9px 9px; display: none; }
.hcard.open .hbody { display: block; }

.hgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; }
.hgrid .f { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 4px; }
.hgrid .f.full { grid-column: 1 / -1; }
.hgrid .f label { font-size: 11px; color: var(--ink3); }
.hgrid input, .hgrid select {
  width: 100%; height: 25px; padding: 1px 5px; font-size: 12px;
  border: 1px solid var(--line); border-radius: 5px; background: var(--surface);
}
.hgrid input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }
.hgrid input:focus, .hgrid select:focus { outline: none; border-color: var(--acc); }

.mini {
  border: 1px solid var(--line); background: var(--surface); color: var(--acc);
  font-size: 11.5px; padding: 3px 9px; border-radius: 5px; cursor: pointer;
}
.mini:hover { border-color: var(--acc); background: var(--hover); }

/* ---------------------------------------------------------------- footer */
footer {
  flex: 0 0 30px; display: flex; align-items: center; gap: 16px;
  padding: 0 14px; font-size: 11.5px; color: var(--ink2);
  background: var(--panel); border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
footer .sep { color: var(--faint); }
footer .err { color: var(--err); font-weight: 600; }
footer .good { color: var(--ok); }
footer .warn { color: var(--warn); }
footer #msg { margin-left: auto; color: var(--ink3); }

/* ---------------------------------------------------------------- 导出面板 */
#dl {
  position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%);
  width: 430px; max-width: calc(100vw - 40px);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 10px 34px var(--shadow);
  z-index: 40; overflow: hidden;
}
#dl.hidden { display: none; }
.dl-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-bottom: 1px solid var(--line2);
  font-size: 12.5px; color: var(--ink);
}
#dl-list { padding: 6px 8px 8px; max-height: 264px; overflow: auto; }
.dl-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px; border-radius: 6px; font-size: 12px;
}
.dl-row:hover { background: var(--hover); }
.dl-row .tag {
  flex: 0 0 auto; font-size: 10.5px; padding: 1px 6px; border-radius: 4px;
  background: var(--chip); color: var(--acc); border: 1px solid var(--chip-line);
  text-transform: uppercase; letter-spacing: .3px;
}
.dl-row .tag.step { background: var(--step); color: var(--step-ink); border-color: var(--step-line); }
.dl-row a {
  flex: 1 1 auto; color: var(--acc); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dl-row a:hover { text-decoration: underline; }
.dl-row .sz { flex: 0 0 auto; color: var(--ink3); font-size: 11px; font-variant-numeric: tabular-nums; }
.dl-f {
  padding: 7px 12px 9px; border-top: 1px solid var(--line2);
  font-size: 11px; color: var(--ink3); word-break: break-all;
}
/* 打包下载按钮 */
.dl-f .zip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 7px;
  background: var(--acc); border: 1px solid var(--acc); color: #fff;
  font-size: 12px; font-weight: 600; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dl-f .zip::before { content: "⤓"; font-size: 13px; font-weight: 400; }
.dl-f .zip:hover { background: var(--acc-d); border-color: var(--acc-d); }

/* ---------------------------------------------------------------- API 入口 */
header a.lnk {
  display: inline-flex; align-items: center; height: 30px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink2); text-decoration: none; font-size: 12.5px;
}
header a.lnk:hover { border-color: var(--acc); color: var(--acc); }

/* ================================================================ 主题切换 */
#btn-theme {
  width: 32px; height: 30px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
}

/* ================================================================ 页脚友链 */
footer { gap: 12px; }
#status {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 16px;
  overflow: hidden;
}
.flinks {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding-left: 12px; border-left: 1px solid var(--line2);
  font-size: 11px; color: var(--ink3); white-space: nowrap;
}
.flinks span { color: var(--ink3); }
.flinks a { color: var(--ink3); text-decoration: none; }
.flinks a:hover { color: var(--acc); }

/* ================================================================ 使用指引 */
.gmask {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  background: rgba(3, 6, 10, .86);
  padding: 20px;
}
.gmask.on { display: flex; }
html[data-theme="light"] .gmask { background: rgba(24, 34, 46, .55); }

.gbox {
  width: min(980px, 100%); max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
  animation: gIn .26s cubic-bezier(.2,.9,.3,1) both;
}
@keyframes gIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

.ghd {
  flex: 0 0 auto; display: flex; align-items: center; gap: 18px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface2);
}
.ghd .gt b { font-size: 14.5px; letter-spacing: .2px; }
.ghd .gt i { display: block; font-style: normal; font-size: 11.5px; color: var(--ink3); margin-top: 2px; }
.gprog { margin-left: auto; display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink3); }
.gprog em { width: 18px; height: 1px; background: var(--line); }
.gprog span.done { color: var(--ok); }
.gprog span.on { color: var(--acc); font-weight: 700; }
.gx {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink2);
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer; font-size: 13px;
}
.gx:hover { border-color: var(--err); color: var(--err); }

.gbody { flex: 1 1 auto; overflow-y: auto; padding: 18px 18px 6px; }
.gbody::-webkit-scrollbar { width: 9px; }
.gbody::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 5px; }

.ghead h3 { margin: 0 0 5px; font-size: 16px; letter-spacing: .2px; }
.ghead p { margin: 0 0 16px; font-size: 12.5px; color: var(--ink2); line-height: 1.65; }

.gft {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--line);
  background: var(--surface2);
}
.gft button {
  height: 32px; padding: 0 16px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink2); font-size: 12.5px;
}
.gft button:hover { border-color: var(--acc); color: var(--acc); }
.gft button.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.gft button.primary:hover { background: var(--acc-d); }
.gdots { display: flex; gap: 6px; margin: 0 auto; }
.gdots i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); cursor: pointer; }
.gdots i.on { background: var(--acc); width: 18px; border-radius: 4px; }

/* ---------- 第一步：三张测量图 ---------- */
.gmeasure { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gcard {
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.gcard.live { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(79, 158, 216, .16); }
.gfig { display: block; width: 100%; height: auto; }
.gfig text { fill: var(--fig-ink); }
.gfig .lbl .big { font-size: 14px; font-weight: 700; }
.gfig .lbl .small { font-size: 10.5px; fill: var(--fig-ink2); }
.gcap { padding: 9px 11px 11px; border-top: 1px solid var(--line2); }
.gcap b { display: block; font-size: 12.5px; margin-bottom: 3px; }
.gcap span { font-size: 11.5px; color: var(--ink3); line-height: 1.55; }

.gfig .dim { stroke-dasharray: 400; stroke-dashoffset: 0; }
.gfig .readout, .gfig .probe { transform-box: fill-box; transform-origin: center; }

.gcard.live .f1 .jl { animation: gJawL 1.5s cubic-bezier(.22,.9,.28,1) both; }
.gcard.live .f1 .jr { animation: gJawR 1.5s cubic-bezier(.22,.9,.28,1) both; }
.gcard.live .f2 .jt { animation: gJawT 1.5s cubic-bezier(.22,.9,.28,1) both; }
.gcard.live .f2 .jb { animation: gJawB 1.5s cubic-bezier(.22,.9,.28,1) both; }
.gcard.live .f3 .probe { animation: gDrop 1.5s cubic-bezier(.22,.9,.28,1) both; }
.gcard.live .dim { animation: gDraw 1.1s ease-out .95s both; }
.gcard.live .readout { animation: gPop .5s ease-out 1.45s both; }

@keyframes gJawL { from { transform: translateX(103px); } to { transform: none; } }
@keyframes gJawR { from { transform: translateX(-103px); } to { transform: none; } }
@keyframes gJawT { from { transform: translateY(68px); } to { transform: none; } }
@keyframes gJawB { from { transform: translateY(-68px); } to { transform: none; } }
@keyframes gDrop { from { transform: translateY(-62px); } to { transform: none; } }
@keyframes gDraw { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }
@keyframes gPop { from { opacity: 0; } to { opacity: 1; } }

.gtips {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--line2);
  font-size: 12px; color: var(--ink2); line-height: 1.7;
}
.gtips b { color: var(--ink); }
.gtips ul { margin: 6px 0 0; padding-left: 18px; }
.gtips li { margin: 3px 0; }
.gtips li b { color: var(--acc); }

.gplaybar { display: flex; align-items: center; gap: 12px; margin: 14px 0 12px; }
.g-play {
  height: 34px; padding: 0 18px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--acc); background: var(--acc); color: #fff; font-size: 13px;
}
.g-play:hover { background: var(--acc-d); }
.g-ghost {
  height: 34px; padding: 0 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink2); font-size: 12.5px;
}
.g-ghost:hover { border-color: var(--acc); color: var(--acc); }
.g-playhint { font-size: 11.5px; color: var(--ink3); }

/* ---------- 第二步 ---------- */
.gfill { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.gmock {
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface2);
  overflow: hidden; font-size: 12px;
}
.gmock-h {
  padding: 7px 11px; font-weight: 700; color: var(--ink2);
  border-bottom: 1px solid var(--line2); display: flex; align-items: center; gap: 6px;
}
.gmock-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 11px 4px 22px; color: var(--ink2);
}
.gmock-row b {
  font-weight: 500; min-width: 62px; text-align: right;
  padding: 2px 7px; border-radius: 5px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.gmock-row.hot b { border-color: var(--acc); color: var(--acc); }
.gmock-row.dim { opacity: .55; }
.gmock-f {
  padding: 7px 11px; font-size: 11px; color: var(--ink3);
  border-top: 1px solid var(--line2);
}
.gnote p { margin: 0 0 8px; font-size: 12.5px; color: var(--ink2); line-height: 1.7; }
.gnote p b { color: var(--ink); }
.gnote p.muted { color: var(--ink3); font-size: 11.5px; }

/* ---------- 第三步 ---------- */
.gflow { display: flex; align-items: stretch; gap: 6px; margin-bottom: 14px; }
.gstep {
  flex: 1 1 0; min-width: 0; padding: 10px 11px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
}
.gstep i { font-style: normal; color: var(--acc); font-size: 12px; font-weight: 700; }
.gstep b { display: block; font-size: 12.5px; margin: 3px 0 2px; }
.gstep span { font-size: 11px; color: var(--ink3); }
.garw { flex: 0 0 auto; align-self: center; color: var(--faint); font-style: normal; font-size: 14px; }

.gtable { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; font-size: 12px; }
.gtr { display: grid; grid-template-columns: 86px 96px 1fr; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line2); }
.gtr:last-child { border-bottom: 0; }
.gtr span { color: var(--ink2); }
.gtr span:first-child { color: var(--ink3); }
.gtr span:nth-child(2) { color: var(--ink); font-weight: 600; }
.gtr.gh { background: var(--surface2); font-size: 11.5px; }
.gtr.gh span { color: var(--ink3) !important; font-weight: 400; }

.gwarn {
  margin-top: 12px; padding: 10px 13px; border-radius: 9px;
  background: var(--surface2); border: 1px solid var(--warn);
  font-size: 12px; color: var(--ink2); line-height: 1.65;
}
.gwarn b { color: var(--warn); }

/* ---------- 参数高亮 ---------- */
.row.g-flash {
  animation: gFlash 1.2s ease-in-out 3;
  border-radius: 6px;
}
@keyframes gFlash {
  0%, 100% { background: transparent; }
  45% { background: var(--chip); box-shadow: inset 0 0 0 1px var(--acc); }
}

@media (max-width: 880px) {
  .gmeasure { grid-template-columns: 1fr; }
  .gfill { grid-template-columns: 1fr; }
  .gflow { flex-wrap: wrap; }
  .garw { display: none; }
  .gstep { flex: 1 1 44%; }
  .ghd { flex-wrap: wrap; }
  .gprog { margin-left: 0; width: 100%; }
}

/* 使用指引入口按钮 */
header button.guide-btn {
  border-color: var(--acc); color: var(--acc); font-weight: 600;
}
header button.guide-btn:hover { background: var(--chip); }

/* 示意图文字取色（用 class 避免被 .gfig text 覆盖） */
.gfig .rd { fill: var(--fig-dim); }
.gfig .cap2 { fill: var(--fig-ink2); }

/* 指引打开时先隐藏 3D 视图：避免 WebGL 画布在某些合成器下盖住遮罩 */
#stage { transition: opacity .18s ease; }
html.g-lock #stage { opacity: 0; }
.gmask { z-index: 9999; }

/* ---------------------------------------------------------------- 窄屏压缩 header */
.acts { gap: 6px; }
@media (max-width: 1560px) {
  .brand .sub { display: none; }
  header { gap: 12px; }
  header button, header a.lnk { padding: 6px 9px; font-size: 12px; }
  .acts select { max-width: 132px; }
  .tabs button { padding: 5px 10px; }
}
@media (max-width: 1240px) {
  .brand b { font-size: 13px; }
  #btn-import, #btn-export-cfg { display: none; }
}

/* ---------------------------------------------------------------- 微信交流群 */
header button.wx {
  display: inline-flex; align-items: center; gap: 5px;
  border-color: var(--ok); color: var(--ok);
}
header button.wx::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(47, 143, 91, .18);
}
header button.wx:hover { background: var(--chip); }
header button.wx b { font-weight: 700; letter-spacing: .2px; }
header button.wx .wxnote {
  color: var(--ink3); font-size: 11px; margin-left: 1px;
}

/* 复制反馈 */
#status-tip {
  position: fixed; left: 50%; bottom: 52px; transform: translate(-50%, 8px);
  padding: 8px 16px; border-radius: 8px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--ok); box-shadow: 0 8px 26px var(--shadow);
  font-size: 12.5px; white-space: nowrap; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
#status-tip.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1240px) {
  header button.wx .wxnote { display: none; }
}
@media (max-width: 900px) {
  header button.wx b { display: none; }
}

/* ---------------------------------------------------------------- 拆解视图 */
#expbar {
  position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--line);
  box-shadow: 0 8px 24px var(--shadow);
  font-size: 11.5px; color: var(--ink2); z-index: 6;
}
#expbar.hidden { display: none; }
#expbar input[type="range"] {
  width: 156px; height: 3px; accent-color: var(--acc); cursor: pointer;
}
#expbar b {
  color: var(--acc); font-weight: 700; min-width: 24px; text-align: right;
  font-variant-numeric: tabular-nums;
}
#expbar .u { color: var(--ink3); font-size: 10.5px; margin-left: -5px; }
#expbar .mini {
  border: 1px solid var(--acc); color: var(--acc); background: var(--panel);
  border-radius: 6px; padding: 2px 8px; font-size: 11px; cursor: pointer;
}
#expbar .mini:hover { background: var(--chip); }

/* ---------------------------------------------------------------- 设计风格 */
.styles {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 9px 10px 8px; border-bottom: 1px solid var(--line2);
  background: var(--surface2);
}
.styles .st {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink2);
  border-radius: 6px; padding: 4px 9px; font-size: 11.5px; cursor: pointer;
  white-space: nowrap; transition: all .15s;
}
.styles .st:hover { border-color: var(--acc); color: var(--acc); }
.styles .st.on {
  background: var(--acc); border-color: var(--acc); color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(79, 158, 216, .3);
}
.style-hint {
  padding: 6px 12px 7px; font-size: 11px; line-height: 1.5;
  color: var(--ink3); border-bottom: 1px solid var(--line2);
  background: var(--surface2);
}

/* ---------------------------------------------------------------- 工作台导览 */
.gregions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 12px; }
.gri {
  display: flex; gap: 9px; align-items: flex-start; cursor: pointer;
  padding: 8px 10px; border: 1px solid var(--line2); border-radius: 8px;
  background: var(--surface); transition: border-color .15s, background .15s;
}
.gri:hover { border-color: var(--acc); background: var(--chip); }
.gri i {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%;
  background: var(--acc); color: #fff; font-style: normal; font-size: 11px;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.gri b { display: block; font-size: 12.5px; margin-bottom: 2px; color: var(--ink); }
.gri span { font-size: 11px; color: var(--ink3); line-height: 1.5; }

/* 聚光灯 */
.gtour { position: fixed; inset: 0; z-index: 9998; pointer-events: none; }
.gt-box {
  position: fixed; border: 2px solid var(--acc); border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(4, 8, 14, .55);
  transition: all .26s cubic-bezier(.2, .9, .3, 1);
}
html[data-theme="light"] .gt-box { box-shadow: 0 0 0 9999px rgba(20, 30, 42, .38); }
.gt-tip {
  position: fixed; pointer-events: auto; padding: 12px 14px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 40px var(--shadow); color: var(--ink);
}
.gt-n {
  font-size: 10.5px; color: var(--acc); font-weight: 700;
  letter-spacing: .5px; margin-bottom: 3px;
}
.gt-tip b { font-size: 13.5px; display: block; margin-bottom: 4px; }
.gt-tip p { margin: 0 0 9px; font-size: 12px; color: var(--ink2); line-height: 1.65; }
.gt-act { display: flex; gap: 8px; justify-content: flex-end; }
.gt-act button {
  height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer; font-size: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink2);
}
.gt-act button.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.gt-act button:hover { border-color: var(--acc); color: var(--acc); }
.gt-act button.primary:hover { background: var(--acc-d); color: #fff; }
@media (max-width: 760px) {
  .gregions { grid-template-columns: 1fr; }
}

/* ================================================================ 多语言 */
/* 语言下拉：紧跟在微信按钮后，比其它 select 窄一点 */
header select.langsel { max-width: 108px; min-width: 78px; padding: 6px 4px; }
@media (max-width: 1560px) { header select.langsel { max-width: 92px; } }

/* 作者落款挂在友链右边，用竖线分隔 */
.flinks .auth {
  padding-left: 10px; margin-left: 2px;
  border-left: 1px solid var(--line2);
  color: var(--ink3);
}

/* 非中日韩文字时，行高和字号略微调顺（阿拉伯语尤其需要） */
html[lang="ar"] body { font-size: 13.5px; line-height: 1.6; }
html[lang="ru"] .brand b, html[lang="de"] .brand b { font-size: 13.5px; letter-spacing: 0; }

/* RTL：面板、边框、推进方向整体镜像 */
html[dir="rtl"] aside { border-right: 0; border-left: 1px solid var(--line); }
html[dir="rtl"] #holes { border-left: 0; border-right: 1px solid var(--line); }
html[dir="rtl"] .acts { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .tabs { margin-left: 0; margin-right: 8px; }
html[dir="rtl"] footer #msg { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .flinks { padding-left: 0; padding-right: 12px; border-left: 0; border-right: 1px solid var(--line2); }
html[dir="rtl"] .flinks .auth { padding-left: 0; padding-right: 10px; margin-right: 2px; border-left: 0; border-right: 1px solid var(--line2); }
html[dir="rtl"] .garw { transform: scaleX(-1); }
html[dir="rtl"] #expbar { transform: translateX(50%); }

/* 多语言下的顶栏：英文/俄文/德文标签更长，禁止按钮内换行，品牌单行显示 */
header button, header a.lnk, header select { white-space: nowrap; }
header .brand { min-width: 0; flex: 0 1 auto; }
header .brand b { white-space: nowrap; display: block; overflow: hidden; text-overflow: ellipsis; }
header .tabs { flex: 0 0 auto; }
header .acts { flex: 0 1 auto; min-width: 0; }
@media (max-width: 1800px) {
  html:not([lang="zh"]) header button,
  html:not([lang="zh"]) header a.lnk { padding: 6px 8px; font-size: 12px; }
  html:not([lang="zh"]) header { gap: 10px; }
}

/* 长语言下再省一点横向空间：隐藏微信按钮里的 ID 和备注（tooltip 仍在） */
@media (max-width: 1800px) {
  html:not([lang="zh"]) header button.wx b,
  html:not([lang="zh"]) header button.wx .wxnote { display: none; }
}
header .brand .sub {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 阿拉伯语（RTL）：纯数字串（尺寸、范围、体积）不能被镜像重排 */
html[dir="rtl"] #hud .big { direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] #status, html[dir="rtl"] #msg { unicode-bidi: plaintext; }

/* 非中文在中等宽度下再多让一点位置给主按钮（导入/导出配置仍可通过宽屏使用） */
@media (max-width: 1480px) {
  html:not([lang="zh"]) #btn-import,
  html:not([lang="zh"]) #btn-export-cfg { display: none; }
}

/* ---------------------------------------------------------- 微信群二维码弹层 */
#wxqr {
  position: fixed; inset: 0; z-index: 60; padding: 20px;
  display: flex; align-items: center; justify-content: center;
}
#wxqr.hidden { display: none; }
.wxqr-bg {
  position: absolute; inset: 0; background: rgba(6, 9, 13, .62);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: wxfade .15s ease-out;
}
.wxqr-card {
  position: relative; width: 312px; max-width: 100%;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
  animation: wxpop .18s ease-out;
}
.wxqr-h {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line2);
  font-size: 12.5px; color: var(--ink);
}
/* 码面必须有白底，暗色主题下也一样 */
#wxqr-img { display: block; width: 100%; height: auto; background: #fff; }
.wxqr-f {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 9px 12px 11px;
}
.wxqr-f .qtip { font-size: 11.5px; color: var(--ink2); }
.wxqr-f .qnote { font-size: 10.5px; color: var(--ink3); }
#wxqr-copy {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 10px; border-radius: 6px; cursor: pointer;
  background: var(--chip); border: 1px solid var(--chip-line); color: var(--ink2);
  font-size: 11.5px;
}
#wxqr-copy:hover { border-color: var(--acc); color: var(--ink); }
#wxqr-copy .w {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  color: var(--acc); font-weight: 600; letter-spacing: .2px;
}
#wxqr-copy i { font-style: normal; font-size: 10.5px; color: var(--ink3); }
#wxqr-copy:hover i { color: var(--acc); }
body.modal-on { overflow: hidden; }
@keyframes wxfade { from { opacity: 0 } to { opacity: 1 } }
@keyframes wxpop {
  from { opacity: 0; transform: translateY(-6px) scale(.97) }
  to   { opacity: 1; transform: none }
}

/* 手机竖屏：卡片吃满可用宽度，码面尽量大，方便「长按识别」 */
@media (max-width: 460px) {
  #wxqr { padding: 12px; }
  .wxqr-card { width: 100%; }
  .wxqr-f .qtip { font-size: 12px; }
}
