:root{
  --panel-bg: rgba(18, 24, 26, 0.68);
  --panel-border: rgba(255,255,255,0.14);
  --text: #eef4f2;
  --text-muted: #a9b8b6;
  --accent: #5fd0c9;
  --warn: #e8935a;
  --danger: #ff6b6b;
  --shadow: 0 10px 34px rgba(0,0,0,.4);
}

*{box-sizing:border-box;}
html,body{
  margin:0;
  width:100%;
  height:100%;
  overflow:hidden;
  background:#0b1113;
  font-family:"Noto Sans KR",system-ui,sans-serif;
  color:var(--text);
}
.num{font-family:"IBM Plex Mono",ui-monospace,monospace;}

#vmap{
  position:fixed;
  inset:0;
  width:100%;
  height:100%;
}

.panel{
  position:absolute;
  z-index:20;
  background:var(--panel-bg);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border:1px solid var(--panel-border);
  border-radius:14px;
  box-shadow:var(--shadow);
  padding:16px;
}

#controls{
  top:calc(16px + env(safe-area-inset-top,0px));
  left:16px;
  width:290px;
  bottom:calc(16px + env(safe-area-inset-bottom,0px) + 150px);
  overflow:auto;
}
#controls h1{font-size:16px;margin:0 0 4px;font-weight:700;}
#controls .sub{font-size:12px;color:var(--text-muted);margin:0 0 14px;line-height:1.4;}

.field{margin-bottom:14px;}
.field label{display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;}
.row{display:flex;gap:8px;margin-bottom:8px;}
.row:last-child{margin-bottom:0;}

input[type="number"],input[type="text"],select{
  flex:1;min-width:0;
  background:rgba(255,255,255,0.06);
  border:1px solid var(--panel-border);
  border-radius:8px;
  color:var(--text);
  padding:8px 9px;
  font:inherit;
  font-size:13px;
}
select{width:100%;}
select option{background:#1a2224;color:var(--text);}
input[type="range"]{width:100%;accent-color:var(--accent);}
input.num-input{width:64px;flex:none;font-size:11.5px;padding:6px 6px;}

.section{
  border:1px solid var(--panel-border);
  border-radius:10px;
  margin-bottom:14px;
  padding:2px 10px;
}
.section summary{
  cursor:pointer;padding:9px 0;font-size:12.5px;font-weight:700;
  color:var(--text-muted);list-style:none;
}
.section summary::-webkit-details-marker{display:none;}
.section summary::before{content:"▸ ";}
.section[open] summary::before{content:"▾ ";}
.section[open] summary{margin-bottom:4px;}
.section .field:last-child{margin-bottom:10px;}

.search-results{
  margin-top:6px;max-height:160px;overflow:auto;
  border:1px solid var(--panel-border);border-radius:8px;
}
.search-result-item{
  padding:7px 9px;font-size:12px;cursor:pointer;border-bottom:1px solid var(--panel-border);
}
.search-result-item:last-child{border-bottom:none;}
.search-result-item:hover{background:rgba(255,255,255,0.08);}
.search-result-item .sr-addr{font-weight:600;}
.search-result-item .sr-sub{color:var(--text-muted);font-size:10.5px;}

.anchor-row{display:flex;align-items:center;gap:6px;margin-bottom:8px;flex-wrap:wrap;}
.anchor-label{font-size:11px;color:var(--text-muted);width:48px;flex:none;}
.anchor-status{font-size:11px;color:var(--accent);flex:none;}
.btn-sm{flex:none;padding:6px 9px;font-size:11.5px;}

.check-row{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--text-muted);margin-top:4px;cursor:pointer;}
.check-row input{accent-color:var(--accent);}

.ws-row.ws-card{flex-direction:column;align-items:stretch;gap:4px;}
.ws-head{display:flex;align-items:center;gap:6px;}
.ws-name{
  flex:1;min-width:0;text-align:left;background:none;border:none;color:var(--text);
  font:inherit;font-size:12.5px;font-weight:700;cursor:pointer;padding:0;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.ws-name:hover{color:var(--accent);}
.ws-btn{
  flex:none;font:inherit;font-size:11px;font-weight:600;padding:3px 7px;border-radius:6px;
  border:1px solid var(--panel-border);background:rgba(255,255,255,0.06);color:var(--text);cursor:pointer;
}
.ws-btn:hover{border-color:var(--accent);color:var(--accent);}

.edit-bar{
  top:calc(16px + env(safe-area-inset-top,0px));
  left:322px;
  right:120px;
  padding:10px 12px;
  z-index:30;
}
.edit-bar[hidden]{display:none;}
.edit-title{font-size:13px;font-weight:700;margin-bottom:2px;}
.edit-hint{font-size:11.5px;color:var(--text-muted);line-height:1.45;margin-bottom:8px;}
.edit-actions{display:flex;gap:6px;flex-wrap:wrap;}
.edit-actions .btn{flex:1 1 auto;}

.ws-tag{
  display:inline-block;font-size:10px;font-weight:700;padding:1px 6px;border-radius:5px;
  margin-left:5px;background:rgba(255,255,255,0.1);color:var(--text-muted);
}
.ws-tag.before{color:#7ec8e3;}
.ws-tag.after{color:#e8935a;}
.ws-memo{
  width:100%;margin-top:6px;background:rgba(255,255,255,0.06);border:1px solid var(--panel-border);
  border-radius:6px;color:var(--text);font:inherit;font-size:11.5px;padding:5px 7px;resize:vertical;min-height:28px;
}

.btn{
  flex:1;
  font:inherit;
  font-size:12.5px;
  font-weight:600;
  padding:9px 10px;
  border-radius:9px;
  border:1px solid var(--panel-border);
  background:rgba(255,255,255,0.06);
  color:var(--text);
  cursor:pointer;
}
.btn:disabled{opacity:.4;cursor:not-allowed;}
.btn-primary{background:var(--accent);border-color:var(--accent);color:#082826;}
.btn-danger{color:var(--danger);}
.btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}

.ws-list{display:flex;flex-direction:column;gap:6px;}
.ws-empty{font-size:12px;color:var(--text-muted);}
.ws-row{
  display:flex;align-items:center;gap:8px;
  background:rgba(255,255,255,0.06);
  border:1px solid var(--panel-border);
  border-radius:8px;
  padding:7px 8px;
}
.ws-dot{width:10px;height:10px;border-radius:50%;flex:none;}
.ws-info{flex:1;min-width:0;}
.ws-info .ws-label{font-size:12.5px;font-weight:600;}
.ws-info .ws-meta{font-size:11px;color:var(--text-muted);}
.ws-del{
  flex:none;width:22px;height:22px;border-radius:50%;
  border:1px solid var(--panel-border);background:transparent;color:var(--text-muted);
  cursor:pointer;font-size:13px;line-height:1;
}
.ws-del:hover{color:var(--danger);border-color:var(--danger);}

#statusPanel{
  bottom:calc(16px + env(safe-area-inset-bottom,0px));
  left:16px;
  width:290px;
  font-size:12.5px;
  line-height:1.5;
  color:var(--text-muted);
}
#statusText{white-space:pre-line;}
#statusText.warn{color:var(--warn);}
#statusText.error{color:var(--danger);}

#panelToggle{
  display:none;
  position:fixed;
  right:16px;
  bottom:calc(16px + env(safe-area-inset-bottom,0px));
  z-index:25;
  width:48px;height:48px;
  border-radius:50%;
  border:1px solid var(--panel-border);
  background:var(--panel-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color:var(--text);
  font-size:18px;
  box-shadow:var(--shadow);
  cursor:pointer;
}

#loadError{
  position:fixed;inset:0;z-index:50;
  display:flex;align-items:center;justify-content:center;
  background:rgba(6,10,11,0.88);
  padding:16px;
}
#loadError[hidden]{display:none;}
.error-box{
  max-width:360px;
  background:var(--panel-bg);
  border:1px solid var(--panel-border);
  border-radius:14px;
  padding:22px;
  text-align:center;
  box-shadow:var(--shadow);
}
.error-box h2{margin:0 0 10px;font-size:16px;}
.error-box p{font-size:13px;color:var(--text-muted);line-height:1.5;margin:0 0 16px;}
.error-box .btn{width:100%;}

/* backdrop-filter re-blurs the live 3D map behind every panel each frame — cheap on a
   desktop GPU, a major source of lag on phones. Use a solid background there instead. */
@media (pointer:coarse), (max-width:640px){
  .panel, #panelToggle{
    -webkit-backdrop-filter:none;
    backdrop-filter:none;
    background:rgba(18,24,26,0.94);
  }
}

/* Side panel can be hidden (☰) to give the whole screen to the map. */
body.panel-hidden #controls{display:none;}
body.panel-hidden .edit-bar{left:16px;}

/* Touch devices (phones and tablets). VWorld's compass/zoom/home widget is redundant
   with pinch-zoom and sits exactly where you tap to draw (its home button resets the
   camera), so hide it — which also frees the right side for the edit toolbar. */
@media (pointer:coarse){
  #naviAllDiv, #naviRotate, #naviZoomPannel{display:none !important;}
  .edit-bar{right:16px;}
  #panelToggle{display:flex;align-items:center;justify-content:center;}
}

/* Phone, portrait: panel becomes a bottom sheet. */
@media (max-width:640px){
  #controls{
    top:auto;
    bottom:calc(100px + env(safe-area-inset-bottom,0px));
    left:12px;
    right:12px;
    width:auto;
    max-height:55vh;
  }
  .edit-bar, body.panel-hidden .edit-bar{left:8px;right:8px;top:calc(8px + env(safe-area-inset-top,0px));padding:8px 10px;}
  .edit-title{font-size:12.5px;}
  .edit-hint{font-size:11px;margin-bottom:6px;}
  .edit-actions{flex-wrap:nowrap;gap:4px;}
  .edit-actions .btn{flex:1 1 0;min-width:0;padding:8px 4px;font-size:11px;white-space:nowrap;}
  #panelToggle{display:flex;align-items:center;justify-content:center;}
  #statusPanel{
    left:12px;
    right:80px;
    width:auto;
  }
}

/* Short landscape screens (phone held sideways, small tablets): full-height side panel,
   status box beside it along the bottom, one-line edit toolbar. Side insets keep
   everything clear of a notch on the left/right edge. */
@media (orientation:landscape) and (max-height:540px){
  .panel{padding:10px 12px;}
  #controls{
    top:calc(8px + env(safe-area-inset-top,0px));
    bottom:calc(8px + env(safe-area-inset-bottom,0px));
    left:calc(8px + env(safe-area-inset-left,0px));
    right:auto;
    width:270px;
    max-height:none;
  }
  #controls h1{font-size:14px;}
  #controls .sub{display:none;}
  .field{margin-bottom:10px;}
  .section{margin-bottom:10px;}
  #statusPanel{
    left:calc(286px + env(safe-area-inset-left,0px));
    right:calc(64px + env(safe-area-inset-right,0px));
    bottom:calc(8px + env(safe-area-inset-bottom,0px));
    width:auto;
    max-height:32vh;
    overflow:auto;
    font-size:11.5px;
    padding:7px 10px;
  }
  body.panel-hidden #statusPanel{left:calc(8px + env(safe-area-inset-left,0px));}
  .edit-bar, body.panel-hidden .edit-bar{
    top:calc(8px + env(safe-area-inset-top,0px));
    left:calc(286px + env(safe-area-inset-left,0px));
    right:calc(8px + env(safe-area-inset-right,0px));
    padding:6px 8px;
    display:flex;align-items:center;gap:8px;
  }
  body.panel-hidden .edit-bar{left:calc(8px + env(safe-area-inset-left,0px));}
  .edit-bar[hidden]{display:none;}
  .edit-title{margin:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex:0 1 auto;}
  .edit-hint{display:none;}
  .edit-actions{flex:1 0 auto;flex-wrap:nowrap;gap:4px;justify-content:flex-end;}
  .edit-actions .btn{flex:0 0 auto;padding:7px 9px;font-size:11px;white-space:nowrap;}
  #panelToggle{
    right:calc(8px + env(safe-area-inset-right,0px));
    bottom:calc(8px + env(safe-area-inset-bottom,0px));
    width:46px;height:46px;
  }
}
