:root {
  --bg: #f4f5f7; --card: #ffffff; --ink: #1d2330; --muted: #5b6475; --line: #dfe3ea; --hover: #eef1f6;
  --accent: #1f6fe0; --radius: 12px;
  --c-viewport: #eef0f3; --c-grid: #c9ced8; --c-body: #b7bec8;
  --c-input: #1f6fe0; --c-cons: #e07a12; --c-result: #2e9d57; --c-bad: #e5484d; --c-warn: #e8b52e;
  --sk-line: #2a303b; --sk-ghost: #9aa3b4; --sk-dim: #5b6475; --sk-grid: rgba(40, 50, 70, .07);
  --c-proj: #8e4ec6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181e; --card: #1d2129; --ink: #e8ebf1; --muted: #9aa3b4; --line: #2c323d; --hover: #252a34;
    --accent: #4f93ff;
    --c-viewport: #262b35; --c-grid: #3a414e; --c-body: #9aa2ad;
    --c-input: #4f93ff; --c-cons: #ff9a3c; --c-result: #3cc46a; --c-bad: #ff6369; --c-warn: #f0c445;
    --sk-line: #e8ebf1; --sk-ghost: #6b7385; --sk-dim: #9aa3b4; --sk-grid: rgba(255, 255, 255, .06);
    --c-proj: #b47cf0;
  }
}
:root[data-theme="dark"] {
  --bg: #15181e; --card: #1d2129; --ink: #e8ebf1; --muted: #9aa3b4; --line: #2c323d; --hover: #252a34;
  --accent: #4f93ff;
  --c-viewport: #262b35; --c-grid: #3a414e; --c-body: #9aa2ad;
  --c-input: #4f93ff; --c-cons: #ff9a3c; --c-result: #3cc46a; --c-bad: #ff6369; --c-warn: #f0c445;
  --sk-line: #e8ebf1; --sk-ghost: #6b7385; --sk-dim: #9aa3b4; --sk-grid: rgba(255, 255, 255, .06);
  --c-proj: #b47cf0;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 150px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 12px 16px 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.brand { flex: 1 1 260px; min-width: 0; }
.brand h1 { font-size: 21px; margin: 0; line-height: 1.25; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: none; padding: 0 14px; min-height: 40px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; min-width: 40px; min-height: 40px; cursor: pointer; }
.search { flex: 1 1 320px; position: relative; }
.search input { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 0 14px 0 38px; font-size: 16px; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search svg { position: absolute; left: 12px; top: 12px; width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }
.jump { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.jump::-webkit-scrollbar { display: none; }
.jump a { white-space: nowrap; text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-size: 14px; display: inline-flex; align-items: center; }
/* Touch: every control at least 44 px (uiux-control-sizes: on a coarse pointer only). */
@media (any-pointer: coarse) { .jump a, .seg button, .search input { min-height: 44px; } .icon-btn { min-width: 44px; min-height: 44px; } }
.jump a:hover { background: var(--hover); }
.jump .ws { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; align-self: center; padding: 0 2px 0 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 16px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; background: var(--c); }
.legend .dash::before { background: repeating-linear-gradient(90deg, var(--c) 0 5px, transparent 5px 9px); }

main { max-width: 1240px; margin: 0 auto; padding: 18px 16px 64px; }
section { margin-bottom: 30px; }
h2 { font-size: 19px; margin: 6px 0 12px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
h2 small { color: var(--muted); font-weight: 500; font-size: 15px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; text-align: left; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pic { aspect-ratio: 16 / 10; background: var(--c-viewport); position: relative; }
.pic canvas, .pic svg { display: block; width: 100%; height: 100%; }
.pic.sketch { background-color: var(--c-viewport); background-image: linear-gradient(var(--sk-grid) 1px, transparent 1px), linear-gradient(90deg, var(--sk-grid) 1px, transparent 1px); background-size: 20px 20px; }
.txt { padding: 12px 14px 14px; display: grid; gap: 6px; }
.txt h3 { margin: 0; font-size: 17px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.txt h3 .alt { color: var(--muted); font-weight: 500; font-size: 15px; }
kbd { font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 3px 6px; color: var(--muted); background: var(--bg); }
.txt p { margin: 0; font-size: 15px; }
.txt .use { color: var(--muted); }
.txt .use b { color: var(--ink); font-weight: 600; }
.bi { display: grid; gap: 2px; }
.bi .zh { color: var(--muted); }
mark { background: color-mix(in srgb, var(--c-warn) 45%, transparent); color: inherit; border-radius: 3px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

dialog { border: 0; padding: 0; border-radius: 16px; width: min(1000px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); background: var(--card); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(10, 12, 18, .55); }
.vw { display: grid; grid-template-columns: 1.5fr 1fr; min-height: 0; }
.vw .stage { position: relative; background: var(--c-viewport); aspect-ratio: 16 / 11; }
.vw .stage canvas, .vw .stage svg { display: block; width: 100%; height: 100%; touch-action: none; }
.vw .stage canvas { cursor: grab; }
.vw .stage.sketch { background-image: linear-gradient(var(--sk-grid) 1px, transparent 1px), linear-gradient(90deg, var(--sk-grid) 1px, transparent 1px); background-size: 24px 24px; }
.vw .hint { position: absolute; left: 12px; bottom: 10px; font-size: 13px; color: var(--muted); pointer-events: none; }
.vw .side { padding: 20px 22px; display: grid; gap: 10px; align-content: start; overflow-y: auto; }
.vw .side h3 { margin: 0; font-size: 22px; }
.vw .side .crumb { color: var(--muted); font-size: 13px; letter-spacing: .04em; }
dialog .close { position: absolute; top: 10px; right: 10px; z-index: 3; }
.vw .side { padding-top: 52px; }
.vw .spin { position: absolute; right: 12px; bottom: 10px; z-index: 2; padding: 0 12px; font-size: 14px; }
.pic .nogl { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; padding: 12px; text-align: center; }
@media (max-width: 760px) { .vw { grid-template-columns: 1fr; } .brand h1 { font-size: 18px; } .top { position: static; } html { scroll-padding-top: 0; } .grid { grid-template-columns: minmax(0, 1fr); } }

/* 2D pictures */
.sk, .sel, .new, .con, .gh, .proj, .fixd, .dim, .dimx { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.sk { stroke: var(--sk-line); stroke-width: 2.2; }
.fixd { stroke: var(--sk-line); stroke-width: 3; }
.sel { stroke: var(--c-input); stroke-width: 3.2; }
.new { stroke: var(--c-result); stroke-width: 3.2; }
.newf { fill: var(--c-result); }
.con { stroke: var(--c-cons); stroke-width: 1.6; stroke-dasharray: 6 5; }
.gh { stroke: var(--sk-ghost); stroke-width: 2; stroke-dasharray: 4 4; }
.proj { stroke: var(--c-proj); stroke-width: 3; }
.face { fill: var(--c-body); opacity: .35; }
.dim { stroke: var(--sk-dim); stroke-width: 1.2; }
.dimx { stroke: var(--sk-dim); stroke-width: 1; }
.dimt, .lbl { fill: var(--sk-dim); font: 600 13px system-ui, sans-serif; }
.skt { fill: var(--sk-line); font: 700 34px system-ui, sans-serif; }
.ahf { fill: var(--sk-dim); } .ahc { fill: var(--c-cons); }
.pt { fill: var(--sk-line); } .ptS { fill: var(--c-input); } .ptN { fill: var(--c-result); }
.ctrl { fill: var(--card); stroke: var(--c-cons); stroke-width: 1.5; }
.num circle { fill: var(--c-input); } .num text { fill: #fff; font: 700 11px system-ui, sans-serif; text-anchor: middle; }
.badge rect { fill: var(--card); stroke: var(--c-result); stroke-width: 1.5; } .badge text { fill: var(--c-result); font: 700 13px system-ui, sans-serif; text-anchor: middle; }
.next { fill: var(--sk-ghost); opacity: .7; }
.cursor { fill: var(--card); stroke: var(--sk-line); stroke-width: 1.2; }
.lock rect, .lock path { fill: none; stroke: var(--c-bad); stroke-width: 2.2; }
.bad { stroke: var(--c-bad); stroke-width: 3; stroke-linecap: round; }
.tl { fill: var(--card); stroke: var(--sk-dim); stroke-width: 1.3; } .tlN { stroke: var(--c-result); stroke-width: 2.4; }
.tli { fill: none; stroke: var(--sk-line); stroke-width: 1.6; stroke-linejoin: round; }
.tlbar { stroke: var(--sk-ghost); stroke-width: 2; }
.pt3 path { fill: color-mix(in srgb, var(--c-body) 60%, transparent); stroke: var(--sk-line); stroke-width: 1.6; stroke-linejoin: round; }
.pt3N path { fill: color-mix(in srgb, var(--c-result) 35%, transparent); stroke: var(--c-result); }
.pt3gh path { fill: none; stroke: var(--sk-ghost); stroke-dasharray: 4 3; }
.doc { fill: var(--card); stroke: var(--sk-dim); stroke-width: 1.4; }
.link rect { fill: none; stroke: var(--c-input); stroke-width: 2.4; }
.tbl { fill: var(--card); stroke: var(--line); } .tblln { stroke: var(--line); } .tblhi { fill: color-mix(in srgb, var(--c-result) 16%, transparent); }
.th { fill: var(--muted); font: 700 12px system-ui, sans-serif; } .td { fill: var(--ink); font: 500 13px system-ui, sans-serif; } .tdb { font-weight: 700; }
.nav { fill: var(--card); stroke: var(--sk-dim); stroke-width: 1.3; } .navhi { stroke: var(--c-input); stroke-width: 2.4; }
.navln { fill: none; stroke: var(--sk-ghost); stroke-width: 1.6; }
.dot { fill: var(--card); stroke: var(--sk-dim); stroke-width: 2; } .dotN { fill: var(--c-input); }
.leaf { fill: color-mix(in srgb, var(--c-result) 40%, transparent); stroke: var(--c-result); stroke-width: 2; }
