
:root{--bg:#f3f5f7;--panel:#fff;--border:#d0d5dd;--text:#101828;--muted:#667085;--accent:#2563eb;--sel:#7c3aed;--danger:#b42318;--ut004:#f97316;--ut008:#111;--lt024:#7b1f17}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif}
body{overscroll-behavior:none}
button,input,select,textarea{font:inherit;font-size:16px}
button,select,input[type="number"],input[type="text"]{min-height:48px;border:1px solid var(--border);border-radius:12px;background:#fff;color:var(--text)}
button{padding:10px 14px;font-weight:700}
button.active{background:#eef2ff;border-color:var(--sel);box-shadow:0 0 0 2px #ddd6fe inset}
button.primary{background:#eff6ff;border-color:#93c5fd}
button.danger{color:var(--danger);border-color:#fda29b}
button:disabled{opacity:.45}
input,select,textarea{padding:10px}
textarea{width:100%;min-height:160px;border:1px solid var(--border);border-radius:12px;font:13px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.app{max-width:1920px;margin:0 auto;padding:10px;padding-bottom:calc(12px + env(safe-area-inset-bottom))}
.toolbar{position:sticky;top:0;z-index:100;background:rgba(255,255,255,.96);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:16px;padding:10px;display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:10px}
.group{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
label.file{display:inline-flex;align-items:center;gap:8px;min-height:48px;border:1px solid var(--border);border-radius:12px;background:#fff;padding:7px 12px;font-weight:700}
label.file input{max-width:230px}
.layout{display:grid;grid-template-columns:minmax(0,1fr) 430px;gap:10px}
@media(max-width:1100px){.layout{grid-template-columns:1fr}.side{order:2}}
.stage-shell{border:1px solid var(--border);background:#fff;border-radius:16px;overflow:auto;-webkit-overflow-scrolling:touch;min-height:68vh}
#empty{padding:72px 20px;text-align:center;color:var(--muted);line-height:1.55}
#stage{position:relative;display:none;line-height:0;user-select:none;-webkit-user-select:none;min-width:850px;background:#fff;transform-origin:top left;outline:none}
#stage.editing{touch-action:none} #stage.panning{touch-action:pan-x pan-y}
#baseImg{display:block;width:100%;height:auto;pointer-events:none}
#vectorSvg{position:absolute;inset:0;width:100%;height:100%;z-index:3;overflow:visible;pointer-events:none}
#svg{position:absolute;inset:0;width:100%;height:100%;z-index:5;overflow:visible}
#nodes,#callouts,#decor{position:absolute;inset:0}
#nodes{z-index:10} #decor{z-index:12;pointer-events:none} #callouts{z-index:15;pointer-events:none}
.status{padding:10px;border:1px solid var(--border);background:#f8fafc;border-radius:12px;font-size:14px;line-height:1.4;margin-top:10px}
.panel{background:#fff;border:1px solid var(--border);border-radius:16px;padding:10px}
.panel h3{margin:0 0 8px;font-size:16px}
.field{display:grid;grid-template-columns:128px 1fr;gap:8px;align-items:center;margin:7px 0}
.row{display:flex;gap:7px;flex-wrap:wrap;align-items:center}
.small{font-size:13px;line-height:1.45;color:var(--muted)}
.note{padding:9px 10px;background:#f0f9ff;border:1px solid #bae6fd;border-radius:10px;font-size:13px;line-height:1.42}
hr{border:0;border-top:1px solid var(--border);margin:10px 0}
.badge{display:inline-block;padding:3px 8px;border-radius:999px;background:#f2f4f7;font-size:12px}
.side{display:flex;flex-direction:column;gap:10px;position:sticky;top:84px;align-self:start;max-height:calc(100vh - 94px);overflow:auto;padding-right:2px}
@media(max-width:1100px){.side{position:static;max-height:none;overflow:visible}}
details.spoiler{border:1px solid var(--border);border-radius:16px;background:#fff;overflow:hidden}
details.spoiler>summary{list-style:none;cursor:pointer;padding:14px 16px;font-weight:800;display:flex;align-items:center;justify-content:space-between;background:#fff}
details.spoiler>summary::-webkit-details-marker{display:none}
details.spoiler>summary::after{content:'▾';color:var(--muted);font-size:18px}
details.spoiler:not([open])>summary::after{content:'▸'}
details.spoiler .panel{border:0;border-top:1px solid var(--border);border-radius:0;padding:10px}
.panel-body h3{display:none}
.route-list{display:flex;flex-direction:column;gap:7px;max-height:250px;overflow:auto}
.route-row{display:grid;grid-template-columns:1fr auto auto;gap:6px;align-items:center;border:1px solid var(--border);border-radius:10px;padding:7px}
.route-row.selected{background:#faf5ff;border-color:var(--sel)}
.route-row button{min-height:42px;padding:7px 10px}
.nudge{display:grid;grid-template-columns:50px 50px 50px;gap:6px;width:max-content;margin-top:7px}
.nudge button{width:50px;height:50px;padding:0}
.refgrid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.refcard{border:1px solid var(--border);border-radius:12px;padding:6px;background:#fcfcfd}
.refcard img{display:block;width:100%;border-radius:8px}
.refcard .caption{margin-top:5px;font-size:12px;color:var(--muted);text-align:center}
.vector-preview{border:1px solid var(--border);border-radius:12px;background:#fff;overflow:hidden;margin-top:8px}
.vector-preview canvas{display:block;width:100%;height:auto;background:#fff}
.sheet-block{position:absolute;pointer-events:auto;touch-action:none;background:rgba(255,255,255,.96);border:1.5px solid #222;color:#111;line-height:1.25;cursor:grab}
.sheet-block.selected{outline:3px solid #c4b5fd}
.sheet-title{position:absolute;pointer-events:none;left:50%;top:2%;transform:translateX(-50%);font-style:italic;font-weight:800;font-size:20px;text-decoration:underline;white-space:nowrap}
.legend-block{padding:8px 10px;width:300px;font-size:12px}
.legend-block h4{margin:0 0 7px;text-align:center;font-style:italic;font-size:13px}
.legend-line{display:grid;grid-template-columns:78px 1fr;gap:7px;align-items:center;margin:4px 0}
.legend-sample{height:0;border-top:2px solid #111}
.summary-block{padding:0;width:330px;font-size:11px}
.summary-block table{border-collapse:collapse;width:100%}.summary-block th,.summary-block td{border:1px solid #555;padding:4px 5px}.summary-block th{font-style:italic;font-weight:700}
.node{position:absolute;transform:translate(-50%,-50%);padding:8px;margin:-8px;background:transparent;border:0;cursor:grab;pointer-events:auto;touch-action:none;line-height:1}
.node.selected .label{outline:4px solid #c4b5fd;outline-offset:3px}
.node .label{position:absolute;left:50%;top:100%;transform:translate(-50%,7px);white-space:nowrap;font-size:16px;font-weight:800;background:rgba(255,255,255,.95);padding:4px 7px;border-radius:7px;box-shadow:0 0 0 1px rgba(0,0,0,.12)}
.node .sym{position:relative;display:block}
.sym.bo{width:42px;height:24px;border:2px solid #111;background:repeating-linear-gradient(to bottom,#fff 0 3px,#d1d5db 3px 6px);border-radius:3px}
.sym.bo::after{content:"";position:absolute;right:-7px;bottom:-7px;width:11px;height:11px;border-radius:50%;background:#fff;border:2px solid #2563eb}
.sym.tes{width:24px;height:24px;border-radius:50%;background:#111;border:2px solid #111}
.sym.tes::after{content:"";position:absolute;right:-7px;bottom:-7px;width:11px;height:11px;border-radius:50%;background:#fff;border:2px solid #2563eb}
.sym.rm{width:24px;height:24px;border-radius:50%;background:#111;border:2px solid #111}
.sym.rm::after{content:"";position:absolute;right:-7px;bottom:-7px;width:11px;height:11px;border-radius:50%;background:#fff;border:2px solid #2563eb}
.sym.pt{width:18px;height:18px;border-radius:50%;background:#fff;border:3px solid #374151;box-shadow:0 0 0 2px rgba(255,255,255,.85)}
.sym.pt::before,.sym.pt::after{content:"";position:absolute;left:50%;top:50%;background:#374151;transform:translate(-50%,-50%)}
.sym.pt::before{width:10px;height:2px}
.sym.pt::after{width:2px;height:10px}
.sym.pt::marker{display:none}
.route-hit{fill:none;stroke:#000;stroke-opacity:.001;stroke-width:30;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}
.route-visible{fill:none;stroke-width:4;vector-effect:non-scaling-stroke;pointer-events:none}
.route-visible.selected{stroke-width:6}
.route-label{font:800 17px -apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;paint-order:stroke;stroke:#fff;stroke-width:5px;fill:#111;pointer-events:none}
.handle{fill:#fff;stroke:var(--sel);stroke-width:.35;cursor:move;pointer-events:all}
.handle.selected{fill:#fde68a;stroke:#b45309}
.callout{position:absolute;pointer-events:auto;touch-action:none;min-width:190px;max-width:340px;line-height:1.24;border:2px solid #444;border-radius:7px;background:rgba(255,255,255,.97);padding:8px 10px;cursor:grab}
.callout.selected{outline:4px solid #c4b5fd}
.callout b{display:block;font-size:15px;font-style:italic} .callout span{display:block;font-size:14px;font-style:italic}

/* v8 layout: fixed workspace + independently controlled sidebar */
.layout{grid-template-columns:minmax(0,1fr) 390px;align-items:start}
.side{position:sticky;top:82px;height:calc(100dvh - 94px);max-height:none;overflow:hidden;padding-right:0}
.side details.spoiler{flex:0 0 auto}
.side details.spoiler[open]{display:flex;flex-direction:column;max-height:calc(100dvh - 132px);min-height:0}
.side details.spoiler[open]>.panel{overflow:auto;min-height:0;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding-bottom:18px}
details.spoiler>summary{position:sticky;top:0;z-index:3;background:#fff;min-height:56px}
.layout.sidebar-hidden{grid-template-columns:minmax(0,1fr)}
.layout.sidebar-hidden .side{display:none}
#toggleSidebar{background:#fff}
#toggleSidebar.active{background:#eef2ff;border-color:#93c5fd}
@media(max-width:1100px){
  .layout{grid-template-columns:1fr}
  .side{position:fixed;right:8px;top:78px;bottom:8px;width:min(410px,calc(100vw - 24px));height:auto;z-index:95;background:var(--bg);border:1px solid var(--border);border-radius:16px;padding:8px;box-shadow:0 18px 50px rgba(16,24,40,.18);overflow:hidden}
  .layout.sidebar-hidden .side{display:none}
  .side details.spoiler[open]{max-height:calc(100dvh - 110px)}
  .stage-shell{min-height:calc(100dvh - 150px)}
}
@media(max-width:700px){
  .toolbar{gap:5px;padding:7px}
  .toolbar button,.toolbar label.file{min-height:44px;padding:8px 10px}
  .side{left:6px;right:6px;width:auto;top:72px}
}


/* v9: draw cable by tapping along a building */
.route-hud{position:absolute;left:12px;top:12px;z-index:40;line-height:1.3;width:min(640px,calc(100% - 24px));padding:10px 12px;background:rgba(255,255,255,.97);border:2px solid #7c3aed;border-radius:12px;box-shadow:0 8px 28px rgba(16,24,40,.18);pointer-events:auto;touch-action:none}
.route-hud-row{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin:7px 0}
.route-hud select,.route-hud button{min-height:42px;padding:7px 10px}.route-hud select{min-width:160px}
body.route-drawing #stage{cursor:crosshair}.route-visible.selected{stroke-width:6}
.callout.bo-project{min-width:130px;max-width:300px;border:0;border-radius:0;background:transparent;padding:2px 4px;box-shadow:none;color:#111}
.callout.bo-project.selected{outline:3px dashed #7c3aed;background:rgba(255,255,255,.82)}
.callout.bo-project b{font-size:13px;font-weight:500;font-style:italic;white-space:nowrap}.callout.bo-project span{font-size:12.5px;font-style:italic;white-space:nowrap}
.callout.bo-box{border:1.2px solid #222;border-radius:0;background:rgba(255,255,255,.97);padding:7px 9px}
.callout.bo-box b{font-size:14px;font-weight:600;font-style:italic}.callout.bo-box span{font-size:13px;font-style:italic}
.handle.route-corner{stroke-width:.45}
@media(max-width:700px){.route-hud{left:6px;top:6px;width:calc(100% - 12px)}.route-hud-row{display:grid;grid-template-columns:1fr 1fr}.route-hud-row select{grid-column:1/-1;width:100%}}


/* v11 full editor */
.check{display:inline-flex;align-items:center;gap:7px;min-height:42px;padding:6px 9px;border:1px solid var(--border);border-radius:10px;background:#fff;font-size:14px}
.check input{width:20px;height:20px}
.node.no-reserve .sym.bo::after,.node.no-reserve .sym.tes::after,.node.no-reserve .sym.rm::after{display:none}
.node.hide-label .label{display:none}
.callout.project-box{border:1.35px solid #222;border-radius:0;background:rgba(255,255,255,.98);padding:7px 9px;min-width:190px;max-width:360px;box-shadow:none}
.callout.project-box b{font-size:14px;font-style:italic;font-weight:600}.callout.project-box span{font-size:13px;font-style:italic}
.callout.project-text{border:0;border-radius:0;background:rgba(255,255,255,.82);padding:2px 4px;box-shadow:none;min-width:130px}
.callout.project-text b{font-size:13px;font-weight:500;font-style:italic}.callout.project-text span{font-size:12.5px;font-style:italic}
.route-preview{fill:none;stroke:#7c3aed;stroke-width:2;stroke-dasharray:5 4;vector-effect:non-scaling-stroke;pointer-events:none;opacity:.9}
.route-label-hit{fill:transparent;stroke:none;pointer-events:all;cursor:move}
.trace-manual{fill:none;stroke:#111;vector-effect:non-scaling-stroke;stroke-linecap:round;stroke-linejoin:round;pointer-events:stroke;cursor:pointer}
.trace-manual.selected{stroke:#7c3aed}
.trace-preview{fill:none;stroke:#7c3aed;stroke-width:.18;stroke-dasharray:.7 .5;pointer-events:none}
.trace-handle{fill:#fff;stroke:#7c3aed;stroke-width:.3;pointer-events:all;cursor:move}
body.trace-drawing #stage{cursor:crosshair}
#baseImg{transition:opacity .1s linear}
.status.good{background:#ecfdf3;border-color:#a6f4c5;color:#027a48}.status.warn{background:#fffaeb;border-color:#fedf89;color:#b54708}
@media(max-width:700px){.field{grid-template-columns:105px 1fr}.callout{max-width:280px}.toolbar .badge{display:none}}


/* v12: calibration, compact reference callouts, SVG-master workflow */
.callout.project-box span:empty,.callout.project-text span:empty{display:none}
.callout.project-box{line-height:1.2;padding:6px 8px;min-width:175px}
.callout.project-box b{font-size:13.5px;line-height:1.2}
.callout.project-box span{font-size:12.5px;line-height:1.22;margin-top:1px}
.scale-marker{fill:#fff;stroke:#7c3aed;stroke-width:.35;pointer-events:none}
.scale-marker-text{font:800 3px -apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;fill:#7c3aed;paint-order:stroke;stroke:#fff;stroke-width:.7;pointer-events:none}
body.scale-picking #stage{cursor:crosshair}
.export-warning{color:#b42318;font-weight:700}
