[hidden] { display: none !important; }
:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #14181f; --muted: #5d6673; --line: #dfe3e8;
  --accent: #0b6bcb; --accent-ink: #fff; --good: #1d7f4e; --warn: #9a5b00; --bad: #b3261e;
  --query: #00a3c4; --cand: #f07c00; --shape: #3b4452; --chip: #eef1f5;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --panel: #171b22; --ink: #e8ebef; --muted: #9aa4b1; --line: #2a303a;
    --accent: #4aa3ff; --accent-ink: #051322; --good: #4cc38a; --warn: #f0b35a; --bad: #ff8a80;
    --query: #3fd6f0; --cand: #ffa040; --shape: #c9d1dc; --chip: #222833;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --panel: #171b22; --ink: #e8ebef; --muted: #9aa4b1; --line: #2a303a;
  --accent: #4aa3ff; --accent-ink: #051322; --good: #4cc38a; --warn: #f0b35a; --bad: #ff8a80;
  --query: #3fd6f0; --cand: #ffa040; --shape: #c9d1dc; --chip: #222833;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.top { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 10px 16px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; fill: var(--accent); }
.sub { color: var(--muted); font-size: 13px; }
.pad { padding: 0 4px 8px; }
main { max-width: 820px; margin: 0 auto; padding: 12px 16px 96px; }
.tab { display: none; } .tab.active { display: block; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h3, .h { margin: 4px 0 10px; font-size: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btns { margin-top: 10px; }
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); border-radius: 10px; padding: 9px 14px; font: inherit; cursor: pointer;
  text-decoration: none; min-height: 40px; }
.btn svg { width: 22px; height: 22px; fill: currentColor; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.big { flex: 1 1 140px; min-height: 56px; font-size: 17px; }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 14px; }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.opts { justify-content: space-between; }
.chk { display: inline-flex; gap: 6px; align-items: center; }
.num input { width: 70px; }
input, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; min-height: 38px; width: 100%; }
.num input { width: 72px; display: inline-block; }
.chk input { width: auto; min-height: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.busy { display: flex; gap: 12px; align-items: center; }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.err { border-color: var(--bad); color: var(--bad); }
.warn { color: var(--warn); font-size: 14px; margin-top: 6px; }
.view { position: relative; background: #000; border-radius: 8px; overflow: hidden; }
.view img { display: block; width: 100%; height: auto; }
.view svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.measured { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 14px; }
.measured b { font-variant-numeric: tabular-nums; }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--muted); }
.chip.warn { color: var(--warn); } .chip.good { color: var(--good); }
.cands { display: grid; gap: 10px; }
.cand { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: center; background: var(--panel);
  border: 2px solid var(--line); border-radius: var(--radius); padding: 10px; cursor: pointer; }
.cand.sel { border-color: var(--cand); }
.cand .code { font-weight: 700; font-size: 16px; }
.cand .nm { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.cand .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.cand .act { grid-column: 1 / -1; display: flex; gap: 8px; }
.bar { height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--cand); }
.thumb { width: 76px; height: 64px; }
.thumb path { fill: var(--shape); fill-rule: evenodd; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; cursor: pointer; }
.tile .thumb { width: 100%; height: 90px; }
.tile .code { font-weight: 700; } .tile .nm { color: var(--muted); font-size: 12px; min-height: 2.5em; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.grid-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.grid-form label.chk { flex-direction: row; align-self: end; }
.banner { background: var(--chip); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; font-size: 14px; }
.list .item { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); }
td.n { text-align: right; font-variant-numeric: tabular-nums; }
nav.bottom { position: fixed; bottom: 0; left: 0; right: 0; background: var(--panel); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav.bottom button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px; padding: 8px 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
nav.bottom button svg { width: 24px; height: 24px; fill: currentColor; }
nav.bottom button.on { color: var(--accent); }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink);
  width: min(720px, calc(100vw - 32px)); max-height: 86vh; padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
.geoms { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.geom { border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-size: 13px; }
.geom .thumb { width: 100%; height: 150px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
label.wide { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-top: 10px; }
details.more { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details.more label { display: flex; gap: 6px; align-items: center; margin-top: 8px; font-size: 14px; }
