:root {
  --bg: #f3f5f4; --panel: #fff; --ink: #0b1533; --text: #1d2430; --muted: #5f6b76; --line: #dfe4e8;
  --teal: #18b8b5; --teal-d: #0b7472; --blue: #4f86f7; --warn: #c92a2a; --amber: #b85c00; --ok: #2f7a45;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--text);
}
@font-face { font-family: "Geist Mono"; src: url(f/geist-mono-latin.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
button { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; white-space: nowrap; min-height: 34px; }
button:hover:not(:disabled) { border-color: var(--teal); }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* header */
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); height: 56px; }
.brand { display: flex; align-items: center; gap: 12px; flex: none; }
.kback { display: inline-flex; align-items: center; gap: 3px; height: 34px; padding: 0 12px 0 7px; border: 1px solid rgba(11,21,51,.18); border-radius: 999px; color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.kback:hover { background: rgba(11,21,51,.05); }
.kback svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.klogo { display: flex; align-items: center; gap: 10px; text-decoration: none; white-space: nowrap; }
.kmark { width: 32px; height: 32px; overflow: visible; } .kmark .k-l { fill: #0b1533; }
.kwm { display: block; height: 15px; width: auto; }
.sub-mark { font: 500 11px/1 "Geist Mono", ui-monospace, monospace; letter-spacing: .14em; text-transform: uppercase; color: var(--teal-d); padding-left: 10px; border-left: 1px solid rgba(11,21,51,.16); }
.prod { font-weight: 700; color: var(--ink); padding-left: 12px; border-left: 1px solid var(--line); white-space: nowrap; }
.tools { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; justify-content: center; }
.tools button { display: inline-flex; align-items: center; gap: 5px; }
.tools svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tools .ic { padding: 6px 8px; }
.seg { display: inline-flex; } .seg button { border-radius: 0; margin-left: -1px; } .seg button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; } .seg button:last-child { border-radius: 0 8px 8px 0; }
.seg.wrap { flex-wrap: wrap; gap: 4px; } .seg.wrap button { border-radius: 8px; margin: 0; }
.chk { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; color: var(--muted); padding: 0 4px; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--ink); }
.sum { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; white-space: nowrap; }
.sum small { font-size: 12px; color: var(--muted); } .sum b { font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }
.cta { background: var(--teal); color: #04201f; font-weight: 700; text-decoration: none; padding: 9px 14px; border-radius: 999px; white-space: nowrap; }
.cta:hover { background: #22cbc8; }
.demo-note { margin: 0; font-size: 12px; text-align: center; padding: 3px 8px; background: #eaf6f6; color: var(--teal-d); border-bottom: 1px solid var(--line); height: 22px; }

/* layout */
.layout { display: grid; grid-template-columns: 300px 1fr 350px; height: calc(100% - 78px); }
.pane { background: var(--panel); overflow-y: auto; padding: 12px; }
.left { border-right: 1px solid var(--line); }
.right { border-left: 1px solid var(--line); }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 4px 0 8px; font-weight: 700; }
h2 + .presets { margin-bottom: 14px; }
.presets { display: grid; gap: 6px; }
.presets button { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; text-align: left; padding: 9px 11px; }
.presets button span { color: var(--muted); font-size: 12px; }
.groups { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px; }
.groups button { font-size: 12.5px; padding: 6px 6px; white-space: normal; line-height: 1.15; }
.groups button.aa:not(.on) { border-color: #c79a5b; color: #7a5520; background: #fbf6ee; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.aa-lead { grid-column: 1 / -1; margin: 0; font-size: 12.5px; line-height: 1.4; color: #6b4a1c; background: #fbf6ee; border: 1px solid #ecdcc2; border-radius: 8px; padding: 8px 10px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 3px; text-align: left; white-space: normal; background: #fff; }
.card:hover { border-color: var(--teal); box-shadow: 0 2px 10px rgba(11,21,51,.08); }
.card .th { display: block; aspect-ratio: 5 / 4; border-radius: 6px; background: linear-gradient(180deg, #eef3f6, #e3ece4); overflow: hidden; }
.card .th img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .n { font-size: 12.5px; font-weight: 650; line-height: 1.2; color: var(--ink); }
.card .m { font-size: 11.5px; color: var(--muted); }

.view { position: relative; min-width: 0; background: #dde8ef; }
#canvasWrap { position: absolute; inset: 0; } #canvasWrap canvas { display: block; touch-action: none; }
.hint { position: absolute; left: 10px; bottom: 10px; background: rgba(255,255,255,.92); border-radius: 8px; padding: 6px 10px; font-size: 12px; color: var(--muted); pointer-events: none; max-width: calc(100% - 20px); }
.drawbar { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 10px; padding: 6px 6px 6px 12px; box-shadow: 0 4px 18px rgba(11,21,51,.18); white-space: nowrap; }
.drawbar #drawOk { background: var(--ink); color: #fff; border-color: var(--ink); }
.legend { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 10px; background: rgba(255,255,255,.92); border-radius: 8px; padding: 5px 9px; font-size: 11.5px; color: var(--muted); pointer-events: none; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.z1 { background: rgba(250,205,60,.75); } .z2 { background: rgba(240,140,0,.75); } .z3 { background: rgba(224,49,49,.85); }
.toast { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 8px; padding: 7px 12px; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: calc(100% - 24px); text-align: center; }
.toast.show { opacity: 1; }
.tosel { position: absolute; left: 50%; bottom: 52px; transform: translateX(-50%); background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 700; box-shadow: 0 4px 16px rgba(11,21,51,.25); }
.plabel { display: block; font-size: 12px; color: var(--muted); margin: 0 0 3px; }
.cta-m { display: none; }

/* right pane */
.proj { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; margin-bottom: 4px; }
details { border-bottom: 1px solid var(--line); padding: 6px 0 12px; }
summary { font-weight: 700; color: var(--ink); cursor: pointer; padding: 6px 0 8px; display: flex; align-items: center; gap: 8px; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
details[open] > summary::after { transform: rotate(-135deg); }
.badge { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; } .badge.good { background: #e3f3e8; color: var(--ok); } .badge.bad { background: #fde8e8; color: var(--warn); }
.opt { margin: 10px 0; } .opt > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.opt .seg button { font-size: 13px; padding: 5px 9px; min-height: 32px; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sides label { display: flex; flex-direction: column; font-size: 11.5px; color: var(--muted); gap: 2px; }
.sides select { border: 1px solid var(--line); border-radius: 6px; padding: 5px; background: #fff; color: var(--text); min-height: 32px; }
.sw { display: flex; gap: 8px; }
.sw button { width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 50%; background: linear-gradient(135deg, var(--a) 50%, var(--b) 50%); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.sw button.on { box-shadow: 0 0 0 2px var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 10px 0 6px; }
.row2 label, .row3 label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
label input[type=number] { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; }
#plotPoly { margin-top: 8px; }
.stat { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.kv { font-size: 12.5px; line-height: 1.5; margin: 0 0 6px; } .kv b { font-weight: 650; color: var(--ink); }
.btns { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; } .btns button { padding: 5px 8px; }
button.danger { color: var(--warn); }
.muted { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin: 6px 0; }
.warn { color: var(--warn); } .amber { color: var(--amber); } .ok { color: var(--ok); }
#checks p { margin: 4px 0; font-size: 13px; line-height: 1.4; }
#checks ul { padding-left: 18px; margin: 4px 0 8px; } #checks li { margin: 2px 0; font-size: 12.5px; }
table.bom { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
table.bom th:nth-child(1) { width: 22%; } table.bom th:nth-child(3) { width: 11%; } table.bom th:nth-child(4) { width: 26%; }
table.bom th, table.bom td { border-bottom: 1px solid var(--line); padding: 4px 3px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
table.bom tbody td:first-child { font-family: "Geist Mono", ui-monospace, monospace; font-size: 11px; color: var(--muted); }
table.bom .r { text-align: right; font-variant-numeric: tabular-nums; }
.tot td { font-weight: 700; color: var(--ink); border-bottom: 0; }

@media (max-width: 1280px) {
  .layout { grid-template-columns: 270px 1fr 320px; }
  .prod, .tools .chk:nth-of-type(2), .kback span { display: none; }
  .kback { padding: 0 8px 0 7px; }
  .tools button span { display: none; }
}
@media (max-width: 1020px) { .sub-mark, .sum small { display: none; } .cta { padding: 8px 10px; font-size: 13px; } }
@media (max-width: 800px) {
  html, body { overflow: auto; height: auto; }
  .bar { flex-wrap: wrap; height: auto; gap: 8px; padding: 8px 12px; }
  .brand { flex: 1 1 auto; min-width: 0; }
  .sub-mark { display: inline; }
  .sum { order: 2; }
  .tools { order: 4; flex: 1 1 100%; justify-content: flex-start; flex-wrap: wrap; }
  .tools button span { display: none; }
  .kback span { display: none; } .kback { padding: 0 8px 0 7px; }
  .cta { display: none; }
  .cta-m { display: block; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20; text-align: center; background: var(--teal); color: #04201f; font-weight: 700; text-decoration: none; padding: 12px; border-radius: 999px; box-shadow: 0 6px 20px rgba(11,21,51,.25); }
  body { padding-bottom: 72px; }
  .demo-note { height: auto; }
  .layout { display: flex; flex-direction: column; height: auto; }
  .view { order: 1; height: 62vh; min-height: 340px; }
  .left { order: 2; border: 0; border-bottom: 1px solid var(--line); }
  .right { order: 3; border: 0; }
  .pane { overflow: visible; }
  .grid { grid-template-columns: 1fr 1fr 1fr; }
  .legend { top: 10px; bottom: auto; right: 10px; }
  .hint { font-size: 11.5px; }
}
@media (max-width: 420px) {
  .kmark { width: 28px; height: 28px; } .kwm { height: 13px; } .sub-mark { display: none; }
  .grid { grid-template-columns: 1fr 1fr; }
  .presets button span { display: none; }
}
